Handle Show / Close of the Filter Box

when you close, remove filter. when you open again, restore.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2018-11-16 15:24:11 +01:00 committed by Dirk Hohndel
parent 81bb6086c0
commit 43178be1f2
2 changed files with 20 additions and 0 deletions

View file

@ -81,5 +81,19 @@ void FilterWidget2::updateFilter()
data.equipment = ui->equipment->text().split(",", QString::SkipEmptyParts);
data.invertFilter = ui->invertFilter->isChecked();
filterData = data;
emit filterDataChanged(data);
}
void FilterWidget2::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
emit filterDataChanged(filterData);
}
void FilterWidget2::hideEvent(QHideEvent *event)
{
QWidget::hideEvent(event);
FilterData data;
emit filterDataChanged(data);
}

View file

@ -2,6 +2,8 @@
#define FILTERWIDGET_2_H
#include <QWidget>
#include <QHideEvent>
#include <QShowEvent>
#include <memory>
@ -18,12 +20,16 @@ class FilterWidget2 : public QWidget {
public:
explicit FilterWidget2(QWidget *parent = 0);
void updateFilter();
protected:
void hideEvent(QHideEvent *event) override;
void showEvent(QShowEvent *event) override;
signals:
void filterDataChanged(const FilterData& data);
private:
std::unique_ptr<Ui::FilterWidget2> ui;
FilterData filterData;
};
#endif