mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	LocationFilter: use equality instead of substring comparison
The location filter used a substring comparison, which had the side effect that dives with the location "Test 1" were shown when filtering for "Test 12". Moreover, avoid a deep copy of the location list. This is done by looping over one item less than rowCount() instead of removing the last item. While doing this, remove an unnecessary if-statement. This commit partially fixes #675. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									e20e1aad0e
								
							
						
					
					
						commit
						739b27427c
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		|  | @ -277,15 +277,12 @@ bool LocationFilterModel::doFilter(struct dive *d, QModelIndex &index0, QAbstrac | |||
| 			return true; | ||||
| 	} | ||||
| 
 | ||||
| 	// there is a location selected
 | ||||
| 	// There is a location selected
 | ||||
| 	QStringList locationList = stringList(); | ||||
| 	if (!locationList.isEmpty()) { | ||||
| 		locationList.removeLast(); // remove the "Show Empty Tags";
 | ||||
| 		for (int i = 0; i < rowCount(); i++) { | ||||
| 			if (checkState[i] && (location.indexOf(stringList()[i]) != -1)) { | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 	// Ignore last item, since this is the "Show Empty Tags" entry
 | ||||
| 	for (int i = 0; i < rowCount() - 1; i++) { | ||||
| 		if (checkState[i] && location == locationList[i]) | ||||
| 			return true; | ||||
| 	} | ||||
| 	return false; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue