summaryrefslogtreecommitdiffstats
path: root/mappingtreeresultmodel.h
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-07-20 14:34:45 +0200
committerArno <arno@disconnect.de>2018-07-20 14:40:30 +0200
commit6baa7366f20eabac32c3d84ae9832e517f5e0400 (patch)
treeae26564ebcf7139ad335025d3e757a29eb847629 /mappingtreeresultmodel.h
parent83873855d4f4d3042b50e521029c902bc5e05893 (diff)
downloadSheMov-6baa7366f20eabac32c3d84ae9832e517f5e0400.tar.gz
SheMov-6baa7366f20eabac32c3d84ae9832e517f5e0400.tar.bz2
SheMov-6baa7366f20eabac32c3d84ae9832e517f5e0400.zip
More code churn
Create separate files for MappingData and MappingTreeResultModel. Hopefully no functional changes.
Diffstat (limited to 'mappingtreeresultmodel.h')
-rw-r--r--mappingtreeresultmodel.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/mappingtreeresultmodel.h b/mappingtreeresultmodel.h
new file mode 100644
index 0000000..e86fc51
--- /dev/null
+++ b/mappingtreeresultmodel.h
@@ -0,0 +1,42 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#ifndef MAPPINGTREERESULTMODEL_H
+#define MAPPINGTREERESULTMODEL_H
+
+#include "mappingtreemodel.h"
+#include "mappingdata.h"
+
+class MappingTreeResultModel : public SmTreeModel {
+ Q_OBJECT
+ public:
+ enum Roles { NameRole = Qt::UserRole + 1, MappingIdRole = Qt::UserRole + 2, ParentIdRole = Qt::UserRole + 3, DescIdRole = Qt::UserRole + 4 };
+ enum Fields { Name = 0, MappingId = 1, ParentId = 2, DescId = 3 };
+ enum { NumFields = 4 };
+ explicit MappingTreeResultModel(const QStringList &headers, QObject *parent = 0);
+
+ //data + flags
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
+ QList<QVariant> getMappings(SmTreeItem *start) const;
+ QList<QVariant> columnValues(int column) const;
+ const QList<MappingData> mappingData() const { return mCurrentData; }
+ void clearData();
+
+ public slots:
+ void addItem(const MappingData &data);
+ void removeItem(const QModelIndex &idx);
+
+ private:
+ int hasChild(SmTreeItem *item, const QVariant &name, int column = 0) const;
+ MappingTreeModel *mSourceModel;
+ QList<QVariant> columnValuesRecursive(SmTreeItem *parent, int column) const;
+ QList<MappingData> mCurrentData;
+};
+
+#endif // MAPPINGTREERESULTMODEL_H