Version: 9.16.0
TreeItem.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// Author: Guillaume Boulant (EDF/R&D)
21
22#ifndef TREEITEM_H
23#define TREEITEM_H
24
25#include "TreeData.hxx"
26
27#include <QList>
28#include <QVariant>
29#include <QVector>
30#include <QModelIndex>
31
32#include "DataObject.hxx"
33#include "TreeModel.hxx"
34
36{
37 public:
38 TreeItem(const QString &nameId, const QVector<QVariant> &columnValues, TreeItem *parent = 0);
39 ~TreeItem();
40
41 QString nameId();
42 void associateToModel(TreeModel * model);
43 TreeModel * associatedModel();
44 QModelIndex modelIndex(int column=0);
45 TreeItem *parent();
46
47 void appendChild(TreeItem * child);
48 void appendChild(DataObject * dataObject,
49 const QStringList &relativePath=QStringList());
50 void appendChild(const QString &nameId,
51 const QVector<QVariant> &columnValues,
52 const QStringList &relativePath=QStringList());
53
54 void removeChild(TreeItem * child);
55 void removeChild(DataObject * dataObject,
56 const QStringList &relativePath=QStringList());
57
58 TreeItem *child(int row);
59 TreeItem *childById(const QString &nameId);
60 TreeItem *childByLabel(const QString &label);
61 int childCount() const;
62 int columnCount() const;
63 int rowIndex() const;
64 QVariant data(int column) const;
65 bool setData(int column, const QVariant &value);
66
67 private:
68 void initialize(const QString &nameId,
69 const QVector<QVariant> &columnValues,
70 TreeItem *parent);
71
73 QMap <QString, TreeItem *> _childItemsMapById;
74 QMap <QString, TreeItem *> _childItemsMapByLabel;
75
76 QString _itemNameId;
77 QVector<QVariant> _itemData;
80
81};
82
83#endif
#define TREEDATA_EXPORT
Definition: TreeData.hxx:33
Definition: DataObject.hxx:30
Definition: TreeItem.hxx:36
TreeModel * _associatedModel
Definition: TreeItem.hxx:79
QString _itemNameId
Definition: TreeItem.hxx:76
QList< TreeItem * > _childItems
Definition: TreeItem.hxx:72
QVector< QVariant > _itemData
Definition: TreeItem.hxx:77
QMap< QString, TreeItem * > _childItemsMapByLabel
Definition: TreeItem.hxx:74
TreeItem * _parentItem
Definition: TreeItem.hxx:78
QMap< QString, TreeItem * > _childItemsMapById
Definition: TreeItem.hxx:73
Definition: TreeModel.hxx:39