Skip to content

Commit d1a61c8

Browse files
committed
Table Browser: progress dialog in copy to clipboard
A progress dialog appears if the copy operation is going to take more than 2 seconds. The operation can be aborted. See issues #3664 and #3632.
1 parent d792cc8 commit d1a61c8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/ExtendedTableWidget.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <QComboBox>
2727
#include <QPainter>
2828
#include <QShortcut>
29+
#include <QProgressDialog>
2930

3031
#include <limits>
3132

@@ -506,7 +507,6 @@ void ExtendedTableWidget::reloadSettings()
506507

507508
void ExtendedTableWidget::copyMimeData(const QModelIndexList& fromIndices, QMimeData* mimeData, const bool withHeaders, const bool inSQL)
508509
{
509-
QApplication::setOverrideCursor(Qt::WaitCursor);
510510
QModelIndexList indices = fromIndices;
511511

512512
// Remove all indices from hidden columns, because if we don't, we might copy data from hidden columns as well which is very
@@ -624,6 +624,11 @@ void ExtendedTableWidget::copyMimeData(const QModelIndexList& fromIndices, QMime
624624
}
625625
}
626626

627+
QProgressDialog progress(this);
628+
progress.setWindowModality(Qt::ApplicationModal);
629+
progress.setRange(*rowsInIndexes.begin(), *rowsInIndexes.end());
630+
progress.setMinimumDuration(2000);
631+
627632
// Iterate over rows x cols checking if the index actually exists when needed, in order
628633
// to support non-rectangular selections.
629634
for(const int row : rowsInIndexes) {
@@ -713,14 +718,19 @@ void ExtendedTableWidget::copyMimeData(const QModelIndexList& fromIndices, QMime
713718
else
714719
htmlResult.append("</tr>");
715720
result.append(rowSepText);
721+
722+
progress.setValue(row);
723+
// Abort the operation if the user pressed ESC key or Cancel button
724+
if (progress.wasCanceled()) {
725+
return;
726+
}
716727
}
717728

718729
if (!inSQL) {
719730
htmlResult.append("</table></body></html>");
720731
mimeData->setHtml(htmlResult);
721732
}
722733
mimeData->setText(result);
723-
QApplication::restoreOverrideCursor();
724734
}
725735

726736
void ExtendedTableWidget::copy(const bool withHeaders, const bool inSQL )

0 commit comments

Comments
 (0)