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_TreeLevelLine_H
17 #define DFBrowser_TreeLevelLine_H
19 #include <Standard.hxx>
20 #include <TreeModel_ItemBase.hxx>
22 #include <QItemSelection>
25 #include <QModelIndex>
27 class DFBrowser_SearchLine;
29 class QAbstractItemModel;
34 //! \class DFBrowser_TreeLevelLine
35 //! This is a control to visualize the current selected item of OCAF tree view.
36 //! It contains history of previous selected items.
37 //! The structure of this control is the next:
38 //! <back button> <forward button> <selected item line> <update button> <search line>
39 //! - <back button> allows moving to previously selected item (if it exists)
40 //! - <forward button> allows moving to next selected item (if it exists)
41 //! - <selected item line> path to currently selected item in OCAF tree view. Click on any level will
42 //! select the clicked item in tree view.
43 //! - <update button> will update content of OCAF tree model
44 //! - <search line> allows type label entry or attribute name and see in search view the available elements
45 class DFBrowser_TreeLevelLine : public QObject
51 Standard_EXPORT DFBrowser_TreeLevelLine (QWidget* theParent);
54 virtual ~DFBrowser_TreeLevelLine() Standard_OVERRIDE {}
56 //! Clears history of selected items
57 Standard_EXPORT void ClearHistory();
59 //! Returns parent control
60 QWidget* GetControl() const { return myMainWindow; }
62 //! Returns current search line
63 DFBrowser_SearchLine* GetSearchLine() const { return mySearchLine; };
67 //! Signal about selection of an item in tree level line
68 //! \param theIndex a tree view model index of selected item
69 void indexSelected (const QModelIndex& theIndex);
71 //! Signal about necessity to update OCAF tree model
76 //! Listens tree view selection model. Update tree level line by selected item. Stores
77 //! \param theSelected a list of selected items
78 //! \param theDeselected a list of deselected items
79 Standard_EXPORT void OnTreeViewSelectionChanged (const QItemSelection& theSelected,
80 const QItemSelection& theDeselected);
84 //! Listens table view selection model. Gets selected tree view model index and emit indexSelected signal.
85 //! \param theSelected a list of selected items
86 //! \param theDeselected a list of deselected items
87 void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
89 //! Listens actions and do the following:
90 //! - <backward>: moves history to the previous selection item, emits indexSelected signal
91 //! - <forward>: moves history to the next selection item, emits indexSelected signal
92 //! - <update>: emits updateClicked signal to update OCAF tree model
93 void onActionClicked();
97 //! Returns the previous index of history selection
98 QModelIndex getBackwardIndex();
100 //! Returns the next index of history selection
101 QModelIndex getForwardIndex();
103 //! Appends new history index, set it active, remove the first history index if the cache is out of range
104 //! \param theIndex a selected OCAF tree model index
105 void setForwardIndex (const QModelIndex& theIndex);
107 //! Updates enable state of backward/forward actions depending on the current item index
108 void updateActionsState();
110 //! Sets the current index and update actions state
111 //! \param theIndexId an item index, should be in range of history of indices
112 void setCurrentHistoryIndex (const int theIndexId);
116 bool mySelectionProcessingBlocked; //!< if true, table view selection is started but has not been finished yet
117 QList<QModelIndex> myHistoryIndices; //!< cached selected OCAF tree model indices
118 int myCurrentHistoryIndex; //!< an index of the current history selected index from myHistoryIndices
120 QWidget* myMainWindow; //!< parent widget for controls
121 QToolButton* myBackwardButton; //!< backward button, to select previous selected item
122 QToolButton* myForwardButton; //!< forward button, to select next selected item
123 QToolButton* myUpdateButton; //!< update button, like F5, to update OCAF tree model content
124 QTableView* myTableView; //!< container of path values to selected item, a path value is a label entry
126 DFBrowser_SearchLine* mySearchLine; //!< line of search