2
class QgsApplication : QApplication
5
#include <qgsapplication.h>
9
// Convert a Python argv list to a conventional C argc count and argv array.
10
static char **qtgui_ArgvToC(PyObject *argvlist, int &argc)
14
argc = PyList_GET_SIZE(argvlist);
16
// Allocate space for two copies of the argument pointers, plus the
18
if ((argv = (char **)sipMalloc(2 * (argc + 1) * sizeof (char *))) == NULL)
22
for (int a = 0; a < argc; ++a)
26
// Get the argument and allocate memory for it.
27
if ((arg = PyString_AsString(PyList_GET_ITEM(argvlist, a))) == NULL ||
28
(argv[a] = (char *)sipMalloc(strlen(arg) + 1)) == NULL)
31
// Copy the argument and save a pointer to it.
33
argv[a + argc + 1] = argv[a];
36
argv[argc + argc + 1] = argv[argc] = NULL;
42
// Remove arguments from the Python argv list that have been removed from the
44
static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
46
for (int a = 0, na = 0; a < argc; ++a)
48
// See if it was removed.
49
if (argv[na] == argv[a + argc + 1])
52
PyList_SetSlice(argvlist, na, na + 1, NULL);
60
//QgsApplication(int argc, char ** argv, bool GUIenabled);
61
QgsApplication(SIP_PYLIST argv, bool GUIenabled) /PostHook=__pyQtQAppHook__/ [(int &argc, char **argv, bool GUIenabled)];
63
// The Python interface is a list of argument strings that is modified.
69
if ((argv = qtgui_ArgvToC(a0, argc)) == NULL)
73
// Create it now the arguments are right.
74
static int nargc = argc;
76
sipCpp = new sipQgsApplication(nargc, argv, a1);
78
// Now modify the original list.
79
qtgui_UpdatePyArgv(a0, argc, argv);
83
virtual ~QgsApplication();
85
/** Set the active theme to the specified theme.
86
* The theme name should be a single word e.g. 'default','classic'.
87
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
88
* but plugin writers etc can use themeName() as a basis for searching
89
* for resources in their own datastores e.g. a Qt4 resource bundle.
90
* @Note A basic test will be carried out to ensure the theme search path
91
* based on the supplied theme name exists. If it does not the theme name will
92
* be reverted to 'default'.
94
static void setThemeName(const QString theThemeName);
96
/** Set the active theme to the specified theme.
97
* The theme name should be a single word e.g. 'default','classic'.
98
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
99
* but plugin writers etc can use this method as a basis for searching
100
* for resources in their own datastores e.g. a Qt4 resource bundle.
102
static const QString themeName();
104
//! Returns the path to the authors file.
105
static const QString authorsFilePath();
107
/**Returns the path to the sponsors file.
108
@note this function was added in version 1.2*/
109
static const QString sponsorsFilePath();
111
/** Returns the path to the donors file.
112
@note this function was added in version 1.2*/
113
static const QString donorsFilePath();
116
* Returns the path to the sponsors file.
117
* @note This was added in QGIS 1.1
119
static const QString translatorsFilePath();
121
//! Returns the path to the developer image directory.
122
static const QString developerPath();
124
//! Returns the path to the help application.
125
static const QString helpAppPath();
127
//! Returns the path to the mapserver export application.
128
static const QString msexportAppPath();
130
//! Returns the path to the translation directory.
131
static const QString i18nPath();
133
//! Returns the path to the master qgis.db file.
134
static const QString qgisMasterDbFilePath();
136
//! Returns the path to the settings directory in user's home dir
137
static const QString qgisSettingsDirPath();
139
//! Returns the path to the user qgis.db file.
140
static const QString qgisUserDbFilePath();
142
//! Returns the path to the splash screen image directory.
143
static const QString splashPath();
145
//! Returns the path to the icons image directory.
146
static const QString iconsPath();
148
//! Returns the path to the srs.db file.
149
static const QString srsDbFilePath();
151
//! Returns the paths to the svg directories.
152
//! @note added in 1.4
153
static const QStringList svgPaths();
155
//! Returns the path to the applications svg paths
157
static const QString svgPath();
159
//! Returns the path to user's style. Added in QGIS 1.4
160
static const QString userStyleV2Path();
162
//! Returns the path to default style (works as a starting point). Added in QGIS 1.4
163
static const QString defaultStyleV2Path();
165
//! Returns the path to the application prefix directory.
166
static const QString prefixPath();
168
//! Returns the path to the application plugin directory.
169
static const QString pluginPath();
171
//! Returns the common root path of all application data directories.
172
static const QString pkgDataPath();
174
//! Returns the path to the currently active theme directory.
175
static const QString activeThemePath();
177
//! Returns the path to the default theme directory.
178
static const QString defaultThemePath();
180
//! Alters prefix path - used by 3rd party apps
181
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);
183
//! Alters plugin path - used by 3rd party apps
184
static void setPluginPath(const QString thePluginPath);
186
//! Alters pkg data path - used by 3rd party apps
187
static void setPkgDataPath(const QString thePkgDataPath);
190
static void initQgis();
192
//! deletes provider registry and map layer registry
193
static void exitQgis();
195
/** constants for endian-ness */
198
XDR = 0, // network, or big-endian, byte order
199
NDR = 1 // little-endian byte order
202
//! Returns whether this machine uses big or little endian
203
static endian_t endian();
205
/** \brief get a standard css style sheet for reports.
206
* Typically you will use this method by doing:
207
* QString myStyle = QgsApplication::reportStyleSheet();
208
* textBrowserReport->document()->setDefaultStyleSheet(myStyle);
209
* @return QString containing the CSS 2.1 compliant stylesheet.
210
* @note you can use the special Qt extensions too, for example
211
* the gradient fills for backgrounds.
213
static QString reportStyleSheet();
215
/** Convenience function to get a summary of the paths used in this
216
* application instance useful for debugging mainly.*/
217
static QString showSettings();
219
/** Register OGR drivers ensuring this only happens once.
220
* This is a workaround for an issue with older gdal versions that
221
* caused duplicate driver name entries to appear in the list
222
* of registered drivers when QgsApplication::registerOgrDrivers was called multiple
225
static void registerOgrDrivers();