[QGIS Commit] r15523 - trunk/qgis/src/gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Mar 16 16:24:38 EDT 2011
Author: jef
Date: 2011-03-16 13:24:38 -0700 (Wed, 16 Mar 2011)
New Revision: 15523
Modified:
trunk/qgis/src/gui/qgsprojectionselector.cpp
trunk/qgis/src/gui/qgsprojectionselector.h
Log:
fix #3624
Modified: trunk/qgis/src/gui/qgsprojectionselector.cpp
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.cpp 2011-03-16 20:03:42 UTC (rev 15522)
+++ trunk/qgis/src/gui/qgsprojectionselector.cpp 2011-03-16 20:24:38 UTC (rev 15523)
@@ -163,18 +163,10 @@
// check if a paricular projection is waiting
// to be pre-selected, and if so, to select it now.
- if ( mCRSNameSelectionPending )
+ if ( mCRSNameSelectionPending || mCRSIDSelectionPending || mAuthIDSelectionPending )
{
- applyCRSNameSelection();
+ applySelection();
}
- if ( mCRSIDSelectionPending )
- {
- applyCRSIDSelection();
- }
- if ( mAuthIDSelectionPending )
- {
- applyAuthIDSelection();
- }
for ( int i = mRecentProjections.size() - 1; i >= 0; i-- )
insertRecent( mRecentProjections.at( i ).toLong() );
@@ -253,7 +245,7 @@
if ( isVisible() )
{
- applyCRSNameSelection();
+ applySelection();
}
// else we will wait for the projection selector to
// become visible (with the showEvent()) and set the
@@ -270,7 +262,7 @@
if ( isVisible() )
{
- applyCRSIDSelection();
+ applySelection();
}
// else we will wait for the projection selector to
// become visible (with the showEvent()) and set the
@@ -290,30 +282,49 @@
mCRSNameSelectionPending = false; // only one type can be pending at a time
}
-void QgsProjectionSelector::applyCRSNameSelection()
+void QgsProjectionSelector::applySelection()
{
- if (
- mCRSNameSelectionPending &&
- mProjListDone &&
- mUserProjListDone
- )
+ if ( !mProjListDone || !mUserProjListDone )
+ return;
+
+ QList<QTreeWidgetItem*> nodes;
+ if ( mCRSNameSelectionPending )
{
//get the srid given the wkt so we can pick the correct list item
QgsDebugMsg( "called with " + mCRSNameSelection );
- QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( mCRSNameSelection, Qt::MatchExactly | Qt::MatchRecursive, 0 );
+ nodes = lstCoordinateSystems->findItems( mCRSNameSelection, Qt::MatchExactly | Qt::MatchRecursive, 0 );
- if ( nodes.count() > 0 )
- {
- lstCoordinateSystems->setCurrentItem( nodes.first() );
- }
- else // unselect the selected item to avoid confusing the user
- {
- lstCoordinateSystems->clearSelection();
- teProjection->setText( "" );
- }
-
mCRSNameSelectionPending = false;
}
+
+ if ( mAuthIDSelectionPending )
+ {
+ //get the srid given the wkt so we can pick the correct list item
+ QgsDebugMsg( "called with " + mAuthIDSelection );
+ nodes = lstCoordinateSystems->findItems( mAuthIDSelection, Qt::MatchExactly | Qt::MatchRecursive, AUTHID_COLUMN );
+
+ mAuthIDSelectionPending = false;
+ }
+
+ if ( mCRSIDSelectionPending )
+ {
+ QString myCRSIDString = QString::number( mCRSIDSelection );
+
+ nodes = lstCoordinateSystems->findItems( myCRSIDString, Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );
+
+ mCRSIDSelectionPending = false;
+ }
+
+ if ( nodes.count() > 0 )
+ {
+ lstCoordinateSystems->setCurrentItem( nodes.first() );
+ lstCoordinateSystems->scrollToItem( lstCoordinateSystems->currentItem(), QAbstractItemView::PositionAtCenter );
+ }
+ else // unselect the selected item to avoid confusing the user
+ {
+ lstCoordinateSystems->clearSelection();
+ teProjection->setText( "" );
+ }
}
void QgsProjectionSelector::insertRecent( long theCrsId )
@@ -332,51 +343,6 @@
<< nodes.first()->text( QGIS_CRS_ID_COLUMN ) ) );
}
-void QgsProjectionSelector::applyAuthIDSelection()
-{
- if ( mAuthIDSelectionPending && mProjListDone && mUserProjListDone )
- {
- //get the srid given the wkt so we can pick the correct list item
- QgsDebugMsg( "called with " + mAuthIDSelection );
- QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( mAuthIDSelection, Qt::MatchExactly | Qt::MatchRecursive, AUTHID_COLUMN );
-
- if ( nodes.count() > 0 )
- {
- lstCoordinateSystems->setCurrentItem( nodes.first() );
- }
- else // unselect the selected item to avoid confusing the user
- {
- lstCoordinateSystems->clearSelection();
- teProjection->setText( "" );
- }
-
- mAuthIDSelectionPending = false;
- }
-}
-
-void QgsProjectionSelector::applyCRSIDSelection()
-{
- if ( mCRSIDSelectionPending && mProjListDone && mUserProjListDone )
- {
- QString myCRSIDString = QString::number( mCRSIDSelection );
-
- QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( myCRSIDString, Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );
-
- if ( nodes.count() > 0 )
- {
- lstCoordinateSystems->setCurrentItem( nodes.first() );
- }
- else // unselect the selected item to avoid confusing the user
- {
- lstCoordinateSystems->clearSelection();
- teProjection->setText( "" );
- }
-
- mCRSIDSelectionPending = false;
- }
-}
-
-
//note this line just returns the projection name!
QString QgsProjectionSelector::selectedName()
{
@@ -848,7 +814,7 @@
QString myDescription;
emit sridSelected( QString::number( selectedCrsId() ) );
QString myProjString = selectedProj4String();
- lstCoordinateSystems->scrollToItem( theItem, QAbstractItemView::PositionAtCenter );
+ lstCoordinateSystems->scrollToItem( theItem );
teProjection->setText( myProjString );
lstRecent->clearSelection();
@@ -868,8 +834,8 @@
item->setHidden( cbxHideDeprecated->isChecked() );
if ( item->isSelected() && item->isHidden() )
{
- teProjection->setText( "" );
item->setSelected( false );
+ teProjection->setText( "" );
}
}
Modified: trunk/qgis/src/gui/qgsprojectionselector.h
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.h 2011-03-16 20:03:42 UTC (rev 15522)
+++ trunk/qgis/src/gui/qgsprojectionselector.h 2011-03-16 20:24:38 UTC (rev 15523)
@@ -140,7 +140,7 @@
QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> * crsFilter );
/**
- * \brief does the legwork of applying the CRS Name Selection
+ * \brief does the legwork of applying CRS Selection
*
* \warning This function does nothing unless getUserList() and getUserProjList()
* Have already been called
@@ -149,33 +149,9 @@
* does not scroll the list to the selection if the widget is not visible.
* Therefore you will typically want to use this in a showEvent().
*/
- void applyCRSNameSelection();
+ void applySelection();
/**
- * \brief does the legwork of applying the CRS ID Selection
- *
- * \warning This function does nothing unless getUserList() and getUserProjList()
- * Have already been called
- *
- * \warning This function only expands the parents of the selection and
- * does not scroll the list to the selection if the widget is not visible.
- * Therefore you will typically want to use this in a showEvent().
- */
- void applyCRSIDSelection();
-
- /**
- * \brief does the legwork of applying the Authority ID Selection
- *
- * \warning This function does nothing unless getUserList() and getUserProjList()
- * Have already been called
- *
- * \warning This function only expands the parents of the selection and
- * does not scroll the list to the selection if the widget is not visible.
- * Therefore you will typically want to use this in a showEvent().
- */
- void applyAuthIDSelection();
-
- /**
* \brief gets an arbitrary sqlite3 expression from the selection
*
* \param e The sqlite3 expression (typically "srid" or "sridid")
More information about the QGIS-commit
mailing list