2017-12-19 18:38:06 +00:00
|
|
|
|
|
|
|
#include "QuickFilterView.h"
|
|
|
|
#include "ui_QuickFilterView.h"
|
|
|
|
|
2018-10-20 18:20:06 +00:00
|
|
|
QuickFilterView::QuickFilterView(QWidget *parent, bool defaultOn) :
|
2018-03-21 20:32:32 +00:00
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::QuickFilterView())
|
2017-12-19 18:38:06 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
connect(ui->closeFilterButton, &QAbstractButton::clicked, this, &QuickFilterView::closeFilter);
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, [this](const QString & text) {
|
2017-12-19 18:38:06 +00:00
|
|
|
emit filterTextChanged(text);
|
|
|
|
});
|
2018-10-20 18:20:06 +00:00
|
|
|
|
|
|
|
if (!defaultOn) {
|
|
|
|
closeFilter();
|
|
|
|
}
|
2017-12-19 18:38:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QuickFilterView::~QuickFilterView() {}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickFilterView::showFilter()
|
|
|
|
{
|
|
|
|
show();
|
|
|
|
ui->filterLineEdit->setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QuickFilterView::clearFilter()
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
if (ui->filterLineEdit->text().isEmpty()) {
|
2017-12-19 18:38:06 +00:00
|
|
|
closeFilter();
|
2018-03-21 20:32:32 +00:00
|
|
|
} else {
|
2017-12-19 18:38:06 +00:00
|
|
|
ui->filterLineEdit->setText("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QuickFilterView::closeFilter()
|
|
|
|
{
|
2018-08-12 16:20:16 +00:00
|
|
|
ui->filterLineEdit->setText("");
|
2017-12-19 18:38:06 +00:00
|
|
|
hide();
|
|
|
|
emit filterClosed();
|
|
|
|
}
|