mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									bef8dc6f4b
								
							
						
					
					
						commit
						06ebd0ea5e
					
				
					 1 changed files with 7 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue