mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-12 13:46:16 +00:00
TagFilter -> MultiFilter
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
19ac1dfa09
commit
c68a94da6a
4 changed files with 13 additions and 13 deletions
|
@ -37,7 +37,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
setItemDelegate(new DiveListDelegate(this));
|
setItemDelegate(new DiveListDelegate(this));
|
||||||
setUniformRowHeights(true);
|
setUniformRowHeights(true);
|
||||||
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate(this));
|
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate(this));
|
||||||
TagFilterSortModel *model = TagFilterSortModel::instance();
|
MultiFilterSortModel *model = MultiFilterSortModel::instance();
|
||||||
model->setSortRole(DiveTripModel::SORT_ROLE);
|
model->setSortRole(DiveTripModel::SORT_ROLE);
|
||||||
model->setFilterKeyColumn(-1); // filter all columns
|
model->setFilterKeyColumn(-1); // filter all columns
|
||||||
model->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
model->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
|
|
@ -2351,17 +2351,17 @@ bool TagFilterModel::filterRow(int source_row, const QModelIndex &source_parent,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagFilterSortModel *TagFilterSortModel::instance()
|
MultiFilterSortModel *MultiFilterSortModel::instance()
|
||||||
{
|
{
|
||||||
static TagFilterSortModel *self = new TagFilterSortModel();
|
static MultiFilterSortModel *self = new MultiFilterSortModel();
|
||||||
return self;
|
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()) {
|
if (models.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -2376,12 +2376,12 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagFilterSortModel::myInvalidate()
|
void MultiFilterSortModel::myInvalidate()
|
||||||
{
|
{
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagFilterSortModel::addFilterModel(MultiFilterInterface *model)
|
void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
|
QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
|
||||||
Q_ASSERT(itemModel);
|
Q_ASSERT(itemModel);
|
||||||
|
@ -2389,7 +2389,7 @@ void TagFilterSortModel::addFilterModel(MultiFilterInterface *model)
|
||||||
connect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
|
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);
|
QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
|
||||||
Q_ASSERT(itemModel);
|
Q_ASSERT(itemModel);
|
||||||
|
|
|
@ -443,17 +443,17 @@ private:
|
||||||
explicit TagFilterModel(QObject *parent = 0);
|
explicit TagFilterModel(QObject *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TagFilterSortModel : public QSortFilterProxyModel {
|
class MultiFilterSortModel : public QSortFilterProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static TagFilterSortModel *instance();
|
static MultiFilterSortModel *instance();
|
||||||
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||||
void addFilterModel(MultiFilterInterface *model);
|
void addFilterModel(MultiFilterInterface *model);
|
||||||
void removeFilterModel(MultiFilterInterface *model);
|
void removeFilterModel(MultiFilterInterface *model);
|
||||||
public slots:
|
public slots:
|
||||||
void myInvalidate();
|
void myInvalidate();
|
||||||
private:
|
private:
|
||||||
TagFilterSortModel(QObject *parent = 0);
|
MultiFilterSortModel(QObject *parent = 0);
|
||||||
QList<MultiFilterInterface*> models;
|
QList<MultiFilterInterface*> models;
|
||||||
};
|
};
|
||||||
#endif // MODELS_H
|
#endif // MODELS_H
|
||||||
|
|
|
@ -467,13 +467,13 @@ TagFilter::TagFilter(QWidget *parent) : QWidget(parent)
|
||||||
|
|
||||||
void TagFilter::showEvent(QShowEvent *event)
|
void TagFilter::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
TagFilterSortModel::instance()->addFilterModel(TagFilterModel::instance());
|
MultiFilterSortModel::instance()->addFilterModel(TagFilterModel::instance());
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagFilter::hideEvent(QHideEvent *event)
|
void TagFilter::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
TagFilterSortModel::instance()->removeFilterModel(TagFilterModel::instance());
|
MultiFilterSortModel::instance()->removeFilterModel(TagFilterModel::instance());
|
||||||
QWidget::hideEvent(event);
|
QWidget::hideEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue