mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Moved the code that handles DiveList column sizes to its correct file.
I got a bit lost trying to find the code that handled DiveList columns today, so I thought it was better to move it to its file, after all we do have a divelistview.h :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									ba638cae05
								
							
						
					
					
						commit
						7dbf76384f
					
				
					 3 changed files with 40 additions and 21 deletions
				
			
		|  | @ -47,6 +47,42 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec | ||||||
| 	connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); | 	connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); | ||||||
| 	connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); | 	connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); | ||||||
| 	selectedTrips.clear(); | 	selectedTrips.clear(); | ||||||
|  | 
 | ||||||
|  | 	setupUi(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | DiveListView::~DiveListView() | ||||||
|  | { | ||||||
|  | 	QSettings settings; | ||||||
|  | 	settings.beginGroup("ListWidget"); | ||||||
|  | 	for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++){ | ||||||
|  | 		if (isColumnHidden(i)) | ||||||
|  | 			continue; | ||||||
|  | 		settings.setValue(QString("colwidth%1").arg(i), columnWidth(i)); | ||||||
|  | 	} | ||||||
|  | 	settings.endGroup(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void DiveListView::setupUi(){ | ||||||
|  | 	QSettings settings; | ||||||
|  | 	settings.beginGroup("ListWidget"); | ||||||
|  | 	/* if no width are set, use the calculated width for each column;
 | ||||||
|  | 	 * for that to work we need to temporarily expand all rows */ | ||||||
|  | 	expandAll(); | ||||||
|  | 	for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) { | ||||||
|  | 		if(isColumnHidden(i)) | ||||||
|  | 			continue; | ||||||
|  | 		QVariant width = settings.value(QString("colwidth%1").arg(i)); | ||||||
|  | 		if (width.isValid()) | ||||||
|  | 			setColumnWidth(i, width.toInt()); | ||||||
|  | 		else | ||||||
|  | 			setColumnWidth(i, 100); | ||||||
|  | 
 | ||||||
|  | 	} | ||||||
|  | 	settings.endGroup(); | ||||||
|  | 	collapseAll(); | ||||||
|  | 	expand(model()->index(0,0)); | ||||||
|  | 	scrollTo(model()->index(0,0), QAbstractItemView::PositionAtCenter); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DiveListView::fixMessyQtModelBehaviour() | void DiveListView::fixMessyQtModelBehaviour() | ||||||
|  | @ -178,6 +214,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort) | ||||||
| 				setCurrentIndex(firstDiveOrTrip); | 				setCurrentIndex(firstDiveOrTrip); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	setupUi(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DiveListView::reloadHeaderActions() | void DiveListView::reloadHeaderActions() | ||||||
|  |  | ||||||
|  | @ -19,6 +19,7 @@ class DiveListView : public QTreeView | ||||||
| 	Q_OBJECT | 	Q_OBJECT | ||||||
| public: | public: | ||||||
| 	DiveListView(QWidget *parent = 0); | 	DiveListView(QWidget *parent = 0); | ||||||
|  | 	~DiveListView(); | ||||||
| 	void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); | 	void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); | ||||||
| 	void currentChanged(const QModelIndex& current, const QModelIndex& previous); | 	void currentChanged(const QModelIndex& current, const QModelIndex& previous); | ||||||
| 	void reload(DiveTripModel::Layout layout, bool forceSort = true); | 	void reload(DiveTripModel::Layout layout, bool forceSort = true); | ||||||
|  | @ -54,6 +55,7 @@ private: | ||||||
| 	QLineEdit *searchBox; | 	QLineEdit *searchBox; | ||||||
| 	QModelIndex contextMenuIndex; | 	QModelIndex contextMenuIndex; | ||||||
| 	void merge_trip(const QModelIndex &a, const int offset); | 	void merge_trip(const QModelIndex &a, const int offset); | ||||||
|  | 	void setupUi(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // DIVELISTVIEW_H
 | #endif // DIVELISTVIEW_H
 | ||||||
|  |  | ||||||
|  | @ -54,9 +54,9 @@ MainWindow::MainWindow() : helpView(0) | ||||||
| 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions())); | 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions())); | ||||||
| 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh())); | 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh())); | ||||||
| 	ui.mainErrorMessage->hide(); | 	ui.mainErrorMessage->hide(); | ||||||
| 	ui.ListWidget->reload(DiveTripModel::TREE); |  | ||||||
| 	initialUiSetup(); | 	initialUiSetup(); | ||||||
| 	readSettings(); | 	readSettings(); | ||||||
|  | 	ui.ListWidget->reload(DiveTripModel::TREE); | ||||||
| 	ui.ListWidget->reloadHeaderActions(); | 	ui.ListWidget->reloadHeaderActions(); | ||||||
| 	ui.ListWidget->setFocus(); | 	ui.ListWidget->setFocus(); | ||||||
| 	ui.globe->reload(); | 	ui.globe->reload(); | ||||||
|  | @ -566,21 +566,6 @@ void MainWindow::initialUiSetup() | ||||||
| 		case PROFILE_MAXIMIZED : on_actionViewProfile_triggered(); break; | 		case PROFILE_MAXIMIZED : on_actionViewProfile_triggered(); break; | ||||||
| 	} | 	} | ||||||
| 	settings.endGroup(); | 	settings.endGroup(); | ||||||
| 	settings.beginGroup("ListWidget"); |  | ||||||
| 	/* if no width are set, use the calculated width for each column;
 |  | ||||||
| 	 * for that to work we need to temporarily expand all rows */ |  | ||||||
| 	ui.ListWidget->expandAll(); |  | ||||||
| 	for (i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) { |  | ||||||
| 		QVariant width = settings.value(QString("colwidth%1").arg(i)); |  | ||||||
| 		if (width.isValid()) |  | ||||||
| 			ui.ListWidget->setColumnWidth(i, width.toInt()); |  | ||||||
| 		else |  | ||||||
| 			ui.ListWidget->resizeColumnToContents(i); |  | ||||||
| 	} |  | ||||||
| 	ui.ListWidget->collapseAll(); |  | ||||||
| 	ui.ListWidget->expand(ui.ListWidget->model()->index(0,0)); |  | ||||||
| 	ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter); |  | ||||||
| 	settings.endGroup(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainWindow::readSettings() | void MainWindow::readSettings() | ||||||
|  | @ -652,11 +637,6 @@ void MainWindow::writeSettings() | ||||||
| 	} | 	} | ||||||
| 	settings.endGroup(); | 	settings.endGroup(); | ||||||
| 
 | 
 | ||||||
| 	settings.beginGroup("ListWidget"); |  | ||||||
| 	for (i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) |  | ||||||
| 		if (!ui.ListWidget->isColumnHidden(i)) |  | ||||||
| 			settings.setValue(QString("colwidth%1").arg(i), ui.ListWidget->columnWidth(i)); |  | ||||||
| 	settings.endGroup(); |  | ||||||
| 	settings.beginGroup("Units"); | 	settings.beginGroup("Units"); | ||||||
| 	SAVE_VALUE("length", units.length); | 	SAVE_VALUE("length", units.length); | ||||||
| 	SAVE_VALUE("pressure", units.pressure); | 	SAVE_VALUE("pressure", units.pressure); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue