~ubuntu-branches/ubuntu/trusty/qgis/trusty

« back to all changes in this revision

Viewing changes to python/core/qgsapplication.sip

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
class QgsApplication : QApplication
 
3
{
 
4
%TypeHeaderCode
 
5
#include <qgsapplication.h>
 
6
%End
 
7
 
 
8
%TypeCode
 
9
// Convert a Python argv list to a conventional C argc count and argv array.
 
10
static char **qtgui_ArgvToC(PyObject *argvlist, int &argc)
 
11
{
 
12
    char **argv;
 
13
 
 
14
    argc = PyList_GET_SIZE(argvlist);
 
15
 
 
16
    // Allocate space for two copies of the argument pointers, plus the
 
17
    // terminating NULL.
 
18
    if ((argv = (char **)sipMalloc(2 * (argc + 1) * sizeof (char *))) == NULL)
 
19
        return NULL;
 
20
 
 
21
    // Convert the list.
 
22
    for (int a = 0; a < argc; ++a)
 
23
    {
 
24
        char *arg;
 
25
 
 
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)
 
29
            return NULL;
 
30
 
 
31
        // Copy the argument and save a pointer to it.
 
32
        strcpy(argv[a], arg);
 
33
        argv[a + argc + 1] = argv[a];
 
34
    }
 
35
 
 
36
    argv[argc + argc + 1] = argv[argc] = NULL;
 
37
 
 
38
    return argv;
 
39
}
 
40
 
 
41
 
 
42
// Remove arguments from the Python argv list that have been removed from the
 
43
// C argv array.
 
44
static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
 
45
{
 
46
    for (int a = 0, na = 0; a < argc; ++a)
 
47
    {
 
48
        // See if it was removed.
 
49
        if (argv[na] == argv[a + argc + 1])
 
50
            ++na;
 
51
        else
 
52
            PyList_SetSlice(argvlist, na, na + 1, NULL);
 
53
    }
 
54
}
 
55
%End
 
56
 
 
57
 
 
58
 
 
59
  public:
 
60
    //QgsApplication(int argc, char ** argv, bool GUIenabled);
 
61
    QgsApplication(SIP_PYLIST argv, bool GUIenabled) /PostHook=__pyQtQAppHook__/ [(int &argc, char **argv, bool GUIenabled)];
 
62
%MethodCode
 
63
        // The Python interface is a list of argument strings that is modified.
 
64
        
 
65
        int argc;
 
66
        char **argv;
 
67
        
 
68
        // Convert the list.
 
69
        if ((argv = qtgui_ArgvToC(a0, argc)) == NULL)
 
70
            sipIsErr = 1;
 
71
        else
 
72
        {
 
73
            // Create it now the arguments are right.
 
74
            static int nargc = argc;
 
75
        
 
76
            sipCpp = new sipQgsApplication(nargc, argv, a1);
 
77
        
 
78
            // Now modify the original list.
 
79
            qtgui_UpdatePyArgv(a0, argc, argv);
 
80
        }
 
81
%End
 
82
 
 
83
    virtual ~QgsApplication();
 
84
 
 
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'.
 
93
     */
 
94
    static void setThemeName(const QString theThemeName);
 
95
 
 
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.
 
101
     */
 
102
    static const QString themeName();
 
103
 
 
104
    //! Returns the path to the authors file.
 
105
    static const QString authorsFilePath();
 
106
 
 
107
    /**Returns the path to the sponsors file.
 
108
      @note this function was added in version 1.2*/
 
109
    static const QString sponsorsFilePath();
 
110
 
 
111
    /** Returns the path to the donors file.
 
112
      @note this function was added in version 1.2*/
 
113
    static const QString donorsFilePath();
 
114
 
 
115
    /**
 
116
     * Returns the path to the sponsors file.
 
117
     * @note This was added in QGIS 1.1
 
118
     */
 
119
    static const QString translatorsFilePath();
 
120
 
 
121
    //! Returns the path to the developer image directory.
 
122
    static const QString developerPath();
 
123
 
 
124
    //! Returns the path to the help application.
 
125
    static const QString helpAppPath();
 
126
 
 
127
    //! Returns the path to the mapserver export application.
 
128
    static const QString msexportAppPath();
 
129
 
 
130
    //! Returns the path to the translation directory.
 
131
    static const QString i18nPath();
 
132
 
 
133
    //! Returns the path to the master qgis.db file.
 
134
    static const QString qgisMasterDbFilePath();
 
135
 
 
136
    //! Returns the path to the settings directory in user's home dir
 
137
    static const QString qgisSettingsDirPath();
 
138
    
 
139
    //! Returns the path to the user qgis.db file.
 
140
    static const QString qgisUserDbFilePath();
 
141
 
 
142
    //! Returns the path to the splash screen image directory.
 
143
    static const QString splashPath();
 
144
 
 
145
    //! Returns the path to the icons image directory.
 
146
    static const QString iconsPath();
 
147
 
 
148
    //! Returns the path to the srs.db file.
 
149
    static const QString srsDbFilePath();
 
150
 
 
151
    //! Returns the paths to the svg directories.
 
152
    //! @note added in 1.4
 
153
    static const QStringList svgPaths();
 
154
 
 
155
    //! Returns the path to the applications svg paths
 
156
    //! @note deprecated
 
157
    static const QString svgPath();
 
158
 
 
159
    //! Returns the path to user's style. Added in QGIS 1.4
 
160
    static const QString userStyleV2Path();
 
161
 
 
162
    //! Returns the path to default style (works as a starting point). Added in QGIS 1.4
 
163
    static const QString defaultStyleV2Path();
 
164
 
 
165
    //! Returns the path to the application prefix directory.
 
166
    static const QString prefixPath();
 
167
 
 
168
    //! Returns the path to the application plugin directory.
 
169
    static const QString pluginPath();
 
170
 
 
171
    //! Returns the common root path of all application data directories.
 
172
    static const QString pkgDataPath();
 
173
 
 
174
    //! Returns the path to the currently active theme directory.
 
175
    static const QString activeThemePath(); 
 
176
 
 
177
    //! Returns the path to the default theme directory.
 
178
    static const QString defaultThemePath(); 
 
179
    
 
180
    //! Alters prefix path - used by 3rd party apps
 
181
    static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);
 
182
    
 
183
    //! Alters plugin path - used by 3rd party apps
 
184
    static void setPluginPath(const QString thePluginPath);
 
185
 
 
186
    //! Alters pkg data path - used by 3rd party apps
 
187
    static void setPkgDataPath(const QString thePkgDataPath);
 
188
    
 
189
    //! loads providers
 
190
    static void initQgis();
 
191
 
 
192
    //! deletes provider registry and map layer registry
 
193
    static void exitQgis();
 
194
    
 
195
    /** constants for endian-ness */
 
196
    enum endian_t
 
197
    {
 
198
      XDR = 0,  // network, or big-endian, byte order
 
199
      NDR = 1   // little-endian byte order
 
200
    };
 
201
    
 
202
    //! Returns whether this machine uses big or little endian
 
203
    static endian_t endian();
 
204
 
 
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.
 
212
     */
 
213
    static QString reportStyleSheet();
 
214
 
 
215
    /** Convenience function to get a summary of the paths used in this 
 
216
     * application instance useful for debugging mainly.*/
 
217
    static QString showSettings();
 
218
 
 
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 
 
223
     * times.
 
224
     */
 
225
    static void registerOgrDrivers();
 
226
 
 
227
};
 
228