Skip to content
Permalink
Browse files

Plugin builder should now successfully generate a compileable plugin …

…framework - ready to be extended by the developer.

I have made a number of improvements over the old 0.7x plugin builder - most importantly the plugins tat are generated now each have their own unique user defined classname and all the filenames are renamed from a generic plugin* to [users plugin name]*


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5198 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Apr 6, 2006
1 parent e204157 commit 74cd48db3cbd9c2f14366c061508439f82187181
@@ -76,6 +76,6 @@ libqgis_plugin_[pluginlcasename]_la_CXXFLAGS = $(CXXFLAGS) \
$(GEOS_CFLAGS) \
-I../../core \
-I../../ui \
-I../../gui \
» » » -I../../raster
-I../../gui -I../../raster

libqgis_plugin_[pluginlcasename]_la_LDFLAGS = -avoid-version -module
@@ -1,16 +1,13 @@
/***************************************************************************
plugin.cpp
Import tool for various worldmap analysis output files
Functions:
[pluginlcasename].cpp
[plugindescription]
-------------------
begin : Jan 21, 2004
copyright : (C) 2004 by Tim Sutton
email : tim@linfiniti.com
-------------------
begin : [PluginDate]
copyright : [(C) Your Name and Date]
email : [Your Email]
***************************************************************************/

/***************************************************************************
***************************************************************************
* *
* 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 *
@@ -20,30 +17,35 @@ email : tim@linfiniti.com
***************************************************************************/
/* $Id$ */

// includes
//
// QGIS Specific includes
//

#include <qgisapp.h>
#include <qgisgui.h>
#include <qgsmaplayer.h>
#include <qgsrasterlayer.h>
#include "[pluginlcasename].h"
//the gui subclass
#include "[pluginlcasename]gui.h"

//
// Qt4 Related Includes
//

#include <q3toolbar.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <q3popupmenu.h>
#include <qlineedit.h>
#include <qaction.h>
#include <qapplication.h>
#include <qcursor.h>
#include <QToolBar>
#include <QMenuBar>
#include <QMessageBox>
#include <QMenu>
#include <QLineEdit>
#include <QAction>
#include <QApplication>
#include <QCursor>

//non qt includes
#include <iostream>

//the gui subclass
#include "[pluginlcasename]gui.h"

// xpm for creating the toolbar icon
#ifdef WIN32
#define QGISEXTERN extern "C" __declspec( dllexport )
#else
@@ -70,9 +72,9 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
*/
[pluginname]::[pluginname](QgisApp * theQGisApp,
QgisIface * theQgisInterface):
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
mQGisApp(theQGisApp),
mQGisIface(theQgisInterface),
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType)
mQGisIface(theQgisInterface)
{
}

