ac6d3f8e06ff1ac0bd5990bf8d1358a3775c567f
[occt.git] / tools / TreeModel / TreeModel_VisibilityState.hxx
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 TreeModel_VisibilityState_H
17 #define TreeModel_VisibilityState_H
18
19 #include <inspector/TreeModel_ModelBase.hxx>
20 #include <inspector/TreeModel_ColumnType.hxx>
21
22 #include <Standard.hxx>
23 #include <Standard_Macro.hxx>
24
25 //! \class TreeModel_VisibilityState
26 //! \brief Interface that provides connection between model and visualization control to:
27 //! - know whether the model item is visible
28 //! - change visibility of the model item
29 class TreeModel_VisibilityState
30 {
31 public:
32   //! Constructor
33   TreeModel_VisibilityState (TreeModel_ModelBase* theModel) : myModel (theModel) {}
34
35   //! Destructor
36   ~TreeModel_VisibilityState() {}
37
38   //! Returns true if visibility of the item can be changed
39   //! \param theIndex tree model index
40   //! \return boolean value
41   virtual bool CanBeVisible (const QModelIndex& theIndex) const = 0;
42
43   //! Sets visibility state
44   //! \param theIndex tree model index
45   //! \param theState visibility state
46   //! \param toEmitDataChanged boolean flag whether emit of the model should be done immediately
47   //! \return true if state is changed
48   virtual bool SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged = true) = 0;
49
50   //! Returns visibility state value
51   //! \param theIndex tree model index
52   //! \return boolean value
53   virtual bool IsVisible (const QModelIndex& theIndex) const = 0;
54
55 protected:
56   //! Processes the mouse clicked on the index.
57   //! It changes the item visibility if model allows to change it.
58   //! \theIndex tree model index
59   //! \return true if click is processed
60   Standard_EXPORT bool processClicked (const QModelIndex& theIndex);
61
62 protected:
63   //! tree view model
64   TreeModel_ModelBase* getModel() const { return myModel; }
65
66 private:
67   TreeModel_ModelBase* myModel; //!< tree view model
68 };
69
70 #endif