stub classes for plugin support

git-svn-id: http://svn.osgeo.org/qgis/trunk@138 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2002-10-14 15:43:42 +00:00
parent 5dc39b6ff5
commit c32f7c04eb
6 changed files with 142 additions and 18 deletions

View File

@ -1,13 +1,56 @@
/*! \mainpage Quantum GIS - Plugin API
*
* \section about About QGis Plugins
* Plugins provide additional functionality to QGis. Plugins must
* implement several required methods in order to be registered with
* QGis. These methods include:
* <ul>name
* <li>version
* <li>description
* <li>guiElements
* </ul>
*
* All QGis plugins must inherit from the abstract base class QgisPlugin. A
* This list will grow as the API is expanded.
*
* In addition, a plugin must implement the classFactory and unload
* functions. Note that these functions must be declared as extern "C" in
* order to be resolved properly and prevent C++ name mangling.
*/
#include <qstring.h>
#ifndef qgisplugin_h
#define qgisplugin_h
#include <qstring.h>
/*! \class QgisPlugin
* \brief Abstract base class from which all plugins must inherit
*
*/
class QgisPlugin{
public:
virtual QString pluginName() = 0;
virtual QString pluginVersion() =0;
virtual QString pluginDescription() = 0;
//! Get the name of the plugin
virtual QString name() = 0;
//! Version of the plugin
virtual QString version() =0;
//! A brief description of the plugin
virtual QString description() = 0;
//! Element types that can be added to the interface
enum ELEMENTS {
MENU,
MENU_ITEM,
TOOLBAR,
TOOLBAR_BUTTON,
};
};
// Typedefs
//! Typedef for function that returns a generic pointer to a plugin object
typedef QgisPlugin* create_t();
//! Typedef for the function to unload a plugin and free its resources
typedef void unload_t(QgisPlugin *);
//! Element type corresponding to one of the values in the ELEMENTS enum
typedef int QGIS_GUI_TYPE;
#endif //qgisplugin_h

22
plugins/qgisplugingui.h Normal file
View File

@ -0,0 +1,22 @@
#include <vector>
class QgisPluginGuiElement;
/*! \class QgisPluginGui
* \brief Class to encapsulate the gui elements of a plugin
*
* QgsPluginGui encapsulates all the GUI elements a plugin supports,
* including menu items, toolbar buttons, and associated graphics
*/
class QgisPluginGui {
public:
//! Constructor
QgisPluginGui();
//! Returns the number of GUI elements in the plugin
int elementCount();
//! Returns a specific GUI element by index from the vector
QgisPluginGuiElement element(int index);
//! Adds a new element
void addElement(QgisPluginGuiElement);
private:
std::vector<QgisPluginGuiElement> elements;
};

View File

@ -0,0 +1,17 @@
/*! \class QgisPluginGuiElement
* \brief Base class for a GUI element (menu, toolbar, etc) of a plugin
*
* QgsPluginGuiElement provides information about a GUI element that
* will be added to the QGis interface when the plugin is loaded
*/
class QgisPluginGuiElement {
public:
//! Constructor
QgisPluginGuiElement();
//! Type of element (see ELEMENTS enum in qgisplugin.h)
virtual QGIS_GUI_TYPE type();
//! destructor
virtual ~QgisPluginGuiElement();
private:
};

20
plugins/qgispluginmenu.h Normal file
View File

@ -0,0 +1,20 @@
#include <map>
#include "qgispluginguielement"
/*! \class QgisPluginMenu
* \brief Class to define a plugin menu
*
*
*
*/
class QgisPluginMenu : public QgisPluginGuiElement {
public:
//! Constructor
QgisPluginMenu();
//! Type of element (see ELEMENTS enum in qgisplugin.h)
QGIS_GUI_TYPE type();
//! destructor
virtual ~QgisPluginMenu();
private:
//! Map to define slot called when a menu item is activated
std::map<QString menuItemName, QString menuItemSlot> itemSlots;
};

View File

@ -0,0 +1,20 @@
#include <map>
#include "qgispluginguielement"
/*! \class QgisPluginToolbar
* \brief Class to define a plugin toolbar
*
*
*
*/
class QgisPluginToolbar : public QgisPluginGuiElement {
public:
//! Constructor
QgisPluginToolbar();
//! Type of element (see ELEMENTS enum in qgisplugin.h)
QGIS_GUI_TYPE type();
//! destructor
virtual ~QgisPluginToolbar();
private:
//! Map to define slot called when a toolbar button is activated
std::map<QString toolName, QString toolSlot> toolSlots;
};

View File

@ -16,38 +16,40 @@
#ifndef qgisplugintest_h
#define qgisplugintest_h
#include "qgisplugin.h"
#include "qgisplugingui.h"
class QgisTestPlugin : public QgisPlugin{
public:
QgisTestPlugin();
virtual QString pluginName();
virtual QString pluginVersion();
virtual QString pluginDescription();
virtual QString name();
virtual QString version();
virtual QString description();
virtual QgisPluginGui *gui();
virtual ~QgisTestPlugin();
private:
QString name;
QString version;
QString description;
QString pName;
QString pVersion;
QString pDescription;
};
#endif
QgisTestPlugin::QgisTestPlugin(){
name = "Test Plugin";
version = "Version 0.0";
description = "This test plugin does nothing but tell you its name, version, and description";
pName = "Test Plugin";
pVersion = "Version 0.0";
pDescription = "This test plugin does nothing but tell you its name, version, and description";
}
QgisTestPlugin::~QgisTestPlugin(){
}
QString QgisTestPlugin::pluginName(){
return name;
QString QgisTestPlugin::name(){
return pName;
}
QString QgisTestPlugin::pluginVersion(){
return version;
QString QgisTestPlugin::version(){
return pVersion;
}
QString QgisTestPlugin::pluginDescription(){
return description;
QString QgisTestPlugin::description(){
return pDescription;
}
extern "C" QgisPlugin * classFactory(){