mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Dive list model: move filtering of trip-items to own function
Implementing proper model semantics (only sending a changed signal for items that actually changed) will be somewhat complicated. Therefore, move the filtering of trip-items to its own function to make the nesting a little bit less deep. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									569e532f5c
								
							
						
					
					
						commit
						3cc6576913
					
				
					 1 changed files with 12 additions and 8 deletions
				
			
		|  | @ -691,6 +691,17 @@ dive *DiveTripModelTree::diveOrNull(const QModelIndex &index) const | |||
| 	return tripOrDive(index).dive; | ||||
| } | ||||
| 
 | ||||
| static bool calculateFilterForTrip(const std::vector<dive *> &dives, const DiveFilter *filter) | ||||
| { | ||||
| 	bool showTrip = false; | ||||
| 	for (dive *d: dives) { | ||||
| 		bool shown = filter->showDive(d); | ||||
| 		filter_dive(d, shown); | ||||
| 		showTrip |= shown; | ||||
| 	} | ||||
| 	return showTrip; | ||||
| } | ||||
| 
 | ||||
| void DiveTripModelTree::recalculateFilter() | ||||
| { | ||||
| 	{ | ||||
|  | @ -710,18 +721,11 @@ void DiveTripModelTree::recalculateFilter() | |||
| 				filter_dive(d, item.shown); | ||||
| 			} else { | ||||
| 				// Trips are shown if any of the dives is shown
 | ||||
| 				bool showTrip = false; | ||||
| 				for (dive *d: item.dives) { | ||||
| 					bool shown = filter->showDive(d); | ||||
| 					filter_dive(d, shown); | ||||
| 					showTrip |= shown; | ||||
| 				} | ||||
| 				item.shown = showTrip; | ||||
| 				item.shown = calculateFilterForTrip(item.dives, filter); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	// Rerender all trip headers. TODO: be smarter about this and only rerender if the number
 | ||||
| 	// of shown dives changed.
 | ||||
| 	for (int idx = 0; idx < (int)items.size(); ++idx) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue