mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <tcanabrava@kde.org>
This commit is contained in:
parent
8394828806
commit
c6f84de37c
3 changed files with 35 additions and 3 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue