Mercurial > retraceit
diff src/filterwidget.cpp @ 88:3916cb3c9105
Add new FilterSort model that allows to include empty values
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 19 Jun 2015 14:26:16 +0200 |
parents | 4e16fbd10945 |
children | b8c7644a9d49 |
line wrap: on
line diff
--- a/src/filterwidget.cpp Thu Jun 18 19:35:22 2015 +0200 +++ b/src/filterwidget.cpp Fri Jun 19 14:26:16 2015 +0200 @@ -15,14 +15,14 @@ #include <QLineEdit> #include <QDebug> -FilterWidget::FilterWidget(QSortFilterProxyModel *model, QWidget *parent, Qt::WindowFlags f) : +FilterWidget::FilterWidget(QSortFilterProxyModel *model, bool addWithEmptyChk, + QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), - mModel(model) { + mModel(model), + mWithEmptyChk(addWithEmptyChk) { Q_ASSERT(model); setupGUI(); - connect(mModel, &QSortFilterProxyModel::sourceModelChanged, - this, &FilterWidget::headersChanged); void (QComboBox:: *idxChanged)(int) = &QComboBox::currentIndexChanged; connect(mCombo, idxChanged, this, &FilterWidget::filterChanged); @@ -32,6 +32,7 @@ } void FilterWidget::headersChanged() { + mCombo->blockSignals(true); QAbstractItemModel *newSource = mModel->sourceModel(); Q_ASSERT(newSource); mCombo->clear(); @@ -48,6 +49,7 @@ } } } + mCombo->blockSignals(false); } void FilterWidget::filterChanged() { @@ -74,6 +76,12 @@ mEditLine->setClearButtonEnabled(true); baseLayout->addWidget(mEditLine); + if (mWithEmptyChk) { + mEmptyChk = new QCheckBox(tr("Include empty fields")); + baseLayout->addWidget(mEmptyChk); + connect(mEmptyChk, &QCheckBox::stateChanged, this, &FilterWidget::includeEmptyChanged); + } + setLayout(root); }