enhancement: preserve field filters when switching tab

This commit is contained in:
schdub
2015-05-11 23:35:59 +03:00
parent b5796d5df7
commit b5c1c7b0ab
7 changed files with 34 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ void FilterTableHeader::generateFilters(int number, bool bKeepValues)
FilterLineEdit* l = new FilterLineEdit(this, &filterWidgets, i);
l->setVisible(i>0); // This hides the first input widget which belongs to the hidden rowid column
connect(l, SIGNAL(textChanged(QString)), this, SLOT(inputChanged(QString)));
if(bKeepValues && !oldvalues[i].isEmpty()) // restore old values
if(bKeepValues && oldvalues.size() > i && !oldvalues[i].isEmpty()) // restore old values
l->setText(oldvalues[i]);
filterWidgets.push_back(l);
}
@@ -123,3 +123,9 @@ void FilterTableHeader::inputChanged(const QString& new_value)
// Just get the column number and the new value and send them to anybody interested in filter changes
emit filterChanged(sender()->property("column").toInt(), new_value);
}
void FilterTableHeader::clearFilters()
{
foreach (FilterLineEdit* filterLineEdit, filterWidgets)
filterLineEdit->clear();
}

View File

@@ -19,6 +19,7 @@ public:
public slots:
void generateFilters(int number, bool bKeepValues = false);
void adjustPositions();
void clearFilters();
signals:
void filterChanged(int column, QString value);

View File

@@ -388,7 +388,7 @@ void MainWindow::resetBrowser()
curBrowseOrderByIndex = 0;
curBrowseOrderByMode = Qt::AscendingOrder;
m_browseTableModel->sort(curBrowseOrderByIndex, curBrowseOrderByMode);
populateTable(ui->comboBrowseTable->currentText());
populateTable(ui->comboBrowseTable->currentText(), true);
}
void MainWindow::fileClose()
@@ -1106,6 +1106,7 @@ void MainWindow::activateFields(bool enable)
ui->actionSqlSaveFile->setEnabled(enable);
ui->actionSaveProject->setEnabled(enable);
ui->actionEncryption->setEnabled(enable);
ui->buttonClearFilters->setEnabled(enable);
}
void MainWindow::browseTableHeaderClicked(int logicalindex)
@@ -2089,3 +2090,8 @@ void MainWindow::switchToBrowseDataTab()
ui->comboBrowseTable->setCurrentIndex(ui->comboBrowseTable->findText(tableToBrowse));
populateTable(tableToBrowse);
}
void MainWindow::on_buttonClearFilters_clicked()
{
ui->dataTable->filterHeader()->clearFilters();
}

View File

@@ -175,6 +175,7 @@ private slots:
void updateFilter(int column, const QString& value);
void editEncryption();
void switchToBrowseDataTab();
void on_buttonClearFilters_clicked();
};
#endif

View File

@@ -125,6 +125,20 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonClearFilters">
<property name="toolTip">
<string>Clear all filters</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/clear_filters</normaloff>:/icons/clear_filters</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@@ -310,8 +324,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>575</width>
<height>458</height>
<width>311</width>
<height>531</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@@ -796,7 +810,7 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>19</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="fileMenu">

BIN
src/icons/clear_filters.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

View File

@@ -44,5 +44,6 @@
<file alias="document_open">document-open.png</file>
<file alias="function">chart_curve.png</file>
<file alias="keyword">cog.png</file>
<file alias="clear_filters">clear_filters.png</file>
</qresource>
</RCC>