mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Updated _all_ plugins so that initGui() is implemented as a slot. This is required if you wish to use qgsproject for storing and reinstating state in qgis. The reason for this is that the initGui() method is only called once at the moment when qgis starts up. I will be adding a signal to qgisproject 'projectLoaded' that will be emitted when a new project is loaded. I will also be adding connect() for each plugin when its initially loaded in qgisapp so that the initgui slot is called whenever the project loads. git-svn-id: http://svn.osgeo.org/qgis/trunk@2238 c8812cc2-4d05-0410-92ff-de0c093fc19c
75 lines
2.0 KiB
C++
75 lines
2.0 KiB
C++
#ifndef QGISEXAMPLEPLUGIN_H
|
|
#define QGISEXAMPLEPLUGIN_H
|
|
#include "../qgisplugin.h"
|
|
#include <qwidget.h>
|
|
#include <qmainwindow.h>
|
|
|
|
class QMessageBox;
|
|
class QToolBar;
|
|
class QMenuBar;
|
|
class QPopupMenu;
|
|
//#include "qgsworkerclass.h"
|
|
#include "../../src/qgisapp.h"
|
|
|
|
/**
|
|
* \class ExamplePlugin
|
|
* \brief Example plugin for QGIS
|
|
*
|
|
* This code is an example plugin for QGIS and a demonstration of the API
|
|
* All QGIS plugins must inherit from the abstract base class QgisPlugin. A
|
|
* plugin must implement the virtual functions defined in QgisPlugin:
|
|
* *name
|
|
* *version
|
|
* *description
|
|
* *type
|
|
*
|
|
* In addition, a plugin must implement a the classFactory and unload
|
|
* functions. Note that these functions must be declared as extern "C"
|
|
*
|
|
* This plugin is not very useful. When loaded, it installs a new menu with two
|
|
* items and illustrates how to connect the items to slots which handle menu events.
|
|
* It also installs a toolbar with one button. When clicked, the button zooms the
|
|
* map to the previous extent.
|
|
*
|
|
* After the UI elements are initialized the plugin zooms the map canvas to the
|
|
* full extent of all layers.
|
|
*/
|
|
class ExamplePlugin:public QObject, public QgisPlugin
|
|
{
|
|
Q_OBJECT public:
|
|
/**
|
|
* Constructor for a plugin. The QgisApp and QgisIface pointers are passed by
|
|
* QGIS when it attempts to instantiate the plugin.
|
|
* @param qgis Pointer to the QgisApp object
|
|
* @param qI Pointer to the QgisIface object.
|
|
*/
|
|
ExamplePlugin(QgisApp * qgis, QgisIface * qI);
|
|
//! Destructor
|
|
virtual ~ ExamplePlugin();
|
|
public slots:
|
|
//! init the gui
|
|
virtual void initGui();
|
|
//! open something
|
|
void open();
|
|
//! create something new
|
|
void newThing();
|
|
//! zoom the map to the previous extent
|
|
void zoomPrevious();
|
|
//! unload the plugin
|
|
void unload();
|
|
private:
|
|
int ptype;
|
|
//! Id of the plugin's menu. Used for unloading
|
|
int menuId;
|
|
//! Pointer to our toolbar
|
|
QToolBar *toolBar;
|
|
//! Pointer to our menu
|
|
QMenuBar *menu;
|
|
//! Pionter to QGIS main application object
|
|
QgisApp *qgisMainWindow;
|
|
//! Pointer to the QGIS interface object
|
|
QgisIface *qI;
|
|
};
|
|
|
|
#endif
|