Skip to content

Commit 822d6f7

Browse files
committedOct 6, 2017
Move actions which apply to selected items only to QgsLayoutView
Selections are a gui concept, so these actions belong to the gui class instead of cluterring QgsLayout
1 parent fdba8f1 commit 822d6f7

File tree

9 files changed

+273
-254
lines changed

9 files changed

+273
-254
lines changed
 

‎python/core/layout/qgslayout.sip

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,6 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
9898
not correctly emit signals to allow the layout's model to update.
9999
%End
100100

101-
void lockSelectedItems();
102-
%Docstring
103-
Locks any selected items, preventing them from being interacted with
104-
by mouse interactions.
105-
.. seealso:: unlockAllItems()
106-
%End
107-
108-
void unlockAllItems();
109-
%Docstring
110-
Unlocks all locked items in the layout.
111-
.. seealso:: lockSelectedItems()
112-
%End
113-
114101
bool raiseItem( QgsLayoutItem *item, bool deferUpdate = false );
115102
%Docstring
116103
Raises an ``item`` up the z-order.
@@ -122,6 +109,7 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
122109
updating the scene for each one.
123110

124111
.. seealso:: lowerItem()
112+
.. seealso:: updateZValues()
125113
:rtype: bool
126114
%End
127115

@@ -136,6 +124,7 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
136124
updating the scene for each one.
137125

138126
.. seealso:: raiseItem()
127+
.. seealso:: updateZValues()
139128
:rtype: bool
140129
%End
141130

@@ -150,6 +139,7 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
150139
updating the scene for each one.
151140

152141
.. seealso:: moveItemToBottom()
142+
.. seealso:: updateZValues()
153143
:rtype: bool
154144
%End
155145

@@ -163,39 +153,15 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
163153
updating the scene for each one.
164154

165155
.. seealso:: moveItemToTop()
156+
.. seealso:: updateZValues()
166157
:rtype: bool
167158
%End
168159

169-
void raiseSelectedItems();
170-
%Docstring
171-
Raises the selected items up the z-order.
172-
.. seealso:: lowerSelectedItems()
173-
.. seealso:: moveSelectedItemsToTop()
174-
.. seealso:: moveSelectedItemsToBottom()
175-
%End
176-
177-
void lowerSelectedItems();
178-
%Docstring
179-
Lowers the selected items down the z-order.
180-
.. seealso:: raiseSelectedItems()
181-
.. seealso:: moveSelectedItemsToTop()
182-
.. seealso:: moveSelectedItemsToBottom()
183-
%End
184-
185-
void moveSelectedItemsToTop();
186-
%Docstring
187-
Raises the selected items to the top of the z-order.
188-
.. seealso:: raiseSelectedItems()
189-
.. seealso:: lowerSelectedItems()
190-
.. seealso:: moveSelectedItemsToBottom()
191-
%End
192-
193-
void moveSelectedItemsToBottom();
160+
void updateZValues( const bool addUndoCommands = true );
194161
%Docstring
195-
Lowers the selected items to the bottom of the z-order.
196-
.. seealso:: raiseSelectedItems()
197-
.. seealso:: lowerSelectedItems()
198-
.. seealso:: moveSelectedItemsToTop()
162+
Resets the z-values of items based on their position in the internal
163+
z order list. This should be called after any stacking changes
164+
which deferred z-order updates.
199165
%End
200166

201167
QgsLayoutItem *itemByUuid( const QString &uuid );

