mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
maintenance fixes
git-svn-id: http://svn.osgeo.org/qgis/trunk@201 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
50602c9628
commit
917c05f525
@ -1,11 +1,13 @@
|
|||||||
|
# File generated by kdevelop's qmake manager.
|
||||||
|
# -------------------------------------------
|
||||||
|
# Subdir relative project main directory: ./plugins
|
||||||
|
# Target is a library:
|
||||||
|
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += qt thread debug
|
CONFIG += debug \
|
||||||
SOURCES = qgistestplugin.cpp \
|
warn_on \
|
||||||
qgisplugingui.cpp
|
qt \
|
||||||
|
thread
|
||||||
HEADERS = qgisplugin.h \
|
SOURCES += qgistestplugin.cpp
|
||||||
qgisplugingui.h \
|
HEADERS += qgisplugin.h \
|
||||||
qgispluginmenu.h \
|
qgistestplugin.h
|
||||||
qgispluginguielement.h \
|
|
||||||
qgisplugintoolbar.h
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
* <ul>name
|
* <ul>name
|
||||||
* <li>version
|
* <li>version
|
||||||
* <li>description
|
* <li>description
|
||||||
* <li>gui
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* All QGis plugins must inherit from the abstract base class QgisPlugin. A
|
* All QGis plugins must inherit from the abstract base class QgisPlugin. A
|
||||||
@ -21,14 +20,16 @@
|
|||||||
#ifndef qgisplugin_h
|
#ifndef qgisplugin_h
|
||||||
#define qgisplugin_h
|
#define qgisplugin_h
|
||||||
#include <qstring.h>
|
#include <qstring.h>
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include <qmainwindow.h>
|
||||||
|
|
||||||
#include "qgisplugingui.h"
|
//#include "qgisplugingui.h"
|
||||||
|
|
||||||
/*! \class QgisPlugin
|
/*! \class QgisPlugin
|
||||||
* \brief Abstract base class from which all plugins must inherit
|
* \brief Abstract base class from which all plugins must inherit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class QgisPlugin{
|
class QgisPlugin {
|
||||||
public:
|
public:
|
||||||
//! Get the name of the plugin
|
//! Get the name of the plugin
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
@ -37,7 +38,7 @@ public:
|
|||||||
//! A brief description of the plugin
|
//! A brief description of the plugin
|
||||||
virtual QString description() = 0;
|
virtual QString description() = 0;
|
||||||
//! Interface to gui element collection object
|
//! Interface to gui element collection object
|
||||||
virtual QgisPluginGui *gui()=0;
|
//virtual QgisPluginGui *gui()=0;
|
||||||
//! Element types that can be added to the interface
|
//! Element types that can be added to the interface
|
||||||
/* enum ELEMENTS {
|
/* enum ELEMENTS {
|
||||||
MENU,
|
MENU,
|
||||||
@ -51,7 +52,7 @@ public:
|
|||||||
// Typedefs
|
// Typedefs
|
||||||
|
|
||||||
//! Typedef for function that returns a generic pointer to a plugin object
|
//! Typedef for function that returns a generic pointer to a plugin object
|
||||||
typedef QgisPlugin* create_t();
|
typedef QgisPlugin* create_t(QMainWindow *);
|
||||||
//! Typedef for the function to unload a plugin and free its resources
|
//! Typedef for the function to unload a plugin and free its resources
|
||||||
typedef void unload_t(QgisPlugin *);
|
typedef void unload_t(QgisPlugin *);
|
||||||
|
|
||||||
|
@ -2,43 +2,41 @@
|
|||||||
* This code is a test plugin for QGis and a demonstration of the API
|
* This code is a test plugin for QGis and a demonstration of the API
|
||||||
* All QGis plugins must inherit from the abstract base class QgisPlugin. A
|
* All QGis plugins must inherit from the abstract base class QgisPlugin. A
|
||||||
* plugin must implement the virtual functions defined in QgisPlugin:
|
* plugin must implement the virtual functions defined in QgisPlugin:
|
||||||
* *pluginName
|
* *name
|
||||||
* *pluginVersion
|
* *version
|
||||||
* *pluginDescription
|
* *description
|
||||||
*
|
*
|
||||||
* This list will grow as the API is expanded.
|
* This list may grow as the API is expanded.
|
||||||
*
|
*
|
||||||
* In addition, a plugin must implement a the classFactory and unload
|
* In addition, a plugin must implement a the classFactory and unload
|
||||||
* functions. Note that these functions must be declared as extern "C"
|
* functions. Note that these functions must be declared as extern "C"
|
||||||
*/
|
*/
|
||||||
|
#include "qgistestplugin.h"
|
||||||
#ifndef qgisplugintest_h
|
#include <qaction.h>
|
||||||
#define qgisplugintest_h
|
QgisTestPlugin::QgisTestPlugin(QWidget *qgis) : qgisMainWindow(qgis){
|
||||||
#include "qgisplugin.h"
|
|
||||||
|
|
||||||
#include "qgisplugingui.h"
|
|
||||||
|
|
||||||
class QgisTestPlugin : public QgisPlugin{
|
|
||||||
public:
|
|
||||||
QgisTestPlugin();
|
|
||||||
virtual QString name();
|
|
||||||
virtual QString version();
|
|
||||||
virtual QString description();
|
|
||||||
virtual QgisPluginGui *gui();
|
|
||||||
virtual ~QgisTestPlugin();
|
|
||||||
private:
|
|
||||||
QString pName;
|
|
||||||
QString pVersion;
|
|
||||||
QString pDescription;
|
|
||||||
QgisPluginGui *guiCollection;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
QgisTestPlugin::QgisTestPlugin(){
|
|
||||||
pName = "Test Plugin";
|
pName = "Test Plugin";
|
||||||
pVersion = "Version 0.0";
|
pVersion = "Version 0.0";
|
||||||
pDescription = "This test plugin does nothing but tell you its name, version, and description";
|
pDescription = "This test plugin does nothing but tell you its name, version, and description";
|
||||||
guiCollection = new QgisPluginGui();
|
|
||||||
|
// see if we can popup a message box in qgis on load
|
||||||
|
QMessageBox::information(qgisMainWindow,"Message From Plugin", "This message is from within the test plugin");
|
||||||
|
// add a test menu
|
||||||
|
QPopupMenu *pluginMenu = new QPopupMenu( qgisMainWindow );
|
||||||
|
|
||||||
|
pluginMenu->insertItem("&Open", this, SLOT(open()));
|
||||||
|
pluginMenu->insertItem( "&New" , this, SLOT(newThing()));
|
||||||
|
// a test toolbar
|
||||||
|
QMenuBar *menu = ((QMainWindow *)qgisMainWindow)->menuBar();
|
||||||
|
|
||||||
|
menu->insertItem( "&PluginMenu", pluginMenu );
|
||||||
|
QAction *fileSaveAction = new QAction( "Save File","&Save", CTRL+Key_S, this, "save" );
|
||||||
|
connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
|
||||||
|
|
||||||
|
QToolBar * fileTools = new QToolBar( (QMainWindow *)qgisMainWindow, "file operations" );
|
||||||
|
fileTools->setLabel( "File Operations" );
|
||||||
|
fileSaveAction->addTo(fileTools);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
QgisTestPlugin::~QgisTestPlugin(){
|
QgisTestPlugin::~QgisTestPlugin(){
|
||||||
|
|
||||||
@ -54,13 +52,20 @@ QString QgisTestPlugin::description(){
|
|||||||
return pDescription;
|
return pDescription;
|
||||||
|
|
||||||
}
|
}
|
||||||
QgisPluginGui *QgisTestPlugin::gui(){
|
|
||||||
// stub
|
void QgisTestPlugin::open(){
|
||||||
return (0);
|
QMessageBox::information(qgisMainWindow, "Message from plugin", "You chose the open menu");
|
||||||
|
}
|
||||||
|
void QgisTestPlugin::newThing(){
|
||||||
|
QMessageBox::information(qgisMainWindow, "Message from plugin", "You chose the new menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" QgisPlugin * classFactory(){
|
void QgisTestPlugin::save(){
|
||||||
return new QgisTestPlugin();
|
QMessageBox::information(qgisMainWindow, "Message from plugin", "You chose the save toolbar function");
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" QgisPlugin * classFactory(QWidget *qgis){
|
||||||
|
return new QgisTestPlugin(qgis);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void unload(QgisPlugin *p){
|
extern "C" void unload(QgisPlugin *p){
|
||||||
|
@ -1,18 +1,35 @@
|
|||||||
|
|
||||||
#ifndef qgisplugintest_h
|
#ifndef qgisplugintest_h
|
||||||
#define qgisplugintest_h
|
#define qgisplugintest_h
|
||||||
#include "qgisplugin.h"
|
#include "qgisplugin.h"
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include <qmainwindow.h>
|
||||||
|
#include <qmessagebox.h>
|
||||||
|
#include <qpopupmenu.h>
|
||||||
|
#include <qmenubar.h>
|
||||||
|
#include "qgisplugin.h"
|
||||||
|
#include "qgistestplugin.h"
|
||||||
|
#include "qgsworkerclass.h"
|
||||||
|
|
||||||
class QgisTestPlugin : public QgisPlugin{
|
class QgisTestPlugin : public QObject, public QgisPlugin{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QgisTestPlugin();
|
QgisTestPlugin(QWidget *qgis);
|
||||||
/* virtual QString pluginName();
|
virtual QString name();
|
||||||
virtual QString pluginVersion();
|
virtual QString version();
|
||||||
virtual QString pluginDescription(); */
|
virtual QString description();
|
||||||
|
|
||||||
virtual ~QgisTestPlugin();
|
virtual ~QgisTestPlugin();
|
||||||
|
public slots:
|
||||||
|
void open();
|
||||||
|
void newThing();
|
||||||
|
void save();
|
||||||
private:
|
private:
|
||||||
QString name;
|
QString pName;
|
||||||
QString version;
|
QString pVersion;
|
||||||
QString description;
|
QString pDescription;
|
||||||
|
|
||||||
|
QWidget *qgisMainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qaction.h>
|
#include <qaction.h>
|
||||||
#include <qmenubar.h>
|
#include <qmenubar.h>
|
||||||
@ -663,16 +665,29 @@ void QgisApp::testPluginFunctions()
|
|||||||
|
|
||||||
for(unsigned i = 0; i < pluginDir.count(); i++){
|
for(unsigned i = 0; i < pluginDir.count(); i++){
|
||||||
std::cout << "Getting information for plugin: " << pluginDir[i] << std::endl;
|
std::cout << "Getting information for plugin: " << pluginDir[i] << std::endl;
|
||||||
QLibrary myLib("../plugins/" + pluginDir[i]);
|
QLibrary *myLib = new QLibrary("../plugins/" + pluginDir[i]);//"/home/gsherman/development/qgis/plugins/" + pluginDir[i]);
|
||||||
bool loaded = myLib.load();
|
std::cout << "Library name is " << myLib->library() << std::endl;
|
||||||
|
//QLibrary myLib("../plugins/" + pluginDir[i]);
|
||||||
|
std::cout << "Attempting to load " << + "../plugins/" + pluginDir[i] << std::endl;
|
||||||
|
/* void *handle = dlopen("/home/gsherman/development/qgis/plugins/" + pluginDir[i], RTLD_LAZY);
|
||||||
|
if (!handle) {
|
||||||
|
std::cout << "Error in dlopen: " << dlerror() << std::endl;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
std::cout << "dlopen suceeded" << std::endl;
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
bool loaded = myLib->load();
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
std::cout << "Loaded test plugin library" << std::endl;
|
std::cout << "Loaded test plugin library" << std::endl;
|
||||||
std::cout << "Attempting to resolve the classFactory function" << std::endl;
|
std::cout << "Attempting to resolve the classFactory function" << std::endl;
|
||||||
create_t *cf = (create_t *) myLib.resolve("classFactory");
|
create_t *cf = (create_t *) myLib->resolve("classFactory");
|
||||||
|
|
||||||
if (cf) {
|
if (cf) {
|
||||||
std::cout << "Getting pointer to a QgisPlugin object from the library\n";
|
std::cout << "Getting pointer to a QgisPlugin object from the library\n";
|
||||||
QgisPlugin *pl = cf();
|
QgisPlugin *pl = cf(this);
|
||||||
std::cout << "Displaying name, version, and description\n";
|
std::cout << "Displaying name, version, and description\n";
|
||||||
std::cout << "Plugin name: " << pl->name() << std::endl;
|
std::cout << "Plugin name: " << pl->name() << std::endl;
|
||||||
std::cout << "Plugin version: " << pl->version() << std::endl;
|
std::cout << "Plugin version: " << pl->version() << std::endl;
|
||||||
@ -681,6 +696,7 @@ void QgisApp::testPluginFunctions()
|
|||||||
+ pl->name() + "\nVersion: " + pl->version() + "\nDescription: " + pl->description());
|
+ pl->name() + "\nVersion: " + pl->version() + "\nDescription: " + pl->description());
|
||||||
// unload the plugin (delete it)
|
// unload the plugin (delete it)
|
||||||
std::cout << "Attempting to resolve the unload function" << std::endl;
|
std::cout << "Attempting to resolve the unload function" << std::endl;
|
||||||
|
/*
|
||||||
unload_t *ul = (unload_t *) myLib.resolve("unload");
|
unload_t *ul = (unload_t *) myLib.resolve("unload");
|
||||||
if (ul) {
|
if (ul) {
|
||||||
ul(pl);
|
ul(pl);
|
||||||
@ -688,10 +704,11 @@ void QgisApp::testPluginFunctions()
|
|||||||
} else {
|
} else {
|
||||||
std::cout << "Unable to resolve unload function. Plugin was not unloaded\n";
|
std::cout << "Unable to resolve unload function. Plugin was not unloaded\n";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, "Unable to Load Plugin",
|
QMessageBox::warning(this, "Unable to Load Plugin",
|
||||||
"QGis was unable to load the plugin from: ../plugins/libqgisplugin.so.1.0.0");
|
"QGis was unable to load the plugin from: ../plugins/" + pluginDir[i]);
|
||||||
std::cout << "Unable to load library" << std::endl;
|
std::cout << "Unable to load library" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ exists ( $(PGSQL)/bin/psql ) {
|
|||||||
}
|
}
|
||||||
CONFIG += qt thread debug
|
CONFIG += qt thread debug
|
||||||
|
|
||||||
LIBS += -L$/usr/local/lib -lgdal
|
LIBS += -L$/usr/local/lib -lgdal.1.1
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
qgisapp.cpp \
|
qgisapp.cpp \
|
||||||
qgsdatasource.cpp \
|
qgsdatasource.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user