Skip to content

Commit

Permalink
Fix repositioning guides on pages > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 19, 2017
1 parent b594ecd commit e9c0d29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/app/layout/qgslayoutguidewidget.cpp
Expand Up @@ -41,11 +41,11 @@ QgsLayoutGuideWidget::QgsLayoutGuideWidget( QWidget *parent, QgsLayout *layout,
mVertGuidesTableView->setEditTriggers( QAbstractItemView::AllEditTriggers );


mHozGuidesTableView->setItemDelegateForColumn( 0, new QgsLayoutGuidePositionDelegate( mHozGuidesTableView, mLayout, mHozProxyModel ) );
mHozGuidesTableView->setItemDelegateForColumn( 1, new QgsLayoutGuideUnitDelegate( mHozGuidesTableView, mLayout, mHozProxyModel ) );
mHozGuidesTableView->setItemDelegateForColumn( 0, new QgsLayoutGuidePositionDelegate( mHozGuidesTableView, mLayout, &mLayout->guides() ) );
mHozGuidesTableView->setItemDelegateForColumn( 1, new QgsLayoutGuideUnitDelegate( mHozGuidesTableView, mLayout, &mLayout->guides() ) );

mVertGuidesTableView->setItemDelegateForColumn( 0, new QgsLayoutGuidePositionDelegate( mVertGuidesTableView, mLayout, mVertProxyModel ) );
mVertGuidesTableView->setItemDelegateForColumn( 1, new QgsLayoutGuideUnitDelegate( mVertGuidesTableView, mLayout, mVertProxyModel ) );
mVertGuidesTableView->setItemDelegateForColumn( 0, new QgsLayoutGuidePositionDelegate( mVertGuidesTableView, mLayout, &mLayout->guides() ) );
mVertGuidesTableView->setItemDelegateForColumn( 1, new QgsLayoutGuideUnitDelegate( mVertGuidesTableView, mLayout, &mLayout->guides() ) );

connect( mAddHozGuideButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::addHorizontalGuide );
connect( mAddVertGuideButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::addVerticalGuide );
Expand Down
7 changes: 5 additions & 2 deletions src/core/layout/qgslayoutguidecollection.cpp
Expand Up @@ -140,11 +140,11 @@ void QgsLayoutGuide::setLayoutPosition( double position )
switch ( mOrientation )
{
case Qt::Horizontal:
p = mLineItem->mapFromScene( QPointF( 0, position ) ).y();
p = mPage->mapFromScene( QPointF( 0, position ) ).y();
break;

case Qt::Vertical:
p = mLineItem->mapFromScene( QPointF( position, 0 ) ).x();
p = mPage->mapFromScene( QPointF( position, 0 ) ).x();
break;
}
mPosition = mLayout->convertFromLayoutUnits( p, mPosition.units() );
Expand Down Expand Up @@ -299,6 +299,9 @@ bool QgsLayoutGuideCollection::setData( const QModelIndex &index, const QVariant
return false;

QgsLayoutMeasurement m = guide->position();
if ( m.length() == newPos )
return true;

m.setLength( newPos );
mLayout->undoStack()->beginCommand( mPageCollection, tr( "Move Guide" ), Move + index.row() );
whileBlocking( guide )->setPosition( m );
Expand Down

0 comments on commit e9c0d29

Please sign in to comment.