mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	TableWidgets: change default column width and don't save unchanged widths
Similar change to the dive list. The idea is to not save things that are the default. This way Subsurface will do the right thing when defaults change. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									75650bd65f
								
							
						
					
					
						commit
						778d6ea103
					
				
					 1 changed files with 17 additions and 3 deletions
				
			
		|  | @ -29,9 +29,23 @@ TableView::~TableView() | |||
| { | ||||
| 	QSettings s; | ||||
| 	s.beginGroup(objectName()); | ||||
| 	// remove the old default
 | ||||
| 	bool oldDefault = (ui.tableView->columnWidth(0) == 30); | ||||
| 	for (int i = 1; oldDefault && i < ui.tableView->model()->columnCount(); i++) { | ||||
| 		if (ui.tableView->columnWidth(i) != 80) | ||||
| 			oldDefault = false; | ||||
| 	} | ||||
| 	if (oldDefault) { | ||||
| 		s.remove(""); | ||||
| 	} else { | ||||
| 		for (int i = 0; i < ui.tableView->model()->columnCount(); i++) { | ||||
| 			if ((i == CylindersModel::REMOVE && ui.tableView->columnWidth(i) == 30) || | ||||
| 			    ui.tableView->columnWidth(i) == 70) | ||||
| 				s.remove(QString("colwidth%1").arg(i)); | ||||
| 			else | ||||
| 				s.setValue(QString("colwidth%1").arg(i), ui.tableView->columnWidth(i)); | ||||
| 		} | ||||
| 	} | ||||
| 	s.endGroup(); | ||||
| } | ||||
| 
 | ||||
|  | @ -54,7 +68,7 @@ void TableView::setModel(QAbstractItemModel *model) | |||
| 	s.beginGroup(objectName()); | ||||
| 	const int columnCount = ui.tableView->model()->columnCount(); | ||||
| 	for (int i = 0; i < columnCount; i++) { | ||||
| 		QVariant width = s.value(QString("colwidth%1").arg(i), i == CylindersModel::REMOVE ? 30 : 80); | ||||
| 		QVariant width = s.value(QString("colwidth%1").arg(i), i == CylindersModel::REMOVE ? 30 : 70); | ||||
| 		ui.tableView->setColumnWidth(i, width.toInt()); | ||||
| 	} | ||||
| 	s.endGroup(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue