mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Fix cells copying (#825)
With this commit, we start to handle empty and NULL single cell selections in a special way. Well, there's nothing special about it. We just push them to inner buffer and clear outer clipboard. That's it. NB: possible side effect might appear if you copy empty value, then select some text and paste your empty value here. Nothing will happen with text though, because, well, we wiped clipboard. Plus, it fixes single-cell multiline text copy-pasting (#541)
This commit is contained in:
@@ -88,6 +88,8 @@ void ExtendedTableWidget::copy()
|
||||
|
||||
SqliteTableModel* m = qobject_cast<SqliteTableModel*>(model());
|
||||
|
||||
m_buffer.clear();
|
||||
|
||||
// If a single cell is selected, copy it to clipboard
|
||||
if (indices.size() == 1) {
|
||||
QImage img;
|
||||
@@ -97,13 +99,23 @@ void ExtendedTableWidget::copy()
|
||||
qApp->clipboard()->setImage(img);
|
||||
return;
|
||||
} else {
|
||||
qApp->clipboard()->setText(data.toString());
|
||||
QString text = data.toString();
|
||||
if (text.isEmpty()) {
|
||||
// NULL and empty single-cells are handled via inner buffer
|
||||
qApp->clipboard()->clear();
|
||||
QByteArrayList lst;
|
||||
lst << data.toByteArray();
|
||||
m_buffer.push_back(lst);
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.contains('\n'))
|
||||
text = QString("\"%1\"").arg(text);
|
||||
qApp->clipboard()->setText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_buffer.clear();
|
||||
|
||||
// If any of the cells contain binary data - we use inner buffer
|
||||
bool containsBinary = false;
|
||||
foreach (const QModelIndex& index, indices)
|
||||
|
||||
Reference in New Issue
Block a user