mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Class member naming now adheres to qgis coding standards.
Win ifdefs added Now in sync with external plugins template (which was more up to date) git-svn-id: http://svn.osgeo.org/qgis/trunk@2237 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
9658be9508
commit
5f9c0e9041
@ -45,25 +45,34 @@ email : tim@linfiniti.com
|
||||
|
||||
// xpm for creating the toolbar icon
|
||||
#include "icon.xpm"
|
||||
//
|
||||
static const char * const ident_ = "$Id$";
|
||||
#ifdef WIN32
|
||||
#define QGISEXTERN extern "C" __declspec( dllexport )
|
||||
#else
|
||||
#define QGISEXTERN extern "C"
|
||||
#endif
|
||||
|
||||
static const char * const name_ = "[pluginname]";
|
||||
static const char * const description_ = "[plugindescription]";
|
||||
static const char * const version_ = "Version 0.1";
|
||||
static const QgisPlugin::PLUGINTYPE type_ = QgisPlugin::UI;
|
||||
static const char * const sIdent = "$Id$";
|
||||
static const char * const sName = "[menuitemname]";
|
||||
static const char * const sDescription = "[plugindescription]";
|
||||
static const char * const sPluginVersion = "Version 0.1";
|
||||
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Constructor for the plugin. The plugin is passed a pointer to the main app
|
||||
* and an interface object that provides access to exposed functions in QGIS.
|
||||
* @param qgis Pointer to the QGIS main window
|
||||
* @param _qI Pointer to the QGIS interface object
|
||||
* @param theQGisApp - Pointer to the QGIS main window
|
||||
* @param theQGisInterface - Pointer to the QGIS interface object
|
||||
*/
|
||||
Plugin::Plugin(QgisApp * theQGisApp, QgisIface * theQgisInterFace):
|
||||
qgisMainWindowPointer(theQGisApp),
|
||||
qGisInterface(theQgisInterFace),
|
||||
QgisPlugin(name_,description_,version_,type_)
|
||||
Plugin::Plugin(QgisApp * theQGisApp, QgisIface * theQgisInterface):
|
||||
mQGisApp(theQGisApp),
|
||||
mQGisIface(theQgisInterface),
|
||||
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType)
|
||||
{
|
||||
}
|
||||
|
||||
@ -77,21 +86,19 @@ Plugin::~Plugin()
|
||||
*/
|
||||
void Plugin::initGui()
|
||||
{
|
||||
// add a menu with 2 items
|
||||
QPopupMenu *pluginMenu = new QPopupMenu(qgisMainWindowPointer);
|
||||
|
||||
pluginMenu->insertItem(QIconSet(icon),"&[pluginname]", this, SLOT(run()));
|
||||
|
||||
menuBarPointer = ((QMainWindow *) qgisMainWindowPointer)->menuBar();
|
||||
|
||||
menuIdInt = qGisInterface->addMenu("&[menuname]", pluginMenu);
|
||||
QPopupMenu *pluginMenu = new QPopupMenu(mQGisApp);
|
||||
pluginMenu->insertItem(QIconSet(icon),"&[menuitemname]", this, SLOT(run()));
|
||||
mMenuBarPointer = ((QMainWindow *) mQGisApp)->menuBar();
|
||||
mMenuId = mQGisIface->addMenu("&[menuname]", pluginMenu);
|
||||
// Create the action for tool
|
||||
QAction *myQActionPointer = new QAction("[menuitemname]", QIconSet(icon), "&Wmi",0, this, "run");
|
||||
mQActionPointer = new QAction("[menuitemname]", QIconSet(icon), "&icon",0, this, "run");
|
||||
// Connect the action to the run
|
||||
connect(myQActionPointer, SIGNAL(activated()), this, SLOT(run()));
|
||||
|
||||
// Add the icon to the toolbar
|
||||
qGisInterface->addToolBarIcon(myQActionPointer);
|
||||
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
|
||||
// Add the toolbar
|
||||
mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "[menuname]");
|
||||
mToolBarPointer->setLabel("[menuitemname]");
|
||||
// Add the to the toolbar
|
||||
mQGisIface->addToolBarIcon(mQActionPointer);
|
||||
|
||||
}
|
||||
//method defined in interface
|
||||
@ -103,70 +110,98 @@ void Plugin::help()
|
||||
// Slot called when the buffer menu item is activated
|
||||
void Plugin::run()
|
||||
{
|
||||
PluginGui *myPluginGui=new PluginGui(qgisMainWindowPointer,"[menuitemname]",true,0);
|
||||
PluginGui *myPluginGui=new PluginGui(mQGisApp,"[menuitemname]",true,0);
|
||||
//listen for when the layer has been made so we can draw it
|
||||
connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
|
||||
connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
|
||||
myPluginGui->show();
|
||||
}
|
||||
//!draw a raster layer in the qui - intended to respond to signal sent by diolog when it as finished creating
|
||||
//layer
|
||||
void Plugin::drawRasterLayer(QString theQString)
|
||||
{
|
||||
qGisInterface->addRasterLayer(theQString);
|
||||
}
|
||||
//!draw a vector layer in the qui - intended to respond to signal sent by diolog when it as finished creating a layer
|
||||
////needs to be given vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
|
||||
void Plugin::drawVectorLayer(QString thePathNameQString, QString theBaseNameQString, QString theProviderQString)
|
||||
{
|
||||
qGisInterface->addVectorLayer( thePathNameQString, theBaseNameQString, theProviderQString);
|
||||
}
|
||||
|
||||
// Unload the plugin by cleaning up the GUI
|
||||
void Plugin::unload()
|
||||
{
|
||||
// remove the GUI
|
||||
menuBarPointer->removeItem(menuIdInt);
|
||||
delete toolBarPointer;
|
||||
mMenuBarPointer->removeItem(mMenuId);
|
||||
mQGisIface->removeToolBarIcon(mQActionPointer);
|
||||
delete mQActionPointer;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// END OF MANDATORY PLUGIN METHODS
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The following methods are provided to demonstrate how you can
|
||||
// load a vector or raster layer into the main gui. Please delete
|
||||
// if you are not intending to use these. Note also that there are
|
||||
// ways in which layers can be loaded.
|
||||
//
|
||||
|
||||
//!draw a raster layer in the qui - intended to respond to signal sent by diolog when it as finished creating
|
||||
//layer
|
||||
void Plugin::drawRasterLayer(QString theQString)
|
||||
{
|
||||
mQGisIface->addRasterLayer(theQString);
|
||||
}
|
||||
|
||||
//!draw a vector layer in the qui - intended to respond to signal sent by
|
||||
// dialog when it as finished creating a layer. It needs to be given
|
||||
// vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
|
||||
void Plugin::drawVectorLayer(QString thePathNameQString, QString theBaseNameQString, QString theProviderQString)
|
||||
{
|
||||
mQGisIface->addVectorLayer( thePathNameQString, theBaseNameQString, theProviderQString);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
|
||||
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
|
||||
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Required extern functions needed for every plugin
|
||||
* These functions can be called prior to creating an instance
|
||||
* of the plugin class
|
||||
*/
|
||||
// Class factory to return a new instance of the plugin class
|
||||
extern "C" QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
|
||||
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
|
||||
{
|
||||
return new Plugin(theQGisAppPointer, theQgisInterfacePointer);
|
||||
}
|
||||
|
||||
// Return the name of the plugin - note that we do not user class members as
|
||||
// the class may not yet be insantiated when this method is called.
|
||||
extern "C" QString name()
|
||||
QGISEXTERN QString name()
|
||||
{
|
||||
return name_;
|
||||
return sName;
|
||||
}
|
||||
|
||||
// Return the description
|
||||
extern "C" QString description()
|
||||
QGISEXTERN QString description()
|
||||
{
|
||||
return description_;
|
||||
return sDescription;
|
||||
}
|
||||
|
||||
// Return the type (either UI or MapLayer plugin)
|
||||
extern "C" int type()
|
||||
QGISEXTERN int type()
|
||||
{
|
||||
return type_;
|
||||
return sPluginType;
|
||||
}
|
||||
|
||||
// Return the version number for the plugin
|
||||
extern "C" QString version()
|
||||
QGISEXTERN QString version()
|
||||
{
|
||||
return version_;
|
||||
return sPluginVersion;
|
||||
}
|
||||
|
||||
// Delete ourself
|
||||
extern "C" void unload(QgisPlugin * thePluginPointer)
|
||||
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
|
||||
{
|
||||
delete thePluginPointer;
|
||||
}
|
||||
|
@ -17,6 +17,23 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
/***************************************************************************
|
||||
* QGIS Programming conventions:
|
||||
*
|
||||
* mVariableName - a class level member variable
|
||||
* sVariableName - a static class level member variable
|
||||
* variableName() - accessor for a class member (no 'get' in front of name)
|
||||
* setVariableName() - mutator for a class member (prefix with 'set')
|
||||
*
|
||||
* Additional useful conventions:
|
||||
*
|
||||
* theVariableName - a method parameter (prefix with 'the')
|
||||
* myVariableName - a locally declared variable within a method ('my' prefix)
|
||||
*
|
||||
* DO: Use mixed case variable names - myVariableName
|
||||
* DON'T: separate variable names using underscores: my_variable_name (NO!)
|
||||
*
|
||||
* **************************************************************************/
|
||||
#ifndef PLUGIN
|
||||
#define PLUGIN
|
||||
#include "../qgisplugin.h"
|
||||
@ -24,49 +41,85 @@
|
||||
|
||||
#include "../../src/qgisapp.h"
|
||||
|
||||
|
||||
/**
|
||||
* \class Plugin
|
||||
* \brief OpenModeller plugin for QGIS
|
||||
*
|
||||
* \brief [name] plugin for QGIS
|
||||
* [description]
|
||||
*/
|
||||
class Plugin: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.
|
||||
*/
|
||||
Plugin(QgisApp * , QgisIface * );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MANDATORY PLUGIN METHODS FOLLOW
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Constructor for a plugin. The QgisApp and QgisIface pointers are passed by
|
||||
* QGIS when it attempts to instantiate the plugin.
|
||||
* @param Pointer to the QgisApp object
|
||||
* @param Pointer to the QgisIface object.
|
||||
*/
|
||||
Plugin(QgisApp * , QgisIface * );
|
||||
//! init the gui
|
||||
virtual void initGui();
|
||||
//! Destructor
|
||||
virtual ~ Plugin();
|
||||
public slots:
|
||||
|
||||
public slots:
|
||||
//! Show the dialog box
|
||||
void run();
|
||||
//!draw a raster layer in the qui
|
||||
void drawRasterLayer(QString);
|
||||
//! Add a vector layer given vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
|
||||
void drawVectorLayer(QString,QString,QString);
|
||||
//! unload the plugin
|
||||
void unload();
|
||||
//! show the help document
|
||||
void help();
|
||||
private:
|
||||
|
||||
int pluginType;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// END OF MANDATORY PLUGIN METHODS
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The following methods are provided to demonstrate how you can
|
||||
// load a vector or raster layer into the main gui. Please delete
|
||||
// if you are not intending to use these. Note also that there are
|
||||
// ways in which layers can be loaded.
|
||||
//
|
||||
|
||||
//!draw a raster layer in the qui
|
||||
void drawRasterLayer(QString);
|
||||
//! Add a vector layer given vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
|
||||
void drawVectorLayer(QString,QString,QString);
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MANDATORY PLUGIN MEMBER DECLARATIONS .....
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
int mPluginType;
|
||||
//! Id of the plugin's menu. Used for unloading
|
||||
int menuIdInt;
|
||||
int mMenuId;
|
||||
//! Pointer to our toolbar
|
||||
QToolBar *toolBarPointer;
|
||||
QToolBar *mToolBarPointer;
|
||||
//! Pointer to our menu
|
||||
QMenuBar *menuBarPointer;
|
||||
QMenuBar *mMenuBarPointer;
|
||||
//! Pionter to QGIS main application object
|
||||
QgisApp *qgisMainWindowPointer;
|
||||
QgisApp *mQGisApp;
|
||||
//! Pointer to the QGIS interface object
|
||||
QgisIface *qGisInterface;
|
||||
QgisIface *mQGisIface;
|
||||
//!pointer to the qaction for this plugin
|
||||
QAction * mQActionPointer;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ADD YOUR OWN MEMBER DECLARATIONS AFTER THIS POINT.....
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user