pqProxyCategory.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef pqProxyCategory_h
4 #define pqProxyCategory_h
5 
7 
8 #include "pqProxyInfo.h" // for pqProxyInfoMap
9 #include <QMap> // for QMap
10 #include <QString> // for QString
11 
12 class vtkPVXMLElement;
13 
61 {
62  Q_OBJECT
63  typedef QObject Superclass;
64 
65 public:
66  pqProxyCategory(pqProxyCategory* parent = nullptr);
67  pqProxyCategory(pqProxyCategory* parent, const QString& name, const QString& label);
68  ~pqProxyCategory() override;
69 
73  bool parseXML(vtkPVXMLElement* root);
77  void convertToXML(vtkPVXMLElement* root) { this->convertToXML(this, root); }
92  bool parseXMLHintsTag(
93  const QString& proxyGroup, const QString& proxyName, vtkPVXMLElement* hints);
95  static void convertLegacyXML(vtkPVXMLElement* root);
97 
101  void writeSettings(const QString& resourceTag);
105  void loadSettings(const QString& resourceTag);
107 
111 
116  void copyAttributes(pqProxyCategory* other);
120  void deepCopy(pqProxyCategory* other);
122 
126  bool hasProxy(const QString& name);
131  pqProxyInfo* findProxy(const QString& name, bool recursive = false);
133  QList<pqProxyInfo*> getRootProxies();
135  QList<pqProxyInfo*> getProxiesRecursive();
137  QStringList getOrderedRootProxiesNames();
139 
143  pqProxyCategory* findSubCategory(const QString& name);
147  QMap<QString, pqProxyCategory*> getSubCategories();
149  QMap<QString, pqProxyCategory*> getSubCategoriesRecursive();
151  QList<pqProxyCategory*> getCategoriesAlphabetically();
153  QString makeUniqueCategoryName(const QString& name);
155  QString makeUniqueCategoryLabel(const QString& label);
157 
161  void addCategory(pqProxyCategory* category);
165  void removeCategory(const QString& name);
167  void addProxy(pqProxyInfo* info);
169  void removeProxy(const QString& name);
171  void clear();
173 
177  bool hasProxiesRecursive();
181  pqProxyCategory* parentCategory() { return dynamic_cast<pqProxyCategory*>(this->parent()); }
183  bool isEmpty();
185  QString name() { return this->Name; }
187  QString label();
189  bool preserveOrder() { return this->PreserveOrder; }
191  bool showInToolbar() { return this->ShowInToolbar; }
193 
197  void rename(const QString& name);
201  void updateLabel(const QString& label = "");
203  void setShowInToolbar(bool show);
205 
206 protected:
211  pqProxyCategory* addCategory(const QString& name, vtkPVXMLElement* node);
212 
213 protected Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
214 
215  void cleanDeletedProxy(QObject* deleted);
216 
217 private:
221  bool parseXML(pqProxyCategory* categoryRoot, vtkPVXMLElement* root);
222 
226  void convertToXML(pqProxyCategory* parent, vtkPVXMLElement* root);
227 
228  QString Name;
229  QString Label;
230 
231  bool PreserveOrder = false;
232  bool ShowInToolbar = false;
233 
234  pqProxyInfoMap Proxies;
235  QMap<QString, pqProxyCategory*> SubCategories;
236  QStringList OrderedProxies;
237 };
238 
240 using pqCategoryMap = QMap<QString, pqProxyCategory*>;
241 
242 #endif
QMap< QString, pqProxyInfo * > pqProxyInfoMap
map a proxy name to its pqProxyInfo
Definition: pqProxyInfo.h:100
info
pqProxyCategory * parentCategory()
Return parent category.
QMap< QString, pqProxyCategory * > pqCategoryMap
map a category name to its pqProxyCategory
#define PQAPPLICATIONCOMPONENTS_EXPORT
Proxy meta data structure for the User Interface.
Definition: pqProxyInfo.h:20
QString name()
Return category name.
bool showInToolbar()
Return true if a toolbar should be created.
name
bool preserveOrder()
Return true if read order should be used in display.
void convertToXML(vtkPVXMLElement *root)
Add Proxies and SubCategories XML declaration to root element.
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.