Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TreeModelObjectSelection.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef TREEMODELOBJECTSELECTION_H
51 #define TREEMODELOBJECTSELECTION_H
52
53 #include <QAbstractItemModel>
54 #include <QModelIndex>
55 #include <QVariant>
56
57 #include "TreeItemObjectSelection.hh"
58
59 class TreeModelObjectSelection : public QAbstractItemModel
60 {
61 Q_OBJECT
62
63 signals:
64 // the connected TreeView changed data
65 void dataChangedInside(int _id, int _column, const QVariant& _value);
66
67 public:
68
70 TreeModelObjectSelection(QObject *_parent = 0);
71
73 ~TreeModelObjectSelection();
74
75 //===========================================================================
78 //===========================================================================
79
80 public:
81
83 QVariant data(const QModelIndex &index, int role) const;
84
86 Qt::ItemFlags flags(const QModelIndex &index) const;
87
89 QVariant headerData(int section,
90 Qt::Orientation orientation,
91 int role = Qt::DisplayRole) const;
92
94 QModelIndex index(int row, int column,
95 const QModelIndex &parent = QModelIndex()) const;
96
98 QModelIndex parent(const QModelIndex &index) const;
99
101 int rowCount(const QModelIndex &parent = QModelIndex()) const;
102
108 int columnCount(const QModelIndex &_parent = QModelIndex()) const;
109
117 bool setData(const QModelIndex &index, const QVariant &value , int role);
118
121 //===========================================================================
124 //===========================================================================
125
126 public:
127
129 QModelIndex getModelIndex(TreeItemObjectSelection* _object, int _column );
130
132 QModelIndex getModelIndex(int _id, int _column );
133
135 bool isRoot(TreeItemObjectSelection* _item);
136
138 bool getObjectName(TreeItemObjectSelection* _object , QString& _name);
139
141 TreeItemObjectSelection *getItem(const QModelIndex &index) const;
142
144 QString itemName(const QModelIndex &index) const;
145
147 int itemId(const QModelIndex &index) const;
148
149
151 void objectChanged(int id_);
152
154 void objectAdded(BaseObject* _object);
155
157 void objectAdded(BaseObject* _object, BaseObject* _parent);
158
160 void objectDeleted(int id_);
161
163 void moveItem(TreeItemObjectSelection* _item, TreeItemObjectSelection* _parent );
164 private:
165
167 TreeItemObjectSelection* rootItem_;
168
169
170 void propagateUpwards(TreeItemObjectSelection* _obj, int _column, bool _value );
171 void propagateDownwards(TreeItemObjectSelection* _obj, int _column );
172
176 };
177
178 #endif
179
TreeModelObjectSelection::propagateUpwards
void propagateUpwards(TreeItemObjectSelection *_obj, int _column, bool _value)
Recursively update a column up to the root of the tree.
Definition: TreeModelObjectSelection.cc:523
TreeItemObjectSelection
Definition: TreeItemObjectSelection.hh:59
TreeModelObjectSelection::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
return the header data of the model
Definition: TreeModelObjectSelection.cc:176
TreeModelObjectSelection::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Get the ModelIndex at given row,column.
Definition: TreeModelObjectSelection.cc:202
TreeModelObjectSelection::itemId
int itemId(const QModelIndex &index) const
Get the id of a TreeItemObjectSelection corresponding to a given ModelIndex.
Definition: TreeModelObjectSelection.cc:463
TreeModelObjectSelection::rootItem_
TreeItemObjectSelection * rootItem_
Rootitem of the tree.
Definition: TreeModelObjectSelection.hh:167
TreeModelObjectSelection::objectChanged
void objectChanged(int id_)
The object with the given id has been changed. Check if model also has to be changed.
Definition: TreeModelObjectSelection.cc:269
TreeModelObjectSelection::~TreeModelObjectSelection
~TreeModelObjectSelection()
Destructor.
Definition: TreeModelObjectSelection.cc:81
TreeModelObjectSelection::objectAdded
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
Definition: TreeModelObjectSelection.cc:328
TreeModelObjectSelection::setData
bool setData(const QModelIndex &index, const QVariant &value, int role)
Set Data at 'index' to 'value'.
Definition: TreeModelObjectSelection.cc:588
TreeModelObjectSelection::moveItem
void moveItem(TreeItemObjectSelection *_item, TreeItemObjectSelection *_parent)
move the item to a new parent
Definition: TreeModelObjectSelection.cc:400
BaseObject
Definition: BaseObject.hh:94
TreeModelObjectSelection::getModelIndex
QModelIndex getModelIndex(TreeItemObjectSelection *_object, int _column)
Return the ModelIndex corresponding to a given TreeItemObjectSelection and Column.
Definition: TreeModelObjectSelection.cc:483
TreeModelObjectSelection::isRoot
bool isRoot(TreeItemObjectSelection *_item)
Check if the given item is the root item.
Definition: TreeModelObjectSelection.cc:604
TreeModelObjectSelection::objectDeleted
void objectDeleted(int id_)
The object with the given id has been deleted. delete it from the internal tree.
Definition: TreeModelObjectSelection.cc:373
TreeModelObjectSelection
Definition: TreeModelObjectSelection.hh:59
TreeModelObjectSelection::getObjectName
bool getObjectName(TreeItemObjectSelection *_object, QString &_name)
Get the name of a given object.
TreeModelObjectSelection::data
QVariant data(const QModelIndex &index, int role) const
Get the data of the corresponding entry.
Definition: TreeModelObjectSelection.cc:105
TreeModelObjectSelection::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
get the number of rows
Definition: TreeModelObjectSelection.cc:248
TreeModelObjectSelection::itemName
QString itemName(const QModelIndex &index) const
Get the name of a TreeItemObjectSelection corresponding to a given ModelIndex.
Definition: TreeModelObjectSelection.cc:446
TreeModelObjectSelection::columnCount
int columnCount(const QModelIndex &_parent=QModelIndex()) const
Return the number of columns.
Definition: TreeModelObjectSelection.cc:90
TreeModelObjectSelection::propagateDownwards
void propagateDownwards(TreeItemObjectSelection *_obj, int _column)
Recursively update a column up to the root of the tree.
Definition: TreeModelObjectSelection.cc:553
TreeModelObjectSelection::TreeModelObjectSelection
TreeModelObjectSelection(QObject *_parent=0)
Constructor.
Definition: TreeModelObjectSelection.cc:70
TreeModelObjectSelection::parent
QModelIndex parent(const QModelIndex &index) const
Get the parent ModelIndex.
Definition: TreeModelObjectSelection.cc:226
TreeModelObjectSelection::flags
Qt::ItemFlags flags(const QModelIndex &index) const
return the types of the corresponding entry
Definition: TreeModelObjectSelection.cc:150
TreeModelObjectSelection::getItem
TreeItemObjectSelection * getItem(const QModelIndex &index) const
Get the TreeItemObjectSelection corresponding to a given ModelIndex.
Definition: TreeModelObjectSelection.cc:429