diff options
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index d53fce5f5..8852eda3e 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -24,16 +24,26 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec setModel(model); setSortingEnabled(false); header()->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(header(), SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int))); } -void DiveListView::reload() +void DiveListView::headerClicked(int i ) +{ + if (i == (int) TreeItemDT::NR){ + reload(DiveTripModel::TREE); + }else{ + reload(DiveTripModel::LIST); + } +} + +void DiveListView::reload(DiveTripModel::Layout layout) { QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model()); QAbstractItemModel *oldModel = m->sourceModel(); if (oldModel) oldModel->deleteLater(); DiveTripModel *tripModel = new DiveTripModel(this); - tripModel->setLayout(DiveTripModel::LIST); + tripModel->setLayout(layout); m->setSourceModel(tripModel); sortByColumn(0, Qt::DescendingOrder); |