mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Only show expand/collapse context menu when in tree mode
The options make no sense when in list view mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									582253fe88
								
							
						
					
					
						commit
						235833b93e
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		|  | @ -274,6 +274,7 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS | ||||||
| 
 | 
 | ||||||
| void DiveListView::mousePressEvent(QMouseEvent *event) | void DiveListView::mousePressEvent(QMouseEvent *event) | ||||||
| { | { | ||||||
|  | 	QAction *collapseAction = NULL; | ||||||
| 	// all we care about is the unmodified right click
 | 	// all we care about is the unmodified right click
 | ||||||
| 	if ( ! (event->modifiers() == Qt::NoModifier && event->buttons() & Qt::RightButton)) { | 	if ( ! (event->modifiers() == Qt::NoModifier && event->buttons() & Qt::RightButton)) { | ||||||
| 		event->ignore(); | 		event->ignore(); | ||||||
|  | @ -281,11 +282,13 @@ void DiveListView::mousePressEvent(QMouseEvent *event) | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	QMenu popup(this); | 	QMenu popup(this); | ||||||
| 	popup.addAction(tr("expand all"), this, SLOT(expandAll())); | 	if (currentLayout == DiveTripModel::TREE) { | ||||||
| 	popup.addAction(tr("collapse all"), this, SLOT(collapseAll())); | 		popup.addAction(tr("expand all"), this, SLOT(expandAll())); | ||||||
| 	QAction *collapseAction = popup.addAction(tr("collapse"), this, SLOT(collapseAll())); | 		popup.addAction(tr("collapse all"), this, SLOT(collapseAll())); | ||||||
|  | 		collapseAction = popup.addAction(tr("collapse"), this, SLOT(collapseAll())); | ||||||
|  | 	} | ||||||
| 	// "collapse all" really closes all trips,
 | 	// "collapse all" really closes all trips,
 | ||||||
| 	// "collaps" keeps the trip with the selected dive open
 | 	// "collapse" keeps the trip with the selected dive open
 | ||||||
| 	if (popup.exec(event->globalPos()) == collapseAction) | 	if (popup.exec(event->globalPos()) == collapseAction && collapseAction) | ||||||
| 		selectDive(current_dive, true); | 		selectDive(current_dive, true); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue