1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef DFBrowser_ItemBase_H
17 #define DFBrowser_ItemBase_H
19 #include <Standard.hxx>
20 #include <TDF_Label.hxx>
22 #include <inspector/TreeModel_ItemBase.hxx>
24 class DFBrowser_ItemBase;
25 class DFBrowser_Module;
26 typedef QExplicitlySharedDataPointer<DFBrowser_ItemBase> DFBrowser_ItemBasePtr;
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
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; }
39 //! Resets the cached item values
40 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
42 //! \return true if the current label is not null
43 bool HasLabel() const { return !GetLabel().IsNull(); }
45 //! \return the current label
46 Standard_EXPORT virtual TDF_Label GetLabel() const;
48 //! \return the current module
49 DFBrowser_Module* GetModule() const { return myModule; }
51 //! Change using of additional information in item. It it does not use additional info,
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);
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;
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; }
68 //! Returns if additional information is shown in item for Display and ToolTip values
69 //! \return boolean value
70 bool useAdditionalInfo() const { return myIsUseAdditionalInfo; }
72 //! Returns sum of label children and attributes
73 //! \return rows count
74 virtual int initRowCount() const Standard_OVERRIDE;
76 //! Returns label information like text, icon or background(if it contains TDataStd_Name attribute)
77 //! \param theItemRole a value role
79 virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
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;
87 //! Initialize the current item. It creates a backup of the specific item information
88 virtual void initItem() const {};
93 //! param theParent a parent item
94 //! \param theRow the item row positition in the parent item
95 //! \param theColumn the item column positition in the parent item
96 DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
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