pqProxyGroupMenuManager.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqProxyGroupMenuManager_h
5 #define pqProxyGroupMenuManager_h
6 
8 
9 #include <QMenu>
10 
11 #include "vtkParaViewDeprecation.h" // for deprecation macro
12 
13 #include <memory> // for unique_ptr
14 
15 class pqProxyCategory;
16 class pqProxyInfo;
17 class vtkPVXMLElement;
18 class vtkSMProxy;
19 
26 {
27  Q_OBJECT
28  typedef QObject Superclass;
29 
30 public:
39  pqProxyGroupMenuManager(QMenu* menu, const QString& resourceTagName,
40  bool supportsQuickLaunch = true, bool enableFavorites = false);
41  ~pqProxyGroupMenuManager() override;
42 
46  QMenu* menu() const { return static_cast<QMenu*>(this->parent()); }
47 
51  QWidget* widgetActionsHolder() const;
52  QMenu* getFavoritesMenu();
53 
58  void setRecentlyUsedMenuSize(unsigned int val) { this->RecentlyUsedMenuSize = val; }
59  unsigned int recentlyUsedMenuSize() const { return this->RecentlyUsedMenuSize; }
64  bool supportsQuickLaunch() const { return this->SupportsQuickLaunch; }
65  void setEnableFavorites(bool enable) { this->EnableFavorites = enable; }
66 
70  PARAVIEW_DEPRECATED_IN_5_13_0("Use pqProxyAction::GetProxyPrototype instead.")
71  vtkSMProxy* getPrototype(QAction* action) const;
72 
76  void addProxy(const QString& xmlgroup, const QString& xmlname);
77 
81  void removeProxy(const QString& xmlgroup, const QString& xmlname);
82 
86 
91  QStringList getToolbarCategories() const;
95  QString getToolbarName(pqProxyCategory* category);
99  QString categoryLabel(const QString& category);
104  "This was mostly unused. Also it is better to avoid test-dedicated code paths.")
105  bool hideForTests(const QString&) const { return false; };
107 
111 
115  QList<QAction*> actions() const;
120  QList<QAction*> categoryActions(const QString& category);
124  QList<QAction*> categoryActions(pqProxyCategory* category);
128  QList<QAction*> actionsInToolbars();
132  QAction* getAction(pqProxyInfo* proxy);
136  void updateActionIcon(pqProxyInfo* proxy);
138 
147  void addProxyDefinitionUpdateListener(const QString& proxyGroupName);
148  void removeProxyDefinitionUpdateListener(const QString& proxyGroupName);
149 
153 
158  pqProxyCategory* getApplicationCategory();
163  pqProxyCategory* getMenuCategory();
167  pqProxyCategory* getFavoritesCategory();
172  bool isFavorites(pqProxyCategory* category);
174 
175 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
179 
186  void loadConfiguration(vtkPVXMLElement*);
191  void lookForNewDefinitions();
195  void removeProxyDefinitionUpdateObservers();
199  void addProxyDefinitionUpdateObservers();
201 
202  PARAVIEW_DEPRECATED_IN_5_13_0("Inner member is not used")
203  void setEnabled(bool){};
204 
212  virtual void populateMenu();
213 
217  void writeCategoryToSettings();
218 
219 Q_SIGNALS:
220  void triggered(const QString& group, const QString& name);
221 
226  void menuPopulated();
227 
231  void categoriesUpdated();
232 
233 protected Q_SLOTS:
234  void triggered();
235  void quickLaunch();
236  void switchActiveServer();
237  void updateMenuStyle();
238  void updateActionsStyle();
239 
241  void populateRecentlyUsedMenu();
242 
248  "Favorites are now a specific category, configurable as the others.")
249  void populateFavoritesMenu();
250 
251 protected: // NOLINT(readability-redundant-access-specifiers)
253  vtkPVXMLElement* MenuRoot = nullptr;
254  int RecentlyUsedMenuSize = 0;
255  PARAVIEW_DEPRECATED_IN_5_13_0("Inner member is not used")
256  bool Enabled;
257  bool EnableFavorites = false;
258 
259  void loadRecentlyUsedItems();
260  void saveRecentlyUsedItems();
261 
266  "Favorites are now a specific category, configurable as the others.")
267  void loadFavoritesItems();
268 
270  "Favorites are now a specific category, configurable as the others.")
271  QAction* getAddToFavoritesAction(const QString& path);
272 
276  QAction* getAction(const QString& pgroup, const QString& proxyname);
277 
278 private Q_SLOTS:
283  void populateAlphabeticalMenu();
287  void populateMiscMenu();
289  void populateCategoriesMenus();
291 
292 private: // NOLINT(readability-redundant-access-specifiers)
293  Q_DISABLE_COPY(pqProxyGroupMenuManager)
294 
299  QAction* createAction(pqProxyInfo* proxy);
300 
304  QAction* createAddToFavoritesAction();
305 
309  void clearMenu();
313  void clearCategoriesMenus();
315  void populateSubCategoriesMenus(QMenu* parent, pqProxyCategory* category);
317  void populateCategoryMenu(QMenu* parent, pqProxyCategory* category);
319 
323  void loadCategorySettings();
324 
325  struct pqInternal;
326  std::unique_ptr<pqInternal> Internal;
327  bool SupportsQuickLaunch = true;
328 };
329 
330 #endif
unsigned int recentlyUsedMenuSize() const
void setRecentlyUsedMenuSize(unsigned int val)
When size>0 a recently used category will be added to the menu.
pqProxyGroupMenuManager is a menu-populator that fills up a menu with proxies defined in an XML confi...
void setEnableFavorites(bool enable)
bool supportsQuickLaunch() const
Returns true if the pqProxyGroupMenuManager has been registered with quick-launch mechanism maintaine...
#define PQAPPLICATIONCOMPONENTS_EXPORT
Proxy meta data structure for the User Interface.
Definition: pqProxyInfo.h:20
name
#define PARAVIEW_DEPRECATED_IN_5_13_0(reason)
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
The pqProxyCategory class reads and writes XML that describes the proxies organisation into categorie...
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
#define const
Definition: zconf.h:238
QMenu * menu() const
Access the menu.