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 
36 class TreeModel : public QAbstractItemModel
37 {
38  Q_OBJECT
39 
40 public:
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 
66 protected:
67  TreeItem* getItem(const QModelIndex& index) const;
68 
70 };
71 
72 using TreeModelPtr = std::shared_ptr<TreeModel>;
TreeModel::~TreeModel
~TreeModel() override
Definition: treemodel.cpp:36
TreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: treemodel.cpp:99
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:10
TreeItem
Definition: treeitem.h:47
TreeModel::insertRow
bool insertRow(int position, TreeItem *item, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:198
TreeModel::clear
virtual void clear()=0
treeitem.h
TreeModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: treemodel.cpp:69
TreeModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: treemodel.cpp:121
TreeModel::removeColumn
bool removeColumn(int position, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:181
TreeModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: treemodel.cpp:88
TreeModel
Definition: treemodel.h:36
TreeModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: treemodel.cpp:51
TreeModel::getItem
TreeItem * getItem(const QModelIndex &index) const
Definition: treemodel.cpp:154
TreeModel::TreeModel
TreeModel(QObject *parent=0)
Definition: treemodel.cpp:32
TreeModel::removeRow
bool removeRow(int position, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:211
TreeModel::insertColumn
bool insertColumn(int position, QVariant data, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:169
TreeModelPtr
std::shared_ptr< TreeModel > TreeModelPtr
Definition: treemodel.h:72
TreeModel::rootItem
TreeItem * rootItem
Definition: treemodel.h:69
TreeModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: treemodel.cpp:45
TreeModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: treemodel.cpp:140