cutter/src/widgets/QuickFilterView.cpp

46 lines
923 B
C++
Raw Normal View History

#include "QuickFilterView.h"
#include "ui_QuickFilterView.h"
QuickFilterView::QuickFilterView(QWidget *parent, bool defaultOn) :
2018-03-21 20:32:32 +00:00
QWidget(parent),
ui(new Ui::QuickFilterView())
{
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) {
emit filterTextChanged(text);
});
if (!defaultOn) {
closeFilter();
}
}
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()) {
closeFilter();
2018-03-21 20:32:32 +00:00
} else {
ui->filterLineEdit->setText("");
}
}
void QuickFilterView::closeFilter()
{
ui->filterLineEdit->setText("");
hide();
emit filterClosed();
}