mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix loading a second dive, after the first file was loaded.
This patch fixes loading a second dive-file after the first one had been loaded. it simply clears some information and makes sure that the current selected dive is invalid when the file closes. I also did a bit of code cleanup on this one to make things simpler in the future. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e3cb36498d
commit
d39b1aedcd
6 changed files with 41 additions and 35 deletions
|
@ -11,12 +11,31 @@
|
|||
#include <QHeaderView>
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
|
||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false)
|
||||
{
|
||||
setUniformRowHeights(true);
|
||||
setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate());
|
||||
QSortFilterProxyModel *model = new QSortFilterProxyModel(this);
|
||||
setModel(model);
|
||||
}
|
||||
|
||||
void DiveListView::reload()
|
||||
{
|
||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||
QAbstractItemModel *oldModel = m->sourceModel();
|
||||
oldModel->deleteLater();
|
||||
m->setSourceModel(new DiveTripModel(this));
|
||||
sortByColumn(0, Qt::DescendingOrder);
|
||||
QModelIndex firstDiveOrTrip = m->index(0,0);
|
||||
if (firstDiveOrTrip.isValid()){
|
||||
if (m->index(0,0, firstDiveOrTrip).isValid())
|
||||
setCurrentIndex(m->index(0,0, firstDiveOrTrip));
|
||||
else
|
||||
setCurrentIndex(firstDiveOrTrip);
|
||||
}
|
||||
}
|
||||
|
||||
void DiveListView::setModel(QAbstractItemModel* model)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue