fix to plugin installation and detection code. Also solve qt 3.1 compile problems

git-svn-id: http://svn.osgeo.org/qgis/trunk@604 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2004-01-27 06:08:44 +00:00
parent e1794c5f93
commit b54897e15f
5 changed files with 33 additions and 15 deletions

View File

@ -244,8 +244,8 @@ qgis_MOC += $(postgresMOC)
# add required defines for compiling PostgreSQL
PGDB = -DPOSTGRESQL -DHAVE_NAMESPACE_STD -DHAVE_CXX_STRING_HEADER -DDLLIMPORT=""
endif
PLUGINS=-DPLUGINS=\"$(libdir)\"
BUILT_SOURCES = $(qgis_MOC) $(qgis_UI)
qgis_LDADD := $(LDADD) $(QT_LDADD) $(GDAL_LIB) $(PG_LIB)
AM_CXXFLAGS := $(PGDB) $(GDAL_CFLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) -I../include $(QT_CXXFLAGS) -I$(PG_INC) -g
AM_CXXFLAGS := $(PLUGINS) $(PGDB) $(GDAL_CFLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) -I../include $(QT_CXXFLAGS) -I$(PG_INC) -g
CLEANFILES = $(BUILT_SOURCES)

View File

@ -272,8 +272,9 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
mySplash->setStatus(tr("Loading plugins..."));
// Get pointer to the provider registry singleton
providerRegistry = QgsProviderRegistry::instance();
providerRegistry = QgsProviderRegistry::instance(PLUGINS);
// set the provider plugin path
std::cout << "Setting plugin lib dir to " << PLUGINS << std::endl;
// connect the "cleanup" slot
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveWindowState()));
restoreWindowState();
@ -281,6 +282,8 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
mapCanvas->setFocus();
mySplash->finish( this );
delete mySplash;
QString plib = PLUGINS;
std::cout << "Plugins are installed in " << plib << std::endl;
}
QgisApp::~QgisApp()

View File

@ -21,6 +21,7 @@
#include "../plugins/qgisplugin.h"
#include "qgspluginmanager.h"
#include "qgspluginitem.h"
#include "qgsproviderregistry.h"
#define TESTLIB
#ifdef TESTLIB
@ -30,12 +31,14 @@ QgsPluginManager::QgsPluginManager(QWidget *parent, const char * name)
: QgsPluginManagerBase(parent, name)
{
// set the default lib dir to the qgis install directory/lib
char **argv = qApp->argv();
QgsProviderRegistry *pr = QgsProviderRegistry::instance();
/* char **argv = qApp->argv();
QString appDir = argv[0];
int bin = appDir.findRev("/bin", -1, false);
QString baseDir = appDir.left(bin);
QString libDir = baseDir + "/lib";
txtPluginDir->setText(libDir);
QString libDir = baseDir + "/lib"; */
txtPluginDir->setText(pr->libDirectory());
getPluginDescriptions();
}

View File

@ -31,26 +31,27 @@ typedef QString description_t();
typedef bool isprovider_t();
QgsProviderRegistry* QgsProviderRegistry::_instance = 0;
QgsProviderRegistry* QgsProviderRegistry::instance ()
QgsProviderRegistry* QgsProviderRegistry::instance (char *pluginPath)
{
if (_instance == 0){
_instance = new QgsProviderRegistry();
_instance = new QgsProviderRegistry(pluginPath);
}
return _instance;
}
QgsProviderRegistry::QgsProviderRegistry(){
QgsProviderRegistry::QgsProviderRegistry(char *pluginPath){
// At startup, examine the libs in the qgis/lib dir and store those that
// are a provider shared lib
// check all libs in the current plugin directory and get name and descriptions
//TODO figure out how to register and identify data source plugin for a specific
//TODO layer type
char **argv = qApp->argv();
/* char **argv = qApp->argv();
QString appDir = argv[0];
int bin = appDir.findRev("/bin", -1, false);
QString baseDir = appDir.left(bin);
QString libDir = baseDir + "/lib";
QString libDir = baseDir + "/lib"; */
libDir = pluginPath;
QDir pluginDir(libDir, "*.so*", QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks);
std::cerr << "Checking " << libDir << " for provider plugins" << std::endl;
if(pluginDir.count() == 0){
QString msg = QObject::tr("No Data Provider Plugins", "No QGIS data provider plugins found in:");
msg += "\n" + libDir + "\n\n";
@ -83,6 +84,7 @@ QDir pluginDir(libDir, "*.so*", QDir::Name | QDir::IgnoreCase, QDir::Files | QDi
}
}
}
delete myLib;
}
}
}
@ -118,3 +120,9 @@ QString QgsProviderRegistry::pluginList(bool asHTML){
}
return list;
}
void QgsProviderRegistry::setLibDirectory(QString path){
libDir = path;
}
QString QgsProviderRegistry::libDirectory(){
return libDir;
}

View File

@ -26,14 +26,18 @@ class QString;
class QgsProviderRegistry
{
public:
static QgsProviderRegistry* instance();
static QgsProviderRegistry* instance(char *pluginPath=0);
QString library(QString providerKey);
QString pluginList(bool asHtml=false);
QString libDirectory();
void setLibDirectory(QString path);
protected:
QgsProviderRegistry();
QgsProviderRegistry(char *pluginPath);
private:
static QgsProviderRegistry* _instance;
std::map<QString,QgsProviderMetadata*> provider;
//! directory provider plugins are installed in
QString libDir;
};
#endif //QGSPROVIDERREGISTRY_H