mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	divelistview: always show at least one column
Currently it is possible to hide all columns by unchecking them in the context menu that appears by right clicking the header of the divelist. But once all are hidden the header disappears. This can cause a situation where the user cannot show any columns and the only fix for that is to edit the application configuration. To avoid this sutuation prevent the last column from being hidden. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
		
							parent
							
								
									5204af58da
								
							
						
					
					
						commit
						449782a892
					
				
					 1 changed files with 18 additions and 1 deletions
				
			
		|  | @ -501,13 +501,30 @@ void DiveListView::toggleColumnVisibilityByIndex() | |||
| 	QAction *action = qobject_cast<QAction *>(sender()); | ||||
| 	if (!action) | ||||
| 		return; | ||||
| 	const int idx = action->property("index").toInt(); | ||||
| 
 | ||||
| 	// Count the number of visible columns.
 | ||||
| 	int totalVisible = 0, lastVisibleIdx = -1; | ||||
| 	for (int i = 0; i < model()->columnCount(); i++) { | ||||
| 		if (isColumnHidden(i)) | ||||
| 			continue; | ||||
| 		totalVisible++; | ||||
| 		lastVisibleIdx = i; | ||||
| 	} | ||||
| 	// If there is only one visible column and we are performing an action on it,
 | ||||
| 	// don't hide the column and revert the action back to checked == true.
 | ||||
| 	// This keeps one column visible at all times.
 | ||||
| 	if (totalVisible == 1 && idx == lastVisibleIdx) { | ||||
| 		action->setChecked(true); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	QSettings s; | ||||
| 	s.beginGroup("DiveListColumnState"); | ||||
| 	s.setValue(action->property("settingName").toString(), action->isChecked()); | ||||
| 	s.endGroup(); | ||||
| 	s.sync(); | ||||
| 	setColumnHidden(action->property("index").toInt(), !action->isChecked()); | ||||
| 	setColumnHidden(idx, !action->isChecked()); | ||||
| 	setColumnWidth(lastVisibleColumn(), 10); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue