mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Fix progress dialog for imports of very large CSV files
QProgressDialog only takes an int as the maximum value and the current value. So using the number of bytes parsed so far isn't going to work for very large files when an int will overflow. This commit changes this by precalculating a progress indicator and handing that over to the QProgressDialog object. See issue #1212.
This commit is contained in:
@@ -117,13 +117,14 @@ void rollback(
|
||||
class CSVImportProgress : public CSVProgress
|
||||
{
|
||||
public:
|
||||
explicit CSVImportProgress(qint64 filesize)
|
||||
explicit CSVImportProgress(unsigned long long filesize)
|
||||
: totalFileSize(filesize)
|
||||
{
|
||||
m_pProgressDlg = new QProgressDialog(
|
||||
QObject::tr("Importing CSV file..."),
|
||||
QObject::tr("Cancel"),
|
||||
0,
|
||||
filesize);
|
||||
10000);
|
||||
m_pProgressDlg->setWindowModality(Qt::ApplicationModal);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ public:
|
||||
|
||||
bool update(unsigned long long pos)
|
||||
{
|
||||
m_pProgressDlg->setValue(pos);
|
||||
m_pProgressDlg->setValue(static_cast<int>((static_cast<float>(pos) / static_cast<float>(totalFileSize)) * 10000.0f));
|
||||
qApp->processEvents();
|
||||
|
||||
return !m_pProgressDlg->wasCanceled();
|
||||
@@ -152,6 +153,8 @@ public:
|
||||
|
||||
private:
|
||||
QProgressDialog* m_pProgressDlg;
|
||||
|
||||
unsigned long long totalFileSize;
|
||||
};
|
||||
|
||||
void ImportCsvDialog::accept()
|
||||
|
||||
Reference in New Issue
Block a user