SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
qtWorkletPalette.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_qtWorkletPalette_h
12 #define smtk_extension_qtWorkletPalette_h
13 
14 #include "smtk/PublicPointerDefs.h"
15 #include "smtk/extension/qt/qtBaseView.h"
16 
17 #include "smtk/common/Categories.h"
18 
19 #include <QtCore/QObject>
20 #include <QtCore/QPointer>
21 #include <QtWidgets/QLayout>
22 
23 class QLineEdit;
24 class QTableView;
25 class QAbstractItemModel;
26 class QSortFilterProxyModel;
27 class QVBoxLayout;
28 class QWidget;
29 class QScrollArea;
30 class qtWorkletModel;
31 
32 namespace smtk
33 {
34 namespace extension
35 {
36 
57 class SMTKQTEXT_EXPORT qtWorkletPalette : public qtBaseView
58 {
59  Q_OBJECT
60 
61 public:
62  // Views do not follow RAII. They require a call to the protected virtual
63  // method buildUI() to be initialized. Since objects that inherit from
64  // qtWorkletPalette are only ever called by qtUIManager, we can code around this
65  // issue by making qtWorkletPalette a friend of qtUIManager and by calling buildUI()
66  // immediately upon construction in qtUIManager.
67  friend class qtUIManager;
68 
71 
73  ~qtWorkletPalette() override;
74 
75  // virtual int advanceLevel() const { return 0; }
76  // virtual bool categoryEnabled() const { return false; }
77  // virtual std::string currentCategory() const { return ""; }
78 
83  // virtual void setInitialCategory() {}
84 
88  bool isEmpty() const override;
89 
90  // Validates the view information to see if it is suitable for creating a qtWorkletPalette instance
91  static bool validateInformation(const smtk::view::Information& info);
92 
94  QSortFilterProxyModel* model() const;
95 
98  qtWorkletModel* workletModel() const;
99 
101  QTableView* workletView() const;
102 
104  QLineEdit* searchTextWidget() const;
105 
108  void setToplevelCatagoryExpression(const smtk::common::Categories::Expression& exp);
109 
114  void setParentTask(const smtk::task::TaskPtr& task);
115 
116 Q_SIGNALS:
117  void emplaceWorklet(const std::string& workletName, const std::array<double, 2>& location);
118 
119 public Q_SLOTS:
124  void updateUI() override {}
125  void childrenResized() override {}
127  void showAdvanceLevel(int /* level */) override {}
128  void enableShowBy(int /* enable */) override {}
130  void onInfo() override;
131 
132  void onShowCategory() override {}
133 
134  virtual void instantiateTopWorklet();
135  virtual void toggleFiltering(int filterState);
136 
137 protected:
140  void buildUI() override;
143  void createWidget() override;
144 
146  void setInfoToBeDisplayed() override;
147 
149  QPointer<qtWorkletModel> m_model;
151  QPointer<QSortFilterProxyModel> m_filter;
152 
154  QPointer<QVBoxLayout> m_layout;
156  QPointer<QLineEdit> m_search;
158  QPointer<QTableView> m_list;
159 };
160 
161 } // namespace extension
162 } // namespace smtk
163 
164 #endif
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::extension::qtWorkletPalette::m_list
QPointer< QTableView > m_list
The list-view of worklets.
Definition: qtWorkletPalette.h:158
PublicPointerDefs.h
smtk::extension::qtWorkletPalette::updateUI
void updateUI() override
Have the view update its contents.
Definition: qtWorkletPalette.h:124
smtk::extension::qtUIManager
Container for managers whose content is presented via Qt widgets.
Definition: qtUIManager.h:56
smtk::extension::qtWorkletPalette::m_filter
QPointer< QSortFilterProxyModel > m_filter
A proxy model for users to search by worklet name.
Definition: qtWorkletPalette.h:151
smtk::extension::qtBaseView
A base class for all view types implemented using Qt.
Definition: qtBaseView.h:46
smtk::common::Categories::Expression
Definition: Categories.h:166
smtk::extension::qtWorkletPalette::m_search
QPointer< QLineEdit > m_search
An optional search bar for users.
Definition: qtWorkletPalette.h:156
smtk::view::Information
A class for information passed to views during initialization.
Definition: Information.h:32
smtk::extension::qtWorkletPalette::m_layout
QPointer< QVBoxLayout > m_layout
The central widget's layout.
Definition: qtWorkletPalette.h:154
qtWorkletModel
A QAbstractListModel populated with SMTK worklets.
Definition: qtWorkletModel.h:37
smtk::extension::qtWorkletPalette::showAdvanceLevel
void showAdvanceLevel(int) override
Have the view update its contents based on a new advance level.
Definition: qtWorkletPalette.h:127
smtk::extension::qtWorkletPalette
An SMTK view that lists worklets which can be added to a project's workflow.
Definition: qtWorkletPalette.h:57
smtkSuperclassMacro
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:167
smtk::extension::qtWorkletPalette::m_model
QPointer< qtWorkletModel > m_model
A QAbstractListModel that lists all registered worklets.
Definition: qtWorkletPalette.h:149
smtk::task::TaskPtr
smtk::shared_ptr< smtk::task::Task > TaskPtr
Definition: PublicPointerDefs.h:729
smtkTypenameMacro
#define smtkTypenameMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:115