Skip to content
Permalink
Browse files

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
  • Loading branch information
wonder
wonder committed May 17, 2009
1 parent 9bd5113 commit 1188ebb8383ebac946aaa098c49725c1f0db2d4b
@@ -119,7 +119,7 @@ void QgsSymbolV2PropertiesDialog::loadSymbol()
connect(selModel, SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(layerChanged()));

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

void QgsSymbolV2PropertiesDialog::updateUi()
{
int row = currentLayerIndex();
int row = currentRowIndex();
btnUp->setEnabled( row > 0 );
btnDown->setEnabled( row < listLayers->model()->rowCount()-1 && row != -1 );
btnRemoveLayer->setEnabled( row != -1 );
@@ -209,17 +209,22 @@ void QgsSymbolV2PropertiesDialog::loadPropertyWidgets()
}
}

int QgsSymbolV2PropertiesDialog::currentLayerIndex()
int QgsSymbolV2PropertiesDialog::currentRowIndex()
{
QModelIndex idx = listLayers->selectionModel()->currentIndex();
if (!idx.isValid())
return -1;
return idx.row();
}

int QgsSymbolV2PropertiesDialog::currentLayerIndex()
{
return listLayers->model()->rowCount() - currentRowIndex() - 1;
}

SymbolLayerItem* QgsSymbolV2PropertiesDialog::currentLayerItem()
{
int index = currentLayerIndex();
int index = currentRowIndex();
if (index < 0)
return NULL;

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

void QgsSymbolV2PropertiesDialog::moveLayerByOffset(int offset)
{
int idx = currentLayerIndex();

int rowIdx = currentRowIndex();
int layerIdx = currentLayerIndex();

// switch layers
QgsSymbolLayerV2* tmpLayer = mSymbol->takeSymbolLayer(idx);
mSymbol->insertSymbolLayer(idx + offset, tmpLayer);
QgsSymbolLayerV2* tmpLayer = mSymbol->takeSymbolLayer(layerIdx);
mSymbol->insertSymbolLayer(layerIdx - offset, tmpLayer);

loadSymbol();

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

updateUi();
@@ -50,6 +50,7 @@ public slots:
void updateSymbolLayerWidget(QgsSymbolLayerV2* layer);
void updateLockButton();

int currentRowIndex();
int currentLayerIndex();
SymbolLayerItem* currentLayerItem();
QgsSymbolLayerV2* currentLayer();

0 comments on commit 1188ebb

Please sign in to comment.
You can’t perform that action at this time.