Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ability to delete multiple categories using Ctrl selection
  • Loading branch information
Arunmozhi committed Oct 11, 2012
1 parent c10920b commit 7faa1b2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
37 changes: 30 additions & 7 deletions src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
Expand Up @@ -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();
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.h
Expand Up @@ -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();
Expand Down

0 comments on commit 7faa1b2

Please sign in to comment.