Skip to content
Permalink
Browse files

change symbols for selected ranges using changeBtn; retains colors

  • Loading branch information
tecoholic committed Oct 11, 2012
1 parent cd3f12f commit 936f4aa5f7d2c146e4db1b89a4288a6b54602763
@@ -239,7 +239,16 @@ void QgsGraduatedSymbolRendererV2Widget::reapplyColorRamp()

void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
{
// Change the selected symbols alone if anything is selected
QItemSelectionModel* m = viewGraduated->selectionModel();
QModelIndexList i = m->selectedRows();
if ( m && i.size() > 0 )
{
changeSelectedSymbols();
return;
}

// Otherwise change the base mGraduatedSymbol
QgsSymbolV2* newSymbol = mGraduatedSymbol->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
@@ -328,6 +337,34 @@ void QgsGraduatedSymbolRendererV2Widget::rangesClicked( const QModelIndex & idx
mRowSelected = idx.row();
}

void QgsGraduatedSymbolRendererV2Widget::changeSelectedSymbols()
{
QItemSelectionModel* m = viewGraduated->selectionModel();
QModelIndexList selectedIndexes = m->selectedRows( 1 );
if ( m && selectedIndexes.size() > 0 )
{
QgsSymbolV2* newSymbol = mGraduatedSymbol->clone();
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
{
delete newSymbol;
return;
}

foreach( QModelIndex idx, selectedIndexes )
{
if( idx.isValid() )
{
int rangeIdx = idx.row();
QgsSymbolV2* newRangeSymbol = newSymbol->clone();
newRangeSymbol->setColor( mRenderer->ranges()[rangeIdx].symbol()->color() );
mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol );
}
}
}
refreshSymbolView();
}

void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol( int rangeIdx )
{
QgsSymbolV2* newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();
@@ -68,6 +68,8 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
void changeRangeSymbol( int rangeIdx );
void changeRange( int rangeIdx );

void changeSelectedSymbols();

QList<QgsSymbolV2*> selectedSymbols();
QgsSymbolV2* findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList& ranges ) const;
void refreshSymbolView();

0 comments on commit 936f4aa

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