Skip to content
Permalink
Browse files

Removed unused functions and polished UI

  • Loading branch information
homann committed Sep 5, 2012
1 parent 655fe1e commit 91ab330324927c617efaf51755d8b814563a6158
Showing with 8 additions and 123 deletions.
  1. +4 −113 src/app/qgsoptions.cpp
  2. +4 −10 src/app/qgsoptions.h
@@ -1207,8 +1207,8 @@ void QgsOptions::populateEllipsoidList()

myItem.acronym = GEO_NONE;
myItem.description = tr( GEO_NONE_DESC );
myItem.semiMajor = 0.0;
myItem.semiMinor = 0.0;
myItem.semiMajor = 1 / 0.0; // Should return +Inf
myItem.semiMinor = 1 / 0.0; // Should reutrn +Inf;
mEllipsoidList.append( myItem );

myItem.acronym = QString( "PARAMETER:6370997:6370997" );
@@ -1277,115 +1277,6 @@ void QgsOptions::populateEllipsoidList()
}
}

void QgsOptions::getEllipsoidList()
{
// (copied from qgscustomprojectiondialog.cpp)

//
// Populate the ellipsoid combo
//
sqlite3 *myDatabase;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;


cmbEllipsoid->addItem( tr( GEO_NONE_DESC ) );
cmbEllipsoid->addItem( tr( "Parameters:" ) );

//check the db is available
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
if ( myResult )
{
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
Q_ASSERT( myResult == 0 );
}

// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select * from tbl_ellipsoid order by name";
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
// XXX Need to free memory from the error msg if one is set
if ( myResult == SQLITE_OK )
{
while ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
{
cmbEllipsoid->addItem(( const char * )sqlite3_column_text( myPreparedStatement, 1 ) );
}
}
// close the sqlite3 statement
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
}

QString QgsOptions::getEllipsoidAcronym( QString theEllipsoidName )
{
sqlite3 *myDatabase;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
QString myName = GEO_NONE;

//check the db is available
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
if ( myResult )
{
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
Q_ASSERT( myResult == 0 );
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select acronym from tbl_ellipsoid where name='" + theEllipsoidName + "'";
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
// XXX Need to free memory from the error msg if one is set
if ( myResult == SQLITE_OK )
{
if ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
myName = QString(( const char * )sqlite3_column_text( myPreparedStatement, 0 ) );
}
// close the sqlite3 statement
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
return myName;

}

QString QgsOptions::getEllipsoidName( QString theEllipsoidAcronym )
{
sqlite3 *myDatabase;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
QString myName;

myName = tr( GEO_NONE_DESC );
//check the db is available
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
if ( myResult )
{
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
Q_ASSERT( myResult == 0 );
}
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
QString mySql = "select name from tbl_ellipsoid where acronym='" + theEllipsoidAcronym + "'";
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
// XXX Need to free memory from the error msg if one is set
if ( myResult == SQLITE_OK )
{
if ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
myName = QString(( const char * )sqlite3_column_text( myPreparedStatement, 0 ) );
}
// close the sqlite3 statement
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
return myName;

}

QStringList QgsOptions::i18nList()
{
QStringList myList;
@@ -1830,13 +1721,13 @@ void QgsOptions::updateEllipsoidUI( int newIndex )
leSemiMinor->setToolTip( QString( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Parameters:" ) ) );
}
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
leSemiMajor->setText( QLocale::system().toString( myMajor, 'f', 3 ) );
leSemiMinor->setText( QLocale::system().toString( myMinor, 'f', 3 ) );
}
else
{
cmbEllipsoid->setEnabled( false );
cmbEllipsoid->setToolTip( tr( "Can only use ellipsoidal calculations when CRS transformation is enabled" ) );
}
leSemiMajor->setText( QLocale::system().toString( myMajor, 'f', 3 ) );
leSemiMinor->setText( QLocale::system().toString( myMinor, 'f', 3 ) );

}
@@ -184,16 +184,9 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
/* Update ComboBox accorindg to the selected new index
* Also sets the new selected Ellipsoid.
* @note added in 2.0
*/
*/
void updateEllipsoidUI( int newIndex );

protected:
//! Populates combo box with ellipsoids
void getEllipsoidList();

QString getEllipsoidAcronym( QString theEllipsoidName );
QString getEllipsoidName( QString theEllipsoidAcronym );

private:
QStringList i18nList();
void initContrastEnhancement( QComboBox *cbox, QString name, QString defaultVal );
@@ -203,7 +196,8 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
bool mLoadedGdalDriverList;

// List for all ellispods, also None and Custom
struct EllipsoidDefs {
struct EllipsoidDefs
{
QString acronym;
QString description;
double semiMajor;
@@ -214,7 +208,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase

//! Populates list with ellipsoids from Sqlite3 db
void populateEllipsoidList();

static const char * GEO_NONE_DESC;
};

0 comments on commit 91ab330

Please sign in to comment.
You can’t perform that action at this time.