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 
7 #include "pqApplicationComponentsModule.h"
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 
25 class PQAPPLICATIONCOMPONENTS_EXPORT pqProxyGroupMenuManager : public QObject
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  void addProxy(const QString& xmlgroup, const QString& xmlname);
71 
75  void removeProxy(const QString& xmlgroup, const QString& xmlname);
76 
80 
85  QStringList getToolbarCategories() const;
89  QString getToolbarName(pqProxyCategory* category);
93  QString categoryLabel(const QString& category);
94 
98 
102  QList<QAction*> actions() const;
107  QList<QAction*> categoryActions(const QString& category);
111  QList<QAction*> categoryActions(pqProxyCategory* category);
115  QList<QAction*> actionsInToolbars();
119  QAction* getAction(pqProxyInfo* proxy);
123  void updateActionIcon(pqProxyInfo* proxy);
125 
134  void addProxyDefinitionUpdateListener(const QString& proxyGroupName);
135  void removeProxyDefinitionUpdateListener(const QString& proxyGroupName);
136 
140 
145  pqProxyCategory* getApplicationCategory();
150  pqProxyCategory* getMenuCategory();
154  pqProxyCategory* getFavoritesCategory();
159  bool isFavorites(pqProxyCategory* category);
161 
162 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
166 
173  void loadConfiguration(vtkPVXMLElement*);
178  void lookForNewDefinitions();
182  void removeProxyDefinitionUpdateObservers();
186  void addProxyDefinitionUpdateObservers();
188 
196  virtual void populateMenu();
197 
201  void writeCategoryToSettings();
202 
203 Q_SIGNALS:
204  void triggered(const QString& group, const QString& name);
205 
210  void menuPopulated();
211 
215  void categoriesUpdated();
216 
217 protected Q_SLOTS:
218  void triggered();
219  void quickLaunch();
220  void switchActiveServer();
221  void updateMenuStyle();
222  void updateActionsStyle();
223 
225  void populateRecentlyUsedMenu();
226 
227 protected: // NOLINT(readability-redundant-access-specifiers)
229  vtkPVXMLElement* MenuRoot = nullptr;
230  int RecentlyUsedMenuSize = 0;
231  bool EnableFavorites = false;
232 
233  void loadRecentlyUsedItems();
234  void saveRecentlyUsedItems();
235 
239  QAction* getAction(const QString& pgroup, const QString& proxyname);
240 
241 private Q_SLOTS:
246  void populateAlphabeticalMenu();
250  void populateMiscMenu();
252  void populateCategoriesMenus();
254 
255 private: // NOLINT(readability-redundant-access-specifiers)
256  Q_DISABLE_COPY(pqProxyGroupMenuManager)
257 
258 
262  QAction* createAction(pqProxyInfo* proxy);
263 
267  QAction* createAddToFavoritesAction();
268 
272  void clearMenu();
276  void clearCategoriesMenus();
278  void populateSubCategoriesMenus(QMenu* parent, pqProxyCategory* category);
280  void populateCategoryMenu(QMenu* parent, pqProxyCategory* category);
282 
286  void loadCategorySettings();
287 
288  struct pqInternal;
289  std::unique_ptr<pqInternal> Internal;
290  bool SupportsQuickLaunch = true;
291 };
292 
293 #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...
Proxy meta data structure for the User Interface.
Definition: pqProxyInfo.h:20
name
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.
QMenu * menu() const
Access the menu.