Skip to content

Commit

Permalink
plot: Add button to load all data
Browse files Browse the repository at this point in the history
See issue sqlitebrowser#499.

This also fixes a bug introduced in 6784a6a
which effectively disabled the partial prefetch mechanism on large
tables.
  • Loading branch information
MKleusberg committed May 5, 2016
1 parent cb79aba commit b00c4f7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 39 deletions.
17 changes: 13 additions & 4 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,10 +1713,6 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update)

if(model)
{
// Make sure all data is loaded before trying to plot anything
while(model->canFetchMore())
model->fetchMore();

for(int i = 0; i < model->columnCount(); ++i)
{
QVariant::Type columntype = guessdatatype(model, i);
Expand Down Expand Up @@ -2493,3 +2489,16 @@ void MainWindow::browseDataSetDefaultTableEncoding()
{
browseDataSetTableEncoding(true);
}

void MainWindow::browseDataFetchAllData()
{
if(m_browseTableModel)
{
// Make sure all data is loaded
while(m_browseTableModel->canFetchMore())
m_browseTableModel->fetchMore();

// Update plot
updatePlot(m_browseTableModel);
}
}
1 change: 1 addition & 0 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ private slots:
void showRowidColumn(bool show);
void browseDataSetTableEncoding(bool forAllTables = false);
void browseDataSetDefaultTableEncoding();
void browseDataFetchAllData();
};

#endif
108 changes: 73 additions & 35 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>280</width>
<width>468</width>
<height>558</height>
</rect>
</property>
Expand Down Expand Up @@ -1255,6 +1255,17 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLoadAllData">
<property name="toolTip">
<string>Load all data. This has only an effect if not all data has been fetched from the table yet due to the partial fetch mechanism.</string>
</property>
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/keyword</normaloff>:/icons/keyword</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1867,6 +1878,16 @@
<tabstop>spinPragmaWalAutoCheckpoint</tabstop>
<tabstop>comboLogSubmittedBy</tabstop>
<tabstop>buttonLogClear</tabstop>
<tabstop>mainTab</tabstop>
<tabstop>buttonBegin</tabstop>
<tabstop>buttonEnd</tabstop>
<tabstop>tabSqlAreas</tabstop>
<tabstop>treePlotColumns</tabstop>
<tabstop>comboLineType</tabstop>
<tabstop>comboPointShape</tabstop>
<tabstop>butSavePlot</tabstop>
<tabstop>buttonLoadAllData</tabstop>
<tabstop>treeSchemaDock</tabstop>
</tabstops>
<resources>
<include location="icons/icons.qrc"/>
Expand Down Expand Up @@ -1959,8 +1980,8 @@
<slot>addRecord()</slot>
<hints>
<hint type="sourcelabel">
<x>443</x>
<y>141</y>
<x>402</x>
<y>143</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand All @@ -1975,8 +1996,8 @@
<slot>deleteRecord()</slot>
<hints>
<hint type="sourcelabel">
<x>565</x>
<y>141</y>
<x>506</x>
<y>143</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand All @@ -1991,8 +2012,8 @@
<slot>navigatePrevious()</slot>
<hints>
<hint type="sourcelabel">
<x>74</x>
<y>585</y>
<x>86</x>
<y>539</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand All @@ -2007,8 +2028,8 @@
<slot>navigateNext()</slot>
<hints>
<hint type="sourcelabel">
<x>168</x>
<y>585</y>
<x>183</x>
<y>539</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand All @@ -2023,8 +2044,8 @@
<slot>navigateGoto()</slot>
<hints>
<hint type="sourcelabel">
<x>413</x>
<y>586</y>
<x>365</x>
<y>539</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand All @@ -2039,8 +2060,8 @@
<slot>navigateGoto()</slot>
<hints>
<hint type="sourcelabel">
<x>565</x>
<y>586</y>
<x>506</x>
<y>538</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand Down Expand Up @@ -2295,8 +2316,8 @@
<slot>createTreeContextMenu(QPoint)</slot>
<hints>
<hint type="sourcelabel">
<x>101</x>
<y>125</y>
<x>111</x>
<y>261</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
Expand Down Expand Up @@ -2343,8 +2364,8 @@
<slot>loadPragmas()</slot>
<hints>
<hint type="sourcelabel">
<x>101</x>
<y>125</y>
<x>111</x>
<y>540</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
Expand All @@ -2359,8 +2380,8 @@
<slot>savePragmas()</slot>
<hints>
<hint type="sourcelabel">
<x>101</x>
<y>125</y>
<x>111</x>
<y>540</y>
</hint>
<hint type="destinationlabel">
<x>802</x>
Expand All @@ -2379,8 +2400,8 @@
<y>126</y>
</hint>
<hint type="destinationlabel">
<x>691</x>
<y>163</y>
<x>632</x>
<y>173</y>
</hint>
</hints>
</connection>
Expand All @@ -2395,8 +2416,8 @@
<y>126</y>
</hint>
<hint type="destinationlabel">
<x>990</x>
<y>240</y>
<x>1028</x>
<y>230</y>
</hint>
</hints>
</connection>
Expand All @@ -2407,12 +2428,12 @@
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>872</x>
<y>126</y>
<x>772</x>
<y>135</y>
</hint>
<hint type="destinationlabel">
<x>987</x>
<y>240</y>
<x>1028</x>
<y>230</y>
</hint>
</hints>
</connection>
Expand All @@ -2439,8 +2460,8 @@
<slot>closeSqlTab(int)</slot>
<hints>
<hint type="sourcelabel">
<x>81</x>
<y>125</y>
<x>91</x>
<y>259</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
Expand Down Expand Up @@ -2663,8 +2684,8 @@
<slot>navigateEnd()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>573</y>
<x>223</x>
<y>539</y>
</hint>
<hint type="destinationlabel">
<x>499</x>
Expand All @@ -2679,8 +2700,8 @@
<slot>navigateBegin()</slot>
<hints>
<hint type="sourcelabel">
<x>69</x>
<y>140</y>
<x>50</x>
<y>539</y>
</hint>
<hint type="destinationlabel">
<x>499</x>
Expand Down Expand Up @@ -2727,8 +2748,8 @@
<slot>jumpToRow(QString,QString,QByteArray)</slot>
<hints>
<hint type="sourcelabel">
<x>60</x>
<y>105</y>
<x>70</x>
<y>242</y>
</hint>
<hint type="destinationlabel">
<x>518</x>
Expand Down Expand Up @@ -2800,6 +2821,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>buttonLoadAllData</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>browseDataFetchAllData()</slot>
<hints>
<hint type="sourcelabel">
<x>1003</x>
<y>389</y>
</hint>
<hint type="destinationlabel">
<x>1005</x>
<y>412</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>fileOpen()</slot>
Expand Down Expand Up @@ -2860,5 +2897,6 @@
<slot>showRowidColumn(bool)</slot>
<slot>browseDataSetTableEncoding()</slot>
<slot>browseDataSetDefaultTableEncoding()</slot>
<slot>browseDataFetchAllData()</slot>
</slots>
</ui>

0 comments on commit b00c4f7

Please sign in to comment.