~ubuntu-branches/ubuntu/maverick/qgis/maverick

« back to all changes in this revision

Viewing changes to src/app/qgisapp.h

  • 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
                          qgisapp.h  -  description
 
3
                             -------------------
 
4
    begin                : Sat Jun 22 2002
 
5
    copyright            : (C) 2002 by Gary E.Sherman
 
6
    email                : sherman at mrcc.com
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
/*  $Id$ */
 
18
 
 
19
#ifndef QGISAPP_H
 
20
#define QGISAPP_H
 
21
 
 
22
class QActionGroup;
 
23
class QCheckBox;
 
24
class QCursor;
 
25
class QFileInfo;
 
26
class QKeyEvent;
 
27
class QLabel;
 
28
class QLineEdit;
 
29
class QMenu;
 
30
class QPixmap;
 
31
class QProgressBar;
 
32
class QPushButton;
 
33
class QRect;
 
34
class QSettings;
 
35
class QSplashScreen;
 
36
class QStringList;
 
37
class QToolButton;
 
38
class QTcpSocket;
 
39
class QValidator;
 
40
 
 
41
class QgisAppInterface;
 
42
class QgsClipboard;
 
43
class QgsComposer;
 
44
class QgsComposerView;
 
45
class QgsGeometry;
 
46
class QgsHelpViewer;
 
47
class QgsFeature;
 
48
 
 
49
class QgsLegend;
 
50
class QgsMapCanvas;
 
51
class QgsMapLayer;
 
52
class QgsMapTip;
 
53
class QgsMapTool;
 
54
class QgsPoint;
 
55
class QgsProviderRegistry;
 
56
class QgsPythonDialog;
 
57
class QgsPythonUtils;
 
58
class QgsRasterLayer;
 
59
class QgsRectangle;
 
60
class QgsUndoWidget;
 
61
class QgsVectorLayer;
 
62
 
 
63
class QDomDocument;
 
64
 
 
65
#include <QMainWindow>
 
66
#include <QToolBar>
 
67
#include <QAbstractSocket>
 
68
#include <QPointer>
 
69
 
 
70
#include "qgsconfig.h"
 
71
#include "qgsfeature.h"
 
72
#include "qgspoint.h"
 
73
 
 
74
/*! \class QgisApp
 
75
 * \brief Main window for the Qgis application
 
76
 */
 
77
class QgisApp : public QMainWindow
 
78
{
 
79
    Q_OBJECT
 
80
  public:
 
81
    //! Constructor
 
82
    QgisApp( QSplashScreen *splash, QWidget * parent = 0, Qt::WFlags fl = Qt::Window );
 
83
    //! Destructor
 
84
    ~QgisApp();
 
85
    /**
 
86
     * Add a vector layer to the canvas, returns pointer to it
 
87
     */
 
88
    QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey );
 
89
 
 
90
    /** \brief overloaded vesion of the privat addLayer method that takes a list of
 
91
     * file names instead of prompting user with a dialog.
 
92
     @param enc encoding type for the layer
 
93
    @param dataSourceType type of ogr datasource
 
94
     @returns true if successfully added layer
 
95
     */
 
96
    bool addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType );
 
97
 
 
98
    /** overloaded vesion of the private addRasterLayer()
 
99
      Method that takes a list of file names instead of prompting
 
100
      user with a dialog.
 
101
      @returns true if successfully added layer(s)
 
102
      */
 
103
    bool addRasterLayers( QStringList const & theLayerQStringList, bool guiWarning = true );
 
104
 
 
105
    /** Open a raster layer using the Raster Data Provider.
 
106
     *  Note this is included to support WMS layers only at this stage,
 
107
     *  GDAL layer support via a Provider is not yet implemented.
 
108
     */
 
109
    QgsRasterLayer* addRasterLayer( QString const & rasterLayerPath,
 
110
                                    QString const & baseName,
 
111
                                    QString const & providerKey,
 
112
                                    QStringList const & layers,
 
113
                                    QStringList const & styles,
 
114
                                    QString const & format,
 
115
                                    QString const & crs );
 
116
 
 
117
    /** open a raster layer for the given file
 
118
      @returns false if unable to open a raster layer for rasterFile
 
119
      @note
 
120
      This is essentially a simplified version of the above
 
121
      */
 
122
    QgsRasterLayer* addRasterLayer( QString const & rasterFile, QString const & baseName, bool guiWarning = true );
 
123
 
 
124
    /** Add a 'pre-made' map layer to the project */
 
125
    void addMapLayer( QgsMapLayer *theMapLayer );
 
126
 
 
127
    /** Set the extents of the map canvas */
 
128
    void setExtent( QgsRectangle theRect );
 
129
    //! Remove all layers from the map and legend - reimplements same method from qgisappbase
 
130
    void removeAllLayers();
 
131
    /** Open a raster or vector file; ignore other files.
 
132
      Used to process a commandline argument or OpenDocument AppleEvent.
 
133
      @returns true if the file is successfully opened
 
134
      */
 
135
    bool openLayer( const QString & fileName );
 
136
    /** Open the specified project file; prompt to save previous project if necessary.
 
137
      Used to process a commandline argument or OpenDocument AppleEvent.
 
138
      */
 
139
    void openProject( const QString & fileName );
 
140
    /** opens a qgis project file
 
141
      @returns false if unable to open the project
 
142
      */
 
143
    bool addProject( QString projectFile );
 
144
    //!Overloaded version of the private function with same name that takes the imagename as a parameter
 
145
    void saveMapAsImage( QString, QPixmap * );
 
146
    /** Get the mapcanvas object from the app */
 
147
    QgsMapCanvas * mapCanvas() { return mMapCanvas; };
 
148
 
 
149
    //! Set theme (icons)
 
150
    void setTheme( QString themeName = "default" );
 
151
    //! Setup the toolbar popup menus for a given theme
 
152
    void setupToolbarPopups( QString themeName );
 
153
    //! Returns a pointer to the internal clipboard
 
154
    QgsClipboard * clipboard();
 
