@@ -74,13 +74,13 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
74
74
sym->setNamedPointSymbol (symbol->pointSymbolName ());
75
75
sym->setPointSize (symbol->pointSize ());
76
76
mValues .insert (std::make_pair (symbolvalue,sym));
77
- mClassBreakBox ->insertItem (symbolvalue);
77
+ mClassBreakBox ->addItem (symbolvalue);
78
78
}
79
79
}
80
80
81
81
QObject::connect (mClassifyButton , SIGNAL (clicked ()), this , SLOT (changeClassificationAttribute ()));
82
82
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 ()));
84
84
QObject::connect (&sydialog, SIGNAL (settingsChanged ()), this , SLOT (applySymbologyChanges ()));
85
85
mSymbolWidgetStack ->addWidget (&sydialog);
86
86
mSymbolWidgetStack ->raiseWidget (&sydialog);
@@ -168,7 +168,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
168
168
int green = 1 + (int ) (255.0 * rand () / (RAND_MAX + 1.0 ));
169
169
int blue = 1 + (int ) (255.0 * rand () / (RAND_MAX + 1.0 ));
170
170
thecolor.setRgb (red, green, blue);
171
- mClassBreakBox ->insertItem (it->first );
171
+ mClassBreakBox ->addItem (it->first );
172
172
QgsSymbol* sym=it->second ;
173
173
QPen pen;
174
174
QBrush brush;
@@ -196,7 +196,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
196
196
void QgsUniqueValueDialog::changeCurrentValue ()
197
197
{
198
198
sydialog.blockSignals (true );// block signal to prevent sydialog from changing the current QgsRenderItem
199
- Q3ListBoxItem * item=mClassBreakBox ->selectedItem ();
199
+ QListWidgetItem * item=mClassBreakBox ->currentItem ();
200
200
if (item)
201
201
{
202
202
QString value=item->text ();
@@ -216,28 +216,38 @@ void QgsUniqueValueDialog::changeCurrentValue()
216
216
217
217
void QgsUniqueValueDialog::deleteCurrentClass ()
218
218
{
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 ();
221
227
mValues .erase (classValue);
222
- mClassBreakBox ->removeItem (currentIndex);
228
+ delete ( mClassBreakBox ->takeItem (currentIndex) );
223
229
qWarning (" numRows: " );
224
- qWarning (QString::number (mClassBreakBox ->numRows ()));
230
+ qWarning (QString::number (mClassBreakBox ->count ()));
225
231
//
226
- if (mClassBreakBox ->numRows () < (currentIndex + 1 ))
232
+ if (mClassBreakBox ->count () < (currentIndex + 1 ))
227
233
{
228
234
qWarning (" selecting numRows - 1" );
229
- mClassBreakBox ->setSelected (mClassBreakBox ->numRows () - 1 , true );
235
+ mClassBreakBox ->setCurrentRow (mClassBreakBox ->count () - 1 );
230
236
}
231
237
else
232
238
{
233
239
qWarning (" selecting currentIndex" );
234
- mClassBreakBox ->setSelected (currentIndex, true );
240
+ mClassBreakBox ->setCurrentRow (currentIndex);
235
241
}
236
242
}
237
243
238
244
void QgsUniqueValueDialog::applySymbologyChanges ()
239
245
{
240
- Q3ListBoxItem* item=mClassBreakBox ->selectedItem ();
246
+ QListWidgetItem* item=mClassBreakBox ->currentItem ();
247
+ if (!item)
248
+ {
249
+ return ;
250
+ }
241
251
QString value=item->text ();
242
252
std::map<QString,QgsSymbol*>::iterator it=mValues .find (value);
243
253
if (it!=mValues .end ())
0 commit comments