7e1c1e48 |
1 | // Created on: 2020-01-25 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2020 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 ViewControl_Table_H |
17 | #define ViewControl_Table_H |
18 | |
19 | #include <NCollection_List.hxx> |
20 | |
21 | #include <Standard.hxx> |
22 | #include <Standard_Macro.hxx> |
23 | #include <Standard_Transient.hxx> |
24 | |
25 | #include <inspector/TreeModel_ItemBase.hxx> |
26 | |
27 | #include <Standard_WarningsDisable.hxx> |
28 | #include <QItemSelection> |
29 | #include <QObject> |
30 | #include <QTableView> |
31 | #include <Standard_WarningsRestore.hxx> |
32 | |
33 | class ViewControl_TableModelValues; |
34 | |
35 | class QAbstractTableModel; |
36 | class QContextMenuEvent; |
37 | class QWidget; |
38 | |
39 | //! \class ViewControl_Table |
40 | //! \brief View to display table values with possibility to change table columns |
41 | //! if the table has 1D dimension and Horizontal orientation |
42 | class ViewControl_Table : public QObject |
43 | { |
44 | Q_OBJECT |
45 | public: |
46 | |
47 | //! Constructor |
48 | Standard_EXPORT ViewControl_Table (QWidget* theParent); |
49 | |
50 | //! Destructor |
51 | virtual ~ViewControl_Table() {} |
52 | |
53 | //! Sets model into table view, init selection model by the given model, connect to selection change |
54 | //! \param theModel table values model |
55 | void SetModel (QAbstractTableModel* theModel); |
56 | |
57 | //! Fills table view and table size control by the model |
58 | //! \param theModel values model |
59 | Standard_EXPORT void Init (ViewControl_TableModelValues* theModelValues); |
60 | |
61 | //! true if the table is used in property view and visible |
62 | bool IsActive() const { return myIsActive; } |
63 | |
64 | //! Sets the table active and show the table |
65 | //! \param theState boolean value |
66 | void SetActive (const bool theState) { myIsActive = theState; TableView()->setVisible (theState); } |
67 | |
68 | //! \return the text edit control |
69 | QWidget* GetControl() const { return myMainWidget; } |
70 | |
71 | //! \return the table view |
72 | QTableView* TableView() const { return myTableView; } |
73 | |
a110c4a3 |
74 | //! Returns model indices of the selected cells in table view |
7e1c1e48 |
75 | //! \param theSelectedIndices [out] a container of indices: row to list of columns |
76 | Standard_EXPORT void SelectedIndices (QMap<int, QList<int>>& aSelectedIndices) const; |
77 | |
78 | //! Returns pointers from selected cells |
79 | Standard_EXPORT void SelectedPointers (QStringList& thePointers) const; |
80 | |
81 | //! Returns text of separation row in table |
82 | //! \return string value |
83 | Standard_EXPORT static QString SeparatorData(); |
84 | |
85 | protected slots: |
86 | void onHeaderResized (int theSectionId, int, int); |
87 | |
88 | private: |
89 | bool myIsActive; //!< true if the table is used in property view and visible |
90 | |
91 | QWidget* myMainWidget; //!< parent of all controls |
92 | bool myIsUseProperty; //!< boolean value whether the property control should be shown/hidden |
93 | QTableView* myTableView; //!< table view |
94 | }; |
95 | #endif |