Skip to content
Permalink
Browse files

[composer] Locked items can't be selected by clicking them in the can…

…vas.
  • Loading branch information
nyalldawson committed Jul 30, 2014
1 parent 7b347c7 commit 0aeb35779870b681aa44c545edda2f3dbd36a1a6
@@ -181,13 +181,20 @@ class QgsComposition : QGraphicsScene
/**Returns pointer to undo/redo command storage*/
QUndoStack* undoStack();

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

/**Returns the highest composer item at a specified position which is below a specified item. Ignores mPaperItem
@note Added in QGIS 2.1
/**Returns the topmost composer item at a specified position which is below a specified item. Ignores paper items.
* @param position point to search for item at
* @param belowItem item to search below
* @param ignoreLocked set to true to ignore locked items
* @returns composer item at position which is below specified item
*/
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem ) const;
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem, const bool ignoreLocked = false ) const;

/** Returns the page number (0-bsaed) given a coordinate */
int pageNumberAt( const QPointF& position ) const;
@@ -444,12 +444,12 @@ void QgsComposition::setStatusMessage( const QString & message )
emit statusMsgChanged( message );
}

QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position ) const
QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position , const bool ignoreLocked ) const
{
return composerItemAt( position, 0 );
return composerItemAt( position, 0, ignoreLocked );
}

QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position, const QgsComposerItem* belowItem ) const
QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position, const QgsComposerItem* belowItem, const bool ignoreLocked ) const
{
//get a list of items which intersect the specified position, in descending z order
QList<QGraphicsItem*> itemList;
@@ -465,7 +465,7 @@ QgsComposerItem* QgsComposition::composerItemAt( const QPointF & position, const
{
// If we are not checking for a an item below a specified item, or if we've
// already found that item, then we've found our target
if ( ! belowItem || foundBelowItem )
if (( ! belowItem || foundBelowItem ) && ( !ignoreLocked || !composerItem->positionLock() ) )
{
return composerItem;
}
@@ -241,13 +241,20 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
/**Returns pointer to undo/redo command storage*/
QUndoStack* undoStack() { return mUndoStack; }

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

/**Returns the highest composer item at a specified position which is below a specified item. Ignores mPaperItem
@note Added in QGIS 2.1
/**Returns the topmost composer item at a specified position which is below a specified item. Ignores paper items.
* @param position point to search for item at
* @param belowItem item to search below
* @param ignoreLocked set to true to ignore locked items
* @returns composer item at position which is below specified item
*/
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem ) const;
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem, const bool ignoreLocked = false ) const;

/** Returns the page number (0-based) given a coordinate */
int pageNumberAt( const QPointF& position ) const;
@@ -208,19 +208,19 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
if ( previousSelectedItem )
{
//select highest item just below previously selected item at position of event
selectedItem = composition()->composerItemAt( scenePoint, previousSelectedItem );
selectedItem = composition()->composerItemAt( scenePoint, previousSelectedItem, true );

//if we didn't find a lower item we'll use the top-most as fall-back
//this duplicates mapinfo/illustrator/etc behaviour where ctrl-clicks are "cyclic"
if ( !selectedItem )
{
selectedItem = composition()->composerItemAt( scenePoint );
selectedItem = composition()->composerItemAt( scenePoint, true );
}
}
else
{
//select topmost item at position of event
selectedItem = composition()->composerItemAt( scenePoint );
selectedItem = composition()->composerItemAt( scenePoint, true );
}

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

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

0 comments on commit 0aeb357

Please sign in to comment.
You can’t perform that action at this time.