Fix repositioning guides on pages > 1

This commit is contained in:
Nyall Dawson 2017-12-19 13:26:32 +10:00
parent b594ecd7c5
commit e9c0d29ff1
2 changed files with 9 additions and 6 deletions

View File

@ -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 );

View File

@ -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() );
@ -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 );