155
 
 
156
    /** Setup the proxy settings from the QSettings environment.
 
157
      * This is not called by default in the constructor. Rather,
 
158
      * the application must explicitly call setupProx(). If
 
159
      * you write your own application and wish to explicitly
 
160
      * set up your own proxy rather, you should e.g.
 
161
      *  QNetworkProxy proxy;
 
162
      *  proxy.setType(QNetworkProxy::Socks5Proxy);
 
163
      *  proxy.setHostName("proxy.example.com");
 
164
      *  proxy.setPort(1080);
 
165
      *  proxy.setUser("username");
 
166
      *  proxy.setPassword("password");
 
167
      *  QNetworkProxy::setApplicationProxy(proxy);
 
168
      *
 
169
      *  (as documented in Qt documentation.
 
170
    */
 
171
    void setupProxy();
 
172
 
 
173
    static QgisApp *instance() { return smInstance; }
 
174
 
 
175
    //! Helper to get a theme icon. It will fall back to the
 
176
    //default theme if the active theme does not have the required
 
177
    //icon.
 
178
    static QIcon getThemeIcon( const QString theName );
 
179
    //! Helper to get a theme icon as a pixmap. It will fall back to the
 
180
    //default theme if the active theme does not have the required
 
181
    //icon.
 
182
    static QPixmap getThemePixmap( const QString theName );
 
183
 
 
184
    /** Add a dock widget to the main window. Overloaded from QMainWindow.
 
185
     * After adding the dock widget to the ui (by delegating to the QMainWindow
 
186
     * parent class, it will also add it to the View menu list of docks.*/
 
187
    void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget );
 
188
    /** Add a toolbar to the main window. Overloaded from QMainWindow.
 
189
     * After adding the toolbar to the ui (by delegating to the QMainWindow
 
190
     * parent class, it will also add it to the View menu list of toolbars.*/
 
191
    QToolBar *addToolBar( QString name );
 
192
 
 
193
    /** Add window to Window menu. The action title is the window title
 
194
     * and the action should raise, unminimize and activate the window. */
 
195
    void addWindow( QAction *action );
 
196
    /** Remove window from Window menu. Calling this is necessary only for
 
197
     * windows which are hidden rather than deleted when closed. */
 
198
    void removeWindow( QAction *action );
 
199
 
 
200
    /**Returns the print composers*/
 
201
    QSet<QgsComposer*> printComposers() const {return mPrintComposers;}
 
202
    /**Creates a new composer and returns a pointer to it*/
 
203
    QgsComposer* createNewComposer();
 
204
    /**Deletes a composer and removes entry from Set*/
 
205
    void deleteComposer( QgsComposer* c );
 
206
 
 
207
 
 
208
    //! Actions to be inserted in menus and toolbars
 
209
    QAction *actionNewProject() { return mActionNewProject; }
 
210
    QAction *actionOpenProject() { return mActionOpenProject; }
 
211
    QAction *actionFileSeparator1() { return mActionFileSeparator1; }
 
212
    QAction *actionSaveProject() { return mActionSaveProject; }
 
213
    QAction *actionSaveProjectAs() { return mActionSaveProjectAs; }
 
214
    QAction *actionSaveMapAsImage() { return mActionSaveMapAsImage; }
 
215
    QAction *actionFileSeparator2() { return mActionFileSeparator2; }
 
216
    QAction *actionProjectProperties() { return mActionProjectProperties; }
 
217
    QAction *actionFileSeparator3() { return mActionFileSeparator3; }
 
218
    QAction *actionNewPrintComposer() { return mActionNewPrintComposer; }
 
219
    QAction *actionFileSeparator4() { return mActionFileSeparator4; }
 
220
    QAction *actionExit() { return mActionExit; }
 
221
 
 
222
    QAction *actionCutFeatures() { return mActionCutFeatures; }
 
223
    QAction *actionCopyFeatures() { return mActionCopyFeatures; }
 
224
    QAction *actionPasteFeatures() { return mActionPasteFeatures; }
 
225
    QAction *actionEditSeparator1() { return mActionEditSeparator1; }
 
226
    QAction *actionCapturePoint() { return mActionCapturePoint; }
 
227
    QAction *actionCaptureLine() { return mActionCaptureLine; }
 
228
    QAction *actionCapturePolygon() { return mActionCapturePolygon; }
 
229
    QAction *actionDeleteSelected() { return mActionDeleteSelected; }
 
230
    QAction *actionMoveFeature() { return mActionMoveFeature; }
 
231
    QAction *actionSplitFeatures() { return mActionSplitFeatures; }
 
232
    //These three tools are deprecated - use node tool rather...
 
233
    //QAction *actionAddVertex() { return mActionAddVertex; }
 
234
    //QAction *actionDeleteVertex() { return mActionDeleteVertex; }
 
235
    //QAction *actionMoveVertex() { return mActionMoveVertex; }
 
236
    QAction *actionAddRing() { return mActionAddRing; }
 
237
    QAction *actionAddIsland() { return mActionAddIsland; }
 
238
    QAction *actionSimplifyFeature() { return mActionSimplifyFeature; }
 
239
    QAction *actionDeleteRing() { return mActionDeleteRing; }
 
240
    QAction *actionDeletePart() { return mActionDeletePart; }
 
241
    QAction *actionNodeTool() { return mActionNodeTool; }
 
242
    QAction *actionEditSeparator2() { return mActionEditSeparator2; }
 
243
 
 
244
    QAction *actionPan() { return mActionPan; }
 
245
    QAction *actionZoomIn() { return mActionZoomIn; }
 
246
    QAction *actionZoomOut() { return mActionZoomOut; }
 
247
    QAction *actionSelect() { return mActionSelect; }
 
248
    QAction *actionIdentify() { return mActionIdentify; }
 
249
    QAction *actionMeasure() { return mActionMeasure; }
 
250
    QAction *actionMeasureArea() { return mActionMeasureArea; }
 
251
    QAction *actionViewSeparator1() { return mActionViewSeparator1; }
 
252
    QAction *actionZoomFullExtent() { return mActionZoomFullExtent; }
 
253
    QAction *actionZoomToLayer() { return mActionZoomToLayer; }
 
254
    QAction *actionZoomToSelected() { return mActionZoomToSelected; }
 
255
    QAction *actionZoomLast() { return mActionZoomLast; }
 
