mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Threshold in row count for disabling value completion
A setting is added for disabling the value completion when the row count of the table is greater than the threshold.
This commit is contained in:
@@ -108,13 +108,16 @@ ExtendedTableWidgetEditorDelegate::ExtendedTableWidgetEditorDelegate(QObject* pa
|
||||
|
||||
QWidget* ExtendedTableWidgetEditorDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& /*option*/, const QModelIndex& index) const
|
||||
{
|
||||
// Just create a normal line editor but set the maximum length to the highest possible value instead of the default 32768.
|
||||
QLineEdit* editor = new QLineEdit(parent);
|
||||
QCompleter *completer = new QCompleter(editor);
|
||||
completer->setModel(const_cast<QAbstractItemModel*>(index.model()));
|
||||
completer->setCompletionColumn(index.column());
|
||||
completer->setCompletionMode(QCompleter::InlineCompletion);
|
||||
editor->setCompleter(completer);
|
||||
// If the row count is not greater than the complete threshold setting, set a completer of values based on current values in the column.
|
||||
if (index.model()->rowCount() <= Settings::getValue("databrowser", "complete_threshold").toInt()) {
|
||||
QCompleter *completer = new QCompleter(editor);
|
||||
completer->setModel(const_cast<QAbstractItemModel*>(index.model()));
|
||||
completer->setCompletionColumn(index.column());
|
||||
completer->setCompletionMode(QCompleter::InlineCompletion);
|
||||
editor->setCompleter(completer);
|
||||
}
|
||||
// Set the maximum length to the highest possible value instead of the default 32768.
|
||||
editor->setMaxLength(std::numeric_limits<int>::max());
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ void PreferencesDialog::loadSettings()
|
||||
loadColorSetting(ui->fr_reg_bg, "reg_bg");
|
||||
|
||||
ui->spinSymbolLimit->setValue(Settings::getValue("databrowser", "symbol_limit").toInt());
|
||||
ui->spinCompleteThreshold->setValue(Settings::getValue("databrowser", "complete_threshold").toInt());
|
||||
ui->txtNull->setText(Settings::getValue("databrowser", "null_text").toString());
|
||||
ui->txtBlob->setText(Settings::getValue("databrowser", "blob_text").toString());
|
||||
ui->editFilterEscape->setText(Settings::getValue("databrowser", "filter_escape").toString());
|
||||
@@ -209,6 +210,7 @@ void PreferencesDialog::saveSettings()
|
||||
saveColorSetting(ui->fr_bin_fg, "bin_fg");
|
||||
saveColorSetting(ui->fr_bin_bg, "bin_bg");
|
||||
Settings::setValue("databrowser", "symbol_limit", ui->spinSymbolLimit->value());
|
||||
Settings::setValue("databrowser", "complete_threshold", ui->spinCompleteThreshold->value());
|
||||
Settings::setValue("databrowser", "null_text", ui->txtNull->text());
|
||||
Settings::setValue("databrowser", "blob_text", ui->txtBlob->text());
|
||||
Settings::setValue("databrowser", "filter_escape", ui->editFilterEscape->text());
|
||||
|
||||
@@ -469,6 +469,40 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinCompleteThreshold">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</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>
|
||||
</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.
|
||||
Can be set to 0 for disabling completion.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCompleteThreshold">
|
||||
<property name="text">
|
||||
<string>Row count threshold for completion</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinCompleteThreshold</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -176,6 +176,8 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
|
||||
return 10;
|
||||
if(name == "symbol_limit")
|
||||
return 5000;
|
||||
if(name == "complete_threshold")
|
||||
return 1000;
|
||||
if(name == "indent_compact")
|
||||
return false;
|
||||
if(name == "auto_switch_mode")
|
||||
|
||||
Reference in New Issue
Block a user