diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-11-08 20:30:17 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-09 15:32:37 +0900 |
commit | 7dbf76384f78b415250ec3de3090ea1ae68e3ac3 (patch) | |
tree | 041def1120191df9dc4e87d4cbcba901bddd4421 /qt-ui/divelistview.cpp | |
parent | ba638cae05a3b285cd7a7f5790f9a3290eef7343 (diff) | |
download | subsurface-7dbf76384f78b415250ec3de3090ea1ae68e3ac3.tar.gz |
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>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 92a10ca38..0a7c2f2e3 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -47,6 +47,42 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); 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() @@ -178,6 +214,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort) setCurrentIndex(firstDiveOrTrip); } } + setupUi(); } void DiveListView::reloadHeaderActions() |