@@ -86,18 +88,18 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
*/
void [pluginname]::initGui()
{
Q3PopupMenu *pluginMenu = qGisInterface->getPluginMenu("&[menuname]");
QMenu *pluginMenu = mQGisIface->getPluginMenu("&[menuname]");
//set teh icon from the resource file
menuId = pluginMenu->insertItem(QIcon(":/[pluginlcasename]/[pluginlcasename].png"),"&[menuitemname]", this, SLOT(run()));
mMenuId = pluginMenu->insertItem(QIcon(":/[pluginlcasename]/[pluginlcasename].png"),"&[menuitemname]", this, SLOT(run()));

pluginMenu->setWhatsThis(menuId, tr("Replace this with a short description of the what the plugin does"));
pluginMenu->setWhatsThis(mMenuId, tr("Replace this with a short description of the what the plugin does"));

// Create the action for tool
mQActionPointer = new QAction("[menuitemname]", QIcon(icon), "&icon",0, this, "run");
mQActionPointer = new QAction(QIcon(":/[pluginlcasename]/[pluginlcasename].png"),"[menuitemname]", this);
// Connect the action to the run
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
// Add the toolbar
mToolBarPointer = new Q3ToolBar((Q3MainWindow *) mQGisApp, "[menuname]");
mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "[menuname]");
mToolBarPointer->setLabel("[menuitemname]");
// Add the to the toolbar
mQGisIface->addToolBarIcon(mQActionPointer);
@@ -112,7 +114,7 @@ void [pluginname]::help()
// Slot called when the buffer menu item is activated
void [pluginname]::run()
{
[pluginname]Gui *myPluginGui=new [pluginname]Gui(mQGisApp,"[menuitemname]",true,0);
[pluginname]Gui *myPluginGui=new [pluginname]Gui(mQGisApp, QgisGui::ModalDialogFlags);
//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)));
@@ -123,7 +125,7 @@ void [pluginname]::run()
void [pluginname]::unload()
{
// remove the GUI
mQGisIface->removePluginMenuItem("&[menuname]",menuId);
mQGisIface->removePluginMenuItem("&[menuname]",mMenuId);
mQGisIface->removeToolBarIcon(mQActionPointer);
delete mQActionPointer;
}
@@ -34,13 +34,18 @@
* DON'T: separate variable names using underscores: my_variable_name (NO!)
*
* **************************************************************************/
#ifndef [pluginname]
#define [pluginname]
#include "../qgisplugin.h"
#include <qwidget.h>
#ifndef [pluginname]_H
#define [pluginname]_H

//QT4 includes
#include <QObject>

#include "../../gui/qgisapp.h"
//QGIS includes
#include <qgisapp.h>
#include "../qgisplugin.h"

//forward declarations
class QToolBar;

/**
* \class Plugin
@@ -49,7 +54,8 @@
*/
class [pluginname]:public QObject, public QgisPlugin
{
Q_OBJECT public:
Q_OBJECT;
public:

//////////////////////////////////////////////////////////////////////
//
@@ -63,9 +69,9 @@ class [pluginname]:public QObject, public QgisPlugin
* @param Pointer to the QgisApp object
* @param Pointer to the QgisIface object.
*/
[pluginname](QgisApp * , QgisIface * );
[pluginname](QgisApp * theApplication, QgisIface * theInterface);
//! Destructor
virtual ~ [pluginname]();
virtual ~[pluginname]();

public slots:
//! init the gui
@@ -106,7 +112,7 @@ public slots:
//! Id of the plugin's menu. Used for unloading
int mMenuId;
//! Pointer to our toolbar
Q3ToolBar *mToolBarPointer;
QToolBar *mToolBarPointer;
//! Pionter to QGIS main application object
QgisApp *mQGisApp;
//! Pointer to the QGIS interface object
@@ -120,4 +126,4 @@ public slots:
////////////////////////////////////////////////////////////////////
};

#endif
#endif //[pluginname]_H
@@ -9,7 +9,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "plugingui.h"
#include "[pluginlcasename]gui.h"

//qt includes

@@ -21,7 +21,7 @@
}

[pluginname]Gui::[pluginname]Gui( QWidget* parent, Qt::WFlags fl )
: [pluginname]GuiBase( parent, fl )
: QDialog ( parent, fl )
{
setupUi(this);
}
@@ -13,7 +13,7 @@
#define [pluginname]GUI_H

#include <QDialog>
#include <ui[pluginname]guibase.h>
#include <ui_[pluginlcasename]guibase.h>

/**
@author Tim Sutton
@@ -46,74 +46,74 @@ class QgisPlugin
};
@todo XXX this may be a hint that there should be subclasses
*/
*/
typedef enum PLUGINTYPE
{
UI = 1, /* user interface plug-in */
MAPLAYER /* map layer plug-in */
};
{
UI = 1, /* user interface plug-in */
MAPLAYER /* map layer plug-in */
};


QgisPlugin ( QString const & name = "",
QString const & description = "",
QString const & version = "",
PLUGINTYPE const & type = MAPLAYER )
: mName(name),
mDescription(description),
mVersion(version),
mType(type)
{}
QString const & description = "",
QString const & version = "",
PLUGINTYPE const & type = MAPLAYER )
: mName(name),
mDescription(description),
mVersion(version),
mType(type)
{}

virtual ~QgisPlugin()
{}
{}

//! Get the name of the plugin
QString const & name() const
{
return mName;
}
{
return mName;
}

QString & name()
{
return mName;
}
{
return mName;
}

//! Version of the plugin
QString const & version() const
{
return mVersion;
}
{
return mVersion;
}

//! Version of the plugin
QString & version()
{
return mVersion;
}
QString & version()
{
return mVersion;
}

//! A brief description of the plugin
QString const & description() const
{
return mDescription;
}
{
return mDescription;
}

//! A brief description of the plugin
QString & description()
{
return mDescription;
}
{
return mDescription;
}

//! Plugin type, either UI or map layer
QgisPlugin::PLUGINTYPE const & type() const
{
return mType;
}
{
return mType;
}


//! Plugin type, either UI or map layer
QgisPlugin::PLUGINTYPE & type()
{
return mType;
}
{
return mType;
}

/// function to initialize connection to GUI
virtual void initGui() = 0;
@@ -134,9 +134,9 @@ class QgisPlugin

/// UI or MAPLAYER plug-in
/**
@todo Really, might be indicative that this needs to split into
maplayer vs. ui plug-in vs. other kind of plug-in
*/
@todo Really, might be indicative that this needs to split into
maplayer vs. ui plug-in vs. other kind of plug-in
*/
PLUGINTYPE mType;

}; // class QgisPlugin

0 comments on commit 74cd48d

Please sign in to comment.
You can’t perform that action at this time.