@@ -73,6 +73,17 @@ void QgsProjectionSelector::showEvent ( QShowEvent * theEvent )
73
73
applyUserProjList (&mCrsFilter );
74
74
}
75
75
76
+ // check if a paricular projection is waiting
77
+ // to be pre-selected, and if so, to select it now.
78
+ if (mSRSNameSelectionPending )
79
+ {
80
+ applySRSNameSelection ();
81
+ }
82
+ if (mSRSIDSelectionPending )
83
+ {
84
+ applySRSIDSelection ();
85
+ }
86
+
76
87
// Pass up the inheritance heirarchy
77
88
QWidget::showEvent (theEvent);
78
89
}
@@ -146,43 +157,33 @@ QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression(QSet<QString> * cr
146
157
147
158
void QgsProjectionSelector::setSelectedSRSName (QString theSRSName)
148
159
{
149
- // ensure the projection list view is actually populated
150
- // before we select from its contents
151
-
152
- if (!mProjListDone )
153
- {
154
- applyProjList (&mCrsFilter );
155
- }
160
+ mSRSNameSelection = theSRSName;
161
+ mSRSNameSelectionPending = TRUE ;
162
+ mSRSIDSelectionPending = FALSE ; // only one type can be pending at a time
156
163
157
- if (! mUserProjListDone )
164
+ if (isVisible () )
158
165
{
159
- applyUserProjList (& mCrsFilter );
166
+ applySRSNameSelection ( );
160
167
}
161
-
162
- mSRSNameSelection = theSRSName;
163
- mSRSNameSelectionPending = TRUE ;
164
- applySRSNameSelection ();
168
+ // else we will wait for the projection selector to
169
+ // become visible (with the showEvent()) and set the
170
+ // selection there
165
171
}
166
172
167
173
168
174
void QgsProjectionSelector::setSelectedSRSID (long theSRSID)
169
175
{
170
- // ensure the projection list view is actually populated
171
- // before we select from its contents
172
-
173
- if (!mProjListDone )
174
- {
175
- applyProjList (&mCrsFilter );
176
- }
176
+ mSRSIDSelection = theSRSID;
177
+ mSRSIDSelectionPending = TRUE ;
178
+ mSRSNameSelectionPending = FALSE ; // only one type can be pending at a time
177
179
178
- if (! mUserProjListDone )
180
+ if (isVisible () )
179
181
{
180
- applyUserProjList (& mCrsFilter );
182
+ applySRSIDSelection ( );
181
183
}
182
-
183
- mSRSIDSelection = theSRSID;
184
- mSRSIDSelectionPending = TRUE ;
185
- applySRSIDSelection ();
184
+ // else we will wait for the projection selector to
185
+ // become visible (with the showEvent()) and set the
186
+ // selection there
186
187
}
187
188
188
189
@@ -203,11 +204,6 @@ void QgsProjectionSelector::applySRSNameSelection()
203
204
if (nodes.count () > 0 )
204
205
{
205
206
lstCoordinateSystems->setCurrentItem (nodes.first ());
206
-
207
- // The following seems to be broken in Qt 4.1.0:
208
- // It only works if the widget is already visible.
209
- // (Which makes it really hard to scroll to an
210
- // item before you exec() the widget)
211
207
lstCoordinateSystems->scrollToItem (nodes.first ());
212
208
}
213
209
else // unselect the selected item to avoid confusing the user
@@ -235,11 +231,6 @@ void QgsProjectionSelector::applySRSIDSelection()
235
231
if (nodes.count () > 0 )
236
232
{
237
233
lstCoordinateSystems->setCurrentItem (nodes.first ());
238
-
239
- // The following seems to be broken in Qt 4.1.0:
240
- // It only works if the widget is already visible.
241
- // (Which makes it really hard to scroll to an
242
- // item before you exec() the widget)
243
234
lstCoordinateSystems->scrollToItem (nodes.first ());
244
235
}
245
236
else // unselect the selected item to avoid confusing the user
@@ -795,10 +786,6 @@ void QgsProjectionSelector::coordinateSystemSelected( QTreeWidgetItem * theItem)
795
786
myDescription+=(myProjString);
796
787
}
797
788
798
- // The following seems to be broken in Qt 4.1.0:
799
- // It only works if the widget is already visible.
800
- // (Which makes it really hard to scroll to an
801
- // item before you exec() the widget)
802
789
lstCoordinateSystems->scrollToItem (theItem);
803
790
teProjection->setText (myDescription);
804
791
}
0 commit comments