pqPythonEditorActions.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 
5 #ifndef pqPythonEditorActions_h
6 #define pqPythonEditorActions_h
7 
8 #include "pqPythonUtils.h"
9 
10 #include <QAction>
11 #include <QMenu>
12 #include <QPointer>
13 
14 #include <array>
15 #include <cstddef>
16 #include <vector>
17 
18 class pqPythonManager;
19 
27 template <typename E>
29 {
30  static_assert(static_cast<int>(E::END), "The input enum must end with END");
31  static_assert(static_cast<int>(E::END) != 0, "At least one action is required");
32 
33  using Type = E;
34 
40  {
41  for (int i = 0; i < static_cast<int>(Type::END); ++i)
42  {
43  this->Actions[static_cast<Type>(i)] = new QAction();
44  }
45  }
46 
50  const QAction& operator[](const Type action) const { return *this->Actions[action]; }
51 
55  QAction& operator[](const Type action) { return *this->Actions[action]; }
56 
61 };
62 
74 {
81 
85  enum class GeneralActionType : std::uint8_t
86  {
87  // File IO Actions
88  NewFile,
89  OpenFile,
90  SaveFile,
91  SaveFileAs,
92  SaveFileAsMacro,
93  SaveFileAsScript,
94  DeleteAll,
95 
96  // Undo/Redo Actions
97  Undo,
98  Redo,
99 
100  // Text Actions
101  Copy,
102  Cut,
103  Paste,
104 
105  // Editor Actions
106  CloseCurrentTab,
107  Exit,
108  Run,
109 
110  END
111  };
112 
117  enum class ScriptActionType : std::uint8_t
118  {
119  Open,
120  Load,
121  Delete,
122  Run,
123 
124  END
125  };
126 
128 
133 
135 
139  std::vector<ScriptAction> ScriptActions;
140 
144  const QAction& operator[](const GeneralActionType action) const
145  {
146  return this->GeneralActions[action];
147  }
148 
152  QAction& operator[](const GeneralActionType action) { return this->GeneralActions[action]; }
153 
159  void updateScriptsList(pqPythonManager* python_mgr);
160 
165  void FillQMenu(EnumArray<ScriptAction::Type, QMenu*> menus);
166 
171  template <class T>
172  static void connect(pqPythonEditorActions&, T*);
173 
178  template <class T>
179  static void disconnect(pqPythonEditorActions&, T*);
180 };
181 
182 #endif // pqPythonEditorActions_h
EditorActionGroup()
Default constructor allocates all the actions listed in the enum.
Stack array using an enum as indexer.
Definition: pqPythonUtils.h:61
QAction & operator[](const GeneralActionType action)
accessor to an action
A template group of action.
const QAction & operator[](const Type action) const
const accessor to an action
std::vector< ScriptAction > ScriptActions
The variable sized array of script actions.
GeneralActionType
General editor actions.
QAction & operator[](const Type action)
accessor to an action
const QAction & operator[](const GeneralActionType action) const
const accessor to an action
EnumArray< Type, QPointer< QAction > > Actions
The array of actions.
connect
pqPythonManager is a class to facilitate the use of a python interpreter by various paraview GUI comp...
int Run(int processType, int argc, char *argv[])
Definition: pvpython.h:70
TGeneralAction GeneralActions
The list of general actions.
ScriptActionType
Specialized actions for the scripting part of the editor.