Skip to content

Commit 608d394

Browse files
committed
Possibility to delete multiple composer legend entries at once
1 parent 53eb763 commit 608d394

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/app/composer/qgscomposerlegendwidget.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,21 @@ void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()
442442
return;
443443
}
444444

445-
QModelIndex currentIndex = mItemTreeView->currentIndex();
446-
if ( !currentIndex.isValid() )
445+
mLegend->beginCommand( "Legend item removed" );
446+
447+
QItemSelectionModel* selectionModel = mItemTreeView->selectionModel();
448+
if( !selectionModel )
447449
{
448450
return;
449451
}
450452

451-
QModelIndex parentIndex = currentIndex.parent();
453+
QModelIndexList selection = selectionModel->selectedIndexes();
454+
for( int i = selection.size() - 1; i >= 0; --i )
455+
{
456+
QModelIndex parentIndex = selection.at( i ).parent();
457+
itemModel->removeRow( selection.at( i ).row(), parentIndex );
458+
}
452459

453-
mLegend->beginCommand( "Legend item removed" );
454-
itemModel->removeRow( currentIndex.row(), parentIndex );
455460
mLegend->adjustBoxSize();
456461
mLegend->update();
457462
mLegend->endCommand();

src/ui/qgscomposerlegendwidgetbase.ui

+9-6
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<rect>
3434
<x>0</x>
3535
<y>0</y>
36-
<width>369</width>
37-
<height>474</height>
36+
<width>367</width>
37+
<height>472</height>
3838
</rect>
3939
</property>
4040
<layout class="QGridLayout" name="gridLayout_3">
@@ -48,8 +48,8 @@
4848
<rect>
4949
<x>0</x>
5050
<y>0</y>
51-
<width>338</width>
52-
<height>404</height>
51+
<width>349</width>
52+
<height>398</height>
5353
</rect>
5454
</property>
5555
<attribute name="label">
@@ -183,8 +183,8 @@
183183
<rect>
184184
<x>0</x>
185185
<y>0</y>
186-
<width>351</width>
187-
<height>394</height>
186+
<width>349</width>
187+
<height>398</height>
188188
</rect>
189189
</property>
190190
<attribute name="label">
@@ -215,6 +215,9 @@
215215
<verstretch>0</verstretch>
216216
</sizepolicy>
217217
</property>
218+
<property name="selectionMode">
219+
<enum>QAbstractItemView::ContiguousSelection</enum>
220+
</property>
218221
<property name="wordWrap">
219222
<bool>false</bool>
220223
</property>

0 commit comments

Comments
 (0)