summaryrefslogtreecommitdiffstats
path: root/qt-models/treemodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-25 21:23:19 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-01 07:48:43 -0700
commit89e0c3f46498ba3e0844514b6709a07c200a68df (patch)
tree8609c84130cb04180d9db4bb43f2dfc11cf563c3 /qt-models/treemodel.h
parent236f0512bec2946b35052abf637c7c8df97f34bf (diff)
downloadsubsurface-89e0c3f46498ba3e0844514b6709a07c200a68df.tar.gz
Cleanup: make DiveTripModel a global object
DiveTripModel (the model describing the dive-list) was destroyed and recreated on every reset of the list. This seems excessive. Instead - in analogy to most other models - make it a single global object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/treemodel.h')
-rw-r--r--qt-models/treemodel.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-models/treemodel.h b/qt-models/treemodel.h
index e68ae1c32..3b2b407e0 100644
--- a/qt-models/treemodel.h
+++ b/qt-models/treemodel.h
@@ -4,6 +4,7 @@
#include <QAbstractItemModel>
#include <QCoreApplication>
+#include <memory>
struct TreeItem {
Q_DECLARE_TR_FUNCTIONS(TreeItemDT)
@@ -25,16 +26,16 @@ class TreeModel : public QAbstractItemModel {
Q_OBJECT
public:
TreeModel(QObject *parent = 0);
- ~TreeModel();
QVariant data(const QModelIndex &index, int role) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
+ void clear();
protected:
int columns;
- TreeItem *rootItem;
+ std::unique_ptr<TreeItem> rootItem;
};
#endif