Skip to content

Commit

Permalink
Better fix for the issues raised in r5618 and r5626 - the selected it…
Browse files Browse the repository at this point in the history
…em is now scrolled into view, even when the projection selector is being opened.

There still seems to be a slight issue when showing the Project Properties for the first time on a blank project (i.e. it scrolls *near* the WGS 84 entry, but not quite on top of it), but I'll leave that for another time.  Other situations now seem to work OK.



git-svn-id: http://svn.osgeo.org/qgis/trunk@5642 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Jul 27, 2006
1 parent 44585e5 commit 4015a6f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
67 changes: 27 additions & 40 deletions src/widgets/projectionselector/qgsprojectionselector.cpp
Expand Up @@ -73,6 +73,17 @@ void QgsProjectionSelector::showEvent ( QShowEvent * theEvent )
applyUserProjList(&mCrsFilter);
}

// check if a paricular projection is waiting
// to be pre-selected, and if so, to select it now.
if (mSRSNameSelectionPending)
{
applySRSNameSelection();
}
if (mSRSIDSelectionPending)
{
applySRSIDSelection();
}

// Pass up the inheritance heirarchy
QWidget::showEvent(theEvent);
}
Expand Down Expand Up @@ -146,43 +157,33 @@ QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression(QSet<QString> * cr

void QgsProjectionSelector::setSelectedSRSName(QString theSRSName)
{
// ensure the projection list view is actually populated
// before we select from its contents

if (!mProjListDone)
{
applyProjList(&mCrsFilter);
}
mSRSNameSelection = theSRSName;
mSRSNameSelectionPending = TRUE;
mSRSIDSelectionPending = FALSE; // only one type can be pending at a time

if (!mUserProjListDone)
if (isVisible())
{
applyUserProjList(&mCrsFilter);
applySRSNameSelection();
}

mSRSNameSelection = theSRSName;
mSRSNameSelectionPending = TRUE;
applySRSNameSelection();
// else we will wait for the projection selector to
// become visible (with the showEvent()) and set the
// selection there
}


void QgsProjectionSelector::setSelectedSRSID(long theSRSID)
{
// ensure the projection list view is actually populated
// before we select from its contents

if (!mProjListDone)
{
applyProjList(&mCrsFilter);
}
mSRSIDSelection = theSRSID;
mSRSIDSelectionPending = TRUE;
mSRSNameSelectionPending = FALSE; // only one type can be pending at a time

if (!mUserProjListDone)
if (isVisible())
{
applyUserProjList(&mCrsFilter);
applySRSIDSelection();
}

mSRSIDSelection = theSRSID;
mSRSIDSelectionPending = TRUE;
applySRSIDSelection();
// else we will wait for the projection selector to
// become visible (with the showEvent()) and set the
// selection there
}


Expand All @@ -203,11 +204,6 @@ void QgsProjectionSelector::applySRSNameSelection()
if (nodes.count() > 0)
{
lstCoordinateSystems->setCurrentItem(nodes.first());

// The following seems to be broken in Qt 4.1.0:
// It only works if the widget is already visible.
// (Which makes it really hard to scroll to an
// item before you exec() the widget)
lstCoordinateSystems->scrollToItem(nodes.first());
}
else // unselect the selected item to avoid confusing the user
Expand Down Expand Up @@ -235,11 +231,6 @@ void QgsProjectionSelector::applySRSIDSelection()
if (nodes.count() > 0)
{
lstCoordinateSystems->setCurrentItem(nodes.first());

// The following seems to be broken in Qt 4.1.0:
// It only works if the widget is already visible.
// (Which makes it really hard to scroll to an
// item before you exec() the widget)
lstCoordinateSystems->scrollToItem(nodes.first());
}
else // unselect the selected item to avoid confusing the user
Expand Down Expand Up @@ -795,10 +786,6 @@ void QgsProjectionSelector::coordinateSystemSelected( QTreeWidgetItem * theItem)
myDescription+=(myProjString);
}

// The following seems to be broken in Qt 4.1.0:
// It only works if the widget is already visible.
// (Which makes it really hard to scroll to an
// item before you exec() the widget)
lstCoordinateSystems->scrollToItem(theItem);
teProjection->setText(myDescription);
}
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/projectionselector/qgsprojectionselector.h
Expand Up @@ -127,6 +127,10 @@ class QgsProjectionSelector: public QWidget, private Ui::QgsProjectionSelectorBa
*
* \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 applySRSNameSelection();

Expand All @@ -135,6 +139,10 @@ class QgsProjectionSelector: public QWidget, private Ui::QgsProjectionSelectorBa
*
* \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 applySRSIDSelection();

Expand Down

0 comments on commit 4015a6f

Please sign in to comment.