Skip to content
Permalink
Browse files

change symbols for selected categories; retains colors

  • Loading branch information
tecoholic committed Oct 11, 2012
1 parent 7faa1b2 commit cd3f12f07c07ccaa667d6d43a1f2ae37bfea7aca
@@ -151,8 +151,49 @@ QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2Widget::renderer()
return mRenderer;
}

void QgsCategorizedSymbolRendererV2Widget::changeSelectedSymbols()
{
QItemSelectionModel* m = viewCategories->selectionModel();
QModelIndexList selectedIndexes = m->selectedRows( 1 );

if ( m && selectedIndexes.size() > 0 )
{
QgsSymbolV2* newSymbol = mCategorizedSymbol->clone();
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
{
delete newSymbol;
return;
}

foreach( QModelIndex idx, selectedIndexes )
{
if( idx.isValid() )
{
int catIdx = mRenderer->categoryIndexForValue( idx.data( Qt::UserRole + 1 ) );
QgsSymbolV2* newCatSymbol = newSymbol->clone();
newCatSymbol->setColor( mRenderer->categories()[catIdx].symbol()->color() );
mRenderer->updateCategorySymbol( catIdx, newCatSymbol );
}
}
}

populateCategories();
}

void QgsCategorizedSymbolRendererV2Widget::changeCategorizedSymbol()
{
// When there is a slection, change the selected symbols alone
QItemSelectionModel* m = viewCategories->selectionModel();
QModelIndexList i = m->selectedRows();

if ( m && i.size() > 0 )
{
changeSelectedSymbols();
return;
}

// When there is no selection, change the base mCategorizedSymbol
QgsSymbolV2* newSymbol = mCategorizedSymbol->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
@@ -73,6 +73,9 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg
//! return a list of keys for the categories unders selection
QList<QVariant> selectedCategories();

//! change the selected symbols alone for the change button, if there is a selection
void changeSelectedSymbols();

void changeCategorySymbol();

QList<QgsSymbolV2*> selectedSymbols();

0 comments on commit cd3f12f

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