256
    QAction *actionZoomNext() { return mActionZoomNext; }
 
257
    QAction *actionZoomActualSize() { return mActionZoomActualSize; }
 
258
    QAction *actionViewSeparator2() { return mActionViewSeparator2; }
 
259
    QAction *actionMapTips() { return mActionMapTips; }
 
260
    QAction *actionNewBookmark() { return mActionNewBookmark; }
 
261
    QAction *actionShowBookmarks() { return mActionShowBookmarks; }
 
262
    QAction *actionDraw() { return mActionDraw; }
 
263
    QAction *actionViewSeparator3() { return mActionViewSeparator3; }
 
264
 
 
265
    QAction *actionNewVectorLayer() { return mActionNewVectorLayer; }
 
266
    QAction *actionAddOgrLayer() { return mActionAddOgrLayer; }
 
267
    QAction *actionAddRasterLayer() { return mActionAddRasterLayer; }
 
268
    QAction *actionAddPgLayer() { return mActionAddPgLayer; }
 
269
    QAction *actionAddSpatiaLiteLayer() { return mActionAddSpatiaLiteLayer; };
 
270
    QAction *actionAddWmsLayer() { return mActionAddWmsLayer; }
 
271
    QAction *actionLayerSeparator1() { return mActionLayerSeparator1; }
 
272
    QAction *actionOpenTable() { return mActionOpenTable; }
 
273
    QAction *actionToggleEditing() { return mActionToggleEditing; }
 
274
    QAction *actionLayerSaveAs() { return mActionLayerSaveAs; }
 
275
    QAction *actionLayerSelectionSaveAs() { return mActionLayerSelectionSaveAs; }
 
276
    QAction *actionRemoveLayer() { return mActionRemoveLayer; }
 
277
    QAction *actionLayerProperties() { return mActionLayerProperties; }
 
278
    QAction *actionLayerSeparator2() { return mActionLayerSeparator2; }
 
279
    QAction *actionAddToOverview() { return mActionAddToOverview; }
 
280
    QAction *actionAddAllToOverview() { return mActionAddAllToOverview; }
 
281
    QAction *actionRemoveAllFromOverview() { return mActionRemoveAllFromOverview; }
 
282
    QAction *actionLayerSeparator3() { return mActionLayerSeparator3; }
 
283
    QAction *actionHideAllLayers() { return mActionHideAllLayers; }
 
284
    QAction *actionShowAllLayers() { return mActionShowAllLayers; }
 
285
 
 
286
    QAction *actionManagePlugins() { return mActionManagePlugins; }
 
287
    QAction *actionPluginSeparator1() { return mActionPluginSeparator1; }
 
288
    QAction *actionPluginListSeparator() { return mActionPluginSeparator1; }
 
289
    QAction *actionPluginSeparator2() { return mActionPluginSeparator2; }
 
290
    QAction *actionPluginPythonSeparator() { return mActionPluginSeparator2; }
 
291
    QAction *actionShowPythonDialog() { return mActionShowPythonDialog; }
 
292
 
 
293
    QAction *actionToggleFullScreen() { return mActionToggleFullScreen; }
 
294
    QAction *actionSettingsSeparator1() { return mActionSettingsSeparator1; }
 
295
    QAction *actionOptions() { return mActionOptions; }
 
296
    QAction *actionCustomProjection() { return mActionCustomProjection; }
 
297
    QAction *actionConfigureShortcuts() { return mActionConfigureShortcuts; }
 
298
 
 
299
#ifdef Q_WS_MAC
 
300
    QAction *actionWindowMinimize() { return mActionWindowMinimize; }
 
301
    QAction *actionWindowZoom() { return mActionWindowZoom; }
 
302
    QAction *actionWindowSeparator1() { return mActionWindowSeparator1; }
 
303
    QAction *actionWindowAllToFront() { return mActionWindowAllToFront; }
 
304
    QAction *actionWindowSeparator2() { return mActionWindowSeparator2; }
 
305
#endif
 
306
 
 
307
    QAction *actionHelpContents() { return mActionHelpContents; }
 
308
    QAction *actionHelpSeparator1() { return mActionHelpSeparator1; }
 
309
    QAction *actionQgisHomePage() { return mActionQgisHomePage; }
 
310
    QAction *actionCheckQgisVersion() { return mActionCheckQgisVersion; }
 
311
    QAction *actionHelpSeparator2() { return mActionHelpSeparator2; }
 
312
    QAction *actionAbout() { return mActionAbout; }
 
313
 
 
314
    //! Menus
 
315
    QMenu *fileMenu() { return mFileMenu; }
 
316
    QMenu *editMenu() { return mEditMenu; }
 
317
    QMenu *viewMenu() { return mViewMenu; }
 
318
    QMenu *layerMenu() { return mLayerMenu; }
 
319
    QMenu *settingsMenu() { return mSettingsMenu; }
 
320
    QMenu *pluginMenu() { return mPluginMenu; }
 
321
#ifdef Q_WS_MAC
 
322
    QMenu *firstRightStandardMenu() { return mWindowMenu; }
 
323
    QMenu *windowMenu() { return mWindowMenu; }
 
324
#else
 
325
    QMenu *firstRightStandardMenu() { return mHelpMenu; }
 
326
    QMenu *windowMenu() { return NULL; }
 
327
#endif
 
328
    QMenu *printComposersMenu() {return mPrintComposersMenu;}
 
329
    QMenu *helpMenu() { return mHelpMenu; }
 
330
 
 
331
    //! Toolbars
 
332
    /** Get a reference to a toolbar. Mainly intended
 
333
    *   to be used by plugins that want to specifically add
 
334
    *   an icon into the file toolbar for consistency e.g.
 
335
    *   addWFS and GPS plugins.
 
336
    */
 
337
    QToolBar *fileToolBar() { return mFileToolBar; }
 
338
    QToolBar *layerToolBar() { return mLayerToolBar; }
 
339
    QToolBar *mapNavToolToolBar() { return mMapNavToolBar; }
 
340
    QToolBar *digitizeToolBar() { return mDigitizeToolBar; }
 
341
    QToolBar *advancedDigitizeToolBar() { return mAdvancedDigitizeToolBar; }
 
