Skip to content

Commit 1188ebb

Browse files
author
wonder
committed
Show symbol layers in symbol properties dialog in more logical order: top layer is now on top :-)
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10807 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9bd5113 commit 1188ebb

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void QgsSymbolV2PropertiesDialog::loadSymbol()
119119
connect(selModel, SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(layerChanged()));
120120

121121
int count = mSymbol->symbolLayerCount();
122-
for (int i = 0; i < count; i++)
122+
for (int i = count-1; i >= 0; i--)
123123
{
124124
model->appendRow(new SymbolLayerItem( mSymbol->symbolLayer(i) ));
125125
}
@@ -140,7 +140,7 @@ void QgsSymbolV2PropertiesDialog::populateLayerTypes()
140140

141141
void QgsSymbolV2PropertiesDialog::updateUi()
142142
{
143-
int row = currentLayerIndex();
143+
int row = currentRowIndex();
144144
btnUp->setEnabled( row > 0 );
145145
btnDown->setEnabled( row < listLayers->model()->rowCount()-1 && row != -1 );
146146
btnRemoveLayer->setEnabled( row != -1 );
@@ -209,17 +209,22 @@ void QgsSymbolV2PropertiesDialog::loadPropertyWidgets()
209209
}
210210
}
211211

212-
int QgsSymbolV2PropertiesDialog::currentLayerIndex()
212+
int QgsSymbolV2PropertiesDialog::currentRowIndex()
213213
{
214214
QModelIndex idx = listLayers->selectionModel()->currentIndex();
215215
if (!idx.isValid())
216216
return -1;
217217
return idx.row();
218218
}
219219

220+
int QgsSymbolV2PropertiesDialog::currentLayerIndex()
221+
{
222+
return listLayers->model()->rowCount() - currentRowIndex() - 1;
223+
}
224+
220225
SymbolLayerItem* QgsSymbolV2PropertiesDialog::currentLayerItem()
221226
{
222-
int index = currentLayerIndex();
227+
int index = currentRowIndex();
223228
if (index < 0)
224229
return NULL;
225230

@@ -339,15 +344,16 @@ void QgsSymbolV2PropertiesDialog::moveLayerUp()
339344

340345
void QgsSymbolV2PropertiesDialog::moveLayerByOffset(int offset)
341346
{
342-
int idx = currentLayerIndex();
343-
347+
int rowIdx = currentRowIndex();
348+
int layerIdx = currentLayerIndex();
349+
344350
// 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);
347353

348354
loadSymbol();
349355

350-
QModelIndex newIndex = listLayers->model()->index(idx + offset,0);
356+
QModelIndex newIndex = listLayers->model()->index(rowIdx + offset,0);
351357
listLayers->setCurrentIndex(newIndex);
352358

353359
updateUi();

src/gui/symbology-ng/qgssymbolv2propertiesdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public slots:
5050
void updateSymbolLayerWidget(QgsSymbolLayerV2* layer);
5151
void updateLockButton();
5252

53+
int currentRowIndex();
5354
int currentLayerIndex();
5455
SymbolLayerItem* currentLayerItem();
5556
QgsSymbolLayerV2* currentLayer();

0 commit comments

Comments
 (0)