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  vtkSMProxy* getPrototype(QAction* action) const;
71 
75  void addProxy(const QString& xmlgroup, const QString& xmlname);
76 
80  void removeProxy(const QString& xmlgroup, const QString& xmlname);
81 
85 
90  QStringList getToolbarCategories() const;
94  QString getToolbarName(pqProxyCategory* category);
98  QString categoryLabel(const QString& category);
103  "This was mostly unused. Also it is better to avoid test-dedicated code paths.")
104  bool hideForTests(const QString&) const { return false; };
106 
110 
114  QList<QAction*> actions() const;
119  QList<QAction*> categoryActions(const QString& category);
123  QList<QAction*> categoryActions(pqProxyCategory* category);
127  QList<QAction*> actionsInToolbars();
131  QAction* getAction(pqProxyInfo* proxy);
135  void updateActionIcon(pqProxyInfo* proxy);
137 
146  void addProxyDefinitionUpdateListener(const QString& proxyGroupName);
147  void removeProxyDefinitionUpdateListener(const QString& proxyGroupName);
148 
152 
157  pqProxyCategory* getApplicationCategory();
162  pqProxyCategory* getMenuCategory();
166  pqProxyCategory* getFavoritesCategory();
171  bool isFavorites(pqProxyCategory* category);
173 
174 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
178 
185  void loadConfiguration(vtkPVXMLElement*);
190  void lookForNewDefinitions();
194  void removeProxyDefinitionUpdateObservers();
198  void addProxyDefinitionUpdateObservers();
200 
201  PARAVIEW_DEPRECATED_IN_5_13_0("Inner member is not used")
202  void setEnabled(bool){};
203 
211  virtual void populateMenu();
212 
216  void writeCategoryToSettings();
217 
218 Q_SIGNALS:
219  void triggered(const QString& group, const QString& name);
220 
225  void menuPopulated();
226 
230  void categoriesUpdated();
231 
232 protected Q_SLOTS:
233  void triggered();
234  void quickLaunch();
235  void switchActiveServer();
236  void updateMenuStyle();
237  void updateActionsStyle();
238 
240  void populateRecentlyUsedMenu();
241 
247  "Favorites are now a specific category, configurable as the others.")
248  void populateFavoritesMenu();
249 
250 protected: // NOLINT(readability-redundant-access-specifiers)
252  vtkPVXMLElement* MenuRoot = nullptr;
253  int RecentlyUsedMenuSize = 0;
254  PARAVIEW_DEPRECATED_IN_5_13_0("Inner member is not used")
255  bool Enabled = true;
256  bool EnableFavorites = false;
257 
258  void loadRecentlyUsedItems();
259  void saveRecentlyUsedItems();
260 
265  "Favorites are now a specific category, configurable as the others.")
266  void loadFavoritesItems();
267 
269  "Favorites are now a specific category, configurable as the others.")
270  QAction* getAddToFavoritesAction(const QString& path);
271 
275  QAction* getAction(const QString& pgroup, const QString& proxyname);
276 
277 private Q_SLOTS:
282  void populateAlphabeticalMenu();
286  void populateMiscMenu();
288  void populateCategoriesMenus();
290 
291 private: // NOLINT(readability-redundant-access-specifiers)
292  Q_DISABLE_COPY(pqProxyGroupMenuManager)
293 
298  QAction* createAction(pqProxyInfo* proxy);
299 
303  QAction* createAddToFavoritesAction();
304 
308  void clearMenu();
312  void clearCategoriesMenus();
314  void populateSubCategoriesMenus(QMenu* parent, pqProxyCategory* category);
316  void populateCategoryMenu(QMenu* parent, pqProxyCategory* category);
318 
322  void loadCategorySettings();
323 
324  struct pqInternal;
325  std::unique_ptr<pqInternal> Internal;
326  bool SupportsQuickLaunch = true;
327 };
328 
329 #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.