0032429: Coding - Warnings during compilation on macosx arm64 with option BUILD_Inspe...
[occt.git] / tools / DFBrowserPane / DFBrowserPane_TDataStdTreeNodeItem.hxx
CommitLineData
14bbbdcb 1// Created on: 2017-06-16
2// Created by: Natalia ERMOLAEVA
3// Copyright (c) 2017 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef DFBrowserPane_TDataStdTreeNodeItem_H
17#define DFBrowserPane_TDataStdTreeNodeItem_H
18
0cb512c0 19#include <inspector/TreeModel_ItemBase.hxx>
20
14bbbdcb 21#include <Standard.hxx>
22#include <TDF_Attribute.hxx>
14bbbdcb 23
130eb114 24#include <Standard_WarningsDisable.hxx>
14bbbdcb 25#include <QList>
26#include <QMap>
27#include <QVariant>
130eb114 28#include <Standard_WarningsRestore.hxx>
14bbbdcb 29
30class DFBrowserPane_TDataStdTreeNodeItem;
31typedef QExplicitlySharedDataPointer<DFBrowserPane_TDataStdTreeNodeItem> DFBrowserPane_TDataStdTreeNodeItemPtr;
32
33//! \class DFBrowserPane_TDataStdTreeNodeItem
34//! An item connected to TDataStd_TreeNode attribute. Parent is NULL or tree node item.
35//! Childrens are items for children of tree node attribute.
36class DFBrowserPane_TDataStdTreeNodeItem : public TreeModel_ItemBase
37{
38
39public:
40
41 //! Creates an item wrapped by a shared pointer
7e1c1e48 42 //! \param theRow the item row position in the parent item
43 //! \param theColumn the item column position in the parent item
14bbbdcb 44 //! \return the pointer to the created item
45 static DFBrowserPane_TDataStdTreeNodeItemPtr CreateItem (TreeModel_ItemBasePtr theParent,
46 const int theRow, const int theColumn)
47 { return DFBrowserPane_TDataStdTreeNodeItemPtr (new DFBrowserPane_TDataStdTreeNodeItem (theParent, theRow, theColumn)); }
48
49 //!Destructor
7e1c1e48 50 virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {}
14bbbdcb 51
52 //! Store a current attribute
53 //! \param theAttribute an attribute
54 void SetAttribute (const Handle(TDF_Attribute)& theAttribute) { myAttribute = theAttribute; }
55
d2c90917 56 //! Returns the current attribute
57 //! \return an attribute
58 Handle(TDF_Attribute) GetAttribute () const { initItem(); return myAttribute; }
59
14bbbdcb 60 //! Set state if the attribute is current(corresponds to the selected attribute in tree)
61 //! \param theCurrent boolean state
d2c90917 62 void setCurrentAttribute (const bool theCurrent) { Reset(); myIsCurrentItem = theCurrent; }
14bbbdcb 63
64 //! Returns child attribute of the current attribute
65 //! \param theChildRow an index of a child attribute
66 //! \returns an attribute
67 Standard_EXPORT Handle(TDF_Attribute) getChildAttribute (const int theChildRow) const;
68
69 //! Inits the item, fills internal containers
70 Standard_EXPORT virtual void Init() Standard_OVERRIDE;
71
72 //! Resets the cached item values. Throws down the initialized state of the item.
73 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
74
75protected:
76
77 //! Returns the data stored under the given role for the current item.
78 //! \param theRole an enumeration value of role for data obtaining
79 virtual QVariant initValue (const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
80
81 //! \return number of children.
82 virtual int initRowCount() const Standard_OVERRIDE { return getRowCount(); }
83
84 //! Creates a child item in the given position.
85 //! \param theRow the child row position
86 //! \param theColumn the child column position
87 //! \return the created item
88 virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
89
90protected:
91
92 //! Constructor
7e1c1e48 93 //! \param theParent a parent item
94 //! \param theRow the item row position in the parent item
95 //! \param theColumn the item column position in the parent item
14bbbdcb 96 DFBrowserPane_TDataStdTreeNodeItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
97 : TreeModel_ItemBase (theParent, theRow, theColumn), myIsCurrentItem (false) {}
98
7e1c1e48 99 //! Initializes the current item. It creates a backup of the specific item information
9e5e4c0c 100 virtual void initItem() const Standard_OVERRIDE;
14bbbdcb 101
102 //! Returns number of children attributes, initializes item is necessary
103 int getRowCount() const;
104
105 //! Returns entry of the label of the current attribute tree node
106 QString getName() const { return myLabelName; }
107
108private:
109
110 Handle(TDF_Attribute) myAttribute; //! current attribute in tree node hierarchy
111 bool myIsCurrentItem; //! state whether this attribute is active in DFBrowser selected attribute in tree
112
113 int myRowCount; //! cached value of rows count
114 QString myLabelName; //! cached value of label name of the label of the current tree node attribute
115};
116
117#endif