342
    QToolBar *attributesToolBar() { return mAttributesToolBar; }
 
343
    QToolBar *pluginToolBar() { return mPluginToolBar; }
 
344
    QToolBar *helpToolBar() { return mHelpToolBar; }
 
345
 
 
346
    //! run python
 
347
    void runPythonString( const QString &expr );
 
348
 
 
349
  public slots:
 
350
    //! Zoom to full extent
 
351
    void zoomFull();
 
352
    //! Zoom to the previous extent
 
353
    void zoomToPrevious();
 
354
    //! Zoom to the forward extent
 
355
    void zoomToNext();
 
356
    //! Zoom to selected features
 
357
    void zoomToSelected();
 
358
 
 
359
    void updateUndoActions();
 
360
 
 
361
    //! cuts selected features on the active layer to the clipboard
 
362
    /**
 
363
       \param layerContainingSelection  The layer that the selection will be taken from
 
364
                                        (defaults to the active layer on the legend)
 
365
     */
 
366
    void editCut( QgsMapLayer * layerContainingSelection = 0 );
 
367
    //! copies selected features on the active layer to the clipboard
 
368
    /**
 
369
       \param layerContainingSelection  The layer that the selection will be taken from
 
370
                                        (defaults to the active layer on the legend)
 
371
     */
 
372
    void editCopy( QgsMapLayer * layerContainingSelection = 0 );
 
373
    //! copies features on the clipboard to the active layer
 
374
    /**
 
375
       \param destinationLayer  The layer that the clipboard will be pasted to
 
376
                                (defaults to the active layer on the legend)
 
377
     */
 
378
    void editPaste( QgsMapLayer * destinationLayer = 0 );
 
379
 
 
380
    void loadOGRSublayers( QString layertype, QString uri, QStringList list );
 
381
 
 
382
    /**Deletes the selected attributes for the currently selected vector layer*/
 
383
    void deleteSelected( QgsMapLayer *layer = 0 );
 
384
 
 
385
  protected:
 
386
 
 
387
    //! Handle state changes (WindowTitleChange)
 
388
    virtual void changeEvent( QEvent * event );
 
389
    //! Have some control over closing of the application
 
390
    virtual void closeEvent( QCloseEvent * event );
 
391
 
 
392
    virtual void dragEnterEvent( QDragEnterEvent * event );
 
393
    virtual void dropEvent( QDropEvent * event );
 
394
 
 
395
    //! reimplements widget keyPress event so we can check if cancel was pressed
 
396
    virtual void keyPressEvent( QKeyEvent * event );
 
397
 
 
398
  private slots:
 
399
    //! About QGis
 
400
    void about();
 
401
    //! Add a raster layer to the map (will prompt user for file name using dlg )
 
402
    void addRasterLayer();
 
403
    //#ifdef HAVE_POSTGRESQL
 
404
    //! Add a databaselayer to the map
 
405
    void addDatabaseLayer();
 
406
    //#endif
 
407
    //#ifdef HAVE_SPATIALITE
 
408
    //! Add a SpatiaLite layer to the map
 
409
    void addSpatiaLiteLayer();
 
410
    //#endif
 
411
    /** toggles whether the current selected layer is in overview or not */
 
412
    void isInOverview();
 
413
    //! Slot to show the map coordinate position of the mouse cursor
 
414
    void showMouseCoordinate( const QgsPoint & );
 
415
    //! Slot to show current map scale;
 
416
    void showScale( double theScale );
 
417
    //! Slot to handle user scale input;
 
418
    void userScale();
 
419
    //! Slot to handle user center input;
 
420
    void userCenter();
 
421
    //! Remove a layer from the map and legend
 
422
    void removeLayer();
 
423
    //! zoom to extent of layer
 
424
    void zoomToLayerExtent();
 
425
    //! zoom to actual size of raster layer
 
426
    void zoomActualSize();
 
427
    //! plugin manager
 
428
    void showPluginManager();
 
429
    //! load python support if possible
 
430
    void loadPythonSupport();
 
431
    //! Find the QMenu with the given name (ie the user visible text on the menu item)
 
432
    QMenu* getPluginMenu( QString menuName );
 
433
    //! Add the action to the submenu with the given name under the plugin menu
 
434
    void addPluginToMenu( QString name, QAction* action );
 
435
    //! Remove the action to the submenu with the given name under the plugin menu
 
436
    void removePluginMenu( QString name, QAction* action );
 
437
    //! Add an icon to the plugin toolbar
 
438
    int addPluginToolBarIcon( QAction * qAction );
 
439
    //! Remove an icon from the plugin toolbar
 
440
    void removePluginToolBarIcon( QAction *qAction );
 
441
    //! Save window state
 
442
    void saveWindowState();
 
443
    //! Restore the window and toolbar state
 
444
    void restoreWindowState();
 
445
    //! Save project. Returns true if the user selected a file to save to, false if not.
 
446
    bool fileSave();
 
447
    //! Save project as
 
448
    void fileSaveAs();
 
449
    //! Open the project file corresponding to the
 
450
    //! text)= of the given action.
 
451
    void openProject( QAction *action );
 
452
    //! Save the map view as an image - user is prompted for image name using a dialog
 
453
    void saveMapAsImage();
 
454
    //! Open a project
 
455
    void fileOpen();
 
456
    //! Create a new project
 
457
    void fileNew();
 
458
    //! As above but allows forcing without prompt
 
459
    void fileNew( bool thePromptToSaveFlag );
 
460
    //! Create a new empty vector layer
 
461
    void newVectorLayer();
 
462
    //! Print the current map view frame
 
463
    void newPrintComposer();
 
464
    void showComposerManager();
 
465
    //! Add all loaded layers into the overview - overides qgisappbase method
 
466
    void addAllToOverview();
 
467
    //! Remove all loaded layers from the overview - overides qgisappbase method
 
468
    void removeAllFromOverview();
 
469
    //reimplements method from base (gui) class
 
470
    void hideAllLayers();
 
471
    //reimplements method from base (gui) class
 
472
    void showAllLayers();
 
473
    // TODO: remove exportMapServer declaration once the mapserver export plugin is complete
 
474
    // and tested
 