‎python/gui/layout/qgslayoutview.sip

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,51 @@ class QgsLayoutView: QGraphicsView
210210
.. seealso:: selectNextItemAbove()
211211
.. seealso:: selectAll()
212212
.. seealso:: deselectAll()
213+
%End
214+
215+
void raiseSelectedItems();
216+
%Docstring
217+
Raises the selected items up the z-order.
218+
.. seealso:: lowerSelectedItems()
219+
.. seealso:: moveSelectedItemsToTop()
220+
.. seealso:: moveSelectedItemsToBottom()
221+
%End
222+
223+
void lowerSelectedItems();
224+
%Docstring
225+
Lowers the selected items down the z-order.
226+
.. seealso:: raiseSelectedItems()
227+
.. seealso:: moveSelectedItemsToTop()
228+
.. seealso:: moveSelectedItemsToBottom()
229+
%End
230+
231+
void moveSelectedItemsToTop();
232+
%Docstring
233+
Raises the selected items to the top of the z-order.
234+
.. seealso:: raiseSelectedItems()
235+
.. seealso:: lowerSelectedItems()
236+
.. seealso:: moveSelectedItemsToBottom()
237+
%End
238+
239+
void moveSelectedItemsToBottom();
240+
%Docstring
241+
Lowers the selected items to the bottom of the z-order.
242+
.. seealso:: raiseSelectedItems()
243+
.. seealso:: lowerSelectedItems()
244+
.. seealso:: moveSelectedItemsToTop()
245+
%End
246+
247+
void lockSelectedItems();
248+
%Docstring
249+
Locks any selected items, preventing them from being interacted with
250+
by mouse interactions.
251+
.. seealso:: unlockAllItems()
252+
%End
253+
254+
void unlockAllItems();
255+
%Docstring
256+
Unlocks all locked items in the layout.
257+
.. seealso:: lockSelectedItems()
213258
%End
214259

215260
void viewChanged();

‎src/app/layout/qgslayoutdesignerdialog.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,12 @@ void QgsLayoutDesignerDialog::snapToItems( bool enabled )
542542

543543
void QgsLayoutDesignerDialog::unlockAllItems()
544544
{
545-
if ( mLayout )
546-
{
547-
mLayout->unlockAllItems();
548-
}
545+
mView->unlockAllItems();
549546
}
550547

551548
void QgsLayoutDesignerDialog::lockSelectedItems()
552549
{
553-
if ( mLayout )
554-
{
555-
mLayout->lockSelectedItems();
556-
}
550+
mView->lockSelectedItems();
557551
}
558552

559553
void QgsLayoutDesignerDialog::setPanelVisibility( bool hidden )
@@ -616,22 +610,22 @@ void QgsLayoutDesignerDialog::setPanelVisibility( bool hidden )
616610

617611
void QgsLayoutDesignerDialog::raiseSelectedItems()
618612
{
619-
mLayout->raiseSelectedItems();
613+
mView->raiseSelectedItems();
620614
}
621615

622616
void QgsLayoutDesignerDialog::lowerSelectedItems()
623617
{
624-
mLayout->lowerSelectedItems();
618+
mView->lowerSelectedItems();
625619
}
626620

627621
void QgsLayoutDesignerDialog::moveSelectedItemsToTop()
628622
{
629-
mLayout->moveSelectedItemsToTop();
623+
mView->moveSelectedItemsToTop();
630624
}
631625

632626
void QgsLayoutDesignerDialog::moveSelectedItemsToBottom()
633627
{
634-
mLayout->moveSelectedItemsToBottom();
628+
mView->moveSelectedItemsToBottom();
635629
}
636630

637631
void QgsLayoutDesignerDialog::closeEvent( QCloseEvent * )

‎src/core/layout/qgslayout.cpp

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -113,47 +113,6 @@ void QgsLayout::deselectAll()
113113
emit selectedItemChanged( nullptr );
114114
}
115115

