Skip to content

Commit

Permalink
Wired up move first and move last button sin custom projections dialog.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@3158 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Apr 14, 2005
1 parent 69b88d7 commit 6446f0e
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 46 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -2,6 +2,8 @@
------------------------------------------------------------------------------
Version 0.6 'Simon' .... development version
QGIS Change Log
2005-04-14 [timlinux] 0.6devel15
** Wired up move first and move last buttons on custom projection dialog
2005-04-14 [timlinux] 0.6devel14
** Status bar widgets show text in 8pt arial. Closes bug #1077217
2005-04-13 [timlinux] 0.6devel13
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=6
MICRO_VERSION=0
EXTRA_VERSION=14
EXTRA_VERSION=15
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
Expand Down
291 changes: 278 additions & 13 deletions src/qgscustomprojectiondialog.cpp
Expand Up @@ -41,11 +41,11 @@
QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const char* name , WFlags fl )
: QgsCustomProjectionDialogBase( parent, "Projection Designer", fl )
{
QString myQGisSettingsDir = QDir::homeDirPath () + "/.qgis/";
mQGisSettingsDir = QDir::homeDirPath () + "/.qgis/";
// first we look for ~/.qgis/user_projections.db
// if it doesnt exist we copy it in from the global resources dir
QFileInfo myFileInfo;
myFileInfo.setFile(myQGisSettingsDir+"user_projections.db");
myFileInfo.setFile(mQGisSettingsDir+"user_projections.db");
if ( !myFileInfo.exists( ) )
{
// make sure the ~/.qgis dir exists first
Expand Down Expand Up @@ -73,11 +73,11 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
return ;
}

std::ofstream myOutputStream(QString(myQGisSettingsDir+"user_projections.db").latin1());
std::ofstream myOutputStream(QString(mQGisSettingsDir+"user_projections.db").latin1());

if (! myOutputStream)
{
std::cerr << "cannot open " << QString(myQGisSettingsDir+"user_projections.db").latin1() << " for output\n";
std::cerr << "cannot open " << QString(mQGisSettingsDir+"user_projections.db").latin1() << " for output\n";
//XXX Do better error handling
return ;
}
Expand All @@ -89,6 +89,27 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
}

}

//
// Setup member vars
//
mCurrentRecordId="";
mCurrentRecordNo=0;

//
// Set up databound controls
//
getProjList();
getEllipsoidList();
}

QgsCustomProjectionDialog::~QgsCustomProjectionDialog()
{

}

void QgsCustomProjectionDialog::getProjList ()
{
//
// Populate the projection combo
//
Expand All @@ -98,7 +119,7 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open(QString(myQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
Expand All @@ -119,8 +140,32 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
}
}
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);
}

void QgsCustomProjectionDialog::getEllipsoidList()
{

//
// Populate the ellipsoid combo
//
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
}

// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
mySql = "select * from tbl_ellipsoid order by name";
QString mySql = "select * from tbl_ellipsoid order by name";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
Expand All @@ -134,51 +179,271 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget* parent , const ch
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);
}
void QgsCustomProjectionDialog::pbnHelp_clicked()
{

QgsCustomProjectionDialog::~QgsCustomProjectionDialog()
}


void QgsCustomProjectionDialog::pbnOK_clicked()
{

}


void QgsCustomProjectionDialog::pbnHelp_clicked()
void QgsCustomProjectionDialog::pbnApply_clicked()
{

}


void QgsCustomProjectionDialog::pbnOK_clicked()
void QgsCustomProjectionDialog::pbnCancel_clicked()
{

}


void QgsCustomProjectionDialog::pbnApply_clicked()
long QgsCustomProjectionDialog::getRecordCount()
{
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
long myRecordCount=0;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
}
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select count(*) from tbl_user_projection";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
sqlite3_step(myPreparedStatement) == SQLITE_ROW;
QString myRecordCountString((char *)sqlite3_column_text(myPreparedStatement,0));
myRecordCount=myRecordCountString.toLong();
}
// close the sqlite3 statement
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);
return myRecordCount;

}

