@@ -119,7 +119,7 @@ void QgsSymbolV2PropertiesDialog::loadSymbol()
119
119
connect (selModel, SIGNAL (currentChanged (const QModelIndex&,const QModelIndex&)), this , SLOT (layerChanged ()));
120
120
121
121
int count = mSymbol ->symbolLayerCount ();
122
- for (int i = 0 ; i < count ; i++ )
122
+ for (int i = count- 1 ; i >= 0 ; i-- )
123
123
{
124
124
model->appendRow (new SymbolLayerItem ( mSymbol ->symbolLayer (i) ));
125
125
}
@@ -140,7 +140,7 @@ void QgsSymbolV2PropertiesDialog::populateLayerTypes()
140
140
141
141
void QgsSymbolV2PropertiesDialog::updateUi ()
142
142
{
143
- int row = currentLayerIndex ();
143
+ int row = currentRowIndex ();
144
144
btnUp->setEnabled ( row > 0 );
145
145
btnDown->setEnabled ( row < listLayers->model ()->rowCount ()-1 && row != -1 );
146
146
btnRemoveLayer->setEnabled ( row != -1 );
@@ -209,17 +209,22 @@ void QgsSymbolV2PropertiesDialog::loadPropertyWidgets()
209
209
}
210
210
}
211
211
212
- int QgsSymbolV2PropertiesDialog::currentLayerIndex ()
212
+ int QgsSymbolV2PropertiesDialog::currentRowIndex ()
213
213
{
214
214
QModelIndex idx = listLayers->selectionModel ()->currentIndex ();
215
215
if (!idx.isValid ())
216
216
return -1 ;
217
217
return idx.row ();
218
218
}
219
219
220
+ int QgsSymbolV2PropertiesDialog::currentLayerIndex ()
221
+ {
222
+ return listLayers->model ()->rowCount () - currentRowIndex () - 1 ;
223
+ }
224
+
220
225
SymbolLayerItem* QgsSymbolV2PropertiesDialog::currentLayerItem ()
221
226
{
222
- int index = currentLayerIndex ();
227
+ int index = currentRowIndex ();
223
228
if (index < 0 )
224
229
return NULL ;
225
230
@@ -339,15 +344,16 @@ void QgsSymbolV2PropertiesDialog::moveLayerUp()
339
344
340
345
void QgsSymbolV2PropertiesDialog::moveLayerByOffset (int offset)
341
346
{
342
- int idx = currentLayerIndex ();
343
-
347
+ int rowIdx = currentRowIndex ();
348
+ int layerIdx = currentLayerIndex ();
349
+
344
350
// switch layers
345
- QgsSymbolLayerV2* tmpLayer = mSymbol ->takeSymbolLayer (idx );
346
- mSymbol ->insertSymbolLayer (idx + offset, tmpLayer);
351
+ QgsSymbolLayerV2* tmpLayer = mSymbol ->takeSymbolLayer (layerIdx );
352
+ mSymbol ->insertSymbolLayer (layerIdx - offset, tmpLayer);
347
353
348
354
loadSymbol ();
349
355
350
- QModelIndex newIndex = listLayers->model ()->index (idx + offset,0 );
356
+ QModelIndex newIndex = listLayers->model ()->index (rowIdx + offset,0 );
351
357
listLayers->setCurrentIndex (newIndex);
352
358
353
359
updateUi ();
0 commit comments