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>
This commit is contained in:
Berthold Stoeger 2018-07-25 21:23:19 +02:00 committed by Dirk Hohndel
parent 236f0512be
commit 89e0c3f464
7 changed files with 31 additions and 28 deletions

View file

@ -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