QString QgsCustomProjectionDialog::getProjectionFamilyName(QString theProjectionFamilyId)
{
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
QString myName;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
}
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select name from tbl_projection where acronym='" + theProjectionFamilyId + "'";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
sqlite3_step(myPreparedStatement) == SQLITE_ROW;
myName = QString((char *)sqlite3_column_text(myPreparedStatement,0));
}
// close the sqlite3 statement
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);
return myName;

void QgsCustomProjectionDialog::pbnCancel_clicked()
}
QString QgsCustomProjectionDialog::getEllipsoidName(QString theEllipsoidId)
{
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
QString myName;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
}
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select name from tbl_ellipsoid where acronym='" + theEllipsoidId + "'";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
sqlite3_step(myPreparedStatement) == SQLITE_ROW;
myName = QString((char *)sqlite3_column_text(myPreparedStatement,0));
}
// close the sqlite3 statement
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);
return myName;

}

void QgsCustomProjectionDialog::pbnFirst_clicked()
{
#ifdef QGISDEBUG
std::cout << "QgsCustomProjectionDialog::pbnFirst_clicked()" << std::endl;
#endif
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
}

QString mySql = "select * from tbl_user_projection order by description limit 1";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
sqlite3_step(myPreparedStatement) == SQLITE_ROW;
leName->setText((char *)sqlite3_column_text(myPreparedStatement,1));
QString myProjectionFamilyId((char *)sqlite3_column_text(myPreparedStatement,2));
cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId));
QString myEllipsoidId((char *)sqlite3_column_text(myPreparedStatement,3));
cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId));
leParameters->setText((char *)sqlite3_column_text(myPreparedStatement,4));
}
else
{
#ifdef QGISDEBUG
std::cout << "pbnFirst query failed: " << mySql << std::endl;
#endif

}
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);
}


void QgsCustomProjectionDialog::pbnPrevious_clicked()
{
#ifdef QGISDEBUG
std::cout << "QgsCustomProjectionDialog::pbnPrevious_clicked()" << std::endl;
#endif

}


void QgsCustomProjectionDialog::pbnNext_clicked()
{
#ifdef QGISDEBUG
std::cout << "QgsCustomProjectionDialog::pbnNext_clicked()" << std::endl;
#endif

}


void QgsCustomProjectionDialog::pbnLast_clicked()
{
#ifdef QGISDEBUG
std::cout << "QgsCustomProjectionDialog::pbnLast_clicked()" << std::endl;
#endif
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
assert(myResult == 0);
}

QString mySql = "select * from tbl_user_projection order by description desc limit 1";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
sqlite3_step(myPreparedStatement) == SQLITE_ROW;
leName->setText((char *)sqlite3_column_text(myPreparedStatement,1));
QString myProjectionFamilyId((char *)sqlite3_column_text(myPreparedStatement,2));
cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId));
QString myEllipsoidId((char *)sqlite3_column_text(myPreparedStatement,3));
cboEllipsoid->setCurrentText(getProjectionFamilyName(myEllipsoidId));
leParameters->setText((char *)sqlite3_column_text(myPreparedStatement,4));
}
else
{
#ifdef QGISDEBUG
std::cout << "pbnLast query failed: " << mySql << std::endl;
#endif

}
sqlite3_finalize(myPreparedStatement);
sqlite3_close(myDatabase);

}


void QgsCustomProjectionDialog::pbnNew_clicked()
{
#ifdef QGISDEBUG
std::cout << "QgsCustomProjectionDialog::pbnNew_clicked()" << std::endl;
#endif

}


void QgsCustomProjectionDialog::pbnSave_clicked()
{
#ifdef QGISDEBUG
std::cout << "QgsCustomProjectionDialog::pbnSave_clicked()" << std::endl;
#endif

}



void QgsCustomProjectionDialog::cboProjectionFamily_highlighted( const QString & theText)
{
#ifdef QGISDEBUG
std::cout << "Projection selected from combo" << std::endl;
#endif
//search the sqlite user projections db for the projection entry
//and display its parameters
QString myQGisSettingsDir = QDir::homeDirPath () + "/.qgis/";
sqlite3 *myDatabase;
char *myErrorMessage = 0;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open(QString(myQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
myResult = sqlite3_open(QString(mQGisSettingsDir+"user_projections.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
Expand Down

0 comments on commit 6446f0e

Please sign in to comment.