Skip to content
Permalink
Browse files

ability to delete multiple categories using Ctrl selection

  • Loading branch information
tecoholic committed Oct 11, 2012
1 parent c10920b commit 7faa1b217ac253342f4c3991192911ba378ab7cb
@@ -405,18 +405,41 @@ QVariant QgsCategorizedSymbolRendererV2Widget::currentCategory()
return m->item( row, 1 )->data();
}

QList<QVariant> QgsCategorizedSymbolRendererV2Widget::selectedCategories()
{
QList<QVariant> categories;
QModelIndexList rows = viewCategories->selectionModel()->selectedRows();
QStandardItemModel* m = qobject_cast<QStandardItemModel*>( viewCategories->model() );

foreach( QModelIndex r, rows )
{
if( r.isValid() )
{
categories.append( m->item( r.row(), 1 )->data() );
}
}

return categories;
}

void QgsCategorizedSymbolRendererV2Widget::deleteCategory()
{
QVariant k = currentCategory();
if ( !k.isValid() )
return;
QList<QVariant> categories = selectedCategories();

int idx = mRenderer->categoryIndexForValue( k );
if ( idx < 0 )
if ( !categories.size() )
return;

mRenderer->deleteCategory( idx );

foreach( const QVariant k, categories )
{
if ( k.isValid() )
{
int idx = mRenderer->categoryIndexForValue( k );
if ( idx >= 0 )
{
mRenderer->deleteCategory( idx );
}
}
}
populateCategories();
}

@@ -70,6 +70,9 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg
//! return key for the currently selected category
QVariant currentCategory();

//! return a list of keys for the categories unders selection
QList<QVariant> selectedCategories();

void changeCategorySymbol();

QList<QgsSymbolV2*> selectedSymbols();

0 comments on commit 7faa1b2

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