Skip to content

Commit eb05a2b

Browse files
committed
Workaround for #2592 and #2787
2 parents 33ee736 + 1baf012 commit eb05a2b

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/Settings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string&
294294
return 10;
295295
if(name == "symbol_limit")
296296
return 5000;
297+
if (name == "rows_limit")
298+
return 10'000'000;
297299
if(name == "complete_threshold")
298300
return 1000;
299301
if(name == "image_preview")

src/TableBrowser.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ void TableBrowser::updateRecordsetLabel()
688688
// Get all the numbers, i.e. the number of the first row and the last row as well as the total number of rows
689689
int from = ui->dataTable->verticalHeader()->visualIndexAt(0) + 1;
690690
int total = m_model->rowCount();
691+
int real_total = m_model->realRowCount();
691692
int to = from + ui->dataTable->numVisibleRows() - 1;
692693
if(to < 0)
693694
to = 0;
@@ -718,10 +719,13 @@ void TableBrowser::updateRecordsetLabel()
718719
txt = tr("determining row count...");
719720
break;
720721
case SqliteTableModel::RowCount::Partial:
721-
txt = tr("%1 - %2 of >= %3").arg(from).arg(to).arg(total);
722+
txt = tr("%L1 - %L2 of >= %L3").arg(from).arg(to).arg(total);
722723
break;
723724
case SqliteTableModel::RowCount::Complete:
724-
txt = tr("%1 - %2 of %3").arg(from).arg(to).arg(total);
725+
txt = tr("%L1 - %L2 of %L3").arg(from).arg(to).arg(real_total);
726+
if (real_total != total) {
727+
txt.append(tr(" (clipped at %L1 rows)").arg(total));
728+
}
725729
break;
726730
}
727731
ui->labelRecordset->setText(txt);

src/sqlitetablemodel.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SqliteTableModel::SqliteTableModel(DBBrowserDB& db, QObject* parent, const QStri
2727
, m_db(db)
2828
, m_lifeCounter(0)
2929
, m_currentRowCount(0)
30+
, m_realRowCount(0)
3031
, m_encoding(encoding)
3132
{
3233
// Load initial settings first
@@ -97,6 +98,11 @@ void SqliteTableModel::handleRowCountComplete (int life_id, int num_rows)
9798
if(life_id < m_lifeCounter)
9899
return;
99100

101+
m_realRowCount = static_cast<unsigned int>(num_rows);
102+
if (num_rows > m_rowsLimit) {
103+
num_rows = m_rowsLimit;
104+
}
105+
100106
m_rowCountAvailable = RowCount::Complete;
101107
handleFinishedFetch(life_id, static_cast<unsigned int>(num_rows), static_cast<unsigned int>(num_rows));
102108

@@ -178,6 +184,11 @@ int SqliteTableModel::rowCount(const QModelIndex&) const
178184
return static_cast<int>(m_currentRowCount);
179185
}
180186

187+
int SqliteTableModel::realRowCount() const
188+
{
189+
return static_cast<int>(m_realRowCount);
190+
}
191+
181192
int SqliteTableModel::columnCount(const QModelIndex&) const
182193
{
183194
return static_cast<int>(m_headers.size());
@@ -637,6 +648,7 @@ bool SqliteTableModel::insertRows(int row, int count, const QModelIndex& parent)
637648
{
638649
m_cache.insert(i + static_cast<size_t>(row), std::move(tempList.at(i)));
639650
m_currentRowCount++;
651+
m_realRowCount++;
640652
}
641653
endInsertRows();
642654

@@ -670,6 +682,7 @@ bool SqliteTableModel::removeRows(int row, int count, const QModelIndex& parent)
670682
{
671683
m_cache.erase(static_cast<size_t>(row + i));
672684
m_currentRowCount--;
685+
m_realRowCount--;
673686
}
674687

675688
endRemoveRows();
@@ -868,6 +881,7 @@ void SqliteTableModel::clearCache()
868881
m_cache.clear();
869882

870883
m_currentRowCount = 0;
884+
m_realRowCount = 0;
871885
m_rowCountAvailable = RowCount::Unknown;
872886
}
873887

@@ -1166,6 +1180,7 @@ void SqliteTableModel::reloadSettings()
11661180
m_font = QFont(Settings::getValue("databrowser", "font").toString());
11671181
m_font.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
11681182
m_symbolLimit = Settings::getValue("databrowser", "symbol_limit").toInt();
1183+
m_rowsLimit = Settings::getValue("databrowser", "rows_limit").toInt();
11691184
m_imagePreviewEnabled = Settings::getValue("databrowser", "image_preview").toBool();
11701185
m_chunkSize = static_cast<std::size_t>(Settings::getValue("db", "prefetchsize").toUInt());
11711186
}

src/sqlitetablemodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SqliteTableModel : public QAbstractTableModel
3535

3636
/// returns logical amount of rows, whether currently cached or not
3737
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
38+
int realRowCount() const;
3839

3940
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
4041
size_t filterCount() const;
@@ -191,6 +192,7 @@ public slots:
191192
/// the full row count, when the row-count query returns)
192193
RowCount m_rowCountAvailable;
193194
unsigned int m_currentRowCount;
195+
unsigned int m_realRowCount;
194196

195197
std::vector<std::string> m_headers;
196198

@@ -237,6 +239,7 @@ public slots:
237239
QColor m_binBgColour;
238240
QFont m_font;
239241
int m_symbolLimit;
242+
int m_rowsLimit;
240243
bool m_imagePreviewEnabled;
241244

242245
/**

0 commit comments

Comments
 (0)