Skip to content

Commit 0aeb357

Browse files
committed
[composer] Locked items can't be selected by clicking them in the canvas.
1 parent 7b347c7 commit 0aeb357

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

python/core/composer/qgscomposition.sip

+12-5
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,20 @@ class QgsComposition : QGraphicsScene
181181
/**Returns pointer to undo/redo command storage*/
182182
QUndoStack* undoStack();
183183

184-
/**Returns the topmost composer item. Ignores mPaperItem*/
185-
QgsComposerItem* composerItemAt( const QPointF & position ) const;
184+
/**Returns the topmost composer item at a specified position. Ignores paper items.
185+
* @param position point to search for item at
186+
* @param ignoreLocked set to true to ignore locked items
187+
* @returns composer item at position
188+
*/
189+
QgsComposerItem* composerItemAt( const QPointF & position, const bool ignoreLocked = false ) const;
186190

187-
/**Returns the highest composer item at a specified position which is below a specified item. Ignores mPaperItem
188-
@note Added in QGIS 2.1
191+
/**Returns the topmost composer item at a specified position which is below a specified item. Ignores paper items.
192+
* @param position point to search for item at
193+
* @param belowItem item to search below
194+
* @param ignoreLocked set to true to ignore locked items
195+
* @returns composer item at position which is below specified item
189196
*/
190-
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem ) const;
197+
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem, const bool ignoreLocked = false ) const;
191198

192199
/** Returns the page number (0-bsaed) given a coordinate */
193200
int pageNumberAt( const QPointF& position ) const;

src/core/composer/qgscomposition.cpp

100755100644
+4-4
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ void QgsComposition::setStatusMessage( const QString & message )
444444
emit statusMsgChanged( message );
445445
}
446446

447-
QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position ) const
447+
QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position , const bool ignoreLocked ) const
448448
{
449-
return composerItemAt( position, 0 );
449+
return composerItemAt( position, 0, ignoreLocked );
450450
}
451451

452-
QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position, const QgsComposerItem* belowItem ) const
452+
QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position, const QgsComposerItem* belowItem, const bool ignoreLocked ) const
453453
{
454454
//get a list of items which intersect the specified position, in descending z order
455455
QList<QGraphicsItem*> itemList;
@@ -465,7 +465,7 @@ QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position, const
465465
{
466466
// If we are not checking for a an item below a specified item, or if we've
467467
// already found that item, then we've found our target
468-
if ( ! belowItem || foundBelowItem )
468+
if (( ! belowItem || foundBelowItem ) && ( !ignoreLocked || !composerItem->positionLock() ) )
469469
{
470470
return composerItem;
471471
}

src/core/composer/qgscomposition.h

+12-5
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,20 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
241241
/**Returns pointer to undo/redo command storage*/
242242
QUndoStack* undoStack() { return mUndoStack; }
243243

244-
/**Returns the topmost composer item. Ignores mPaperItem*/
245-
QgsComposerItem* composerItemAt( const QPointF & position ) const;
244+
/**Returns the topmost composer item at a specified position. Ignores paper items.
245+
* @param position point to search for item at
246+
* @param ignoreLocked set to true to ignore locked items
247+
* @returns composer item at position
248+
*/
249+
QgsComposerItem* composerItemAt( const QPointF & position, const bool ignoreLocked = false ) const;
246250

247-
/**Returns the highest composer item at a specified position which is below a specified item. Ignores mPaperItem
248-
@note Added in QGIS 2.1
251+
/**Returns the topmost composer item at a specified position which is below a specified item. Ignores paper items.
252+
* @param position point to search for item at
253+
* @param belowItem item to search below
254+
* @param ignoreLocked set to true to ignore locked items
255+
* @returns composer item at position which is below specified item
249256
*/
250-
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem ) const;
257+
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem, const bool ignoreLocked = false ) const;
251258

252259
/** Returns the page number (0-based) given a coordinate */
253260
int pageNumberAt( const QPointF& position ) const;

src/gui/qgscomposerview.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,19 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
208208
if ( previousSelectedItem )
209209
{
210210
//select highest item just below previously selected item at position of event
211-
selectedItem = composition()->composerItemAt( scenePoint, previousSelectedItem );
211+
selectedItem = composition()->composerItemAt( scenePoint, previousSelectedItem, true );
212212

213213
//if we didn't find a lower item we'll use the top-most as fall-back
214214
//this duplicates mapinfo/illustrator/etc behaviour where ctrl-clicks are "cyclic"
215215
if ( !selectedItem )
216216
{
217-
selectedItem = composition()->composerItemAt( scenePoint );
217+
selectedItem = composition()->composerItemAt( scenePoint, true );
218218
}
219219
}
220220
else
221221
{
222222
//select topmost item at position of event
223-
selectedItem = composition()->composerItemAt( scenePoint );
223+
selectedItem = composition()->composerItemAt( scenePoint, true );
224224
}
225225

226226
if ( !selectedItem )
@@ -1506,7 +1506,7 @@ void QgsComposerView::wheelEvent( QWheelEvent* event )
15061506

15071507
QPointF scenePoint = mapToScene( event->pos() );
15081508
//select topmost item at position of event
1509-
QgsComposerItem* theItem = composition()->composerItemAt( scenePoint );
1509+
QgsComposerItem* theItem = composition()->composerItemAt( scenePoint, true );
15101510
if ( theItem )
15111511
{
15121512
if ( theItem->isSelected() )

0 commit comments

Comments
 (0)