475
    /*
 
476
    //! Export current view as a mapserver map file
 
477
    void exportMapServer();
 
478
    */
 
479
    //! Return pointer to the active layer
 
480
    QgsMapLayer *activeLayer();
 
481
    //! set the active layer
 
482
    bool setActiveLayer( QgsMapLayer * );
 
483
    //! Open the help contents in a browser
 
484
    void helpContents();
 
485
    //! Open the QGIS homepage in users browser
 
486
    void helpQgisHomePage();
 
487
    //! Open a url in the users configured browser
 
488
    void openURL( QString url, bool useQgisDocDirectory = true );
 
489
    //! Check qgis version against the qgis version server
 
490
    void checkQgisVersion();
 
491
    //!Invoke the custom projection dialog
 
492
    void customProjection();
 
493
    //! configure shortcuts
 
494
    void configureShortcuts();
 
495
    //! options dialog slot
 
496
    void options();
 
497
    //! Whats-this help slot
 
498
    void whatsThis();
 
499
    void socketConnected();
 
500
    void socketConnectionClosed();
 
501
    void socketReadyRead();
 
502
    void socketError( QAbstractSocket::SocketError e );
 
503
    //! Set project properties, including map untis
 
504
    void projectProperties();
 
505
    //! Open project properties dialog and show the projections tab
 
506
    void projectPropertiesProjections();
 
507
    /*  void urlData(); */
 
508
    //! Show the spatial bookmarks dialog
 
509
    void showBookmarks();
 
510
    //! Create a new spatial bookmark
 
511
    void newBookmark();
 
512
    //! activates the capture point tool
 
513
    void capturePoint();
 
514
    //! activates the capture line tool
 
515
    void captureLine();
 
516
    //! activates the capture polygon tool
 
517
    void capturePolygon();
 
518
    //! activates the move feature tool
 
519
    void moveFeature();
 
520
    //! activates the reshape features tool
 
521
    void reshapeFeatures();
 
522
    //! activates the split features tool
 
523
    void splitFeatures();
 
524
    //! activates the add vertex tool
 
525
    void addVertex();
 
526
    //! activates the move vertex tool
 
527
    void moveVertex();
 
528
    //! activates the delete vertex tool
 
529
    void deleteVertex();
 
530
    //! activates the add ring tool
 
531
    void addRing();
 
532
    //! activates the add island tool
 
533
    void addIsland();
 
534
    //! simplifies feature
 
535
    void simplifyFeature();
 
536
    //! deletes ring in polygon
 
537
    void deleteRing();
 
538
    //! deletes part of polygon
 
539
    void deletePart();
 
540
    //! merges the selected features together
 
541
    void mergeSelectedFeatures();
 
542
    //! provides operations with nodes
 
543
    void nodeTool();
 
544
    //! activates the rotate points tool
 
545
    void rotatePointSymbols();
 
546
 
 
547
    //! activates the selection tool
 
548
    void select();
 
549
 
 
550
    //! deselect features from all layers
 
551
    void deselectAll();
 
552
 
 
553
    //! refresh map canvas
 
554
    void refreshMapCanvas();
 
555
    //! returns pointer to map legend
 
556
    QgsLegend *legend() { return mMapLegend; }
 
557
 
 
558
    //! starts/stops editing mode of the current layer
 
559
    void toggleEditing();
 
560
 
 
561
    //! map tool changed
 
562
    void mapToolChanged( QgsMapTool *tool );
 
563
 
 
564
    /** Activates or deactivates actions depending on the current maplayer type.
 
565
    Is called from the legend when the current legend item has changed*/
 
566
    void activateDeactivateLayerRelatedActions( QgsMapLayer* layer );
 
567
 
 
568
    void showProgress( int theProgress, int theTotalSteps );
 
569
    void extentsViewToggled( bool theFlag );
 
570
    void showExtents();
 
571
    void showStatusMessage( QString theMessage );
 
572
    void updateMouseCoordinatePrecision();
 
573
    void hasCrsTransformEnabled( bool theFlag );
 
574
    void destinationSrsChanged();
 
575
    //    void debugHook();
 
576
    //! Add a vector layer to the map
 
577
    void addVectorLayer();
 
578
    //! Exit Qgis
 
579
    void fileExit();
 
580
    //! Add a WMS layer to the map
 
581
    void addWmsLayer();
 
582
    //! Set map tool to Zoom out
 
583
    void zoomOut();
 
584
    //! Set map tool to Zoom in
 
585
    void zoomIn();
 
586
    //! Set map tool to pan
 
587
    void pan();
 
588
    //! Identify feature(s) on the currently selected layer
 
589
    void identify();
 
590
    //! Measure distance
 
591
    void measure();
 
592
    //! Measure area
 
593
    void measureArea();
 
594
 
 
595
    //! show the attribute table for the currently selected layer
 
596
    void attributeTable();
 
597
 
 
598
    //! starts/stops editing mode of a layer
 
599
    void toggleEditing( QgsMapLayer *layer );
 
600
 
 
601
    //! save current vector layer
 
602
    void saveAsShapefile();
 
603
    void saveSelectionAsShapefile();
 
604
 
 
605
    //! open the properties dialog for the currently selected layer
 
606
    void layerProperties();
 
607
 
 
608
    //! show python console
 
609
    void showPythonDialog();
 
610
 
 
611
    //! Shows a warning when an old project file is read.
 
612
    void oldProjectVersionWarning( QString );
 
613
 
 
614
    //! Toggle map tips on/off
 
615
    void toggleMapTips();
 
616
 
 
617
    //! Show the map tip
 
618
    void showMapTip();
 
619
 
 
620
    //! Toggle full screen mode
 
621
    void toggleFullScreen();
 
622
 
 
623
    //! Set minimized mode of active window
 
624
    void showActiveWindowMinimized();
 
625
 
 
626
    //! Toggle maximized mode of active window
 
627
    void toggleActiveWindowMaximized();
 
628
 
 
629
    //! Raise, unminimize and activate this window
 
630
    void activate();
 
631
 
 
632
    //! Bring forward all open windows
 
633
    void bringAllToFront();
 
634
 
 
635
    //! Stops rendering of the main map
 
636
    void stopRendering();
 
