treemodel.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::gui
19 * @author Cedric Seehausen (usdnr at kit dot edu)
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <memory>
28
29#include <QAbstractItemModel>
30#include <QList>
31#include <QModelIndex>
32#include <QVariant>
33
34#include "treeitem.h"
35
36class TreeModel : public QAbstractItemModel
37{
38 Q_OBJECT
39
40public:
41 explicit TreeModel(QObject* parent = 0);
42 ~TreeModel() override;
43
44 Qt::ItemFlags flags(const QModelIndex& index) const override;
45 QModelIndex parent(const QModelIndex& index) const override;
46
47 QVariant data(const QModelIndex& index, int role) const override;
48 QVariant
49 headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
50
51 QModelIndex
52 index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
53
54 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
55 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
56
57 bool insertColumn(int position, QVariant data, const QModelIndex& parent = QModelIndex());
58 bool removeColumn(int position, const QModelIndex& parent = QModelIndex());
59 bool insertRow(int position, TreeItem* item, const QModelIndex& parent = QModelIndex());
60 bool removeRow(int position, const QModelIndex& parent = QModelIndex());
61
62 //TreeItem* getRootItem();
63
64 virtual void clear() = 0;
65
66protected:
67 TreeItem* getItem(const QModelIndex& index) const;
68
70};
71
72using TreeModelPtr = std::shared_ptr<TreeModel>;
uint8_t data[1]
uint8_t index
bool insertColumn(int position, QVariant data, const QModelIndex &parent=QModelIndex())
TreeItem * rootItem
Definition treemodel.h:69
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition treemodel.cpp:88
bool insertRow(int position, TreeItem *item, const QModelIndex &parent=QModelIndex())
int rowCount(const QModelIndex &parent=QModelIndex()) const override
TreeModel(QObject *parent=0)
Definition treemodel.cpp:32
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition treemodel.cpp:69
virtual void clear()=0
bool removeRow(int position, const QModelIndex &parent=QModelIndex())
bool removeColumn(int position, const QModelIndex &parent=QModelIndex())
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition treemodel.cpp:99
~TreeModel() override
Definition treemodel.cpp:36
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition treemodel.cpp:45
QModelIndex parent(const QModelIndex &index) const override
TreeItem * getItem(const QModelIndex &index) const
QVariant data(const QModelIndex &index, int role) const override
Definition treemodel.cpp:51
std::shared_ptr< TreeModel > TreeModelPtr
Definition treemodel.h:72