Skip to content

Commit ee8adab

Browse files
committed
Fix empty cells not being copied properly
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.
1 parent 7570a00 commit ee8adab

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/ExtendedTableWidget.cpp‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ void ExtendedTableWidget::copy()
8888

8989
SqliteTableModel* m = qobject_cast<SqliteTableModel*>(model());
9090

91+
m_buffer.clear();
92+
9193
// If a single cell is selected, copy it to clipboard
9294
if (indices.size() == 1) {
9395
QImage img;
@@ -96,14 +98,16 @@ void ExtendedTableWidget::copy()
9698
if (img.loadFromData(data.toByteArray())) { // If it's an image
9799
qApp->clipboard()->setImage(img);
98100
return;
99-
} else {
101+
} else if(!data.toString().isEmpty()) {
100102
qApp->clipboard()->setText(data.toString());
101103
return;
104+
} else {
105+
qApp->clipboard()->clear();
106+
m_buffer.push_back({data.toByteArray()});
107+
return;
102108
}
103109
}
104110

105-
m_buffer.clear();
106-
107111
// If any of the cells contain binary data - we use inner buffer
108112
bool containsBinary = false;
109113
foreach (const QModelIndex& index, indices)

0 commit comments

Comments
 (0)