Make number of rows to prefetch when doing lazy population configuarable

Add a new option to the settings dialog to allow changing the number of
rows to get at a time.
This commit is contained in:
Martin Kleusberg
2013-04-24 20:25:36 +02:00
parent 3d5d7fabe0
commit 7799ef1865
3 changed files with 31 additions and 4 deletions
+6
View File
@@ -43,6 +43,7 @@ void PreferencesDialog::loadSettings()
ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(getSettingsValue("db", "defaultencoding").toString(), Qt::MatchFixedString)); ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(getSettingsValue("db", "defaultencoding").toString(), Qt::MatchFixedString));
ui->locationEdit->setText(getSettingsValue("db", "defaultlocation").toString()); ui->locationEdit->setText(getSettingsValue("db", "defaultlocation").toString());
ui->foreignKeysCheckBox->setChecked(getSettingsValue("db", "foreignkeys").toBool()); ui->foreignKeysCheckBox->setChecked(getSettingsValue("db", "foreignkeys").toBool());
ui->spinPrefetchSize->setValue(getSettingsValue("db", "prefetchsize").toInt());
for(int i=0;i<ui->treeSyntaxHighlighting->topLevelItemCount();i++) for(int i=0;i<ui->treeSyntaxHighlighting->topLevelItemCount();i++)
{ {
@@ -63,6 +64,7 @@ void PreferencesDialog::saveSettings()
setSettingsValue("db", "defaultencoding", ui->encodingComboBox->currentText()); setSettingsValue("db", "defaultencoding", ui->encodingComboBox->currentText());
setSettingsValue("db", "defaultlocation", ui->locationEdit->text()); setSettingsValue("db", "defaultlocation", ui->locationEdit->text());
setSettingsValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked()); setSettingsValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked());
setSettingsValue("db", "prefetchsize", ui->spinPrefetchSize->value());
for(int i=0;i<ui->treeSyntaxHighlighting->topLevelItemCount();i++) for(int i=0;i<ui->treeSyntaxHighlighting->topLevelItemCount();i++)
{ {
@@ -120,6 +122,10 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
if(group == "db" && name == "foreignkeys") if(group == "db" && name == "foreignkeys")
return true; return true;
// db/prefetchsize?
if(group == "db" && name == "prefetchsize")
return 50000;
// MainWindow/geometry? // MainWindow/geometry?
if(group == "MainWindow" && name == "geometry") if(group == "MainWindow" && name == "geometry")
return ""; return "";
+23 -2
View File
@@ -102,6 +102,26 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Prefetch block size</string>
</property>
<property name="buddy">
<cstring>spinPrefetchSize</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spinPrefetchSize">
<property name="minimum">
<number>255</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
@@ -271,6 +291,7 @@
<tabstop>foreignKeysCheckBox</tabstop> <tabstop>foreignKeysCheckBox</tabstop>
<tabstop>locationEdit</tabstop> <tabstop>locationEdit</tabstop>
<tabstop>setLocationButton</tabstop> <tabstop>setLocationButton</tabstop>
<tabstop>spinPrefetchSize</tabstop>
<tabstop>treeSyntaxHighlighting</tabstop> <tabstop>treeSyntaxHighlighting</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
@@ -331,8 +352,8 @@
<slot>showColourDialog(QTreeWidgetItem*,int)</slot> <slot>showColourDialog(QTreeWidgetItem*,int)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>223</x> <x>103</x>
<y>92</y> <y>53</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>395</x> <x>395</x>
+2 -2
View File
@@ -1,6 +1,6 @@
#include "sqlitetablemodel.h" #include "sqlitetablemodel.h"
#include "sqlitedb.h" #include "sqlitedb.h"
#include "PreferencesDialog.h"
#include <QDebug> #include <QDebug>
SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db) SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db)
@@ -9,7 +9,7 @@ SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db)
, m_rowCount(0) , m_rowCount(0)
, m_iSortColumn(0) , m_iSortColumn(0)
, m_sSortOrder("ASC") , m_sSortOrder("ASC")
, m_chunkSize(50000) , m_chunkSize(PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt())
, m_valid(false) , m_valid(false)
{ {
} }