Skip to content

Commit 1b3c383

Browse files
committedNov 22, 2011
Merge pull request #66 from rduivenvoorde/projection-ui
[FEATURE] UI Overhaul for #4550 projection ui work
2 parents ec7e159 + b6d986c commit 1b3c383

File tree

3 files changed

+223
-127
lines changed

3 files changed

+223
-127
lines changed
 

‎src/gui/qgsprojectionselector.cpp

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,25 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
5252
lstCoordinateSystems->header()->setResizeMode( AUTHID_COLUMN, QHeaderView::Stretch );
5353
lstCoordinateSystems->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
5454
lstCoordinateSystems->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
55+
// Hide (internal) ID column
56+
lstCoordinateSystems->setColumnHidden(QGIS_CRS_ID_COLUMN, true);
5557

5658
lstRecent->header()->setResizeMode( AUTHID_COLUMN, QHeaderView::Stretch );
5759
lstRecent->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
5860
lstRecent->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
61+
// Hide (internal) ID column
62+
lstRecent->setColumnHidden(QGIS_CRS_ID_COLUMN, true);
5963

6064
cbxAuthority->addItem( tr( "All" ) );
6165
cbxAuthority->addItems( authorities() );
6266

67+
// TEMP? hide buttons, we now implemented filter
68+
cbxAuthority->hide();
69+
cbxMode->hide();
70+
label->hide();
71+
label_2->hide();
72+
pbnFind->hide();
73+
6374
// Read settings from persistent storage
6475
QSettings settings;
6576
mRecentProjections = settings.value( "/UI/recentProjections" ).toStringList();
@@ -189,7 +200,6 @@ QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression( QSet<QString> * c
189200
{
190201
return sqlExpression;
191202
}
192-
193203
/*
194204
Ref: WMS 1.3.0, section 6.7.3 "Layer CRS":
195205
@@ -794,7 +804,8 @@ void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
794804
newItem->setText( AUTHID_COLUMN, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 2 ) ) );
795805
// display the qgis srs_id (field 1) in the third column of the list view
796806
newItem->setText( QGIS_CRS_ID_COLUMN, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 1 ) ) );
797-
807+
// expand also parent node
808+
newItem->parent()->setExpanded(true);
798809
}
799810

800811
// display the qgis deprecated in the user data of the item
@@ -982,6 +993,65 @@ void QgsProjectionSelector::on_pbnFind_clicked()
982993
teProjection->setText( "" );
983994
}
984995

996+
void QgsProjectionSelector::on_leSearch_textChanged( const QString & theFilterTxt)
997+
{
998+
// filter recent crs's
999+
QTreeWidgetItemIterator itr(lstRecent);
1000+
while (*itr) {
1001+
if ( (*itr)->childCount() == 0 ) // it's an end node aka a projection
1002+
{
1003+
if ( (*itr)->text( NAME_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1004+
|| (*itr)->text( AUTHID_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1005+
)
1006+
{
1007+
(*itr)->setHidden(false);
1008+
QTreeWidgetItem * parent = (*itr)->parent();
1009+
while (parent != NULL)
1010+
{
1011+
parent->setExpanded(true);
1012+
parent->setHidden(false);
1013+
parent = parent->parent();
1014+
}
1015+
}
1016+
else{
1017+
(*itr)->setHidden(true);
1018+
}
1019+
}
1020+
else{
1021+
(*itr)->setHidden(true);
1022+
}
1023+
++itr;
1024+
}
1025+
// filter crs's
1026+
QTreeWidgetItemIterator it(lstCoordinateSystems);
1027+
while (*it) {
1028+
if ( (*it)->childCount() == 0 ) // it's an end node aka a projection
1029+
{
1030+
if ( (*it)->text( NAME_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1031+
|| (*it)->text( AUTHID_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1032+
)
1033+
{
1034+
(*it)->setHidden(false);
1035+
QTreeWidgetItem * parent = (*it)->parent();
1036+
while (parent != NULL)
1037+
{
1038+
parent->setExpanded(true);
1039+
parent->setHidden(false);
1040+
parent = parent->parent();
1041+
}
1042+
}
1043+
else{
1044+
(*it)->setHidden(true);
1045+
}
1046+
}
1047+
else{
1048+
(*it)->setHidden(true);
1049+
}
1050+
++it;
1051+
}
1052+
}
1053+
1054+
9851055
long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
9861056
{
9871057
long mySrsId = 0;
@@ -1094,7 +1164,7 @@ QStringList QgsProjectionSelector::authorities()
10941164
return authorities;
10951165
}
10961166

1097-
/*!
1167+
/*!linfinity qtcreator qgis
10981168
* \brief Make the string safe for use in SQL statements.
10991169
* This involves escaping single quotes, double quotes, backslashes,
11001170
* and optionally, percentage symbols. Percentage symbols are used

‎src/gui/qgsprojectionselector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
117117
void on_pbnFind_clicked();
118118
void on_lstRecent_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * );
119119
void on_cbxHideDeprecated_stateChanged();
120+
void on_leSearch_textChanged(const QString &);
120121

121122
protected:
122123
/** Used to ensure the projection list view is actually populated */

‎src/ui/qgsprojectionselectorbase.ui

Lines changed: 149 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>590</width>
10-
<height>358</height>
9+
<width>574</width>
10+
<height>389</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -31,69 +31,7 @@
3131
<property name="margin">
3232
<number>3</number>
3333
</property>
34-
<item row="1" column="0">
35-
<widget class="QTextEdit" name="teProjection">
36-
<property name="sizePolicy">
37-
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
38-
<horstretch>0</horstretch>
39-
<verstretch>0</verstretch>
40-
</sizepolicy>
41-
</property>
42-
<property name="minimumSize">
43-
<size>
44-
<width>0</width>
45-
<height>30</height>
46-
</size>
47-
</property>
48-
<property name="maximumSize">
49-
<size>
50-
<width>16777215</width>
51-
<height>50</height>
52-
</size>
53-
</property>
54-
<property name="baseSize">
55-
<size>
56-
<width>0</width>
57-
<height>50</height>
58-
</size>
59-
</property>
60-
<property name="autoFormatting">
61-
<set>QTextEdit::AutoBulletList</set>
62-
</property>
63-
<property name="readOnly">
64-
<bool>true</bool>
65-
</property>
66-
</widget>
67-
</item>
6834
<item row="0" column="0">
69-
<widget class="QTreeWidget" name="lstCoordinateSystems">
70-
<property name="alternatingRowColors">
71-
<bool>true</bool>
72-
</property>
73-
<property name="uniformRowHeights">
74-
<bool>true</bool>
75-
</property>
76-
<property name="columnCount">
77-
<number>3</number>
78-
</property>
79-
<column>
80-
<property name="text">
81-
<string>Coordinate Reference System</string>
82-
</property>
83-
</column>
84-
<column>
85-
<property name="text">
86-
<string>Authority ID</string>
87-
</property>
88-
</column>
89-
<column>
90-
<property name="text">
91-
<string>ID</string>
92-
</property>
93-
</column>
94-
</widget>
95-
</item>
96-
<item row="2" column="0">
9735
<widget class="QGroupBox" name="groupBox">
9836
<property name="sizePolicy">
9937
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
@@ -102,64 +40,9 @@
10240
</sizepolicy>
10341
</property>
10442
<property name="title">
105-
<string>Search</string>
43+
<string>Filter</string>
10644
</property>
10745
<layout class="QVBoxLayout" name="verticalLayout">
108-
<item>
109-
<layout class="QHBoxLayout" name="horizontalLayout_2">
110-
<item>
111-
<widget class="QLabel" name="label">
112-
<property name="text">
113-
<string>Authority</string>
114-
</property>
115-
</widget>
116-
</item>
117-
<item>
118-
<widget class="QComboBox" name="cbxAuthority"/>
119-
</item>
120-
<item>
121-
<widget class="QLabel" name="label_2">
122-
<property name="text">
123-
<string>Search for</string>
124-
</property>
125-
</widget>
126-
</item>
127-
<item>
128-
<widget class="QComboBox" name="cbxMode">
129-
<item>
130-
<property name="text">
131-
<string>ID</string>
132-
</property>
133-
</item>
134-
<item>
135-
<property name="text">
136-
<string>Name</string>
137-
</property>
138-
</item>
139-
</widget>
140-
</item>
141-
<item>
142-
<spacer name="horizontalSpacer">
143-
<property name="orientation">
144-
<enum>Qt::Horizontal</enum>
145-
</property>
146-
<property name="sizeHint" stdset="0">
147-
<size>
148-
<width>40</width>
149-
<height>20</height>
150-
</size>
151-
</property>
152-
</spacer>
153-
</item>
154-
<item>
155-
<widget class="QCheckBox" name="cbxHideDeprecated">
156-
<property name="text">
157-
<string>Hide deprecated CRSs</string>
158-
</property>
159-
</widget>
160-
</item>
161-
</layout>
162-
</item>
16346
<item>
16447
<layout class="QHBoxLayout" name="horizontalLayout">
16548
<item>
@@ -196,7 +79,7 @@
19679
<item row="4" column="0">
19780
<widget class="QTreeWidget" name="lstRecent">
19881
<property name="sizePolicy">
199-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
82+
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
20083
<horstretch>0</horstretch>
20184
<verstretch>0</verstretch>
20285
</sizepolicy>
@@ -210,7 +93,7 @@
21093
<property name="maximumSize">
21194
<size>
21295
<width>16777215</width>
213-
<height>105</height>
96+
<height>200</height>
21497
</size>
21598
</property>
21699
<property name="alternatingRowColors">
@@ -242,6 +125,150 @@
242125
</column>
243126
</widget>
244127
</item>
128+
<item row="7" column="0" rowspan="5">
129+
<layout class="QHBoxLayout" name="horizontalLayout_3">
130+
<property name="topMargin">
131+
<number>15</number>
132+
</property>
133+
<item>
134+
<widget class="QLabel" name="label_4">
135+
<property name="text">
136+
<string>Coordinate reference systems of the world</string>
137+
</property>
138+
</widget>
139+
</item>
140+
<item>
141+
<spacer name="horizontalSpacer_2">
142+
<property name="orientation">
143+
<enum>Qt::Horizontal</enum>
144+
</property>
145+
<property name="sizeHint" stdset="0">
146+
<size>
147+
<width>40</width>
148+
<height>20</height>
149+
</size>
150+
</property>
151+
</spacer>
152+
</item>
153+
<item>
154+
<widget class="QCheckBox" name="cbxHideDeprecated">
155+
<property name="text">
156+
<string>Hide deprecated CRSs</string>
157+
</property>
158+
</widget>
159+
</item>
160+
</layout>
161+
</item>
162+
<item row="15" column="0">
163+
<widget class="QTreeWidget" name="lstCoordinateSystems">
164+
<property name="alternatingRowColors">
165+
<bool>true</bool>
166+
</property>
167+
<property name="uniformRowHeights">
168+
<bool>true</bool>
169+
</property>
170+
<property name="columnCount">
171+
<number>3</number>
172+
</property>
173+
<column>
174+
<property name="text">
175+
<string>Coordinate Reference System</string>
176+
</property>
177+
</column>
178+
<column>
179+
<property name="text">
180+
<string>Authority ID</string>
181+
</property>
182+
</column>
183+
<column>
184+
<property name="text">
185+
<string>ID</string>
186+
</property>
187+
</column>
188+
</widget>
189+
</item>
190+
<item row="19" column="0">
191+
<widget class="QTextEdit" name="teProjection">
192+
<property name="sizePolicy">
193+
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
194+
<horstretch>0</horstretch>
195+
<verstretch>0</verstretch>
196+
</sizepolicy>
197+
</property>
198+
<property name="minimumSize">
199+
<size>
200+
<width>0</width>
201+
<height>30</height>
202+
</size>
203+
</property>
204+
<property name="maximumSize">
205+
<size>
206+
<width>16777215</width>
207+
<height>50</height>
208+
</size>
209+
</property>
210+
<property name="baseSize">
211+
<size>
212+
<width>0</width>
213+
<height>50</height>
214+
</size>
215+
</property>
216+
<property name="autoFormatting">
217+
<set>QTextEdit::AutoBulletList</set>
218+
</property>
219+
<property name="readOnly">
220+
<bool>true</bool>
221+
</property>
222+
</widget>
223+
</item>
224+
<item row="16" column="0">
225+
<layout class="QHBoxLayout" name="horizontalLayout_2">
226+
<item>
227+
<widget class="QLabel" name="label">
228+
<property name="text">
229+
<string>Authority</string>
230+
</property>
231+
</widget>
232+
</item>
233+
<item>
234+
<widget class="QComboBox" name="cbxAuthority"/>
235+
</item>
236+
<item>
237+
<widget class="QLabel" name="label_2">
238+
<property name="text">
239+
<string>Search for</string>
240+
</property>
241+
</widget>
242+
</item>
243+
<item>
244+
<widget class="QComboBox" name="cbxMode">
245+
<item>
246+
<property name="text">
247+
<string>ID</string>
248+
</property>
249+
</item>
250+
<item>
251+
<property name="text">
252+
<string>Name</string>
253+
</property>
254+
</item>
255+
</widget>
256+
</item>
257+
<item>
258+
<spacer name="horizontalSpacer">
259+
<property name="orientation">
260+
<enum>Qt::Horizontal</enum>
261+
</property>
262+
<property name="sizeHint" stdset="0">
263+
<size>
264+
<width>40</width>
265+
<height>20</height>
266+
</size>
267+
</property>
268+
</spacer>
269+
</item>
270+
</layout>
271+
</item>
245272
</layout>
246273
</widget>
247274
<layoutdefault spacing="6" margin="11"/>
@@ -250,10 +277,8 @@
250277
<tabstop>teProjection</tabstop>
251278
<tabstop>cbxAuthority</tabstop>
252279
<tabstop>cbxMode</tabstop>
253-
<tabstop>cbxHideDeprecated</tabstop>
254280
<tabstop>leSearch</tabstop>
255281
<tabstop>pbnFind</tabstop>
256-
<tabstop>lstRecent</tabstop>
257282
</tabstops>
258283
<resources/>
259284
<connections/>

0 commit comments

Comments
 (0)
Please sign in to comment.