Don't copy data from hidden columns to clipboard

Copying data from hidden columns is not only confusing but does also
break some common use cases. This commit makes sure that we're not
copying any data from hidden columns. That means the only way to get the
old behaviour now is to unhide all columns, including the rowid column.

See issue #1094.
This commit is contained in:
Martin Kleusberg
2017-12-04 12:10:22 +01:00
parent cef1e9020b
commit 2b1004602f

View File

@@ -154,6 +154,17 @@ void ExtendedTableWidget::copy(const bool withHeaders)
{
QModelIndexList indices = selectionModel()->selectedIndexes();
// Remove all indices from hidden columns, because if we don't we might copy data from hidden columns as well which is very
// unintuitive; especially copying the rowid column when selecting all columns of a table is a problem because pasting the data
// won't work as expected.
for(int i=indices.size()-1;i>=0;)
{
if(isColumnHidden(indices.at(i).column()))
indices.removeAt(i);
else
i--;
}
// Abort if there's nothing to copy
if (indices.isEmpty())
return;