Skip to content

Commit

Permalink
Possibility to delete multiple composer legend entries at once
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 16, 2011
1 parent 53eb763 commit 608d394
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
15 changes: 10 additions & 5 deletions src/app/composer/qgscomposerlegendwidget.cpp
Expand Up @@ -442,16 +442,21 @@ void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()
return;
}

QModelIndex currentIndex = mItemTreeView->currentIndex();
if ( !currentIndex.isValid() )
mLegend->beginCommand( "Legend item removed" );

QItemSelectionModel* selectionModel = mItemTreeView->selectionModel();
if( !selectionModel )
{
return;
}

QModelIndex parentIndex = currentIndex.parent();
QModelIndexList selection = selectionModel->selectedIndexes();
for( int i = selection.size() - 1; i >= 0; --i )
{
QModelIndex parentIndex = selection.at( i ).parent();
itemModel->removeRow( selection.at( i ).row(), parentIndex );
}

mLegend->beginCommand( "Legend item removed" );
itemModel->removeRow( currentIndex.row(), parentIndex );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand Down
15 changes: 9 additions & 6 deletions src/ui/qgscomposerlegendwidgetbase.ui
Expand Up @@ -33,8 +33,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>474</height>
<width>367</width>
<height>472</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
Expand All @@ -48,8 +48,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>338</width>
<height>404</height>
<width>349</width>
<height>398</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -183,8 +183,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>394</height>
<width>349</width>
<height>398</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -215,6 +215,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ContiguousSelection</enum>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
Expand Down

0 comments on commit 608d394

Please sign in to comment.