637
 
 
638
    void showStyleManagerV2();
 
639
 
 
640
    //! project changed
 
641
    void projectChanged( const QDomDocument & );
 
642
 
 
643
  signals:
 
644
    /** emitted when a key is pressed and we want non widget sublasses to be able
 
645
      to pick up on this (e.g. maplayer) */
 
646
    void keyPressed( QKeyEvent *e );
 
647
 
 
648
    /** emitted when a project file is successfully read
 
649
      @note
 
650
      This is useful for plug-ins that store properties with project files.  A
 
651
      plug-in can connect to this signal.  When it is emitted, the plug-in
 
652
      knows to then check the project properties for any relevant state.
 
653
      */
 
654
    void projectRead();
 
655
    /** emitted when starting an entirely new project
 
656
      @note
 
657
      This is similar to projectRead(); plug-ins might want to be notified
 
658
      that they're in a new project.  Yes, projectRead() could have been
 
659
      overloaded to be used in the case of new projects instead.  However,
 
660
      it's probably more semantically correct to have an entirely separate
 
661
      signal for when this happens.
 
662
      */
 
663
    void newProject();
 
664
 
 
665
    //! emitted when a new bookmark is added
 
666
    void bookmarkAdded();
 
667
 
 
668
    /** Signal emitted when the current theme is changed so plugins
 
669
     * can change there tool button icons.
 
670
     * @note This was added in QGIS 1.1
 
671
     */
 
672
    void currentThemeChanged( QString );
 
673
 
 
674
    /**This signal is emitted when a new composer instance has been created
 
675
       @note added in version 1.4*/
 
676
    void composerAdded( QgsComposerView* v );
 
677
 
 
678
    /**This signal is emitted before a new composer instance is going to be removed
 
679
      @note added in version 1.4*/
 
680
    void composerWillBeRemoved( QgsComposerView* v );
 
681
 
 
682
 
 
683
  private:
 
684
    /** This method will open a dialog so the user can select the sublayers
 
685
    * to load
 
686
    */
 
687
    void askUserForSublayers( QgsVectorLayer *layer );
 
688
    /** Add a raster layer to the map (passed in as a ptr).
 
689
     * It won't force a refresh.
 
690
     */
 
691
    bool addRasterLayer( QgsRasterLayer * theRasterLayer );
 
692
    //@todo We should move these next two into vector layer class
 
693
    /** This helper checks to see whether the file name appears to be a valid shape file name */
 
694
    bool isValidShapeFileName( QString theFileNameQString );
 
695
    /** Overloaded version of the above function provided for convenience that takes a qstring pointer */
 
696
    bool isValidShapeFileName( QString * theFileNameQString );
 
697
    /** add this file to the recently opened/saved projects list
 
698
     *  pass settings by reference since creating more than one
 
699
     * instance simultaneously results in data loss.
 
700
     */
 
701
    void saveRecentProjectPath( QString projectPath, QSettings & settings );
 
702
    //! Update file menu with the current list of recently accessed projects
 
703
    void updateRecentProjectPaths();
 
704
    //! Read Well Known Binary stream from PostGIS
 
705
    //void readWKB(const char *, QStringList tables);
 
706
    //! shows the paste-transformations dialog
 
707
    void pasteTransformations();
 
708
    //! check to see if file is dirty and if so, prompt the user th save it
 
709
    bool saveDirty();
 
710
    /** Helper function to union several geometries together (used in function mergeSelectedFeatures)
 
711
      @return 0 in case of error*/
 
712
    QgsGeometry* unionGeometries( const QgsVectorLayer* vl, QgsFeatureList& featureList );
 
713
 
 
714
    /**Deletes all the composer objects and clears mPrintComposers*/
 
715
    void deletePrintComposers();
 
716
    /**Creates the composer instances in a project file and adds them to the menu*/
 
717
    bool loadComposersFromProject( const QString& projectFilePath );
 
718
 
 
719
    /// QgisApp aren't copyable
 
720
    QgisApp( QgisApp const & );
 
721
    /// QgisApp aren't copyable
 
722
    QgisApp & operator=( QgisApp const & );
 
723
 
 
724
    void readSettings();
 
725
    void writeSettings();
 
726
    void createActions();
 
727
    void createActionGroups();
 
728
    void createMenus();
 
729
    void createToolBars();
 
730
    void createStatusBar();
 
731
    void setupConnections();
 
732
    void createLegend();
 
733
    void createOverview();
 
734
    void createCanvas();
 
735
    bool createDB();
 
736
    void createMapTips();
 
737
 
 
738
    // toolbars ---------------------------------------
 
739
    QToolBar *mFileToolBar;
 
740
    QToolBar *mLayerToolBar;
 
741
    QToolBar *mMapNavToolBar;
 
742
    QToolBar *mDigitizeToolBar;
 
743
    QToolBar *mAdvancedDigitizeToolBar;
 
744
    QToolBar *mAttributesToolBar;
 
745
    QToolBar *mPluginToolBar;
 
746
    QToolBar *mHelpToolBar;
 
747
 
 
748
    // actions for menus and toolbars -----------------
 
749
 
 
750
    QAction *mActionNewProject;
 
751
    QAction *mActionOpenProject;
 
752
    QAction *mActionFileSeparator1;
 
753
    QAction *mActionSaveProject;
 
754
    QAction *mActionSaveProjectAs;
 
755
    QAction *mActionSaveMapAsImage;
 
756
    QAction *mActionFileSeparator2;
 
757
    QAction *mActionProjectProperties;
 
758
    QAction *mActionFileSeparator3;
 
759
    QAction *mActionNewPrintComposer;
 
760
    QAction *mActionShowComposerManager;
 
761
    QAction *mActionFileSeparator4;
 
762
    QAction *mActionExit;
 
763
 
 
764
    QAction *mActionUndo;
 
765
    QAction *mActionRedo;
 
766
    QAction *mActionEditSeparator0;
 
767
    QAction *mActionCutFeatures;
 
768
    QAction *mActionCopyFeatures;
 
769
    QAction *mActionPasteFeatures;
 
770
    QAction *mActionEditSeparator1;
 
771
    QAction *mActionCapturePoint;
 
