diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-09-17 17:47:35 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-09-17 15:32:05 -0700 |
commit | 06ebd0ea5e83d3f4b923a150858d2f05372e013a (patch) | |
tree | 581e22c73795b8f0cbe4ac56530ca2d3575bb7a4 /qt-ui | |
parent | bef8dc6f4b462472dbcced0ea59cac5727bb45be (diff) | |
download | subsurface-06ebd0ea5e83d3f4b923a150858d2f05372e013a.tar.gz |
Better filtering of dives with no tags.
New rules for them, a new item on the model with the text
"Empty Tags" should be marked if the user wants it to be
displayed.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/models.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index e170c4d04..8b52e6562 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2136,10 +2136,12 @@ void TagFilterModel::repopulate() list.append(QString(current_tag_entry->tag->name)); current_tag_entry = current_tag_entry->next; } + list << tr("Empty Tags"); setStringList(list); delete[] checkState; checkState = new bool[list.count()]; memset(checkState, false, list.count()); + checkState[list.count()-1] = true; } bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, int role) @@ -2173,18 +2175,16 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou // Checked means 'Show', Unchecked means 'Hide'. struct tag_entry *head = d->tag_list; - if (!head){ // doesn't have tags, only show if no tags are selected. - for(int i = 0; i < TagFilterModel::instance()->stringList().count(); i++){ - if (TagFilterModel::instance()->checkState[i]) - return false; - } - return true; + if (!head){ // last tag means "Show empty tags"; + return TagFilterModel::instance()->checkState[TagFilterModel::instance()->rowCount()-1]; } // have at least one tag. + QStringList tagList = TagFilterModel::instance()->stringList(); + tagList.removeLast(); // remove the "Show Empty Tags"; while(head) { QString tagName(head->tag->name); - int index = TagFilterModel::instance()->stringList().indexOf(tagName); + int index = tagList.indexOf(tagName); if (TagFilterModel::instance()->checkState[index]) return true; head = head->next; |