@@ -47,11 +47,15 @@ class PYTHON_EXPORT QgsPythonUtils
47
47
48
48
virtual ~QgsPythonUtils () = default ;
49
49
50
- // ! returns TRUE if Python support is ready to use (must be inited first)
50
+ /* *
51
+ * Returns TRUE if Python support is ready to use.
52
+ *
53
+ * Python support must be initialized first, via a call to initPython().
54
+ */
51
55
virtual bool isEnabled () = 0;
52
56
53
57
/* *
54
- * Initialize Python and import bindings.
58
+ * Initializes Python and imports the PyQGIS bindings.
55
59
*
56
60
* The \a iface argument should be set to an instance of the QGIS interface, or
57
61
* NULLPTR if no interface is available.
@@ -61,30 +65,41 @@ class PYTHON_EXPORT QgsPythonUtils
61
65
virtual void initPython ( QgisInterface *iface, bool installErrorHook ) = 0;
62
66
63
67
#ifdef HAVE_SERVER_PYTHON_PLUGINS
64
- // ! initialize Python and import server bindings
68
+
69
+ /* *
70
+ * Initializes Python and imports server bindings.
71
+ */
65
72
virtual void initServerPython ( QgsServerInterface *iface ) = 0;
66
73
67
- // ! start server plugin: call plugin's classServerFactory(serverInterface) add to active plugins
74
+ /* *
75
+ * Starts a server plugin.
76
+ *
77
+ * Calls the plugin's classServerFactory(serverInterface) and adds the matching plugin to the
78
+ * active plugins list.
79
+ */
68
80
virtual bool startServerPlugin ( QString packageName ) = 0;
69
81
#endif
70
82
71
- // ! close Python interpreter
83
+ /* *
84
+ * Gracefully closes the Python interpreter and cleans up Python library handles.
85
+ */
72
86
virtual void exitPython () = 0;
73
87
74
- /* console */
75
-
76
88
/* *
77
- * run a statement, show an error message on error
89
+ * Runs a Python \a command, showing an error message if one occurred.
78
90
* \returns TRUE if no error occurred
79
91
*/
80
92
virtual bool runString ( const QString &command, QString msgOnError = QString(), bool single = true ) = 0;
81
93
82
94
/* *
83
- * run a statement, error reporting is not done
95
+ * Runs a Python \a command. No error reporting is not performed.
84
96
* \returns TRUE if no error occurred
85
97
*/
86
98
virtual bool runStringUnsafe ( const QString &command, bool single = true ) = 0;
87
99
100
+ /* *
101
+ * Evaluates a Python \a command and stores the result in a the \a result string.
102
+ */
88
103
virtual bool evalString ( const QString &command, QString &result ) = 0;
89
104
90
105
/* *
@@ -95,31 +110,68 @@ class PYTHON_EXPORT QgsPythonUtils
95
110
96
111
/* plugins */
97
112
98
- // ! Returns a list of all available Python plugins
113
+ /* *
114
+ * Returns a list of all available Python plugins.
115
+ *
116
+ * \see listActivePlugins()
117
+ */
99
118
virtual QStringList pluginList () = 0;
100
119
101
- // ! Returns whether the plugin is loaded (active)
120
+ /* *
121
+ * Returns TRUE if the plugin with matching name is loaded (active).
122
+ *
123
+ * \see listActivePlugins()
124
+ * \see loadPlugin()
125
+ */
102
126
virtual bool isPluginLoaded ( const QString &packageName ) = 0;
103
127
104
- // ! Returns a list of active plugins
128
+ /* *
129
+ * Returns a list of active (loaded) plugins.
130
+ *
131
+ * \see isPluginLoaded()
132
+ * \see loadPlugin()
133
+ */
105
134
virtual QStringList listActivePlugins () = 0;
106
135
107
- // ! load Python plugin (import)
136
+ /* *
137
+ * Loads a Python plugin (via import) and returns TRUE if the plugin was successfully loaded.
138
+ *
139
+ * \see isPluginLoaded()
140
+ * \see startPlugin()
141
+ */
108
142
virtual bool loadPlugin ( const QString &packageName ) = 0;
109
143
110
- // ! start plugin: add to active plugins and call initGui()
144
+ /* *
145
+ * Starts the plugin with matching \a packageName. The plugin must have already been loaded
146
+ * via a call to loadPlugin().
147
+ *
148
+ * Calling this adds the plugin to the active plugins list and calls its initGui() implementation.
149
+ *
150
+ * Returns TRUE if the plugin was successfully started.
151
+ *
152
+ * \see loadPlugin()
153
+ */
111
154
virtual bool startPlugin ( const QString &packageName ) = 0;
112
155
113
156
/* *
114
- * helper function to get some information about plugin
115
- * \param function one of these strings: name, tpye, version, description
157
+ * Helper function to return some information about a plugin.
158
+ *
159
+ * \param function metadata component to return. Must match one of the strings: name, type, version, or description.
116
160
*/
117
161
virtual QString getPluginMetadata ( const QString &pluginName, const QString &function ) = 0;
118
162
119
- // ! confirm that the plugin can be uninstalled
163
+ /* *
164
+ * Confirms that the plugin can be uninstalled.
165
+ */
120
166
virtual bool canUninstallPlugin ( const QString &packageName ) = 0;
121
167
122
- // ! unload plugin
168
+ /* *
169
+ * Unloads a plugin.
170
+ *
171
+ * Triggers the plugin's unload() implementation and removes it from the list of loaded plugins.
172
+ *
173
+ * Returns TRUE if the plugin was successfully unloaded.
174
+ */
123
175
virtual bool unloadPlugin ( const QString &packageName ) = 0;
124
176
};
125
177
0 commit comments