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>
This commit is contained in:
Tomaz Canabrava 2014-09-17 17:47:35 -03:00 committed by Dirk Hohndel
parent bef8dc6f4b
commit 06ebd0ea5e

View file

@ -2136,10 +2136,12 @@ void TagFilterModel::repopulate()
list.append(QString(current_tag_entry->tag->name)); list.append(QString(current_tag_entry->tag->name));
current_tag_entry = current_tag_entry->next; current_tag_entry = current_tag_entry->next;
} }
list << tr("Empty Tags");
setStringList(list); setStringList(list);
delete[] checkState; delete[] checkState;
checkState = new bool[list.count()]; checkState = new bool[list.count()];
memset(checkState, false, list.count()); memset(checkState, false, list.count());
checkState[list.count()-1] = true;
} }
bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, int role) 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'. // Checked means 'Show', Unchecked means 'Hide'.
struct tag_entry *head = d->tag_list; struct tag_entry *head = d->tag_list;
if (!head){ // doesn't have tags, only show if no tags are selected. if (!head){ // last tag means "Show empty tags";
for(int i = 0; i < TagFilterModel::instance()->stringList().count(); i++){ return TagFilterModel::instance()->checkState[TagFilterModel::instance()->rowCount()-1];
if (TagFilterModel::instance()->checkState[i])
return false;
}
return true;
} }
// have at least one tag. // have at least one tag.
QStringList tagList = TagFilterModel::instance()->stringList();
tagList.removeLast(); // remove the "Show Empty Tags";
while(head) { while(head) {
QString tagName(head->tag->name); QString tagName(head->tag->name);
int index = TagFilterModel::instance()->stringList().indexOf(tagName); int index = tagList.indexOf(tagName);
if (TagFilterModel::instance()->checkState[index]) if (TagFilterModel::instance()->checkState[index])
return true; return true;
head = head->next; head = head->next;