[QGIS Commit] r13125 - in trunk/qgis: resources src/gui src/ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Mar 20 19:41:56 EDT 2010
Author: jef
Date: 2010-03-20 19:41:55 -0400 (Sat, 20 Mar 2010)
New Revision: 13125
Modified:
trunk/qgis/resources/srs.db
trunk/qgis/src/gui/qgsprojectionselector.cpp
trunk/qgis/src/gui/qgsprojectionselector.h
trunk/qgis/src/ui/qgsprojectionselectorbase.ui
Log:
[FEATURE] allow to hide deprecated CRSes
Modified: trunk/qgis/resources/srs.db
===================================================================
(Binary files differ)
Modified: trunk/qgis/src/gui/qgsprojectionselector.cpp
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.cpp 2010-03-20 23:30:23 UTC (rev 13124)
+++ trunk/qgis/src/gui/qgsprojectionselector.cpp 2010-03-20 23:41:55 UTC (rev 13125)
@@ -16,7 +16,7 @@
#include <sqlite3.h>
//qgis includes
-#include "qgis.h" //magick numbers here
+#include "qgis.h" //magic numbers here
#include "qgsapplication.h"
#include "qgslogger.h"
#include <qgscoordinatereferencesystem.h>
@@ -36,15 +36,13 @@
const int QGIS_CRS_ID_COLUMN = 2;
const int POPULAR_CRSES = 3;
-QgsProjectionSelector::QgsProjectionSelector( QWidget* parent,
- const char * name,
- Qt::WFlags fl )
- : QWidget( parent, fl ),
- mProjListDone( FALSE ),
- mUserProjListDone( FALSE ),
- mCRSNameSelectionPending( FALSE ),
- mCRSIDSelectionPending( FALSE ),
- mAuthIDSelectionPending( FALSE )
+QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char * name, Qt::WFlags fl )
+ : QWidget( parent, fl )
+ , mProjListDone( false )
+ , mUserProjListDone( false )
+ , mCRSNameSelectionPending( false )
+ , mCRSIDSelectionPending( false )
+ , mAuthIDSelectionPending( false )
{
setupUi( this );
connect( lstCoordinateSystems, SIGNAL( currentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ),
@@ -268,9 +266,9 @@
void QgsProjectionSelector::setSelectedCrsName( QString theCRSName )
{
mCRSNameSelection = theCRSName;
- mCRSNameSelectionPending = TRUE;
- mCRSIDSelectionPending = FALSE; // only one type can be pending at a time
- mAuthIDSelectionPending = TRUE;
+ mCRSNameSelectionPending = true;
+ mCRSIDSelectionPending = false; // only one type can be pending at a time
+ mAuthIDSelectionPending = true;
if ( isVisible() )
{
@@ -285,9 +283,9 @@
void QgsProjectionSelector::setSelectedCrsId( long theCRSID )
{
mCRSIDSelection = theCRSID;
- mCRSIDSelectionPending = TRUE;
- mCRSNameSelectionPending = FALSE; // only one type can be pending at a time
- mAuthIDSelectionPending = FALSE;
+ mCRSIDSelectionPending = true;
+ mCRSNameSelectionPending = false; // only one type can be pending at a time
+ mAuthIDSelectionPending = false;
if ( isVisible() )
{
@@ -306,9 +304,9 @@
void QgsProjectionSelector::setSelectedAuthId( QString id )
{
mAuthIDSelection = id;
- mCRSIDSelectionPending = FALSE;
- mAuthIDSelectionPending = TRUE;
- mCRSNameSelectionPending = FALSE; // only one type can be pending at a time
+ mCRSIDSelectionPending = false;
+ mAuthIDSelectionPending = true;
+ mCRSNameSelectionPending = false; // only one type can be pending at a time
}
void QgsProjectionSelector::applyCRSNameSelection()
@@ -334,7 +332,7 @@
teProjection->setText( "" );
}
- mCRSNameSelectionPending = FALSE;
+ mCRSNameSelectionPending = false;
}
}
@@ -379,7 +377,7 @@
teProjection->setText( "" );
}
- mAuthIDSelectionPending = FALSE;
+ mAuthIDSelectionPending = false;
}
}
@@ -402,7 +400,7 @@
teProjection->setText( "" );
}
- mCRSIDSelectionPending = FALSE;
+ mCRSIDSelectionPending = false;
}
}
@@ -654,8 +652,8 @@
mUserProjList = new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr( "User Defined Coordinate Systems" ) ) );
QFont fontTemp = mUserProjList->font( 0 );
- fontTemp.setItalic( TRUE );
- fontTemp.setBold( TRUE );
+ fontTemp.setItalic( true );
+ fontTemp.setBold( true );
mUserProjList->setFont( 0, fontTemp );
mUserProjList->setIcon( 0, QIcon( QgsApplication::activeThemePath() + "user.png" ) );
@@ -671,7 +669,7 @@
{
QgsDebugMsg( "Users qgis.db not found...skipping" );
- mUserProjListDone = TRUE;
+ mUserProjListDone = true;
return;
}
@@ -714,7 +712,7 @@
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
- mUserProjListDone = TRUE;
+ mUserProjListDone = true;
}
void QgsProjectionSelector::loadCrsList( QSet<QString> * crsFilter )
@@ -729,8 +727,8 @@
mGeoList = new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr( "Geographic Coordinate Systems" ) ) );
QFont fontTemp = mGeoList->font( 0 );
- fontTemp.setItalic( TRUE );
- fontTemp.setBold( TRUE );
+ fontTemp.setItalic( true );
+ fontTemp.setBold( true );
mGeoList->setFont( 0, fontTemp );
mGeoList->setIcon( 0, QIcon( QgsApplication::activeThemePath() + "geographic.png" ) );
@@ -738,8 +736,8 @@
mProjList = new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr( "Projected Coordinate Systems" ) ) );
fontTemp = mProjList->font( 0 );
- fontTemp.setItalic( TRUE );
- fontTemp.setBold( TRUE );
+ fontTemp.setItalic( true );
+ fontTemp.setBold( true );
mProjList->setFont( 0, fontTemp );
mProjList->setIcon( 0, QIcon( QgsApplication::activeThemePath() + "transformed.png" ) );
@@ -752,7 +750,7 @@
myFileInfo.setFile( mSrsDatabaseFileName );
if ( !myFileInfo.exists( ) )
{
- mProjListDone = TRUE;
+ mProjListDone = true;
return;
}
@@ -782,7 +780,7 @@
// Set up the query to retrieve the projection information needed to populate the list
//note I am giving the full field names for clarity here and in case someone
//changes the underlying view TS
- sql = QString( "select description, srs_id, auth_id, is_geo, name, parameters from vw_srs where %1 order by name,description" )
+ sql = QString( "select description, srs_id, auth_name||':'||auth_id, is_geo, name, parameters, deprecated from vw_srs where %1 order by name,description" )
.arg( sqlFilter );
rc = sqlite3_prepare( db, sql.toUtf8(), sql.toUtf8().length(), &ppStmt, &pzTail );
@@ -832,7 +830,7 @@
node = new QTreeWidgetItem( mProjList, QStringList( srsType ) );
QFont fontTemp = node->font( 0 );
- fontTemp.setItalic( TRUE );
+ fontTemp.setItalic( true );
node->setFont( 0, fontTemp );
}
else
@@ -849,7 +847,12 @@
newItem->setText( AUTHID_COLUMN, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 2 ) ) );
// display the qgis srs_id (field 1) in the third column of the list view
newItem->setText( QGIS_CRS_ID_COLUMN, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 1 ) ) );
+
}
+
+ // display the qgis deprecated in the user data of the item
+ newItem->setData( 0, Qt::UserRole, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 6 ) ) );
+ newItem->setHidden( cbxHideDeprecated->isChecked() );
}
mProjList->setExpanded( true );
}
@@ -858,7 +861,7 @@
// close the database
sqlite3_close( db );
- mProjListDone = TRUE;
+ mProjListDone = true;
}
@@ -867,7 +870,7 @@
{
// If the item has children, it's not an end node in the tree, and
// hence is just a grouping thingy, not an actual CRS.
- if ( theItem != NULL && theItem->childCount() == 0 )
+ if ( theItem && theItem->childCount() == 0 )
{
// Found a real CRS
QString myDescription;
@@ -879,11 +882,33 @@
else
{
// Not an CRS - remove the highlight so the user doesn't get too confused
- lstCoordinateSystems->setItemSelected( theItem, FALSE ); // TODO - make this work.
+ theItem->setSelected( false );
teProjection->setText( "" );
}
}
+void QgsProjectionSelector::hideDeprecated( QTreeWidgetItem *item )
+{
+ if( item->data( 0, Qt::UserRole ).toBool() )
+ {
+ item->setHidden( cbxHideDeprecated->isChecked() );
+ if( item->isSelected() && item->isHidden() )
+ {
+ teProjection->setText( "" );
+ item->setSelected( false );
+ }
+ }
+
+ for( int i=0; i < item->childCount(); i++ )
+ hideDeprecated( item->child(i) );
+}
+
+void QgsProjectionSelector::on_cbxHideDeprecated_stateChanged()
+{
+ for( int i = 0; i<lstCoordinateSystems->topLevelItemCount(); i++ )
+ hideDeprecated( lstCoordinateSystems->topLevelItem(i) );
+}
+
void QgsProjectionSelector::on_pbnPopular1_clicked()
{
setSelectedCrsId( mRecentProjections.at( 0 ).toLong() );
@@ -893,10 +918,12 @@
{
setSelectedCrsId( mRecentProjections.at( 1 ).toLong() );
}
+
void QgsProjectionSelector::on_pbnPopular3_clicked()
{
setSelectedCrsId( mRecentProjections.at( 2 ).toLong() );
}
+
void QgsProjectionSelector::on_pbnPopular4_clicked()
{
setSelectedCrsId( mRecentProjections.at( 3 ).toLong() );
@@ -904,7 +931,6 @@
void QgsProjectionSelector::on_pbnFind_clicked()
{
-
QgsDebugMsg( "pbnFind..." );
QString mySearchString( sqlSafeString( leSearch->text() ) );
@@ -918,7 +944,10 @@
{
//we need to find what the largest srsid matching our query so we know whether to
//loop backto the beginning
- mySql = "select srs_id from tbl_srs where description like '%" + mySearchString + "%' order by srs_id desc limit 1";
+ mySql = "select srs_id from tbl_srs where description like '%" + mySearchString + "%'";
+ if( cbxHideDeprecated->isChecked() )
+ mySql += " and not deprecated";
+ mySql += " order by srs_id desc limit 1";
long myLargestSrsId = getLargestCRSIDMatch( mySql );
QgsDebugMsg( QString( "Largest CRSID%1" ).arg( myLargestSrsId ) );
//a name search is ambiguous, so we find the first srsid after the current seelcted srsid
@@ -926,14 +955,18 @@
if ( myLargestSrsId <= selectedCrsId() )
{
//roll search around to the beginning
- mySql = "select srs_id from tbl_srs where description like '%" + mySearchString + "%'" +
- " order by srs_id limit 1";
+ mySql = "select srs_id from tbl_srs where description like '%" + mySearchString + "%'";
+ if( cbxHideDeprecated->isChecked() )
+ mySql += " and not deprecated";
+ mySql += " order by srs_id limit 1";
}
else
{
// search ahead of the current position
- mySql = "select srs_id from tbl_srs where description like '%" + mySearchString + "%'" +
- " and srs_id > " + QString::number( selectedCrsId() ) + " order by srs_id limit 1";
+ mySql = "select srs_id from tbl_srs where description like '%" + mySearchString + "%'";
+ if( cbxHideDeprecated->isChecked() )
+ mySql += " and not deprecated";
+ mySql += " and srs_id > " + QString::number( selectedCrsId() ) + " order by srs_id limit 1";
}
}
QgsDebugMsg( QString( " Search sql: %1" ).arg( mySql ) );
@@ -1002,8 +1035,13 @@
// close the sqlite3 statement
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
+ return;
}
}
+
+ QMessageBox::information( this, tr( "Find projection" ), tr( "No matching projection found." ) );
+ lstCoordinateSystems->clearSelection();
+ teProjection->setText( "" );
}
long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
Modified: trunk/qgis/src/gui/qgsprojectionselector.h
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.h 2010-03-20 23:30:23 UTC (rev 13124)
+++ trunk/qgis/src/gui/qgsprojectionselector.h 2010-03-20 23:41:55 UTC (rev 13125)
@@ -110,6 +110,7 @@
void setOgcWmsCrsFilter( QSet<QString> crsFilter );
void on_pbnFind_clicked();
+ void on_cbxHideDeprecated_stateChanged();
void on_pbnPopular1_clicked();
void on_pbnPopular2_clicked();
@@ -233,6 +234,9 @@
//! Most recently used projections (trimmed at 25 entries)
QStringList mRecentProjections;
+ //! hide deprecated CRSes
+ void hideDeprecated( QTreeWidgetItem *item );
+
private slots:
/**private handler for when user selects a cs
*it will cause wktSelected and sridSelected events to be spawned
Modified: trunk/qgis/src/ui/qgsprojectionselectorbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsprojectionselectorbase.ui 2010-03-20 23:30:23 UTC (rev 13124)
+++ trunk/qgis/src/ui/qgsprojectionselectorbase.ui 2010-03-20 23:41:55 UTC (rev 13125)
@@ -153,6 +153,13 @@
</property>
</widget>
</item>
+ <item row="1" column="0" colspan="4">
+ <widget class="QCheckBox" name="cbxHideDeprecated">
+ <property name="text">
+ <string>Hide deprecated CRSs</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
More information about the QGIS-commit
mailing list