Skip to content

Commit ccf59bb

Browse files
author
mhugent
committedFeb 4, 2007
Replaced Q3ListBox in the unique value dialog with QListWidget
git-svn-id: http://svn.osgeo.org/qgis/trunk@6523 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9488c74 commit ccf59bb

File tree

2 files changed

+60
-55
lines changed

2 files changed

+60
-55
lines changed
 

‎src/app/qgsuniquevaluedialog.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
7474
sym->setNamedPointSymbol(symbol->pointSymbolName());
7575
sym->setPointSize(symbol->pointSize());
7676
mValues.insert(std::make_pair(symbolvalue,sym));
77-
mClassBreakBox->insertItem(symbolvalue);
77+
mClassBreakBox->addItem(symbolvalue);
7878
}
7979
}
8080

8181
QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(changeClassificationAttribute()));
8282
QObject::connect(mDeletePushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
83-
QObject::connect(mClassBreakBox, SIGNAL(selectionChanged()), this, SLOT(changeCurrentValue()));
83+
QObject::connect(mClassBreakBox, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeCurrentValue()));
8484
QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
8585
mSymbolWidgetStack->addWidget(&sydialog);
8686
mSymbolWidgetStack->raiseWidget(&sydialog);
@@ -168,7 +168,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
168168
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
169169
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
170170
thecolor.setRgb(red, green, blue);
171-
mClassBreakBox->insertItem(it->first);
171+
mClassBreakBox->addItem(it->first);
172172
QgsSymbol* sym=it->second;
173173
QPen pen;
174174
QBrush brush;
@@ -196,7 +196,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
196196
void QgsUniqueValueDialog::changeCurrentValue()
197197
{
198198
sydialog.blockSignals(true);//block signal to prevent sydialog from changing the current QgsRenderItem
199-
Q3ListBoxItem* item=mClassBreakBox->selectedItem();
199+
QListWidgetItem* item=mClassBreakBox->currentItem();
200200
if(item)
201201
{
202202
QString value=item->text();
@@ -216,28 +216,38 @@ void QgsUniqueValueDialog::changeCurrentValue()
216216

217217
void QgsUniqueValueDialog::deleteCurrentClass()
218218
{
219-
QString classValue = mClassBreakBox->currentText();
220-
int currentIndex = mClassBreakBox->currentItem();
219+
QListWidgetItem* currentItem = mClassBreakBox->currentItem();
220+
if(!currentItem)
221+
{
222+
return;
223+
}
224+
225+
QString classValue = currentItem->text();
226+
int currentIndex = mClassBreakBox->currentRow();
221227
mValues.erase(classValue);
222-
mClassBreakBox->removeItem(currentIndex);
228+
delete (mClassBreakBox->takeItem(currentIndex));
223229
qWarning("numRows: ");
224-
qWarning(QString::number(mClassBreakBox->numRows()));
230+
qWarning(QString::number(mClassBreakBox->count()));
225231
//
226-
if(mClassBreakBox->numRows() < (currentIndex + 1))
232+
if(mClassBreakBox->count() < (currentIndex + 1))
227233
{
228234
qWarning("selecting numRows - 1");
229-
mClassBreakBox->setSelected(mClassBreakBox->numRows() - 1, true);
235+
mClassBreakBox->setCurrentRow(mClassBreakBox->count() - 1);
230236
}
231237
else
232238
{
233239
qWarning("selecting currentIndex");
234-
mClassBreakBox->setSelected(currentIndex, true);
240+
mClassBreakBox->setCurrentRow(currentIndex);
235241
}
236242
}
237243

238244
void QgsUniqueValueDialog::applySymbologyChanges()
239245
{
240-
Q3ListBoxItem* item=mClassBreakBox->selectedItem();
246+
QListWidgetItem* item=mClassBreakBox->currentItem();
247+
if(!item)
248+
{
249+
return;
250+
}
241251
QString value=item->text();
242252
std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
243253
if(it!=mValues.end())

‎src/ui/qgsuniquevaluedialogbase.ui

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,38 @@
1919
<property name="spacing" >
2020
<number>6</number>
2121
</property>
22-
<item row="0" column="0" >
23-
<widget class="QLabel" name="mClassVarLabel" >
22+
<item row="1" column="2" colspan="4" >
23+
<widget class="QListWidget" name="mClassBreakBox" />
24+
</item>
25+
<item row="1" column="0" colspan="2" >
26+
<widget class="Q3WidgetStack" name="mSymbolWidgetStack" >
27+
<widget class="QWidget" name="WStackPage" >
28+
<property name="geometry" >
29+
<rect>
30+
<x>0</x>
31+
<y>0</y>
32+
<width>190</width>
33+
<height>246</height>
34+
</rect>
35+
</property>
36+
</widget>
37+
</widget>
38+
</item>
39+
<item row="0" column="3" >
40+
<widget class="QPushButton" name="mClassifyButton" >
41+
<property name="text" >
42+
<string>Classify</string>
43+
</property>
44+
</widget>
45+
</item>
46+
<item row="0" column="1" colspan="2" >
47+
<widget class="QComboBox" name="mClassificationComboBox" >
2448
<property name="minimumSize" >
2549
<size>
2650
<width>0</width>
2751
<height>20</height>
2852
</size>
2953
</property>
30-
<property name="text" >
31-
<string>Classification Field:</string>
32-
</property>
33-
<property name="buddy" >
34-
<cstring>mClassificationComboBox</cstring>
35-
</property>
36-
</widget>
37-
</item>
38-
<item row="0" column="4" >
39-
<widget class="QPushButton" name="mDeletePushButton" >
40-
<property name="text" >
41-
<string>Delete class</string>
42-
</property>
4354
</widget>
4455
</item>
4556
<item row="0" column="5" >
@@ -58,50 +69,34 @@
5869
</property>
5970
</spacer>
6071
</item>
61-
<item row="1" column="2" colspan="4" >
62-
<widget class="Q3ListBox" name="mClassBreakBox" />
72+
<item row="0" column="4" >
73+
<widget class="QPushButton" name="mDeletePushButton" >
74+
<property name="text" >
75+
<string>Delete class</string>
76+
</property>
77+
</widget>
6378
</item>
64-
<item row="0" column="1" colspan="2" >
65-
<widget class="QComboBox" name="mClassificationComboBox" >
79+
<item row="0" column="0" >
80+
<widget class="QLabel" name="mClassVarLabel" >
6681
<property name="minimumSize" >
6782
<size>
6883
<width>0</width>
6984
<height>20</height>
7085
</size>
7186
</property>
72-
</widget>
73-
</item>
74-
<item row="0" column="3" >
75-
<widget class="QPushButton" name="mClassifyButton" >
7687
<property name="text" >
77-
<string>Classify</string>
88+
<string>Classification Field:</string>
89+
</property>
90+
<property name="buddy" >
91+
<cstring>mClassificationComboBox</cstring>
7892
</property>
79-
</widget>
80-
</item>
81-
<item row="1" column="0" colspan="2" >
82-
<widget class="Q3WidgetStack" name="mSymbolWidgetStack" >
83-
<widget class="QWidget" name="WStackPage" >
84-
<property name="geometry" >
85-
<rect>
86-
<x>0</x>
87-
<y>0</y>
88-
<width>190</width>
89-
<height>246</height>
90-
</rect>
91-
</property>
92-
</widget>
9393
</widget>
9494
</item>
9595
</layout>
9696
</widget>
9797
<layoutdefault spacing="6" margin="11" />
9898
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
9999
<customwidgets>
100-
<customwidget>
101-
<class>Q3ListBox</class>
102-
<extends>Q3Frame</extends>
103-
<header>q3listbox.h</header>
104-
</customwidget>
105100
<customwidget>
106101
<class>Q3WidgetStack</class>
107102
<extends>Q3WidgetStack</extends>

0 commit comments

Comments
 (0)
Please sign in to comment.