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 DFBrowser_ItemBase_H |
17 | #define DFBrowser_ItemBase_H |
18 | |
19 | #include <Standard.hxx> |
14bbbdcb |
20 | #include <TDF_Label.hxx> |
21 | |
0cb512c0 |
22 | #include <inspector/TreeModel_ItemBase.hxx> |
23 | |
14bbbdcb |
24 | class DFBrowser_ItemBase; |
25 | class DFBrowser_Module; |
26 | typedef QExplicitlySharedDataPointer<DFBrowser_ItemBase> DFBrowser_ItemBasePtr; |
27 | |
28 | //! \class DFBrowser_ItemBase |
29 | //! \brief Declaration of the tree model base item. |
30 | //! This item provide method to process a TDF label. |
31 | class DFBrowser_ItemBase : public TreeModel_ItemBase |
32 | { |
33 | public: |
34 | |
35 | //! Sets the module to have an access to attribute information |
36 | //! \param theModule a current loaded application module |
37 | void SetModule (DFBrowser_Module* theModule) { myModule = theModule; } |
38 | |
39 | //! Resets the cached item values |
40 | Standard_EXPORT virtual void Reset() Standard_OVERRIDE; |
41 | |
42 | //! \return true if the current label is not null |
43 | bool HasLabel() const { return !GetLabel().IsNull(); } |
44 | |
45 | //! \return the current label |
46 | Standard_EXPORT virtual TDF_Label GetLabel() const; |
47 | |
48 | //! \return the current module |
49 | DFBrowser_Module* GetModule() const { return myModule; } |
50 | |
7e1c1e48 |
51 | //! Changes using of additional information in item. If it does not use additional info, |
14bbbdcb |
52 | //! it will not return extended text in initValue(). |
53 | //! \param theValue a new value |
54 | //! \return the previous value |
55 | Standard_EXPORT bool SetUseAdditionalInfo (const bool theValue); |
56 | |
57 | //! Returns the data stored under the given role for the current item |
58 | //! \param theIndex the item model index |
59 | //! \param theRole the item model role |
60 | Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole) const Standard_OVERRIDE; |
61 | |
62 | protected: |
63 | |
64 | //! Sets the item label |
65 | //! \param theLabel an object where the child items structure is found |
66 | void setLabel(TDF_Label theLabel) { myLabel = theLabel; } |
67 | |
68 | //! Returns if additional information is shown in item for Display and ToolTip values |
69 | //! \return boolean value |
70 | bool useAdditionalInfo() const { return myIsUseAdditionalInfo; } |
71 | |
72 | //! Returns sum of label children and attributes |
73 | //! \return rows count |
74 | virtual int initRowCount() const Standard_OVERRIDE; |
75 | |
76 | //! Returns label information like text, icon or background(if it contains TDataStd_Name attribute) |
77 | //! \param theItemRole a value role |
78 | //! \return the value |
79 | virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; |
80 | |
81 | //! Creates a child item in the given position. |
82 | //! \param theRow the child row position |
83 | //! \param theColumn the child column position |
84 | //! \return the created item |
85 | virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; |
86 | |
7e1c1e48 |
87 | //! Initializes the current item. It creates a backup of the specific item information |
9e5e4c0c |
88 | virtual void initItem() const Standard_OVERRIDE {} |
14bbbdcb |
89 | |
90 | protected: |
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 | DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn); |
97 | |
98 | private: |
99 | |
100 | TDF_Label myLabel; //!< a label of the document, which contains child labels and attributes |
101 | DFBrowser_Module* myModule; //!< the current module |
102 | bool myIsUseAdditionalInfo; //!< if true, additional item info is shown in square brackets |
103 | }; |
104 | |
105 | #endif |