mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
- [API] Remove recently added, and unnecessary, mMessageTimeout and setMessageTimeout() from QgisApp
383 lines
14 KiB
C++
383 lines
14 KiB
C++
/***************************************************************************
|
|
qgisappinterface.h
|
|
Interface class for exposing functions in QgisApp for use by plugins
|
|
-------------------
|
|
begin : 2004-02-11
|
|
copyright : (C) 2004 by Gary E.Sherman
|
|
email : sherman at mrcc.com
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
#ifndef QGISIFACE_H
|
|
#define QGISIFACE_H
|
|
|
|
#include "qgisinterface.h"
|
|
#include "qgsapplegendinterface.h"
|
|
|
|
class QgisApp;
|
|
|
|
#ifdef _MSC_VER
|
|
# pragma warning( push )
|
|
# pragma warning( disable: 4996 ) // declared deprecated
|
|
#endif
|
|
|
|
/** \class QgisAppInterface
|
|
* \brief Interface class to provide access to private methods in QgisApp
|
|
* for use by plugins.
|
|
*
|
|
* Only those functions "exposed" by QgisInterface can be called from within a
|
|
* plugin.
|
|
*/
|
|
class QgisAppInterface : public QgisInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
/**
|
|
* Constructor.
|
|
* @param qgis Pointer to the QgisApp object
|
|
*/
|
|
QgisAppInterface( QgisApp *qgisapp );
|
|
~QgisAppInterface();
|
|
|
|
QgsLegendInterface* legendInterface();
|
|
|
|
/* Exposed functions */
|
|
/** Set the app font size
|
|
* @param fontSize point size of font
|
|
* @note added in 2.0
|
|
*/
|
|
void setFontSize( int fontSize );
|
|
|
|
/** Set the app font family
|
|
* @param fontFamily family of font (not including any style)
|
|
* @note added in 2.0
|
|
*/
|
|
void setFontFamily( QString fontFamily );
|
|
|
|
//! Zoom map to full extent
|
|
void zoomFull();
|
|
//! Zoom map to previous extent
|
|
void zoomToPrevious();
|
|
//! Zoom map to next extent
|
|
void zoomToNext();
|
|
//! Zoom to active layer
|
|
void zoomToActiveLayer();
|
|
|
|
//! Add a vector layer
|
|
QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey );
|
|
//! Add a raster layer given its file name
|
|
QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName );
|
|
//! Add a WMS layer
|
|
QgsRasterLayer* addRasterLayer( const QString& url, const QString& baseName, const QString& providerKey );
|
|
|
|
//! Add a project
|
|
bool addProject( QString theProjectName );
|
|
//! Start a new blank project
|
|
void newProject( bool thePromptToSaveFlag = false );
|
|
|
|
//! Get pointer to the active layer (layer selected in the legend)
|
|
QgsMapLayer *activeLayer();
|
|
|
|
//! set the active layer (layer selected in the legend)
|
|
bool setActiveLayer( QgsMapLayer *layer );
|
|
|
|
//! Add an icon to the plugins toolbar
|
|
int addToolBarIcon( QAction *qAction );
|
|
//! Remove an icon (action) from the plugin toolbar
|
|
void removeToolBarIcon( QAction *qAction );
|
|
//! Add an icon to the Raster toolbar
|
|
int addRasterToolBarIcon( QAction *qAction );
|
|
//! Remove an icon (action) from the Raster toolbar
|
|
void removeRasterToolBarIcon( QAction *qAction );
|
|
//! Add an icon to the Vector toolbar
|
|
int addVectorToolBarIcon( QAction *qAction );
|
|
//! Remove an icon (action) from the Vector toolbar
|
|
void removeVectorToolBarIcon( QAction *qAction );
|
|
//! Add an icon to the Database toolbar
|
|
int addDatabaseToolBarIcon( QAction *qAction );
|
|
//! Remove an icon (action) from the Database toolbar
|
|
void removeDatabaseToolBarIcon( QAction *qAction );
|
|
//! Add an icon to the Web toolbar
|
|
int addWebToolBarIcon( QAction *qAction );
|
|
//! Remove an icon (action) from the Web toolbar
|
|
void removeWebToolBarIcon( QAction *qAction );
|
|
|
|
//! Add toolbar with specified name
|
|
QToolBar* addToolBar( QString name );
|
|
|
|
/** Open a url in the users browser. By default the QGIS doc directory is used
|
|
* as the base for the URL. To open a URL that is not relative to the installed
|
|
* QGIS documentation, set useQgisDocDirectory to false.
|
|
* @param url URL to open
|
|
* @param useQgisDocDirectory If true, the URL will be formed by concatenating
|
|
* url to the QGIS documentation directory path (<prefix>/share/doc)
|
|
*/
|
|
void openURL( QString url, bool useQgisDocDirectory = true );
|
|
|
|
/** Return a pointer to the map canvas used by qgisapp */
|
|
QgsMapCanvas * mapCanvas();
|
|
|
|
/** Gives access to main QgisApp object
|
|
|
|
Plugins don't need to know about QgisApp, as we pass it as QWidget,
|
|
it can be used for connecting slots and using as widget's parent
|
|
*/
|
|
QWidget * mainWindow();
|
|
|
|
QgsMessageBar * messageBar();
|
|
|
|
QList<QgsComposerView*> activeComposers();
|
|
|
|
/** Add action to the plugins menu */
|
|
void addPluginToMenu( QString name, QAction* action );
|
|
/** Remove action from the plugins menu */
|
|
void removePluginMenu( QString name, QAction* action );
|
|
|
|
/** Add action to the Database menu */
|
|
void addPluginToDatabaseMenu( QString name, QAction* action );
|
|
/** Remove action from the Database menu */
|
|
void removePluginDatabaseMenu( QString name, QAction* action );
|
|
|
|
/** Add action to the Raster menu */
|
|
void addPluginToRasterMenu( QString name, QAction* action );
|
|
/** Remove action from the Raster menu */
|
|
void removePluginRasterMenu( QString name, QAction* action );
|
|
|
|
/** Add action to the Vector menu */
|
|
void addPluginToVectorMenu( QString name, QAction* action );
|
|
/** Remove action from the Raster menu */
|
|
void removePluginVectorMenu( QString name, QAction* action );
|
|
|
|
/** Add action to the Web menu */
|
|
void addPluginToWebMenu( QString name, QAction* action );
|
|
/** Remove action from the Web menu */
|
|
void removePluginWebMenu( QString name, QAction* action );
|
|
|
|
/** Add "add layer" action to the layer menu */
|
|
void insertAddLayerAction( QAction *action );
|
|
/** remove "add layer" action from the layer menu */
|
|
void removeAddLayerAction( QAction *action );
|
|
|
|
/** Add a dock widget to the main window */
|
|
void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget );
|
|
|
|
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
|
|
void removeDockWidget( QDockWidget * dockwidget );
|
|
|
|
/** show layer properties dialog for layer
|
|
* @param l layer to show properties table for
|
|
* @note added in added in 1.5
|
|
*/
|
|
virtual void showLayerProperties( QgsMapLayer *l );
|
|
|
|
/** show layer attribute dialog for layer
|
|
* @param l layer to show attribute table for
|
|
* @note added in added in 1.7
|
|
*/
|
|
virtual void showAttributeTable( QgsVectorLayer *l );
|
|
|
|
/** Add window to Window menu. The action title is the window title
|
|
* and the action should raise, unminimize and activate the window. */
|
|
virtual void addWindow( QAction *action );
|
|
/** Remove window from Window menu. Calling this is necessary only for
|
|
* windows which are hidden rather than deleted when closed. */
|
|
virtual void removeWindow( QAction *action );
|
|
|
|
/** Register action to the shortcuts manager so its shortcut can be changed in GUI.
|
|
@note added in version 1.2. */
|
|
virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut );
|
|
|
|
/** Unregister a previously registered action. (e.g. when plugin is going to be unloaded.
|
|
@note added in version 1.2. */
|
|
virtual bool unregisterMainWindowAction( QAction* action );
|
|
|
|
/** Accessors for inserting items into menus and toolbars.
|
|
* An item can be inserted before any existing action.
|
|
*/
|
|
|
|
//! Menus
|
|
virtual QMenu *fileMenu();
|
|
virtual QMenu *editMenu();
|
|
virtual QMenu *viewMenu();
|
|
virtual QMenu *layerMenu();
|
|
virtual QMenu *settingsMenu();
|
|
virtual QMenu *pluginMenu();
|
|
virtual QMenu *rasterMenu();
|
|
virtual QMenu *vectorMenu();
|
|
virtual QMenu *databaseMenu();
|
|
virtual QMenu *webMenu();
|
|
virtual QMenu *firstRightStandardMenu();
|
|
virtual QMenu *windowMenu();
|
|
virtual QMenu *helpMenu();
|
|
|
|
//! ToolBars
|
|
virtual QToolBar *fileToolBar();
|
|
virtual QToolBar *layerToolBar();
|
|
virtual QToolBar *mapNavToolToolBar();
|
|
virtual QToolBar *digitizeToolBar();
|
|
virtual QToolBar *advancedDigitizeToolBar();
|
|
virtual QToolBar *attributesToolBar();
|
|
virtual QToolBar *pluginToolBar();
|
|
virtual QToolBar *helpToolBar();
|
|
virtual QToolBar *rasterToolBar();
|
|
virtual QToolBar *vectorToolBar();
|
|
virtual QToolBar *databaseToolBar();
|
|
virtual QToolBar *webToolBar();
|
|
|
|
//! File menu actions
|
|
virtual QAction *actionNewProject();
|
|
virtual QAction *actionOpenProject();
|
|
virtual QAction *actionSaveProject();
|
|
virtual QAction *actionSaveProjectAs();
|
|
virtual QAction *actionSaveMapAsImage();
|
|
virtual QAction *actionProjectProperties();
|
|
virtual QAction *actionPrintComposer();
|
|
virtual QAction *actionExit();
|
|
|
|
//! Edit menu actions
|
|
virtual QAction *actionCutFeatures();
|
|
virtual QAction *actionCopyFeatures();
|
|
virtual QAction *actionPasteFeatures();
|
|
virtual QAction *actionAddFeature();
|
|
virtual QAction *actionDeleteSelected();
|
|
virtual QAction *actionMoveFeature();
|
|
virtual QAction *actionSplitFeatures();
|
|
virtual QAction *actionAddRing();
|
|
virtual QAction *actionAddPart();
|
|
virtual QAction *actionSimplifyFeature();
|
|
virtual QAction *actionDeleteRing();
|
|
virtual QAction *actionDeletePart();
|
|
virtual QAction *actionNodeTool();
|
|
|
|
//! View menu actions
|
|
virtual QAction *actionPan();
|
|
virtual QAction *actionTouch();
|
|
virtual QAction *actionPanToSelected();
|
|
virtual QAction *actionZoomIn();
|
|
virtual QAction *actionZoomOut();
|
|
virtual QAction *actionSelect();
|
|
virtual QAction *actionSelectRectangle();
|
|
virtual QAction *actionSelectPolygon();
|
|
virtual QAction *actionSelectFreehand();
|
|
virtual QAction *actionSelectRadius();
|
|
virtual QAction *actionIdentify();
|
|
virtual QAction *actionFeatureAction();
|
|
virtual QAction *actionMeasure();
|
|
virtual QAction *actionMeasureArea();
|
|
virtual QAction *actionZoomFullExtent();
|
|
virtual QAction *actionZoomToLayer();
|
|
virtual QAction *actionZoomToSelected();
|
|
virtual QAction *actionZoomLast();
|
|
virtual QAction *actionZoomNext();
|
|
virtual QAction *actionZoomActualSize();
|
|
virtual QAction *actionMapTips();
|
|
virtual QAction *actionNewBookmark();
|
|
virtual QAction *actionShowBookmarks();
|
|
virtual QAction *actionDraw();
|
|
|
|
//! Layer menu actions
|
|
virtual QAction *actionNewVectorLayer();
|
|
virtual QAction *actionAddOgrLayer();
|
|
virtual QAction *actionAddRasterLayer();
|
|
virtual QAction *actionAddPgLayer();
|
|
virtual QAction *actionAddWmsLayer();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionCopyLayerStyle();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionPasteLayerStyle();
|
|
virtual QAction *actionOpenTable();
|
|
virtual QAction *actionToggleEditing();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionSaveActiveLayerEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionAllEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionSaveEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionSaveAllEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionRollbackEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionRollbackAllEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionCancelEdits();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionCancelAllEdits();
|
|
virtual QAction *actionLayerSaveAs();
|
|
virtual QAction *actionLayerSelectionSaveAs();
|
|
virtual QAction *actionRemoveLayer();
|
|
/** @note added in 1.9 */
|
|
virtual QAction *actionDuplicateLayer();
|
|
virtual QAction *actionLayerProperties();
|
|
virtual QAction *actionAddToOverview();
|
|
virtual QAction *actionAddAllToOverview();
|
|
virtual QAction *actionRemoveAllFromOverview();
|
|
virtual QAction *actionHideAllLayers();
|
|
virtual QAction *actionShowAllLayers();
|
|
|
|
//! Plugin menu actions
|
|
virtual QAction *actionManagePlugins();
|
|
virtual QAction *actionPluginListSeparator();
|
|
virtual QAction *actionShowPythonDialog();
|
|
|
|
//! Settings menu actions
|
|
virtual QAction *actionToggleFullScreen();
|
|
virtual QAction *actionOptions();
|
|
virtual QAction *actionCustomProjection();
|
|
|
|
//! Help menu actions
|
|
virtual QAction *actionHelpContents();
|
|
virtual QAction *actionQgisHomePage();
|
|
virtual QAction *actionCheckQgisVersion();
|
|
virtual QAction *actionAbout();
|
|
|
|
//! open feature form
|
|
// returns true when dialog was accepted
|
|
// @param l vector layer
|
|
// @param f feature to show/modify
|
|
// @param updateFeatureOnly only update the feature update (don't change any attributes of the layer)
|
|
// @added in 1.6
|
|
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false );
|
|
|
|
/** Return vector layers in edit mode
|
|
* @param modified whether to return only layers that have been modified
|
|
* @returns list of layers in legend order, or empty list
|
|
* @note added in 1.9 */
|
|
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const;
|
|
|
|
/** Get timeout for timed messages: default of 5 seconds
|
|
* @note added in 1.9 */
|
|
virtual int messageTimeout();
|
|
|
|
signals:
|
|
void currentThemeChanged( QString );
|
|
|
|
private:
|
|
|
|
/// QgisInterface aren't copied
|
|
QgisAppInterface( QgisAppInterface const & );
|
|
|
|
/// QgisInterface aren't copied
|
|
QgisAppInterface & operator=( QgisAppInterface const & );
|
|
|
|
//! Pointer to the QgisApp object
|
|
QgisApp *qgis;
|
|
|
|
//! Pointer to the LegendInterface object
|
|
QgsAppLegendInterface legendIface;
|
|
};
|
|
|
|
#ifdef _MSC_VER
|
|
# pragma warning( pop )
|
|
#endif
|
|
|
|
#endif //#define QGISAPPINTERFACE_H
|