00a9a7c2adc6dab6ef87f36a58fca83fa6e65753
[occt.git] / tools / DFBrowser / DFBrowser_TreeLevelView.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 DFBrowser_TreeLevelView_H
17 #define DFBrowser_TreeLevelView_H
18
19 #include <Standard.hxx>
20 #include <TreeModel_ItemBase.hxx>
21
22 #include <QObject>
23 #include <QItemSelection>
24
25 class QWidget;
26 class QTableView;
27
28 //! \class DFBrowser_TreeLevelView
29 //! This is a control to visualize the current selected item of OCAF tree view in table view.
30 //! The table contains two colums: name and value. The information is similar the one OCAF tree view label
31 //! content: children and attributes for the current label. Selection or double click of item emits
32 //! signals about this event.
33 class DFBrowser_TreeLevelView : public QObject
34 {
35   Q_OBJECT
36 public:
37
38   //! Constructor
39   Standard_EXPORT DFBrowser_TreeLevelView (QWidget* theParent);
40
41   //! Destructor
42   virtual ~DFBrowser_TreeLevelView() Standard_OVERRIDE {}
43
44   //! Returns parent control
45   QWidget* GetControl() const { return myMainWindow; }
46
47   //! Clear selection of the table view selection model
48   Standard_EXPORT void ClearSelection();
49
50   //! Returns true if this control may be filled by the index
51   //! It is possible if an item of the index is application, document or label
52   //! \param theIndex OCAF tree view model index
53   //! \return boolean result
54   Standard_EXPORT static bool ProcessItem (const QModelIndex& theIndex);
55
56   //! Init view by the first selected item in OCAF tree view
57   //! \param theSelected selected items
58   //! \param theDeselected deselected items
59   Standard_EXPORT void UpdateByTreeSelectionChanged (const QItemSelection& theSelected,
60                                                      const QItemSelection& theDeselected);
61
62 signals:
63
64   //! Signal about selection of an item in tree view
65   //! \param theIndex a tree view model index of selected item
66   void indexSelected (const QModelIndex& theIndex);
67
68   //! Signal about double click on an item in tree view
69   //! \param theIndex a tree view model index of selected item
70   void indexDoubleClicked (const QModelIndex& theIndex);
71
72 private slots:
73
74   //! Listens table view selection model. Gets the first selected tree view model index and emit indexSelected signal.
75   //! \param theSelected a list of selected items
76   //! \param theDeselected a list of deselected items
77   void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
78
79   //! Listens table view double click. Gets clicked index and emit indexDoubleClicked signal.
80   //! \param theIndex a tree view model index of selected item
81   void onTableDoubleClicked (const QModelIndex& theIndex);
82
83 private:
84
85   QWidget* myMainWindow; //!< parent control
86   QTableView* myTableView; //!< current view
87 };
88 #endif