Massive changes to provide Windows support. This is a work in progress but

has been tested and it compiles under unix. Future changes to the code must
be aware of multiplatform issues.


git-svn-id: http://svn.osgeo.org/qgis/trunk@1563 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2004-06-12 18:27:11 +00:00
parent 0731c653f3
commit aa04b4759e
34 changed files with 181 additions and 34 deletions

View File

@ -20,8 +20,9 @@ email : sherman at mrcc.com
#include <iostream>
#include <cstdio>
#ifndef WIN32
#include <getopt.h>
#endif
#include <qapplication.h>
#include <qfont.h>
@ -35,7 +36,10 @@ email : sherman at mrcc.com
#include <qstringlist.h>
#include <splashscreen.h>
#ifdef WIN32
//TODO - fix this to use the appdir for setting path to i18ln and other resources
#define PKGDATAPATH "/home"
#endif
static const char * const ident_ = "$Id$";
@ -91,7 +95,7 @@ int main(int argc, char *argv[])
// This is the 'leftover' arguments collection
QStringList * myFileList=new QStringList();
#ifndef WIN32
////////////////////////////////////////////////////////////////
// USe the GNU Getopts utility to parse cli arguments
@ -175,6 +179,7 @@ int main(int argc, char *argv[])
}
}
#endif //WIN32
/////////////////////////////////////////////////////////////////////
// Now we have the handlers for the different behaviours...
////////////////////////////////////////////////////////////////////

View File

@ -10,7 +10,6 @@
*
*/
/* $Id$ */
#include <qgsconfig.h>
namespace QGis

View File

