summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelistview.cpp20
-rw-r--r--desktop-widgets/divelistview.h5
2 files changed, 13 insertions, 12 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index a4b5ad282..ee0c1c98f 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -135,7 +135,7 @@ void DiveListView::calculateInitialColumnWidth(int col)
void DiveListView::setColumnWidths()
{
QSettings settings;
- backupExpandedRows();
+ std::vector<int> expandedRows = backupExpandedRows();
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 */
@@ -150,7 +150,7 @@ void DiveListView::setColumnWidths()
setColumnWidth(i, initialColumnWidths[i]);
}
settings.endGroup();
- restoreExpandedRows();
+ restoreExpandedRows(expandedRows);
setColumnWidth(lastVisibleColumn(), 10);
}
@@ -165,18 +165,19 @@ int DiveListView::lastVisibleColumn()
return lastColumn;
}
-void DiveListView::backupExpandedRows()
+std::vector<int> DiveListView::backupExpandedRows()
{
- expandedRows.clear();
+ std::vector<int> expandedRows;
for (int i = 0; i < model()->rowCount(); i++)
if (isExpanded(model()->index(i, 0)))
expandedRows.push_back(i);
+ return expandedRows;
}
-void DiveListView::restoreExpandedRows()
+void DiveListView::restoreExpandedRows(const std::vector<int> &expandedRows)
{
setAnimated(false);
- Q_FOREACH (const int &i, expandedRows)
+ for (int i: expandedRows)
setExpanded(model()->index(i, 0), true);
setAnimated(true);
}
@@ -437,13 +438,14 @@ void DiveListView::sortIndicatorChanged(int i, Qt::SortOrder order)
sortByColumn(i, order);
} else {
// clear the model, repopulate with new indexes.
- if (currentLayout == DiveTripModelBase::TREE)
- backupExpandedRows();
+ std::vector<int> expandedRows;
+ if(currentLayout == DiveTripModelBase::TREE)
+ expandedRows = backupExpandedRows();
currentLayout = newLayout;
resetModel();
sortByColumn(i, order);
if (newLayout == DiveTripModelBase::TREE)
- restoreExpandedRows();
+ restoreExpandedRows(expandedRows);
}
}
diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h
index d4954ee86..ce3021b3f 100644
--- a/desktop-widgets/divelistview.h
+++ b/desktop-widgets/divelistview.h
@@ -69,7 +69,6 @@ private:
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override;
void selectAll() override;
void selectionChangeDone();
- QList<int> expandedRows;
DiveTripModelBase::Layout currentLayout;
QModelIndex contextMenuIndex;
bool dontEmitDiveChangedSignal;
@@ -80,8 +79,8 @@ private:
void merge_trip(const QModelIndex &a, const int offset);
void setColumnWidths();
void calculateInitialColumnWidth(int col);
- void backupExpandedRows();
- void restoreExpandedRows();
+ std::vector<int> backupExpandedRows();
+ void restoreExpandedRows(const std::vector<int> &);
int lastVisibleColumn();
void selectTrip(dive_trip *trip);
void updateLastImageTimeOffset(int offset);