Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed May 17, 2009
1 parent 9bd5113 commit 1188ebb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
Expand Up @@ -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) ));
}
Expand All @@ -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 );
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.h
Expand Up @@ -50,6 +50,7 @@ public slots:
void updateSymbolLayerWidget(QgsSymbolLayerV2* layer);
void updateLockButton();

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

0 comments on commit 1188ebb

Please sign in to comment.