@ -18,8 +18,9 @@
***************************************************************************/
/* $Id$ */
#ifndef WIN32
#include <dlfcn.h>
#endif
#include <qaction.h>
#include <qapplication.h>
#include <qbitmap.h>
@ -83,13 +84,18 @@
#ifdef HAVE_POSTGRESQL
#include "qgsdbsourceselect.h"
#endif
#ifdef WIN32
#include "qgsmessageviewer.h"
#include "qgsabout.h"
#else
#include "qgsabout.uic.h"
#include "qgsmessageviewer.uic.h"
#endif
#include "qgshelpviewer.h"
#include "qgsmaplayerregistry.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsvectorlayer.h"
#include "qgsabout.uic.h"
#include "qgspluginmanager.h"
#include "qgsmaplayerinterface.h"
#include "qgis.h"
@ -350,6 +356,13 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
gSplashScreen->setStatus(tr("Loading plugins..."));
}
// store the application dir
#ifdef WIN32
mAppDir = qApp->applicationDirPath();
QString PLUGINPATH = mAppDir + "/lib/qgis";
#else
mAppDir = PREFIX;
#endif
// Get pointer to the provider registry singleton
QString plib = PLUGINPATH;
mProviderRegistry = QgsProviderRegistry::instance(plib);
@ -386,8 +399,6 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
// store the application dir
mAppDir = PREFIX;
// get the users theme preference from the settings
QString themeName = settings.readEntry("/qgis/theme","default");
@ -563,7 +574,7 @@ static void buildSupportedVectorFileFilter_(QString & fileFilters)
if (!driverRegistrar)
{
qWarning("unable to get OGRDriverManager");
QMessageBox::warning(0,"OGR Driver Manger","unable to get OGRDriverManager");
return; // XXX good place to throw exception if we
} // XXX decide to do exceptions
@ -2303,6 +2314,7 @@ void QgisApp::loadPlugin(QString name, QString description, QString theFullPathN
}
void QgisApp::testMapLayerPlugins()
{
#ifndef WIN32
// map layer plugins live in their own directory (somewhere to be determined)
QDir mlpDir("../plugins/maplayer", "*.so.1.0.0", QDir::Name | QDir::IgnoreCase, QDir::Files);
if (mlpDir.count() == 0)
@ -2377,6 +2389,7 @@ void QgisApp::testMapLayerPlugins()
}
}
}
#endif //#ifndef WIN32
}
void QgisApp::testPluginFunctions()
{
@ -2407,7 +2420,7 @@ void QgisApp::testPluginFunctions()
#endif
//QLibrary myLib("../plugins/" + pluginDir[i]);
#ifdef QGISDEBUG
std::cout << "Attempting to load " << +"../plugins/" + pluginDir[i] << std::endl;
std::cout << "Attempting to load " << "../plugins/" + pluginDir[i] << std::endl;
#endif
/* void *handle = dlopen("/home/gsherman/development/qgis/plugins/" + pluginDir[i], RTLD_LAZY);
if (!handle) {
@ -2490,10 +2503,16 @@ void QgisApp::saveWindowState()
// store window geometry
QPoint p = this->pos();
QSize s = this->size();
QRect fg = this->frameGeometry();
int y = this->y();
settings.writeEntry("/qgis/Geometry/maximized", this->isMaximized());
settings.writeEntry("/qgis/Geometry/x", p.x());
#ifdef WIN32
// y value creeps under win32 by the value of the title bar height
settings.writeEntry("/qgis/Geometry/y", p.y() + 30);
#else
settings.writeEntry("/qgis/Geometry/y", p.y());
#endif
settings.writeEntry("/qgis/Geometry/w", s.width());
settings.writeEntry("/qgis/Geometry/h", s.height());
@ -2923,6 +2942,9 @@ void QgisApp::populateMenuMaps()
int QgisApp::addPluginMenu(QString menuText, QPopupMenu *menu)
{
mPluginMenu->insertItem(menuText, menu);
// added cuz windows wants the return
// TODO - fix this up later
return 0;
}
// slot to update the progress bar in the status bar

View File

@ -40,8 +40,11 @@ class QgsProviderRegistry;
class QgsHelpViewer;
class QgsMapCanvas;
class QgsMapLayerRegistry;
#ifdef WIN32
#include "qgisappbase.h"
#else
#include "qgisappbase.uic.h"
#endif
#include "qgisiface.h"
#include "splashscreen.h"
#include "qgsconfig.h"

View File

@ -50,11 +50,15 @@ void QgisIface::zoomActiveLayer()
bool QgisIface::addVectorLayer(QString vectorLayerPath, QString baseName, QString providerKey)
{
qgis->addVectorLayer(vectorLayerPath, baseName, providerKey);
//TODO fix this so it returns something meaningfull
return true;
}
bool QgisIface::addRasterLayer(QString rasterLayerPath)
{
qgis->addRasterLayer(rasterLayerPath);
//TODO fix this so it returns something meaningfull
return true;
}
bool QgisIface::addProject(QString theProjectName)

View File

@ -19,8 +19,11 @@
#ifndef QGSATTRIBUTETABLEDISPLAY_H
#define QGSATTRIBUTETABLEDISPLAY_H
#ifdef WIN32
#include "qgsattributetablebase.h"
#else
#include "qgsattributetablebase.uic.h"
#endif
class QgsAttributeTable;
/**
*@author Gary E.Sherman

View File

@ -18,8 +18,11 @@
/* $Id$ */
#ifndef QGSCONTCOLDIALOG_H
#define QGSCONTCOLDIALOG_H
#ifdef WIN32
#include "qgscontcoldialogbase.h"
#else
#include "qgscontcoldialogbase.uic.h"
#endif
#include <map>
class QgsVectorLayer;

View File

@ -17,7 +17,11 @@
/* $Id$ */
#ifndef QGSDBSOURCESELECT_H
#define QGSDBSOURCESELECT_H
#ifdef WIN32
#include "qgsdbsourceselectbase.h"
#else
#include "qgsdbsourceselectbase.uic.h"
#endif
class QListBoxItem;
class QgisApp;

View File

@ -18,8 +18,11 @@
/* $Id$ */
#ifndef QGSDLGVECTORLAYERPROPERTIES
#define QGSDLGVECTORLAYERPROPERTIES
#ifdef WIN32
#include "qgsdlgvectorlayerpropertiesbase.h"
#else
#include "qgsdlgvectorlayerpropertiesbase.uic.h"
#endif
#include "qgsrenderer.h"
#include "qpixmap.h"
#include "qlineedit.h"

View File

@ -18,8 +18,11 @@
#ifndef QGSGRAMADIALOG_H
#define QGSGRAMADIALOG_H
#ifdef WIN32
#include "qgsgramadialogbase.h"
#else
#include "qgsgramadialogbase.uic.h"
#endif
#include <map>
class QgsGraMaExtensionWidget;

View File

@ -142,7 +142,13 @@ QgsGraMaExtensionWidget::QgsGraMaExtensionWidget()
void QgsGraMaExtensionWidget::selectMarker()
{
#ifdef WIN32
//TODO fix this so it uses the path gained using
//QApplication::applicationPathDir()
QgsMarkerDialog mdialog("");
#else
QgsMarkerDialog mdialog(QString(PKGDATAPATH)+"/svg");
#endif
if(mdialog.exec()==QDialog::Accepted)
{

View File

@ -18,8 +18,11 @@
#ifndef QGSGRASYDIALOG_H
#define QGSGRASYDIALOG_H
#ifdef WIN32
#include "qgsgrasydialogbase.h"
#else
#include "qgsgrasydialogbase.uic.h"
#endif
#include <map>
class QgsGraSyExtensionWidget;

View File

@ -22,6 +22,11 @@
#include <qvariant.h>
#include <qdialog.h>
#ifdef WIN32
#include "qgshelpviewerbase.h"
#else
#include "qgshelpviewerbase.uic.h"
#endif
class QVBoxLayout;
class QHBoxLayout;
@ -29,7 +34,6 @@ class QGridLayout;
class QPushButton;
class QTextBrowser;
class QString;
#include "qgshelpviewerbase.uic.h"
class QgsHelpViewer : public QgsHelpViewerBase
{
Q_OBJECT

View File

@ -18,8 +18,11 @@ Romans 3:23=>Romans 6:23=>Romans 5:8=>Romans 10:9,10=>Romans 12
/* $Id$ */
#ifndef QGSIDENTIFYRESULTS_H
#define QGSIDENTIFYRESULTS_H
#ifdef WIN32
#include "qgsidentifyresultsbase.h"
#else
#include "qgsidentifyresultsbase.uic.h"
#endif
/**
*@author Gary E.Sherman

View File

@ -20,8 +20,11 @@
#define QGSLINESTYLEDIALOG_H
class qnamespace;
#ifdef WIN32
#include "qgslinestyledialogbase.h"
#else
#include "qgslinestyledialogbase.uic.h"
#endif
/**Dialog class to query line styles*/
class QgsLineStyleDialog: public QgsLineStyleDialogBase
{

View File

@ -16,7 +16,12 @@
#ifndef QGSMAPSERVEREXPORT_H
#define QGSMAPSERVEREXPORT_H
#ifdef WIN32
#include "qgsmapserverexportbase.h"
#else
#include "qgsmapserverexportbase.uic.h"
#endif
class QgsMapCanvas;
/*! \class QgsMapServerExport

View File

@ -102,7 +102,13 @@ void QgsMarkerDialog::visualizeMarkers(QString directory)
QString QgsMarkerDialog::defaultDir()
{
#ifdef WIN32
//TODO fix this to use appropriate path on windows
//qgis install
QString dir = "Foo";
#else
QString dir = QString(PKGDATAPATH)+"/svg";
#endif
return dir;
}

View File

@ -19,8 +19,12 @@
#ifndef QGSMARKERDIALOG_H
#define QGSMARKERDIALOG_H
#ifdef WIN32
#include "qgsmarkerdialogbase.h"
#else
#include "qgsmarkerdialogbase.uic.h"
#endif
#include <qdir.h>
/**A class for choosing marker images by clicking icons*/

View File

@ -17,7 +17,11 @@
/* $Id$ */
#ifndef QGSNEWCONNECTION_H
#define QGSNEWCONNECTION_H
#ifdef WIN32
#include "qgsnewconnectionbase.h"
#else
#include "qgsnewconnectionbase.uic.h"
#endif
/*! \class QgsNewConnection
* \brief Dialog to allow the user to configure and save connection
* information for a PostgresQl database

View File

@ -19,7 +19,11 @@
#ifndef QGSOPTIONS_H
#define QGSOPTIONS_H
class QString;
#ifdef WIN32
#include "qgsoptionsbase.h"
#else
#include "qgsoptionsbase.uic.h"
#endif
/**
* \class QgsOptions
* \brief Set user options and preferences

View File

@ -20,7 +20,11 @@
#define QGSPATTERNDIALOG_H
class qnamespace;
#ifdef WIN32
#include "qgspatterndialogbase.h"
#else
#include "qgspatterndialogbase.uic.h"
#endif
/**A dialog class to query the fill pattern.*/
class QgsPatternDialog: public QgsPatternDialogBase

View File

@ -27,8 +27,10 @@
#define TESTLIB
#ifdef TESTLIB
#ifndef WIN32
#include <dlfcn.h>
#endif
#endif
QgsPluginManager::QgsPluginManager(QWidget * parent, const char *name):QgsPluginManagerBase(parent, name)
{
// set the default lib dir to the qgis install directory/lib (this info is
@ -70,6 +72,7 @@ void QgsPluginManager::getPluginDescriptions()
for (unsigned i = 0; i < pluginDir.count(); i++)
{
#ifdef TESTLIB
#ifndef WIN32
// test code to help debug loading problems
QString lib = QString("%1/%2").arg(txtPluginDir->text()).arg(pluginDir[i]);
void *handle = dlopen((const char *) lib, RTLD_LAZY);
@ -82,8 +85,8 @@ void QgsPluginManager::getPluginDescriptions()
std::cout << "dlopen suceeded" << std::endl;
dlclose(handle);
}
#endif
#endif //#ifndef WIN32
#endif //#ifdef TESTLIB
std::cout << "Examining " << txtPluginDir->text() << "/" << pluginDir[i] << std::endl;

View File

@ -20,7 +20,11 @@
#ifndef QGSPLUGINMANAGER_H
#define QGSPLUGINMANAGER_H
#include <vector>
#ifdef WIN32
#include "qgspluginmanagerbase.h"
#else
#include "qgspluginmanagerbase.uic.h"
#endif
class QgsPluginItem;
/**

View File

@ -16,7 +16,11 @@
* *
***************************************************************************/
/* $Id$ */
#ifdef WIN32
#include "qgsprojectpropertiesbase.h"
#else
#include "qgsprojectpropertiesbase.uic.h"
#endif
/**
* \class QgsProjectProperties
* \brief Dialog to set project level properties

View File

@ -53,7 +53,11 @@ int bin = appDir.findRev("/bin", -1, false);
QString baseDir = appDir.left(bin);
QString libDir = baseDir + "/lib"; */
libDir = pluginPath;
#ifdef WIN32
QDir pluginDir(libDir, "*.dll", QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks);
#else
QDir pluginDir(libDir, "*.so*", QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks);
#endif
#ifdef QGISDEBUG
std::cerr << "Checking " << libDir << " for provider plugins" << std::endl;
#endif
@ -89,6 +93,7 @@ QString libDir = baseDir + "/lib"; */
providerkey_t *pKey = (providerkey_t *) myLib->resolve("providerKey");
if (pDesc && pKey)
{
const char *foo = pKey();
// add this provider to the provider map
provider[pKey()] = new QgsProviderMetadata(pKey(), pDesc(), myLib->library());
#ifdef QGISDEBUG

View File

@ -121,6 +121,10 @@ QgsRasterLayer::QgsRasterLayer(QString path, QString baseName):QgsMapLayer(RASTE
//populate the list of what pyramids exist
buildRasterPyramidList();
//load up the pyramid icons
#ifdef WIN32
//TODO Fix this to use the right path
const char *PKGDATAPATH = "foo";
#endif
mPyramidPixmap.load(QString(PKGDATAPATH) + QString("/images/icons/pyramid.png"));
mNoPyramidPixmap.load(QString(PKGDATAPATH) + QString("/images/icons/no_pyramid.png"));
//just testing remove this later

View File

@ -18,6 +18,7 @@
#include "qgsrasterlayerproperties.h"
#include <qlabel.h>
#include <qapplication.h>
#include <qpixmap.h>
#include <qimage.h>
#include <qslider.h>
@ -294,6 +295,9 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer * lyr):QgsRasterL
//
// Set up the pyramiding tab
//
#ifdef WIN32
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
#endif
QPixmap myPyramidPixmap(QString(PKGDATAPATH) + QString("/images/icons/pyramid.png"));
QPixmap myNoPyramidPixmap(QString(PKGDATAPATH) + QString("/images/icons/no_pyramid.png"));
RasterPyramidList myPyramidList = rasterLayer->buildRasterPyramidList();
@ -770,6 +774,9 @@ void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
// repopulate the pyramids list
//
lbxPyramidResolutions->clear();
#ifdef WIN32
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
#endif
QPixmap myPyramidPixmap(QString(PKGDATAPATH) + QString("/images/icons/pyramid.png"));
QPixmap myNoPyramidPixmap(QString(PKGDATAPATH) + QString("/images/icons/no_pyramid.png"));
RasterPyramidList::iterator myRasterPyramidIterator;

View File

@ -19,7 +19,11 @@
/* $Id$ */
#ifndef QGSRASTERLAYERPROPERTIES_H
#define QGSRASTERLAYERPROPERTIES_H
#ifdef WIN32
#include "qgsrasterlayerpropertiesbase.h"
#else
#include "qgsrasterlayerpropertiesbase.uic.h"
#endif
#include "qgsmaplayer.h"
#include "qgsrasterlayer.h"

View File

@ -25,6 +25,7 @@
#include "qgsrenderitem.h"
#include "qgsdlgvectorlayerproperties.h"
#include "qgslegenditem.h"
#include <qapplication.h>
#include <qfiledialog.h>
#include <qpushbutton.h>
#include <qlineedit.h>
@ -42,7 +43,7 @@ QgsSiMaDialog::QgsSiMaDialog(QgsVectorLayer* vectorlayer): QgsSiMaDialogBase(),
//initial settings, use the buffer of the propertiesDialog if possible. If this is not possible, use the renderer of the vectorlayer directly
if (mVectorLayer->propertiesDialog())
{
renderer = dynamic_cast < QgsSiMaRenderer * >(mVectorLayer->propertiesDialog()->getBufferRenderer());
renderer = dynamic_cast < QgsSiMaRenderer * >(mVectorLayer->propertiesDialog()->getBufferRenderer());
}
else
{
@ -79,7 +80,7 @@ QgsSiMaDialog::QgsSiMaDialog(QgsVectorLayer* vectorlayer): QgsSiMaDialogBase(),
p.scale(scalefactor,scalefactor);
p.drawPicture(0,0,pic);
pmPreview->setPixmap(pixmap);
pmPreview->setName(svgfile);
pmPreview->setName(svgfile);
}
else
@ -92,11 +93,14 @@ QgsSiMaDialog::QgsSiMaDialog(QgsVectorLayer* vectorlayer): QgsSiMaDialogBase(),
{
qWarning("Warning, typecast failed in qgssimadialog.cpp on line 42 or 46");
}
//set the dir to the default svg dir
//set the dir to the default svg dir
#ifdef WIN32
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
#endif
mCurrentDir=QString(PKGDATAPATH)+"/svg/";
#ifdef QGISDEBUG
qWarning("mCurrentDir in constructor: "+mCurrentDir);
qWarning("mCurrentDir in constructor: "+mCurrentDir);
#endif
visualizeMarkers(mCurrentDir);
mDirectoryEdit->setText(mCurrentDir);
@ -256,9 +260,9 @@ void QgsSiMaDialog::mScaleSpin_valueChanged( int theSize)
pic.load(svgfile,"svg");
int width=pic.boundingRect().width();
width=static_cast<int>(static_cast<double>(width)*scalefactor);
width=static_cast<int>(static_cast<double>(width)*scalefactor);
int height=pic.boundingRect().height();
height=static_cast<int>(static_cast<double>(height)*scalefactor);
height=static_cast<int>(static_cast<double>(height)*scalefactor);
//prevent 0 width or height, which would cause a crash
if(width==0)
{
@ -318,6 +322,9 @@ void QgsSiMaDialog::visualizeMarkers(QString directory)
QString QgsSiMaDialog::defaultDir()
{
#ifdef WIN32
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
#endif
QString dir = QString(PKGDATAPATH)+"/svg";
return dir;
}

View File

@ -19,8 +19,11 @@
#ifndef QGSSIMADIALOG_H
#define QGSSIMADIALOG_H
#ifdef WIN32
#include "qgssimadialogbase.h"
#else
#include "qgssimadialogbase.uic.h"
#endif
#include <qiconview.h>

View File

@ -18,8 +18,11 @@
#ifndef QGSSISYDIALOG_H
#define QGSSISYDIALOG_H
#ifdef WIN32
#include "qgssisydialogbase.h"
#else
#include "qgssisydialogbase.uic.h"
#endif
class QgsVectorLayer;

View File

@ -68,7 +68,9 @@ QgsVectorLayerProperties::~QgsVectorLayerProperties()
QgsSymbol *QgsVectorLayerProperties::getSymbol()
{
//TODO Added return statement during win32 port
//TODO Check on this and remove or fix
return 0;
}
void QgsVectorLayerProperties::alterLayerDialog(const QString & string)

View File

@ -21,7 +21,11 @@
class QgsVectorLayer;
#include "qgssymbol.h"
class QString;
#ifdef WIN32
#include "qgsvectorlayerpropertiesbase.h"
#else
#include "qgsvectorlayerpropertiesbase.uic.h"
#endif
#include "qgsrenderer.h"
#include "qpixmap.h"

View File

@ -21,7 +21,9 @@
#include "splashscreen.h"
#include "qfont.h"
#include "qgis.h"
#ifdef WIN32
QString PKGDATAPATH = qApp->applicationDirPath() + "/qgis/share";
#endif
SplashScreen::SplashScreen():QWidget(0, 0, WStyle_Customize | WStyle_Splash)
{
splashImage.load(QString(PKGDATAPATH) + QString("/images/splash/splash.png"));