116-
void QgsLayout::lockSelectedItems()
117-
{
118-
mUndoStack->beginMacro( tr( "Items locked" ) );
119-
const QList<QgsLayoutItem *> selectionList = selectedLayoutItems();
120-
for ( QgsLayoutItem *item : selectionList )
121-
{
122-
mUndoStack->beginCommand( item, QString() );
123-
item->setLocked( true );
124-
mUndoStack->endCommand();
125-
}
126-
127-
deselectAll();
128-
mUndoStack->endMacro();
129-
}
130-
131-
void QgsLayout::unlockAllItems()
132-
{
133-
//unlock all items in composer
134-
135-
mUndoStack->beginMacro( tr( "Items unlocked" ) );
136-
137-
//first, clear the selection
138-
deselectAll();
139-
140-
const QList<QGraphicsItem *> itemList = items();
141-
for ( QGraphicsItem *graphicItem : itemList )
142-
{
143-
QgsLayoutItem *item = dynamic_cast<QgsLayoutItem *>( graphicItem );
144-
if ( item && item->isLocked() )
145-
{
146-
mUndoStack->beginCommand( item, QString() );
147-
item->setLocked( false );
148-
//select unlocked items, same behavior as illustrator
149-
item->setSelected( true );
150-
emit selectedItemChanged( item );
151-
mUndoStack->endCommand();
152-
}
153-
}
154-
mUndoStack->endMacro();
155-
}
156-
157116
bool QgsLayout::raiseItem( QgsLayoutItem *item, bool deferUpdate )
158117
{
159118
//model handles reordering items
@@ -206,86 +165,6 @@ bool QgsLayout::moveItemToBottom( QgsLayoutItem *item, bool deferUpdate )
206165
return result;
207166
}
208167

