git-svn-id: http://svn.osgeo.org/qgis/trunk@15523 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2011-03-16 20:24:38 +00:00
parent 31d7cc1d5a
commit fb666a2eb0
2 changed files with 44 additions and 102 deletions

View File

@ -163,17 +163,9 @@ void QgsProjectionSelector::showEvent( QShowEvent * theEvent )
// 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();
}
if ( mCRSIDSelectionPending )
{
applyCRSIDSelection();
}
if ( mAuthIDSelectionPending )
{
applyAuthIDSelection();
applySelection();
}
for ( int i = mRecentProjections.size() - 1; i >= 0; i-- )
@ -253,7 +245,7 @@ void QgsProjectionSelector::setSelectedCrsName( QString theCRSName )
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 @@ void QgsProjectionSelector::setSelectedCrsId( long theCRSID )
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 @@ void QgsProjectionSelector::setSelectedAuthId( QString id )
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 );
if ( nodes.count() > 0 )
{
lstCoordinateSystems->setCurrentItem( nodes.first() );
}
else // unselect the selected item to avoid confusing the user
{
lstCoordinateSystems->clearSelection();
teProjection->setText( "" );
}
nodes = lstCoordinateSystems->findItems( mCRSNameSelection, Qt::MatchExactly | Qt::MatchRecursive, 0 );
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 @@ void QgsProjectionSelector::insertRecent( long theCrsId )
<< 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 @@ void QgsProjectionSelector::coordinateSystemSelected( QTreeWidgetItem * theItem
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 @@ void QgsProjectionSelector::hideDeprecated( QTreeWidgetItem *item )
item->setHidden( cbxHideDeprecated->isChecked() );
if ( item->isSelected() && item->isHidden() )
{
teProjection->setText( "" );
item->setSelected( false );
teProjection->setText( "" );
}
}

View File

@ -140,7 +140,7 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
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,31 +149,7 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
* 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();
/**
* \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();
void applySelection();
/**
* \brief gets an arbitrary sqlite3 expression from the selection