772
    QAction *mActionCaptureLine;
 
773
    QAction *mActionCapturePolygon;
 
774
    QAction *mActionDeleteSelected;
 
775
    QAction *mActionMoveFeature;
 
776
    QAction *mActionReshapeFeatures;
 
777
    QAction *mActionSplitFeatures;
 
778
#if 0 // deprecated
 
779
    QAction *mActionAddVertex;
 
780
    QAction *mActionDeleteVertex;
 
781
    QAction *mActionMoveVertex;
 
782
#endif
 
783
    QAction *mActionAddRing;
 
784
    QAction *mActionAddIsland;
 
785
    QAction *mActionEditSeparator2;
 
786
    QAction *mActionSimplifyFeature;
 
787
    QAction *mActionDeleteRing;
 
788
    QAction *mActionDeletePart;
 
789
    QAction *mActionMergeFeatures;
 
790
    QAction *mActionNodeTool;
 
791
    QAction *mActionRotatePointSymbols;
 
792
    QAction *mActionEditSeparator3;
 
793
 
 
794
    QAction *mActionPan;
 
795
    QAction *mActionZoomIn;
 
796
    QAction *mActionZoomOut;
 
797
    QAction *mActionSelect;
 
798
    QAction *mActionDeselectAll;
 
799
    QAction *mActionIdentify;
 
800
    QAction *mActionMeasure;
 
801
    QAction *mActionMeasureArea;
 
802
    QAction *mActionViewSeparator1;
 
803
    QAction *mActionZoomFullExtent;
 
804
    QAction *mActionZoomToLayer;
 
805
    QAction *mActionZoomToSelected;
 
806
    QAction *mActionZoomLast;
 
807
    QAction *mActionZoomNext;
 
808
    QAction *mActionZoomActualSize;
 
809
    QAction *mActionViewSeparator2;
 
810
    QAction *mActionMapTips;
 
811
    QAction *mActionNewBookmark;
 
812
    QAction *mActionShowBookmarks;
 
813
    QAction *mActionDraw;
 
814
    QAction *mActionViewSeparator3;
 
815
 
 
816
    QAction *mActionNewVectorLayer;
 
817
    QAction *mActionAddOgrLayer;
 
818
    QAction *mActionAddRasterLayer;
 
819
    QAction *mActionAddPgLayer;
 
820
    QAction *mActionAddSpatiaLiteLayer;
 
821
    QAction *mActionAddWmsLayer;
 
822
    QAction *mActionLayerSeparator1;
 
823
    QAction *mActionOpenTable;
 
824
    QAction *mActionToggleEditing;
 
825
    QAction *mActionLayerSaveAs;
 
826
    QAction *mActionLayerSelectionSaveAs;
 
827
    QAction *mActionRemoveLayer;
 
828
    QAction *mActionLayerProperties;
 
829
    QAction *mActionLayerSeparator2;
 
830
    QAction *mActionAddToOverview;
 
831
    QAction *mActionAddAllToOverview;
 
832
    QAction *mActionRemoveAllFromOverview;
 
833
    QAction *mActionLayerSeparator3;
 
834
    QAction *mActionHideAllLayers;
 
835
    QAction *mActionShowAllLayers;
 
836
 
 
837
    QAction *mActionManagePlugins;
 
838
    QAction *mActionPluginSeparator1;
 
839
    QAction *mActionPluginSeparator2;
 
840
    QAction *mActionShowPythonDialog;
 
841
 
 
842
    QAction *mActionToggleFullScreen;
 
843
    QAction *mActionSettingsSeparator1;
 
844
    QAction *mActionOptions;
 
845
    QAction *mActionCustomProjection;
 
846
    QAction *mActionConfigureShortcuts;
 
847
 
 
848
#ifdef Q_WS_MAC
 
849
    QAction *mActionWindowMinimize;
 
850
    QAction *mActionWindowZoom;
 
851
    QAction *mActionWindowSeparator1;
 
852
    QAction *mActionWindowAllToFront;
 
853
    QAction *mActionWindowSeparator2;
 
854
    QActionGroup *mWindowActions;
 
855
#endif
 
856
 
 
857
    QAction *mActionHelpContents;
 
858
    QAction *mActionHelpSeparator1;
 
859
    QAction *mActionQgisHomePage;
 
860
    QAction *mActionCheckQgisVersion;
 
861
    QAction *mActionHelpSeparator2;
 
862
    QAction *mActionAbout;
 
863
 
 
864
    QAction *mActionUseRendererV2;
 
865
    QAction *mActionStyleManagerV2;
 
866
 
 
867
    // action groups ----------------------------------
 
868
    QActionGroup *mMapToolGroup;
 
869
 
 
870
    // menus ------------------------------------------
 
871
    QMenu *mFileMenu;
 
872
    QMenu *mEditMenu;
 
873
    QMenu *mRecentProjectsMenu;
 
874
    QMenu *mViewMenu;
 
875
    QMenu *mPanelMenu;
 
876
    QMenu *mToolbarMenu;
 
877
    QMenu *mLayerMenu;
 
878
    QMenu *mSettingsMenu;
 
879
#ifdef Q_WS_MAC
 
880
    QMenu *mWindowMenu;
 
881
#endif
 
882
    QMenu *mPrintComposersMenu;
 
883
    QMenu *mHelpMenu;
 
884
 
 
885
    // docks ------------------------------------------
 
886
    QDockWidget *mLegendDock;
 
887
    QDockWidget *mOverviewDock;
 
888
 
 
889
#ifdef Q_WS_MAC
 
890
    //! Window menu action to select this window
 
891
    QAction *mWindowAction;
 
892
#endif
 
893
 
 
894
    class Tools
 