209-
void QgsLayout::raiseSelectedItems()
210-
{
211-
const QList<QgsLayoutItem *> selectedItems = selectedLayoutItems();
212-
bool itemsRaised = false;
213-
for ( QgsLayoutItem *item : selectedItems )
214-
{
215-
itemsRaised = itemsRaised | raiseItem( item, true );
216-
}
217-
218-
if ( !itemsRaised )
219-
{
220-
//no change
221-
return;
222-
}
223-
224-
//update all positions
225-
updateZValues();
226-
update();
227-
}
228-
229-
void QgsLayout::lowerSelectedItems()
230-
{
231-
const QList<QgsLayoutItem *> selectedItems = selectedLayoutItems();
232-
bool itemsLowered = false;
233-
for ( QgsLayoutItem *item : selectedItems )
234-
{
235-
itemsLowered = itemsLowered | lowerItem( item, true );
236-
}
237-
238-
if ( !itemsLowered )
239-
{
240-
//no change
241-
return;
242-
}
243-
244-
//update all positions
245-
updateZValues();
246-
update();
247-
}
248-
249-
void QgsLayout::moveSelectedItemsToTop()
250-
{
251-
const QList<QgsLayoutItem *> selectedItems = selectedLayoutItems();
252-
bool itemsRaised = false;
253-
for ( QgsLayoutItem *item : selectedItems )
254-
{
255-
itemsRaised = itemsRaised | moveItemToTop( item, true );
256-
}
257-
258-
if ( !itemsRaised )
259-
{
260-
//no change
261-
return;
262-
}
263-
264-
//update all positions
265-
updateZValues();
266-
update();
267-
}
268-
269-
void QgsLayout::moveSelectedItemsToBottom()
270-
{
271-
const QList<QgsLayoutItem *> selectedItems = selectedLayoutItems();
272-
bool itemsLowered = false;
273-
for ( QgsLayoutItem *item : selectedItems )
274-
{
275-
itemsLowered = itemsLowered | moveItemToBottom( item, true );
276-
}
277-
278-
if ( !itemsLowered )
279-
{
280-
//no change
281-
return;
282-
}
283-
284-
//update all positions
285-
updateZValues();
286-
update();
287-
}
288-
289168
QgsLayoutItem *QgsLayout::itemByUuid( const QString &uuid )
290169
{
291170
QList<QgsLayoutItem *> itemList;

‎src/core/layout/qgslayout.h

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
135135
*/
136136
void deselectAll();
137137

138-
/**
139-
* Locks any selected items, preventing them from being interacted with
140-
* by mouse interactions.
141-
* \see unlockAllItems()
142-
*/
143-
void lockSelectedItems();
144-
145-
/**
146-
* Unlocks all locked items in the layout.
147-
* \see lockSelectedItems()
148-
*/
149-
void unlockAllItems();
150-
151138
/**
152139
* Raises an \a item up the z-order.
153140
* Returns true if the item was successfully raised.
@@ -158,6 +145,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
158145
* updating the scene for each one.
159146
*
160147
* \see lowerItem()
148+
* \see updateZValues()
161149
*/
162150
bool raiseItem( QgsLayoutItem *item, bool deferUpdate = false );
163151

@@ -171,6 +159,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
171159
* updating the scene for each one.
172160
*
173161
* \see raiseItem()
162+
* \see updateZValues()
174163
*/
175164
bool lowerItem( QgsLayoutItem *item, bool deferUpdate = false );
176165

@@ -184,6 +173,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
184173
* updating the scene for each one.
185174
*
186175
* \see moveItemToBottom()
176+
* \see updateZValues()
187177
*/
188178
bool moveItemToTop( QgsLayoutItem *item, bool deferUpdate = false );
189179

@@ -196,40 +186,16 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
196186
* updating the scene for each one.
197187
*
198188
* \see moveItemToTop()
189+
* \see updateZValues()
199190
*/
200191
bool moveItemToBottom( QgsLayoutItem *item, bool deferUpdate = false );
201192

202193
/**
203-
* Raises the selected items up the z-order.
204-
* \see lowerSelectedItems()
205-
* \see moveSelectedItemsToTop()
206-
* \see moveSelectedItemsToBottom()
207-
*/
208-
void raiseSelectedItems();
209-
210-
/**
211-
* Lowers the selected items down the z-order.
212-
* \see raiseSelectedItems()
213-
* \see moveSelectedItemsToTop()
214-
* \see moveSelectedItemsToBottom()
194+
* Resets the z-values of items based on their position in the internal
195+
* z order list. This should be called after any stacking changes
196+
* which deferred z-order updates.
215197
*/
216-
void lowerSelectedItems();
217-
218-
/**
219-
* Raises the selected items to the top of the z-order.
220-
* \see raiseSelectedItems()
221-
* \see lowerSelectedItems()
222-
* \see moveSelectedItemsToBottom()
223-
*/
224-
void moveSelectedItemsToTop();
225-
226-
/**
227-
* Lowers the selected items to the bottom of the z-order.
228-
* \see raiseSelectedItems()
229-
* \see lowerSelectedItems()
230-
* \see moveSelectedItemsToTop()
231-
*/
232-
void moveSelectedItemsToBottom();
198+
void updateZValues( const bool addUndoCommands = true );
233199

234200
/**
235201
* Returns the layout item with matching \a uuid unique identifier, or a nullptr
@@ -523,9 +489,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
523489
//! Reads only the layout settings (not member settings like grid settings, etc) from XML
524490
bool readXmlLayoutSettings( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context );
525491

526-
//! Reset z-values of items based on position in z list
527-
void updateZValues( const bool addUndoCommands = true );
528-
529492

530493
friend class QgsLayoutUndoCommand;
531494
friend class QgsLayoutModel;

‎src/gui/layout/qgslayoutview.cpp

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,130 @@ void QgsLayoutView::selectNextItemBelow()
398398
selectNextByZOrder( currentLayout(), false );
399399
}
400400

401+
void QgsLayoutView::raiseSelectedItems()
402+
{
403+
const QList<QgsLayoutItem *> selectedItems = currentLayout()->selectedLayoutItems();
404+
bool itemsRaised = false;
405+
for ( QgsLayoutItem *item : selectedItems )
406+
{
407+
itemsRaised = itemsRaised | currentLayout()->raiseItem( item, true );
408+
}
409+
410+
if ( !itemsRaised )
411+
{
412+
//no change
413+
return;
414+
}
415+
416+
//update all positions
417+
currentLayout()->updateZValues();
418+
currentLayout()->update();
419+
}
420+
421+
void QgsLayoutView::lowerSelectedItems()
422+
{
423+
const QList<QgsLayoutItem *> selectedItems = currentLayout()->selectedLayoutItems();
424+
bool itemsLowered = false;
425+
for ( QgsLayoutItem *item : selectedItems )
426+
{
427+
itemsLowered = itemsLowered | currentLayout()->lowerItem( item, true );
428+
}
429+
430+
if ( !itemsLowered )
431+
{
432+
//no change
433+
return;
434+
}
435+
436+
//update all positions
437+
currentLayout()->updateZValues();
438+
currentLayout()->update();
439+
}
440+
441+
void QgsLayoutView::moveSelectedItemsToTop()
442+
{
443+
const QList<QgsLayoutItem *> selectedItems = currentLayout()->selectedLayoutItems();
444+
bool itemsRaised = false;
445+
for ( QgsLayoutItem *item : selectedItems )
446+
{
447+
itemsRaised = itemsRaised | currentLayout()->moveItemToTop( item, true );
448+
}
449+
450+
if ( !itemsRaised )
451+
{
452+
//no change
453+
return;
454+
}
455+
456+
//update all positions
457+
currentLayout()->updateZValues();
458+
currentLayout()->update();
459+
}
460+
461+
void QgsLayoutView::moveSelectedItemsToBottom()
462+
{
463+
const QList<QgsLayoutItem *> selectedItems = currentLayout()->selectedLayoutItems();
464+
bool itemsLowered = false;
465+
for ( QgsLayoutItem *item : selectedItems )
466+
{
467+
itemsLowered = itemsLowered | currentLayout()->moveItemToBottom( item, true );
468+
}
469+
470+
if ( !itemsLowered )
471+
{
472+
//no change
473+
return;
474+
}
475+
476+
//update all positions
477+
currentLayout()->updateZValues();
478+
currentLayout()->update();
479+
}
480+
481+
void QgsLayoutView::lockSelectedItems()
482+
{
483+
currentLayout()->undoStack()->beginMacro( tr( "Items locked" ) );
484+
const QList<QgsLayoutItem *> selectionList = currentLayout()->selectedLayoutItems();
485+
for ( QgsLayoutItem *item : selectionList )
486+
{
487+
currentLayout()->undoStack()->beginCommand( item, QString() );
488+
item->setLocked( true );
489+
currentLayout()->undoStack()->endCommand();
490+
}
491+
492+
currentLayout()->deselectAll();
493+
currentLayout()->undoStack()->endMacro();
494+
}
495+
496+
void QgsLayoutView::unlockAllItems()
497+
{
498+
//unlock all items in layout
499+
currentLayout()->undoStack()->beginMacro( tr( "Items unlocked" ) );
500+
501+
//first, clear the selection
502+
currentLayout()->deselectAll();
503+
504+
QgsLayoutItem *focusItem = nullptr;
505+
506+
const QList<QGraphicsItem *> itemList = currentLayout()->items();
507+
for ( QGraphicsItem *graphicItem : itemList )
508+
{
509+
QgsLayoutItem *item = dynamic_cast<QgsLayoutItem *>( graphicItem );
510+
if ( item && item->isLocked() )
511+
{
512+
focusItem = item;
513+
currentLayout()->undoStack()->beginCommand( item, QString() );
514+
item->setLocked( false );
515+
//select unlocked items, same behavior as illustrator
516+
item->setSelected( true );
517+
currentLayout()->undoStack()->endCommand();
518+
}
519+
}
520+
currentLayout()->undoStack()->endMacro();
521+
522+
emit itemFocused( focusItem );
523+
}
524+
401525
void QgsLayoutView::mousePressEvent( QMouseEvent *event )
402526
{
403527
mSnapMarker->setVisible( false );

‎src/gui/layout/qgslayoutview.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,51 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView
255255
*/
256256
void selectNextItemBelow();
257257

258+
/**
259+
* Raises the selected items up the z-order.
260+
* \see lowerSelectedItems()
261+
* \see moveSelectedItemsToTop()
262+
* \see moveSelectedItemsToBottom()
263+
*/
264+
void raiseSelectedItems();
265+
266+
/**
267+
* Lowers the selected items down the z-order.
268+
* \see raiseSelectedItems()
269+
* \see moveSelectedItemsToTop()
270+
* \see moveSelectedItemsToBottom()
271+
*/
272+
void lowerSelectedItems();
273+
274+
/**
275+
* Raises the selected items to the top of the z-order.
276+
* \see raiseSelectedItems()
277+
* \see lowerSelectedItems()
278+
* \see moveSelectedItemsToBottom()
279+
*/
280+
void moveSelectedItemsToTop();
281+
282+
/**
283+
* Lowers the selected items to the bottom of the z-order.
284+
* \see raiseSelectedItems()
285+
* \see lowerSelectedItems()
286+
* \see moveSelectedItemsToTop()
287+
*/
288+
void moveSelectedItemsToBottom();
289+
290+
/**
291+
* Locks any selected items, preventing them from being interacted with
292+
* by mouse interactions.
293+
* \see unlockAllItems()
294+
*/
295+
void lockSelectedItems();
296+
297+
/**
298+
* Unlocks all locked items in the layout.
299+
* \see lockSelectedItems()
300+
*/
301+
void unlockAllItems();
302+
258303
/**
259304
* Updates associated rulers and other widgets after view extent or zoom has changed.
260305
* This should be called after calling any of the QGraphicsView

‎tests/src/python/test_qgslayout.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -179,40 +179,6 @@ def testLayoutItemAt(self):
179179
item2.setLocked(True)
180180
self.assertEqual(l.layoutItemAt(QPointF(9, 13), item3, True), item1)
181181

182-
def testLockActions(self):
183-
p = QgsProject()
184-
l = QgsLayout(p)
185-
186-
# add some items
187-
item1 = QgsLayoutItemMap(l)
188-
l.addItem(item1)
189-
item2 = QgsLayoutItemMap(l)
190-
l.addItem(item2)
191-
item3 = QgsLayoutItemMap(l)
192-
l.addItem(item3)
193-
194-
item1.setLocked(True)
195-
item3.setLocked(True)
196-
self.assertTrue(item1.isLocked())
197-
self.assertFalse(item2.isLocked())
198-
self.assertTrue(item3.isLocked())
199-
200-
l.unlockAllItems()
201-
self.assertFalse(item1.isLocked())
202-
self.assertFalse(item2.isLocked())
203-
self.assertFalse(item3.isLocked())
204-
self.assertTrue(item1.isSelected())
205-
self.assertFalse(item2.isSelected())
206-
self.assertTrue(item3.isSelected())
207-
208-
l.lockSelectedItems()
209-
self.assertTrue(item1.isLocked())
210-
self.assertFalse(item2.isLocked())
211-
self.assertTrue(item3.isLocked())
212-
self.assertFalse(item1.isSelected())
213-
self.assertFalse(item2.isSelected())
214-
self.assertFalse(item3.isSelected())
215-
216182
def testStacking(self):
217183
p = QgsProject()
218184
l = QgsLayout(p)

‎tests/src/python/test_qgslayoutview.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,43 @@ def testSelectNextByZOrder(self):
251251
self.assertFalse(item3.isSelected())
252252
self.assertEqual(len(focused_item_spy), 5)
253253

254+
def testLockActions(self):
255+
p = QgsProject()
256+
l = QgsLayout(p)
257+
258+
view = QgsLayoutView()
259+
view.setCurrentLayout(l)
260+
261+
# add some items
262+
item1 = QgsLayoutItemMap(l)
263+
l.addItem(item1)
264+
item2 = QgsLayoutItemMap(l)
265+
l.addItem(item2)
266+
item3 = QgsLayoutItemMap(l)
267+
l.addItem(item3)
268+
269+
item1.setLocked(True)
270+
item3.setLocked(True)
271+
self.assertTrue(item1.isLocked())
272+
self.assertFalse(item2.isLocked())
273+
self.assertTrue(item3.isLocked())
274+
275+
view.unlockAllItems()
276+
self.assertFalse(item1.isLocked())
277+
self.assertFalse(item2.isLocked())
278+
self.assertFalse(item3.isLocked())
279+
self.assertTrue(item1.isSelected())
280+
self.assertFalse(item2.isSelected())
281+
self.assertTrue(item3.isSelected())
282+
283+
view.lockSelectedItems()
284+
self.assertTrue(item1.isLocked())
285+
self.assertFalse(item2.isLocked())
286+
self.assertTrue(item3.isLocked())
287+
self.assertFalse(item1.isSelected())
288+
self.assertFalse(item2.isSelected())
289+
self.assertFalse(item3.isSelected())
290+
254291

255292
if __name__ == '__main__':
256293
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.