mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-03 02:19:27 -05:00
Show info in status bar when a selection is made in Data Browser
When a selection is made in the Data Browser, the status bar shows: number of rows, number of columns, sum and average of numeric values (other data types count as 0) in the selection. For avoiding expensive computations when the selection is very big (selecting all cells or an entire column) the threshold setting for the completion is reused. This was inspired by #1791, but does not implement the proposed feature.
This commit is contained in:
@@ -721,6 +721,20 @@ void MainWindow::populateTable()
|
||||
connect(ui->dataTable->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex)));
|
||||
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection&, const QItemSelection&) {
|
||||
updateInsertDeleteRecordButton();
|
||||
|
||||
const QModelIndexList& sel = ui->dataTable->selectionModel()->selectedIndexes();
|
||||
if (sel.count() > 1 && sel.count() < Settings::getValue("databrowser", "complete_threshold").toInt()) {
|
||||
int rows = sel.last().row() - sel.first().row() + 1;
|
||||
int columns = sel.last().column() - sel.first().column() + 1;
|
||||
double sum = 0;
|
||||
for (const QModelIndex& index : sel) {
|
||||
QVariant data = m_browseTableModel->data(index, Qt::EditRole);
|
||||
sum += data.toDouble();
|
||||
}
|
||||
ui->statusbar->showMessage(QString("%1 rows, %2 columns. Sum: %3. Average: %4").arg(rows).arg(columns).arg(sum).
|
||||
arg(sum/sel.count()));
|
||||
} else
|
||||
ui->statusbar->showMessage(QString());
|
||||
});
|
||||
}
|
||||
// Search stored table settings for this table
|
||||
|
||||
@@ -794,8 +794,10 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This is the maximum number of rows in a table for enabling the value completion based on current values in the column.
|
||||
Can be set to 0 for disabling completion.</string>
|
||||
<string>This is the maximum number of items allowed for some computationally expensive functionalities to be enabled:
|
||||
Maximum number of rows in a table for enabling the value completion based on current values in the column.
|
||||
Maximum number of indexes in a selection for calculating sum and average.
|
||||
Can be set to 0 for disabling the functionalities.</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>This is the maximum number of rows in a table for enabling the value completion based on current values in the column.
|
||||
@@ -812,7 +814,7 @@ Can be set to 0 for disabling completion.</string>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCompleteThreshold">
|
||||
<property name="text">
|
||||
<string>Row count threshold for completion</string>
|
||||
<string>Threshold for completion and calculation on selection</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinCompleteThreshold</cstring>
|
||||
|
||||
Reference in New Issue
Block a user