@@ -46,6 +46,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
46
46
QStandardItemModel* model = new QStandardItemModel ( listItems );
47
47
listItems->setModel ( model );
48
48
49
+ connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ), this , SLOT ( itemChanged ( QStandardItem* ) ) );
50
+
49
51
populateTypes ();
50
52
51
53
connect ( tabItemType, SIGNAL ( currentChanged ( int ) ), this , SLOT ( populateList () ) );
@@ -68,7 +70,7 @@ void QgsStyleV2ManagerDialog::populateTypes()
68
70
// save current selection index in types combo
69
71
int current = ( tabItemType->count() > 0 ? tabItemType->currentIndex() : 0 );
70
72
71
- // no counting of style items
73
+ // no counting of style items
72
74
int markerCount = 0, lineCount = 0, fillCount = 0;
73
75
74
76
QStringList symbolNames = mStyle->symbolNames();
@@ -130,6 +132,7 @@ void QgsStyleV2ManagerDialog::populateSymbols( int type )
130
132
QStandardItem* item = new QStandardItem ( name );
131
133
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon ( symbol, listItems->iconSize () );
132
134
item->setIcon ( icon );
135
+ item->setData ( name ); // used to find out original name when user edited the name
133
136
// add to model
134
137
model->appendRow ( item );
135
138
}
@@ -153,6 +156,7 @@ void QgsStyleV2ManagerDialog::populateColorRamps()
153
156
QStandardItem* item = new QStandardItem ( name );
154
157
QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon ( ramp, listItems->iconSize () );
155
158
item->setIcon ( icon );
159
+ item->setData ( name ); // used to find out original name when user edited the name
156
160
model->appendRow ( item );
157
161
delete ramp;
158
162
}
@@ -453,3 +457,25 @@ bool QgsStyleV2ManagerDialog::removeColorRamp()
453
457
mModified = true ;
454
458
return true ;
455
459
}
460
+
461
+ void QgsStyleV2ManagerDialog::itemChanged ( QStandardItem* item )
462
+ {
463
+ // an item has been edited
464
+ QString oldName = item->data ().toString ();
465
+
466
+ bool changed = false ;
467
+ if ( currentItemType () < 3 )
468
+ {
469
+ changed = mStyle ->renameSymbol ( oldName, item->text () );
470
+ }
471
+ else if ( currentItemType () == 3 )
472
+ {
473
+ changed = mStyle ->renameColorRamp ( oldName, item->text () );
474
+ }
475
+
476
+ if ( changed )
477
+ {
478
+ populateList ();
479
+ mModified = true ;
480
+ }
481
+ }
0 commit comments