diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-09-17 16:18:37 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-09-17 15:28:21 -0700 |
commit | 4e3689370d8e81716759a5b29934c35cf848a379 (patch) | |
tree | ba31729f83291facedc3ddc232aa23e815371031 /qt-ui/models.cpp | |
parent | a6e9a1eab561af3255d99d31011c57135a90ca3f (diff) | |
download | subsurface-4e3689370d8e81716759a5b29934c35cf848a379.tar.gz |
Create the sorting method.
This method should remove a row on the dive list model
visualization if none of the tags that it have are marked
as 'visible'.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r-- | qt-ui/models.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index b22702795..def258a5f 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2150,3 +2150,28 @@ bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, in } return false; } + +TagFilterSortModel::TagFilterSortModel(QObject *parent): QSortFilterProxyModel(parent) +{ + +} + +bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent); + QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE); + struct dive* d = (struct dive* ) diveVariant.value<void*>(); + if(!d) + return false; // it's a trip. + + // Checked means 'Show', Unchecked means 'Hide'. + struct tag_entry *head = d->tag_list; + + while(head) { + QString tagName(head->tag->name); + int index = TagFilterModel::instance()->stringList().indexOf(tagName); + if (TagFilterModel::instance()->checkState[index] == false ) + return true; + } + return false; +} |