From c6f84de37c33ef66f479d1adcffea6eab903c674 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 28 May 2013 16:56:58 -0300 Subject: Adds the code to make the dive list behave like tree or list This code adds the possibility to make the DiveList behave like a Tree or a List, depending on what layout is set. Signed-off-by: Tomaz Canabrava --- qt-ui/divelistview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qt-ui/divelistview.cpp') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 4957e3374..d53fce5f5 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -22,6 +22,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate()); QSortFilterProxyModel *model = new QSortFilterProxyModel(this); setModel(model); + setSortingEnabled(false); header()->setContextMenuPolicy(Qt::ActionsContextMenu); } @@ -31,7 +32,10 @@ void DiveListView::reload() QAbstractItemModel *oldModel = m->sourceModel(); if (oldModel) oldModel->deleteLater(); - m->setSourceModel(new DiveTripModel(this)); + DiveTripModel *tripModel = new DiveTripModel(this); + tripModel->setLayout(DiveTripModel::LIST); + + m->setSourceModel(tripModel); sortByColumn(0, Qt::DescendingOrder); QModelIndex firstDiveOrTrip = m->index(0,0); if (firstDiveOrTrip.isValid()) { -- cgit v1.2.3-70-g09d2