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 "treeitem.h"
28 #include <QAbstractItemModel>
29 #include <QModelIndex>
30 #include <QVariant>
31 #include <QList>
32 #include <memory>
33 
34 class TreeModel : public QAbstractItemModel
35 {
36  Q_OBJECT
37 
38 public:
39  explicit TreeModel(QObject* parent = 0);
40  ~TreeModel() override;
41 
42  Qt::ItemFlags flags(const QModelIndex& index) const override;
43  QModelIndex parent(const QModelIndex& index) const override;
44 
45  QVariant data(const QModelIndex& index, int role) const override;
46  QVariant headerData(int section, Qt::Orientation orientation,
47  int role = Qt::DisplayRole) const override;
48 
49  QModelIndex index(int row, int column,
50  const QModelIndex& parent = QModelIndex()) const override;
51 
52  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
53  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
54 
55  bool insertColumn(int position, QVariant data,
56  const QModelIndex& parent = QModelIndex());
57  bool removeColumn(int position,
58  const QModelIndex& parent = QModelIndex());
59  bool insertRow(int position, TreeItem* item,
60  const QModelIndex& parent = QModelIndex());
61  bool removeRow(int position,
62  const QModelIndex& parent = QModelIndex());
63 
64  //TreeItem* getRootItem();
65 
66  virtual void clear() = 0;
67 protected:
68  TreeItem* getItem(const QModelIndex& index) const;
69 
71 };
72 
73 using TreeModelPtr = std::shared_ptr<TreeModel>;
74 
TreeModel::~TreeModel
~TreeModel() override
Definition: treemodel.cpp:37
TreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: treemodel.cpp:96
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:9
TreeItem
Definition: treeitem.h:46
TreeModel::insertRow
bool insertRow(int position, TreeItem *item, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:192
TreeModel::clear
virtual void clear()=0
treeitem.h
TreeModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: treemodel.cpp:67
TreeModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: treemodel.cpp:118
TreeModel::removeColumn
bool removeColumn(int position, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:176
TreeModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: treemodel.cpp:85
TreeModel
Definition: treemodel.h:34
TreeModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: treemodel.cpp:50
TreeModel::getItem
TreeItem * getItem(const QModelIndex &index) const
Definition: treemodel.cpp:150
TreeModel::TreeModel
TreeModel(QObject *parent=0)
Definition: treemodel.cpp:32
TreeModel::removeRow
bool removeRow(int position, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:204
TreeModel::insertColumn
bool insertColumn(int position, QVariant data, const QModelIndex &parent=QModelIndex())
Definition: treemodel.cpp:165
TreeModelPtr
std::shared_ptr< TreeModel > TreeModelPtr
Definition: treemodel.h:73
TreeModel::rootItem
TreeItem * rootItem
Definition: treemodel.h:70
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:136