TagFilter -> MultiFilter

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-10-31 15:27:33 -02:00 committed by Dirk Hohndel
parent 19ac1dfa09
commit c68a94da6a
4 changed files with 13 additions and 13 deletions

View file

@ -37,7 +37,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
setItemDelegate(new DiveListDelegate(this));
setUniformRowHeights(true);
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate(this));
TagFilterSortModel *model = TagFilterSortModel::instance();
MultiFilterSortModel *model = MultiFilterSortModel::instance();
model->setSortRole(DiveTripModel::SORT_ROLE);
model->setFilterKeyColumn(-1); // filter all columns
model->setFilterCaseSensitivity(Qt::CaseInsensitive);

View file

@ -2351,17 +2351,17 @@ bool TagFilterModel::filterRow(int source_row, const QModelIndex &source_parent,
return false;
}
TagFilterSortModel *TagFilterSortModel::instance()
MultiFilterSortModel *MultiFilterSortModel::instance()
{
static TagFilterSortModel *self = new TagFilterSortModel();
static MultiFilterSortModel *self = new MultiFilterSortModel();
return self;
}
TagFilterSortModel::TagFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent)
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent)
{
}
bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
if (models.isEmpty()) {
return true;
@ -2376,12 +2376,12 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou
return false;
}
void TagFilterSortModel::myInvalidate()
void MultiFilterSortModel::myInvalidate()
{
invalidate();
}
void TagFilterSortModel::addFilterModel(MultiFilterInterface *model)
void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model)
{
QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
Q_ASSERT(itemModel);
@ -2389,7 +2389,7 @@ void TagFilterSortModel::addFilterModel(MultiFilterInterface *model)
connect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
}
void TagFilterSortModel::removeFilterModel(MultiFilterInterface *model)
void MultiFilterSortModel::removeFilterModel(MultiFilterInterface *model)
{
QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
Q_ASSERT(itemModel);

View file

@ -443,17 +443,17 @@ private:
explicit TagFilterModel(QObject *parent = 0);
};
class TagFilterSortModel : public QSortFilterProxyModel {
class MultiFilterSortModel : public QSortFilterProxyModel {
Q_OBJECT
public:
static TagFilterSortModel *instance();
static MultiFilterSortModel *instance();
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
void addFilterModel(MultiFilterInterface *model);
void removeFilterModel(MultiFilterInterface *model);
public slots:
void myInvalidate();
private:
TagFilterSortModel(QObject *parent = 0);
MultiFilterSortModel(QObject *parent = 0);
QList<MultiFilterInterface*> models;
};
#endif // MODELS_H

View file

@ -467,13 +467,13 @@ TagFilter::TagFilter(QWidget *parent) : QWidget(parent)
void TagFilter::showEvent(QShowEvent *event)
{
TagFilterSortModel::instance()->addFilterModel(TagFilterModel::instance());
MultiFilterSortModel::instance()->addFilterModel(TagFilterModel::instance());
QWidget::showEvent(event);
}
void TagFilter::hideEvent(QHideEvent *event)
{
TagFilterSortModel::instance()->removeFilterModel(TagFilterModel::instance());
MultiFilterSortModel::instance()->removeFilterModel(TagFilterModel::instance());
QWidget::hideEvent(event);
}