SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
qtOperationPalette.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 
11 #ifndef smtk_extension_qtOperationPalette_h
12 #define smtk_extension_qtOperationPalette_h
13 
14 #include "smtk/PublicPointerDefs.h"
15 #include "smtk/extension/qt/qtBaseView.h"
16 
17 #include <QtCore/QObject>
18 #include <QtCore/QPointer>
19 #include <QtWidgets/QLayout>
20 
21 class QLineEdit;
22 class QSortFilterProxyModel;
23 class QVBoxLayout;
24 class QWidget;
25 class QScrollArea;
28 
29 namespace smtk
30 {
31 namespace view
32 {
33 class OperationDecorator;
34 }
35 namespace extension
36 {
37 
89 class SMTKQTEXT_EXPORT qtOperationPalette : public qtBaseView
90 {
91  Q_OBJECT
92 
93 public:
94  // Views do not follow RAII. They require a call to the protected virtual
95  // method buildUI() to be initialized. Since objects that inherit from
96  // qtOperationPalette are only ever called by qtUIManager, we can code around this
97  // issue by making qtOperationPalette a friend of qtUIManager and by calling buildUI()
98  // immediately upon construction in qtUIManager.
99  friend class qtUIManager;
100 
103 
105  ~qtOperationPalette() override;
106 
107  // virtual int advanceLevel() const { return 0; }
108  // virtual bool categoryEnabled() const { return false; }
109  // virtual std::string currentCategory() const { return ""; }
110 
115  // virtual void setInitialCategory() {}
116 
120  bool isEmpty() const override;
121 
122  // Validates the view information to see if it is suitable for creating a qtOperationPalette instance
123  static bool validateInformation(const smtk::view::Information& info);
124 
126  QSortFilterProxyModel* model() const;
127 
132  qtOperationTypeModel* operationModel() const;
133 
135  qtOperationTypeView* operationView() const;
136 
138  QLineEdit* searchTextWidget() const;
139 
140 public Q_SLOTS:
145  void updateUI() override {}
146  void childrenResized() override {}
148  void showAdvanceLevel(int /* level */) override {}
149  void enableShowBy(int /* enable */) override {}
151  void onInfo() override;
152 
153  void onShowCategory() override {}
154 
155  virtual void editTopOperation();
156  virtual void toggleFiltering(int filterState);
157 
158 protected:
161  void buildUI() override;
164  void createWidget() override;
165 
167  void setInfoToBeDisplayed() override;
168 
170  QPointer<qtOperationTypeModel> m_model;
172  QPointer<QSortFilterProxyModel> m_subset;
174  QPointer<QSortFilterProxyModel> m_filter;
175 
177  QPointer<QVBoxLayout> m_layout;
179  QPointer<QLineEdit> m_search;
181  QPointer<qtOperationTypeView> m_list;
186  std::shared_ptr<smtk::view::OperationDecorator> m_decorator;
187 };
188 
189 } // namespace extension
190 } // namespace smtk
191 
192 #endif
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
PublicPointerDefs.h
smtk::extension::qtOperationPalette::showAdvanceLevel
void showAdvanceLevel(int) override
Have the view update its contents based on a new advance level.
Definition: qtOperationPalette.h:148
smtk::extension::qtUIManager
Container for managers whose content is presented via Qt widgets.
Definition: qtUIManager.h:57
smtk::extension::qtBaseView
A base class for all view types implemented using Qt.
Definition: qtBaseView.h:46
smtk::view::Information
A class for information passed to views during initialization.
Definition: Information.h:32
qtOperationTypeView
A view that displays a list-model as toolbar buttons.
Definition: qtOperationTypeView.h:29
smtk::extension::qtOperationPalette::m_list
QPointer< qtOperationTypeView > m_list
The list-view of operations.
Definition: qtOperationPalette.h:181
smtk::extension::qtOperationPalette::m_decorator
std::shared_ptr< smtk::view::OperationDecorator > m_decorator
The default operation decorator owned by m_model.
Definition: qtOperationPalette.h:186
smtk::extension::qtOperationPalette::m_search
QPointer< QLineEdit > m_search
An optional search bar for users.
Definition: qtOperationPalette.h:179
qtOperationTypeModel
A QAbstractListModel populated with SMTK operation types.
Definition: qtOperationTypeModel.h:97
smtk::extension::qtOperationPalette::m_model
QPointer< qtOperationTypeModel > m_model
A QAbstractListModel that lists all registered operations.
Definition: qtOperationPalette.h:170
smtk::extension::qtOperationPalette
An SMTK view that lists types of operations.
Definition: qtOperationPalette.h:89
smtkSuperclassMacro
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:87
smtk::extension::qtOperationPalette::updateUI
void updateUI() override
Have the view update its contents.
Definition: qtOperationPalette.h:145
smtk::extension::qtOperationPalette::m_subset
QPointer< QSortFilterProxyModel > m_subset
A proxy model that chooses a subset of operations relevant to users.
Definition: qtOperationPalette.h:172
smtk::extension::qtOperationPalette::m_layout
QPointer< QVBoxLayout > m_layout
The central widget's layout.
Definition: qtOperationPalette.h:177
smtk::extension::qtOperationPalette::m_filter
QPointer< QSortFilterProxyModel > m_filter
A proxy model for users to search by operation name.
Definition: qtOperationPalette.h:174
smtkTypenameMacro
#define smtkTypenameMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:68