Skip to content

Commit 91ab330

Browse files
committed
Removed unused functions and polished UI
1 parent 655fe1e commit 91ab330

File tree

2 files changed

+8
-123
lines changed

2 files changed

+8
-123
lines changed

src/app/qgsoptions.cpp

Lines changed: 4 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,8 @@ void QgsOptions::populateEllipsoidList()
12071207

12081208
myItem.acronym = GEO_NONE;
12091209
myItem.description = tr( GEO_NONE_DESC );
1210-
myItem.semiMajor = 0.0;
1211-
myItem.semiMinor = 0.0;
1210+
myItem.semiMajor = 1 / 0.0; // Should return +Inf
1211+
myItem.semiMinor = 1 / 0.0; // Should reutrn +Inf;
12121212
mEllipsoidList.append( myItem );
12131213

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

1280-
void QgsOptions::getEllipsoidList()
1281-
{
1282-
// (copied from qgscustomprojectiondialog.cpp)
1283-
1284-
//
1285-
// Populate the ellipsoid combo
1286-
//
1287-
sqlite3 *myDatabase;
1288-
const char *myTail;
1289-
sqlite3_stmt *myPreparedStatement;
1290-
int myResult;
1291-
1292-
1293-
cmbEllipsoid->addItem( tr( GEO_NONE_DESC ) );
1294-
cmbEllipsoid->addItem( tr( "Parameters:" ) );
1295-
1296-
//check the db is available
1297-
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1298-
if ( myResult )
1299-
{
1300-
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
1301-
// XXX This will likely never happen since on open, sqlite creates the
1302-
// database if it does not exist.
1303-
Q_ASSERT( myResult == 0 );
1304-
}
1305-
1306-
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
1307-
QString mySql = "select * from tbl_ellipsoid order by name";
1308-
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
1309-
// XXX Need to free memory from the error msg if one is set
1310-
if ( myResult == SQLITE_OK )
1311-
{
1312-
while ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1313-
{
1314-
cmbEllipsoid->addItem(( const char * )sqlite3_column_text( myPreparedStatement, 1 ) );
1315-
}
1316-
}
1317-
// close the sqlite3 statement
1318-
sqlite3_finalize( myPreparedStatement );
1319-
sqlite3_close( myDatabase );
1320-
}
1321-
1322-
QString QgsOptions::getEllipsoidAcronym( QString theEllipsoidName )
1323-
{
1324-
sqlite3 *myDatabase;
1325-
const char *myTail;
1326-
sqlite3_stmt *myPreparedStatement;
1327-
int myResult;
1328-
QString myName = GEO_NONE;
1329-
1330-
//check the db is available
1331-
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1332-
if ( myResult )
1333-
{
1334-
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
1335-
// XXX This will likely never happen since on open, sqlite creates the
1336-
// database if it does not exist.
1337-
Q_ASSERT( myResult == 0 );
1338-
}
1339-
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
1340-
QString mySql = "select acronym from tbl_ellipsoid where name='" + theEllipsoidName + "'";
1341-
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
1342-
// XXX Need to free memory from the error msg if one is set
1343-
if ( myResult == SQLITE_OK )
1344-
{
1345-
if ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1346-
myName = QString(( const char * )sqlite3_column_text( myPreparedStatement, 0 ) );
1347-
}
1348-
// close the sqlite3 statement
1349-
sqlite3_finalize( myPreparedStatement );
1350-
sqlite3_close( myDatabase );
1351-
return myName;
1352-
1353-
}
1354-
1355-
QString QgsOptions::getEllipsoidName( QString theEllipsoidAcronym )
1356-
{
1357-
sqlite3 *myDatabase;
1358-
const char *myTail;
1359-
sqlite3_stmt *myPreparedStatement;
1360-
int myResult;
1361-
QString myName;
1362-
1363-
myName = tr( GEO_NONE_DESC );
1364-
//check the db is available
1365-
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1366-
if ( myResult )
1367-
{
1368-
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
1369-
// XXX This will likely never happen since on open, sqlite creates the
1370-
// database if it does not exist.
1371-
Q_ASSERT( myResult == 0 );
1372-
}
1373-
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
1374-
QString mySql = "select name from tbl_ellipsoid where acronym='" + theEllipsoidAcronym + "'";
1375-
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
1376-
// XXX Need to free memory from the error msg if one is set
1377-
if ( myResult == SQLITE_OK )
1378-
{
1379-
if ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1380-
myName = QString(( const char * )sqlite3_column_text( myPreparedStatement, 0 ) );
1381-
}
1382-
// close the sqlite3 statement
1383-
sqlite3_finalize( myPreparedStatement );
1384-
sqlite3_close( myDatabase );
1385-
return myName;
1386-
1387-
}
1388-
13891280
QStringList QgsOptions::i18nList()
13901281
{
13911282
QStringList myList;
@@ -1830,13 +1721,13 @@ void QgsOptions::updateEllipsoidUI( int newIndex )
18301721
leSemiMinor->setToolTip( QString( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Parameters:" ) ) );
18311722
}
18321723
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
1833-
leSemiMajor->setText( QLocale::system().toString( myMajor, 'f', 3 ) );
1834-
leSemiMinor->setText( QLocale::system().toString( myMinor, 'f', 3 ) );
18351724
}
18361725
else
18371726
{
18381727
cmbEllipsoid->setEnabled( false );
18391728
cmbEllipsoid->setToolTip( tr( "Can only use ellipsoidal calculations when CRS transformation is enabled" ) );
18401729
}
1730+
leSemiMajor->setText( QLocale::system().toString( myMajor, 'f', 3 ) );
1731+
leSemiMinor->setText( QLocale::system().toString( myMinor, 'f', 3 ) );
18411732

18421733
}

src/app/qgsoptions.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,9 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
184184
/* Update ComboBox accorindg to the selected new index
185185
* Also sets the new selected Ellipsoid.
186186
* @note added in 2.0
187-
*/
187+
*/
188188
void updateEllipsoidUI( int newIndex );
189189

190-
protected:
191-
//! Populates combo box with ellipsoids
192-
void getEllipsoidList();
193-
194-
QString getEllipsoidAcronym( QString theEllipsoidName );
195-
QString getEllipsoidName( QString theEllipsoidAcronym );
196-
197190
private:
198191
QStringList i18nList();
199192
void initContrastEnhancement( QComboBox *cbox, QString name, QString defaultVal );
@@ -203,7 +196,8 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
203196
bool mLoadedGdalDriverList;
204197

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

215209
//! Populates list with ellipsoids from Sqlite3 db
216210
void populateEllipsoidList();
217-
211+
218212
static const char * GEO_NONE_DESC;
219213
};
220214

0 commit comments

Comments
 (0)