Merge pull request #2801 from sandman7920/master

QTableView int32_t overflow workaround
This commit is contained in:
Manuel
2023-09-06 14:35:13 +02:00
committed by GitHub
4 changed files with 26 additions and 2 deletions

View File

@@ -297,6 +297,8 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string&
return 10;
if(name == "symbol_limit")
return 5000;
if (name == "rows_limit")
return 10'000'000;
if(name == "complete_threshold")
return 1000;
if(name == "image_preview")

View File

@@ -727,6 +727,7 @@ void TableBrowser::updateRecordsetLabel()
// Get all the numbers, i.e. the number of the first row and the last row as well as the total number of rows
int from = ui->dataTable->verticalHeader()->visualIndexAt(0) + 1;
int total = m_model->rowCount();
int real_total = m_model->realRowCount();
int to = from + ui->dataTable->numVisibleRows() - 1;
if(to < 0)
to = 0;
@@ -757,10 +758,13 @@ void TableBrowser::updateRecordsetLabel()
txt = tr("determining row count...");
break;
case SqliteTableModel::RowCount::Partial:
txt = tr("%1 - %2 of >= %3").arg(from).arg(to).arg(total);
txt = tr("%L1 - %L2 of >= %L3").arg(from).arg(to).arg(total);
break;
case SqliteTableModel::RowCount::Complete:
txt = tr("%1 - %2 of %3").arg(from).arg(to).arg(total);
txt = tr("%L1 - %L2 of %L3").arg(from).arg(to).arg(real_total);
if (real_total != total) {
txt.append(tr(" (clipped at %L1 rows)").arg(total));
}
break;
}
ui->labelRecordset->setText(txt);

View File

@@ -24,6 +24,7 @@ SqliteTableModel::SqliteTableModel(DBBrowserDB& db, QObject* parent, const QStri
, m_db(db)
, m_lifeCounter(0)
, m_currentRowCount(0)
, m_realRowCount(0)
, m_encoding(encoding)
{
// Load initial settings first
@@ -94,6 +95,11 @@ void SqliteTableModel::handleRowCountComplete (int life_id, int num_rows)
if(life_id < m_lifeCounter)
return;
m_realRowCount = static_cast<unsigned int>(num_rows);
if (num_rows > m_rowsLimit) {
num_rows = m_rowsLimit;
}
m_rowCountAvailable = RowCount::Complete;
handleFinishedFetch(life_id, static_cast<unsigned int>(num_rows), static_cast<unsigned int>(num_rows));
@@ -175,6 +181,11 @@ int SqliteTableModel::rowCount(const QModelIndex&) const
return static_cast<int>(m_currentRowCount);
}
int SqliteTableModel::realRowCount() const
{
return static_cast<int>(m_realRowCount);
}
int SqliteTableModel::columnCount(const QModelIndex&) const
{
return static_cast<int>(m_headers.size());
@@ -662,6 +673,7 @@ bool SqliteTableModel::insertRows(int row, int count, const QModelIndex& parent)
{
m_cache.insert(i + static_cast<size_t>(row), std::move(tempList.at(i)));
m_currentRowCount++;
m_realRowCount++;
}
endInsertRows();
@@ -695,6 +707,7 @@ bool SqliteTableModel::removeRows(int row, int count, const QModelIndex& parent)
{
m_cache.erase(static_cast<size_t>(row + i));
m_currentRowCount--;
m_realRowCount--;
}
endRemoveRows();
@@ -837,6 +850,7 @@ void SqliteTableModel::clearCache()
m_cache.clear();
m_currentRowCount = 0;
m_realRowCount = 0;
m_rowCountAvailable = RowCount::Unknown;
}
@@ -1137,6 +1151,7 @@ void SqliteTableModel::reloadSettings()
m_font = QFont(Settings::getValue("databrowser", "font").toString());
m_font.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
m_symbolLimit = Settings::getValue("databrowser", "symbol_limit").toInt();
m_rowsLimit = Settings::getValue("databrowser", "rows_limit").toInt();
m_imagePreviewEnabled = Settings::getValue("databrowser", "image_preview").toBool();
m_chunkSize = static_cast<std::size_t>(Settings::getValue("db", "prefetchsize").toUInt());
}

View File

@@ -35,6 +35,7 @@ public:
/// returns logical amount of rows, whether currently cached or not
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int realRowCount() const;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
size_t filterCount() const;
@@ -191,6 +192,7 @@ private:
/// the full row count, when the row-count query returns)
RowCount m_rowCountAvailable;
unsigned int m_currentRowCount;
unsigned int m_realRowCount;
std::vector<std::string> m_headers;
@@ -239,6 +241,7 @@ private:
QColor m_binBgColour;
QFont m_font;
int m_symbolLimit;
int m_rowsLimit;
bool m_imagePreviewEnabled;
/**