mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
- Added QgsBookmark class which implements the spatial bookmarks dialog.
- Added new files to Makefile.am - Changes to the custom projection dialog to use the new qgis.db git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@3209 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
eaab5f3700
commit
4b9cac991c
@ -49,6 +49,7 @@ headers = qgisapp.h \
|
||||
qgsattributedialog.h \
|
||||
qgsattributetabledisplay.h \
|
||||
qgsattributetable.h \
|
||||
qgsbookmarks.h \
|
||||
qgsclipper.h \
|
||||
qgscolortable.h \
|
||||
qgscomposer.h \
|
||||
@ -233,6 +234,7 @@ qgis_MOC = qgisapp.moc.cpp \
|
||||
qgsattributedialog.moc.cpp \
|
||||
qgsattributetabledisplay.moc.cpp \
|
||||
qgsattributetable.moc.cpp \
|
||||
qgsbookmarks.moc.cpp \
|
||||
qgscomposerlabel.moc.cpp \
|
||||
qgscomposermap.moc.cpp \
|
||||
qgscomposer.moc.cpp \
|
||||
@ -299,6 +301,7 @@ qgis_SOURCES = main.cpp \
|
||||
qgsattributedialog.cpp \
|
||||
qgsattributetable.cpp \
|
||||
qgsattributetabledisplay.cpp \
|
||||
qgsbookmarks.cpp \
|
||||
qgsclipper.cpp \
|
||||
qgscolortable.cpp \
|
||||
qgscomposer.cpp \
|
||||
|
@ -114,7 +114,7 @@
|
||||
#include "qgsprojectproperties.h"
|
||||
#include "qgsvectorfilewriter.h"
|
||||
#include "qgscomposer.h"
|
||||
#include "qgsbookmarksbase.uic.h"
|
||||
#include "qgsbookmarks.h"
|
||||
|
||||
|
||||
#include "xpm/qgis.xpm"
|
||||
@ -4456,7 +4456,7 @@ void QgisApp::actionCustomProjection_activated()
|
||||
}
|
||||
void QgisApp::actionShowBookmarks_activated()
|
||||
{
|
||||
QgsBookmarksBase *bookmarks = new QgsBookmarksBase(this);
|
||||
QgsBookmarks *bookmarks = new QgsBookmarks(this);
|
||||
bookmarks->show();
|
||||
}
|
||||
|
||||
|
170
src/qgsbookmarks.cpp
Normal file
170
src/qgsbookmarks.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
/***************************************************************************
|
||||
QgsBookmarks.cpp - Spatial Bookmarks
|
||||
-------------------
|
||||
begin : 2005-04-23
|
||||
copyright : (C) 2005 Gary Sherman
|
||||
email : sherman at mrcc dot com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
//standard includes
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <sqlite3.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <qfileinfo.h>
|
||||
#include <qstring.h>
|
||||
#include <qdir.h>
|
||||
#include <qlistview.h>
|
||||
|
||||
#include "qgsbookmarks.h"
|
||||
|
||||
QgsBookmarks::QgsBookmarks(QWidget *parent, const char *name)
|
||||
{
|
||||
// make sure the users database for bookmarks exists
|
||||
mQGisSettingsDir = QDir::homeDirPath () + "/.qgis/";
|
||||
// first we look for ~/.qgis/qgis.db
|
||||
// if it doesnt exist we copy it in from the global resources dir
|
||||
QFileInfo myFileInfo;
|
||||
mUserDbPath = mQGisSettingsDir + "qgis.db";
|
||||
myFileInfo.setFile(mUserDbPath);
|
||||
if ( !myFileInfo.exists( ) )
|
||||
{
|
||||
// make sure the ~/.qgis dir exists first
|
||||
QDir myUserQGisDir;
|
||||
QString myPath = QDir::homeDirPath();
|
||||
myPath += "/.qgis";
|
||||
myUserQGisDir.setPath(myPath);
|
||||
//now make sure the users .qgis dir exists
|
||||
makeDir(myUserQGisDir);
|
||||
// Get the package data path and set the full path name to the sqlite3 spatial reference
|
||||
// database.
|
||||
#if defined(Q_OS_MACX) || defined(WIN32)
|
||||
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
|
||||
#endif
|
||||
QString myMasterDatabaseFileName = PKGDATAPATH;
|
||||
myMasterDatabaseFileName += "/resources/qgis.db";
|
||||
//now copy the master file into the users .qgis dir
|
||||
std::ifstream myInputStream(myMasterDatabaseFileName.latin1() );
|
||||
|
||||
if (! myInputStream)
|
||||
{
|
||||
std::cerr << "unable to open input file: "
|
||||
<< myMasterDatabaseFileName << " --bailing out! \n";
|
||||
//XXX Do better error handling
|
||||
return ;
|
||||
}
|
||||
|
||||
std::ofstream myOutputStream(QString(mQGisSettingsDir+"qgis.db").latin1());
|
||||
|
||||
if (! myOutputStream)
|
||||
{
|
||||
std::cerr << "cannot open " << QString(mQGisSettingsDir+"qgis.db").latin1() << " for output\n";
|
||||
//XXX Do better error handling
|
||||
return ;
|
||||
}
|
||||
|
||||
char myChar;
|
||||
while (myInputStream.get(myChar))
|
||||
{
|
||||
myOutputStream.put(myChar);
|
||||
}
|
||||
|
||||
}
|
||||
// Note proper queens english on next line
|
||||
initialise();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
QgsBookmarks::~QgsBookmarks()
|
||||
{
|
||||
}
|
||||
|
||||
// Initialise the bookmark tree from the database
|
||||
void QgsBookmarks::initialise()
|
||||
{
|
||||
sqlite3 *db;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
rc = sqlite3_open(mUserDbPath, &db);
|
||||
if(rc)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
|
||||
|
||||
// XXX This will likely never happen since on open, sqlite creates the
|
||||
// database if it does not exist.
|
||||
assert(rc == 0);
|
||||
}
|
||||
// prepare the sql statement
|
||||
const char *pzTail;
|
||||
sqlite3_stmt *ppStmt;
|
||||
char *pzErrmsg;
|
||||
QString sql = "select * from tbl_bookmarks";
|
||||
|
||||
rc = sqlite3_prepare(db, (const char *)sql, sql.length(), &ppStmt, &pzTail);
|
||||
// XXX Need to free memory from the error msg if one is set
|
||||
if(rc == SQLITE_OK)
|
||||
{
|
||||
// get the first row of the result set
|
||||
while(sqlite3_step(ppStmt) == SQLITE_ROW)
|
||||
{
|
||||
QString name = (char*)sqlite3_column_text(ppStmt, 1);
|
||||
// sqlite3_bind_parameter_index(ppStmt, "name"));
|
||||
std::cout << "Bookmark name: " << name << std::endl;
|
||||
new QListViewItem(lstBookmarks, name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX query failed -- warn the user some how
|
||||
std::cout << "Failed to get bookmarks: " << sqlite3_errmsg(db) << std::endl;
|
||||
}
|
||||
// close the statement
|
||||
sqlite3_finalize(ppStmt);
|
||||
// close the database
|
||||
sqlite3_close(db);
|
||||
// return the srs wkt
|
||||
|
||||
|
||||
}
|
||||
|
||||
// A recursive function to make a directory and its ancestors
|
||||
// XXX Note we use this function in two places, one more and we
|
||||
// XXX should consider making a utility class to contain this and
|
||||
// XXX other, if any functions that are used across the application.
|
||||
bool QgsBookmarks::makeDir(QDir &theQDir)
|
||||
{
|
||||
if (theQDir.isRoot ())
|
||||
{
|
||||
//cannot create a root dir
|
||||
return (false);
|
||||
}
|
||||
|
||||
QDir myBaseDir;
|
||||
QFileInfo myTempFileInfo;
|
||||
|
||||
myTempFileInfo.setFile(theQDir.path());
|
||||
myBaseDir = myTempFileInfo.dir();
|
||||
|
||||
if(!myBaseDir.exists() && !makeDir(myBaseDir))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
qDebug("attempting to create directory %s in %s",
|
||||
(const char *)myTempFileInfo.fileName(),
|
||||
myBaseDir.path().latin1());
|
||||
|
||||
return myBaseDir.mkdir(myTempFileInfo.fileName());
|
||||
}
|
||||
|
||||
|
37
src/qgsbookmarks.h
Normal file
37
src/qgsbookmarks.h
Normal file
@ -0,0 +1,37 @@
|
||||
/***************************************************************************
|
||||
QgsBookmarks.h - Spatial Bookmarks
|
||||
-------------------
|
||||
begin : 2005-04-23
|
||||
copyright : (C) 2005 Gary Sherman
|
||||
email : sherman at mrcc dot com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
#ifndef QGSBOOKMARKS_H
|
||||
#define QGSBOOKMARKS_H
|
||||
#include "qgsbookmarksbase.uic.h"
|
||||
class QString;
|
||||
class QDir;
|
||||
class QgsBookmarks : public QgsBookmarksBase{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsBookmarks(QWidget *parent=0, const char *name=0);
|
||||
~QgsBookmarks();
|
||||
|
||||
private:
|
||||
bool makeDir(QDir &theQDir);
|
||||
void initialise();
|
||||
QString mUserDbPath;
|
||||
QString mQGisSettingsDir;
|
||||
|
||||
};
|
||||
#endif // QGSBOOKMARKS_H
|
||||
|
@ -374,21 +374,24 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
|
||||
int projResult;
|
||||
if(direction == INVERSE)
|
||||
{
|
||||
/*
|
||||
std::cout << "!!!! INVERSE PROJ4 TRANSFORM !!!!" << std::endl;
|
||||
std::cout << " numPoint: " << numPoints << std::endl;
|
||||
std::cout << " x : " << x << std::endl;
|
||||
std::cout << " y : " << y << std::endl;
|
||||
*/
|
||||
projResult = pj_transform(mDestinationProjection, mSourceProjection , numPoints, 0, x, y, z);
|
||||
dir = "inverse";
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
std::cout << "!!!! FORWARD PROJ4 TRANSFORM !!!!" << std::endl;
|
||||
std::cout << " numPoint: " << numPoints << std::endl;
|
||||
std::cout << " x : " << x << std::endl;
|
||||
std::cout << " y : " << y << std::endl;
|
||||
std::cout << " z : " << z << std::endl;
|
||||
|
||||
*/
|
||||
assert(mSourceProjection != 0);
|
||||
assert(mDestinationProjection !=0);
|
||||
projResult = pj_transform(mSourceProjection, mDestinationProjection, numPoints, 0, x, y, z);
|
||||
|
@ -37,17 +37,16 @@
|
||||
#include <qmessagebox.h>
|
||||
|
||||
//stdc++ includes
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const char* name , WFlags fl )
|
||||
: QgsCustomProjectionDialogBase( parent, "Projection Designer", fl )
|
||||
{
|
||||
mQGisSettingsDir = QDir::homeDirPath () + "/.qgis/";
|
||||
// first we look for ~/.qgis/user_projections.db
|
||||
// first we look for ~/.qgis/qgis.db
|
||||
// if it doesnt exist we copy it in from the global resources dir
|
||||
QFileInfo myFileInfo;
|
||||
myFileInfo.setFile(mQGisSettingsDir+"user_projections.db");
|
||||
myFileInfo.setFile(mQGisSettingsDir+"qgis.db");
|
||||
if ( !myFileInfo.exists( ) )
|
||||
{
|
||||
// make sure the ~/.qgis dir exists first
|
||||
@ -63,7 +62,7 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
|
||||
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
|
||||
#endif
|
||||
QString myMasterDatabaseFileName = PKGDATAPATH;
|
||||
myMasterDatabaseFileName += "/resources/user_projections.db";
|
||||
myMasterDatabaseFileName += "/resources/qgis.db";
|
||||
//now copy the master file into the users .qgis dir
|
||||
std::ifstream myInputStream(myMasterDatabaseFileName.latin1() );
|
||||
|
||||
@ -75,11 +74,11 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
|
||||
return ;
|
||||
}
|
||||
|
||||
std::ofstream myOutputStream(QString(mQGisSettingsDir+"user_projections.db").latin1());
|
||||
std::ofstream myOutputStream(QString(mQGisSettingsDir+"qgis.db").latin1());
|
||||
|
||||
if (! myOutputStream)
|
||||
{
|
||||
std::cerr << "cannot open " << QString(mQGisSettingsDir+"user_projections.db").latin1() << " for output\n";
|
||||
std::cerr << "cannot open " << QString(mQGisSettingsDir+"qgis.db").latin1() << " for output\n";
|
||||
//XXX Do better error handling
|
||||
return ;
|
||||
}
|
||||
@ -122,7 +121,7 @@ void QgsCustomProjectionDialog::getProjList ()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -158,7 +157,7 @@ void QgsCustomProjectionDialog::getEllipsoidList()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -206,7 +205,7 @@ void QgsCustomProjectionDialog::pbnDelete_clicked()
|
||||
int myResult;
|
||||
QString myName;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -267,7 +266,7 @@ long QgsCustomProjectionDialog::getRecordCount()
|
||||
int myResult;
|
||||
long myRecordCount=0;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -301,7 +300,7 @@ QString QgsCustomProjectionDialog::getProjectionFamilyName(QString theProjection
|
||||
int myResult;
|
||||
QString myName;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -333,7 +332,7 @@ QString QgsCustomProjectionDialog::getEllipsoidName(QString theEllipsoidAcronym)
|
||||
int myResult;
|
||||
QString myName;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -365,7 +364,7 @@ QString QgsCustomProjectionDialog::getProjectionFamilyAcronym(QString theProject
|
||||
int myResult;
|
||||
QString myName;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -397,7 +396,7 @@ QString QgsCustomProjectionDialog::getEllipsoidAcronym(QString theEllipsoidName)
|
||||
int myResult;
|
||||
QString myName;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -432,7 +431,7 @@ void QgsCustomProjectionDialog::pbnFirst_clicked()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -501,7 +500,7 @@ void QgsCustomProjectionDialog::pbnPrevious_clicked()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -579,7 +578,7 @@ void QgsCustomProjectionDialog::pbnNext_clicked()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -653,7 +652,7 @@ void QgsCustomProjectionDialog::pbnLast_clicked()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -780,7 +779,7 @@ void QgsCustomProjectionDialog::pbnSave_clicked()
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
@ -829,7 +828,7 @@ void QgsCustomProjectionDialog::cboProjectionFamily_highlighted( const QString &
|
||||
sqlite3_stmt *myPreparedStatement;
|
||||
int myResult;
|
||||
//check the db is available
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
|
||||
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
|
||||
if(myResult)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
|
||||
|
@ -593,7 +593,7 @@ std::cerr << i << ": " << ring->first[i]
|
||||
}
|
||||
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
#ifdef QGISDEBUGVERBOSE
|
||||
std::cerr << "Pixel points are:\n";
|
||||
for (int i = 0; i < pa.size(); ++i)
|
||||
std::cerr << i << ": " << pa.point(i).x() << ", "
|
||||
|
Loading…
x
Reference in New Issue
Block a user