895
    {
 
896
      public:
 
897
        QgsMapTool* mZoomIn;
 
898
        QgsMapTool* mZoomOut;
 
899
        QgsMapTool* mPan;
 
900
        QgsMapTool* mIdentify;
 
901
        QgsMapTool* mMeasureDist;
 
902
        QgsMapTool* mMeasureArea;
 
903
        QgsMapTool* mCapturePoint;
 
904
        QgsMapTool* mCaptureLine;
 
905
        QgsMapTool* mCapturePolygon;
 
906
        QgsMapTool* mMoveFeature;
 
907
        QgsMapTool* mReshapeFeatures;
 
908
        QgsMapTool* mSplitFeatures;
 
909
        QgsMapTool* mSelect;
 
910
        QgsMapTool* mVertexAdd;
 
911
        QgsMapTool* mVertexMove;
 
912
        QgsMapTool* mVertexDelete;
 
913
        QgsMapTool* mAddRing;
 
914
        QgsMapTool* mAddIsland;
 
915
        QgsMapTool* mSimplifyFeature;
 
916
        QgsMapTool* mDeleteRing;
 
917
        QgsMapTool* mDeletePart;
 
918
        QgsMapTool* mNodeTool;
 
919
        QgsMapTool* mRotatePointSymbolsTool;
 
920
    } mMapTools;
 
921
 
 
922
    QgsMapTool *mNonEditMapTool;
 
923
 
 
924
    //! Widget that will live on the statusbar to display "scale 1:"
 
925
    QLabel * mScaleLabel;
 
926
    //! Widget that will live on the statusbar to display scale value
 
927
    QLineEdit * mScaleEdit;
 
928
    //! The validator for the mScaleEdit
 
929
    QValidator * mScaleEditValidator;
 
930
    //! Widget that will live on the statusbar to display "Coordinate / Extent"
 
931
    QLabel * mCoordsLabel;
 
932
    //! Widget that will live in the statusbar to display and edit coords
 
933
    QLineEdit * mCoordsEdit;
 
934
    //! The validator for the mCoordsEdit
 
935
    QValidator * mCoordsEditValidator;
 
936
    //! Widget that will live in the statusbar to show progress of operations
 
937
    QProgressBar * mProgressBar;
 
938
    //! Widget used to suppress rendering
 
939
    QCheckBox * mRenderSuppressionCBox;
 
940
    //! A toggle to switch between mouse coords and view extents display
 
941
    QToolButton * mToggleExtentsViewButton;
 
942
    //! Button used to stop rendering
 
943
    QToolButton* mStopRenderButton;
 
944
    //! Widget in status bar used to show status of on the fly projection
 
945
    QToolButton * mOnTheFlyProjectionStatusButton;
 
946
    //! Popup menu
 
947
    QMenu * mPopupMenu;
 
948
    //! Top level plugin menu
 
949
    QMenu *mPluginMenu;
 
950
    //! Popup menu for the map overview tools
 
951
    QMenu *toolPopupOverviews;
 
952
    //! Popup menu for the display tools
 
953
    QMenu *toolPopupDisplay;
 
954
    //! Popup menu for the capture tools
 
955
    QMenu *toolPopupCapture;
 
956
    //! Map canvas
 
957
    QgsMapCanvas *mMapCanvas;
 
958
    //! Table of contents (legend) for the map
 
959
    QgsLegend *mMapLegend;
 
960
    //! Cursor for the overview map
 
961
    QCursor *mOverviewMapCursor;
 
962
    //! scale factor
 
963
    double mScaleFactor;
 
964
    //! Current map window extent in real-world coordinates
 
965
    QRect *mMapWindow;
 
966
    //! The previously selected non zoom map tool.
 
967
    int mPreviousNonZoomMapTool;
 
968
    //QCursor *mCursorZoomIn; //doesnt seem to be used anymore (TS)
 
969
    QString mStartupPath;
 
970
    //! full path name of the current map file (if it has been saved or loaded)
 
971
    QString mFullPathName;
 
972
 
 
973
    //! interface to QgisApp for plugins
 
974
    QgisAppInterface *mQgisInterface;
 
975
    friend class QgisAppInterface;
 
976
 
 
977
    QTcpSocket *mSocket;
 
978
    QString mVersionMessage;
 
979
    QSplashScreen *mSplash;
 
980
    //! help viewer
 
981
    QgsHelpViewer *mHelpViewer;
 
982
    //! list of recently opened/saved project files
 
983
    QStringList mRecentProjectPaths;
 
984
    //! Print composers of this project, accessible by id string
 
985
    QSet<QgsComposer*> mPrintComposers;
 
986
    //! How to determine the number of decimal places used to
 
987
    //! display the mouse position
 
988
    bool mMousePrecisionAutomatic;
 
989
    //! The number of decimal places to use if not automatic
 
990
    unsigned int mMousePrecisionDecimalPlaces;
 
991
    /** QGIS-internal vector feature clipboard */
 
992
    QgsClipboard* mInternalClipboard;
 
993
    //! Flag to indicate how the project properties dialog was summoned
 
994
    bool mShowProjectionTab;
 
995
    /** String containing supporting vector file formats
 
996
      Suitable for a QFileDialog file filter.  Build in ctor.
 
997
      */
 
998
    QString mVectorFileFilter;
 
999
    /** String containing supporting raster file formats
 
1000
      Suitable for a QFileDialog file filter.  Build in ctor.
 
1001
      */
 
1002
    QString mRasterFileFilter;
 
1003
 
 
1004
    /** Timer for map tips
 
1005
     */
 
1006
    QTimer *mpMapTipsTimer;
 
1007
 
 
1008
    /** Point of last mouse position in map coordinates (used with MapTips)
 
1009
     */
 
1010
    QgsPoint mLastMapPosition;
 
1011
 
 
1012
    /* Maptip object
 
1013
     */
 
1014
    QgsMapTip *mpMaptip;
 
1015
 
 
1016
    // Flag to indicate if maptips are on or off
 
1017
    bool mMapTipsVisible;
 
1018
 
 
1019
    //!flag to indicate whether we are in fullscreen mode or not
 
1020
    bool mFullScreenMode;
 
1021
 
 
1022
    //!flag to indicate that the previous screen mode was 'maximised'
 
1023
    bool mPrevScreenModeMaximized;
 
1024
 
 
1025
    QgsPythonDialog* mPythonConsole;
 
1026
    QgsPythonUtils* mPythonUtils;
 
1027
 
 
1028
    static QgisApp *smInstance;
 
1029
 
 
1030
    QgsUndoWidget* mUndoWidget;
 
1031
 
 
1032
    int mLastComposerId;
 
1033
};
 
1034
 
 
1035
#endif