Skip to content

Commit 0e1eb7d

Browse files
committed
Remove filter widgets when the table is empty
Instead of hiding them, which had some noticeable glitches. See comments in issue #2188.
1 parent 8503184 commit 0e1eb7d

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/FilterTableHeader.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,3 @@ void FilterTableHeader::setFilter(size_t column, const QString& value)
128128
if(column < filterWidgets.size())
129129
filterWidgets.at(column)->setText(value);
130130
}
131-
132-
void FilterTableHeader::setFiltersVisible(bool visible)
133-
{
134-
// Loop through all widgets
135-
for(size_t i=0; i < filterWidgets.size(); ++i)
136-
{
137-
// Get the current widget, and set it visible or not
138-
filterWidgets.at(i)->setVisible(visible);
139-
}
140-
}

src/FilterTableHeader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class FilterTableHeader : public QHeaderView
1515
explicit FilterTableHeader(QTableView* parent = nullptr);
1616
QSize sizeHint() const override;
1717
bool hasFilters() const {return (filterWidgets.size() > 0);}
18-
void setFiltersVisible(bool visible);
1918

2019
public slots:
2120
void generateFilters(size_t number, bool showFirst = false);

src/TableBrowser.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,16 @@ void TableBrowser::updateRecordsetLabel()
691691
enableEditing(m_model->rowCountAvailable() != SqliteTableModel::RowCount::Unknown && is_table_or_unlocked_view);
692692

693693
// Show filters unless the table is empty
694-
const bool filtersVisible = m_model->rowCount() > 0 || m_model->filterCount() != 0;
695-
qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader())->setFiltersVisible(filtersVisible);
694+
const bool needs_filters = total > 0 || m_model->filterCount() > 0;
695+
FilterTableHeader* header = qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader());
696+
if(header) {
697+
if(needs_filters && !header->hasFilters()) {
698+
generateFilters();
699+
ui->dataTable->adjustSize();
700+
} else if(!needs_filters && header->hasFilters()) {
701+
header->generateFilters(0);
702+
}
703+
}
696704
}
697705

698706
sqlb::Query TableBrowser::buildQuery(const BrowseDataTableSettings& storedData, const sqlb::ObjectIdentifier& tablename) const

0 commit comments

Comments
 (0)