Remove redundant custom enum (use Qt version instead)

This commit is contained in:
Nyall Dawson 2017-10-03 10:55:41 +10:00
parent 639ecd1748
commit de9653044a
11 changed files with 137 additions and 149 deletions

View File

@ -20,13 +20,7 @@ class QgsLayoutGuide : QObject
%End
public:
enum Orientation
{
Horizontal,
Vertical,
};
QgsLayoutGuide( Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page );
QgsLayoutGuide( Qt::Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page );
%Docstring
Constructor for a new guide with the specified ``orientation`` and
initial ``position``.
@ -57,10 +51,10 @@ class QgsLayoutGuide : QObject
.. seealso:: layout()
%End
Orientation orientation() const;
Qt::Orientation orientation() const;
%Docstring
Returns the guide's orientation.
:rtype: Orientation
:rtype: Qt.Orientation
%End
QgsLayoutMeasurement position() const;
@ -213,7 +207,7 @@ class QgsLayoutGuideCollection : QAbstractTableModel, QgsLayoutSerializableObjec
Updates the position (and visibility) of all guide line items.
%End
QList< QgsLayoutGuide * > guides( QgsLayoutGuide::Orientation orientation, int page = -1 );
QList< QgsLayoutGuide * > guides( Qt::Orientation orientation, int page = -1 );
%Docstring
Returns the list of guides contained in the collection with the specified
``orientation`` and on a matching ``page``.
@ -273,7 +267,7 @@ class QgsLayoutGuideProxyModel : QSortFilterProxyModel
%End
public:
explicit QgsLayoutGuideProxyModel( QObject *parent /TransferThis/, QgsLayoutGuide::Orientation orientation, int page );
explicit QgsLayoutGuideProxyModel( QObject *parent /TransferThis/, Qt::Orientation orientation, int page );
%Docstring
Constructor for QgsLayoutGuideProxyModel, filtered to guides of the specified ``orientation`` and ``page`` only.

View File

@ -162,7 +162,7 @@ class QgsLayoutSnapper: QgsLayoutSerializableObject
:rtype: QPointF
%End
double snapPointToGuides( double original, QgsLayoutGuide::Orientation orientation, double scaleFactor, bool &snapped /Out/ ) const;
double snapPointToGuides( double original, Qt::Orientation orientation, double scaleFactor, bool &snapped /Out/ ) const;
%Docstring
Snaps an ``original`` layout coordinate to the guides. If the point
was snapped, ``snapped`` will be set to true.
@ -178,7 +178,7 @@ class QgsLayoutSnapper: QgsLayoutSerializableObject
:rtype: float
%End
double snapPointsToGuides( const QList< double > &points, QgsLayoutGuide::Orientation orientation, double scaleFactor, bool &snapped /Out/ ) const;
double snapPointsToGuides( const QList< double > &points, Qt::Orientation orientation, double scaleFactor, bool &snapped /Out/ ) const;
%Docstring
Snaps a set of ``points`` to the guides. If the points
were snapped, ``snapped`` will be set to true.

View File

@ -27,9 +27,9 @@ QgsLayoutGuideWidget::QgsLayoutGuideWidget( QWidget *parent, QgsLayout *layout,
setupUi( this );
setPanelTitle( tr( "Guides" ) );
mHozProxyModel = new QgsLayoutGuideProxyModel( mHozGuidesTableView, QgsLayoutGuide::Horizontal, 0 );
mHozProxyModel = new QgsLayoutGuideProxyModel( mHozGuidesTableView, Qt::Horizontal, 0 );
mHozProxyModel->setSourceModel( &mLayout->guides() );
mVertProxyModel = new QgsLayoutGuideProxyModel( mVertGuidesTableView, QgsLayoutGuide::Vertical, 0 );
mVertProxyModel = new QgsLayoutGuideProxyModel( mVertGuidesTableView, Qt::Vertical, 0 );
mVertProxyModel->setSourceModel( &mLayout->guides() );
mHozGuidesTableView->setModel( mHozProxyModel );
@ -60,13 +60,13 @@ QgsLayoutGuideWidget::QgsLayoutGuideWidget( QWidget *parent, QgsLayout *layout,
void QgsLayoutGuideWidget::addHorizontalGuide()
{
std::unique_ptr< QgsLayoutGuide > newGuide( new QgsLayoutGuide( QgsLayoutGuide::Horizontal, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ) );
std::unique_ptr< QgsLayoutGuide > newGuide( new QgsLayoutGuide( Qt::Horizontal, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ) );
mLayout->guides().addGuide( newGuide.release() );
}
void QgsLayoutGuideWidget::addVerticalGuide()
{
std::unique_ptr< QgsLayoutGuide > newGuide( new QgsLayoutGuide( QgsLayoutGuide::Vertical, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ) );
std::unique_ptr< QgsLayoutGuide > newGuide( new QgsLayoutGuide( Qt::Vertical, QgsLayoutMeasurement( 0 ), mLayout->pageCollection()->page( mPage ) ) );
mLayout->guides().addGuide( newGuide.release() );
}

View File

@ -25,7 +25,7 @@
// QgsLayoutGuide
//
QgsLayoutGuide::QgsLayoutGuide( Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page )
QgsLayoutGuide::QgsLayoutGuide( Qt::Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page )
: QObject( nullptr )
, mOrientation( orientation )
, mPosition( position )
@ -84,7 +84,7 @@ void QgsLayoutGuide::update()
bool showGuide = mLayout->guides().visible();
switch ( mOrientation )
{
case Horizontal:
case Qt::Horizontal:
if ( layoutPos > mPage->rect().height() )
{
mLineItem->hide();
@ -97,7 +97,7 @@ void QgsLayoutGuide::update()
break;
case Vertical:
case Qt::Vertical:
if ( layoutPos > mPage->rect().width() )
{
mLineItem->hide();
@ -124,10 +124,10 @@ double QgsLayoutGuide::layoutPosition() const
switch ( mOrientation )
{
case Horizontal:
case Qt::Horizontal:
return mLineItem->mapToScene( mLineItem->line().p1() ).y();
case Vertical:
case Qt::Vertical:
return mLineItem->mapToScene( mLineItem->line().p1() ).x();
}
return -999; // avoid warning
@ -141,11 +141,11 @@ void QgsLayoutGuide::setLayoutPosition( double position )
double p = 0;
switch ( mOrientation )
{
case Horizontal:
case Qt::Horizontal:
p = mLineItem->mapFromScene( QPointF( 0, position ) ).y();
break;
case Vertical:
case Qt::Vertical:
p = mLineItem->mapFromScene( QPointF( position, 0 ) ).x();
break;
}
@ -180,7 +180,7 @@ void QgsLayoutGuide::setLayout( QgsLayout *layout )
update();
}
QgsLayoutGuide::Orientation QgsLayoutGuide::orientation() const
Qt::Orientation QgsLayoutGuide::orientation() const
{
return mOrientation;
}
@ -469,7 +469,7 @@ void QgsLayoutGuideCollection::update()
}
}
QList<QgsLayoutGuide *> QgsLayoutGuideCollection::guides( QgsLayoutGuide::Orientation orientation, int page )
QList<QgsLayoutGuide *> QgsLayoutGuideCollection::guides( Qt::Orientation orientation, int page )
{
QList<QgsLayoutGuide *> res;
Q_FOREACH ( QgsLayoutGuide *guide, mGuides )
@ -556,7 +556,7 @@ bool QgsLayoutGuideCollection::readXml( const QDomElement &e, const QDomDocument
for ( int i = 0; i < guideNodeList.size(); ++i )
{
QDomElement element = guideNodeList.at( i ).toElement();
QgsLayoutGuide::Orientation orientation = static_cast< QgsLayoutGuide::Orientation >( element.attribute( QStringLiteral( "orientation" ), QStringLiteral( "0" ) ).toInt() );
Qt::Orientation orientation = static_cast< Qt::Orientation >( element.attribute( QStringLiteral( "orientation" ), QStringLiteral( "1" ) ).toInt() );
double pos = element.attribute( QStringLiteral( "position" ), QStringLiteral( "0" ) ).toDouble();
QgsUnitTypes::LayoutUnit unit = QgsUnitTypes::decodeLayoutUnit( element.attribute( QStringLiteral( "units" ) ) );
int page = element.attribute( QStringLiteral( "page" ), QStringLiteral( "0" ) ).toInt();
@ -574,7 +574,7 @@ bool QgsLayoutGuideCollection::readXml( const QDomElement &e, const QDomDocument
// QgsLayoutGuideProxyModel
//
QgsLayoutGuideProxyModel::QgsLayoutGuideProxyModel( QObject *parent, QgsLayoutGuide::Orientation orientation, int page )
QgsLayoutGuideProxyModel::QgsLayoutGuideProxyModel( QObject *parent, Qt::Orientation orientation, int page )
: QSortFilterProxyModel( parent )
, mOrientation( orientation )
, mPage( page )
@ -592,7 +592,7 @@ void QgsLayoutGuideProxyModel::setPage( int page )
bool QgsLayoutGuideProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
{
QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
QgsLayoutGuide::Orientation orientation = static_cast< QgsLayoutGuide::Orientation>( sourceModel()->data( index, QgsLayoutGuideCollection::OrientationRole ).toInt() );
Qt::Orientation orientation = static_cast< Qt::Orientation>( sourceModel()->data( index, QgsLayoutGuideCollection::OrientationRole ).toInt() );
if ( orientation != mOrientation )
return false;

View File

@ -46,13 +46,6 @@ class CORE_EXPORT QgsLayoutGuide : public QObject
public:
//! Guide orientation
enum Orientation
{
Horizontal, //!< Horizontal guide
Vertical, //!< Vertical guide
};
/**
* Constructor for a new guide with the specified \a orientation and
* initial \a position.
@ -61,7 +54,7 @@ class CORE_EXPORT QgsLayoutGuide : public QObject
* Adding the guide to a QgsLayoutGuideCollection will automatically set
* the corresponding layout for you.
*/
QgsLayoutGuide( Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page );
QgsLayoutGuide( Qt::Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page );
~QgsLayoutGuide();
@ -84,7 +77,7 @@ class CORE_EXPORT QgsLayoutGuide : public QObject
/**
* Returns the guide's orientation.
*/
Orientation orientation() const;
Qt::Orientation orientation() const;
/**
* Returns the guide's position within the page.
@ -151,7 +144,7 @@ class CORE_EXPORT QgsLayoutGuide : public QObject
private:
Orientation mOrientation = Vertical;
Qt::Orientation mOrientation = Qt::Vertical;
//! Horizontal/vertical position of guide on page
QgsLayoutMeasurement mPosition;
@ -248,7 +241,7 @@ class CORE_EXPORT QgsLayoutGuideCollection : public QAbstractTableModel, public
* If \a page is -1, guides from all pages will be returned.
* \see guidesOnPage()
*/
QList< QgsLayoutGuide * > guides( QgsLayoutGuide::Orientation orientation, int page = -1 );
QList< QgsLayoutGuide * > guides( Qt::Orientation orientation, int page = -1 );
/**
* Returns the list of guides contained on a matching \a page.
@ -323,7 +316,7 @@ class CORE_EXPORT QgsLayoutGuideProxyModel : public QSortFilterProxyModel
*
* Page numbers begin at 0.
*/
explicit QgsLayoutGuideProxyModel( QObject *parent SIP_TRANSFERTHIS, QgsLayoutGuide::Orientation orientation, int page );
explicit QgsLayoutGuideProxyModel( QObject *parent SIP_TRANSFERTHIS, Qt::Orientation orientation, int page );
/**
* Sets the current \a page for filtering matching guides. Page numbers begin at 0.
@ -334,7 +327,7 @@ class CORE_EXPORT QgsLayoutGuideProxyModel : public QSortFilterProxyModel
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
private:
QgsLayoutGuide::Orientation mOrientation = QgsLayoutGuide::Horizontal;
Qt::Orientation mOrientation = Qt::Horizontal;
int mPage = 0;
};

View File

@ -56,7 +56,7 @@ QPointF QgsLayoutSnapper::snapPoint( QPointF point, double scaleFactor, bool &sn
// highest priority - guides
bool snappedXToGuides = false;
double newX = snapPointToGuides( point.x(), QgsLayoutGuide::Vertical, scaleFactor, snappedXToGuides );
double newX = snapPointToGuides( point.x(), Qt::Vertical, scaleFactor, snappedXToGuides );
if ( snappedXToGuides )
{
snapped = true;
@ -65,7 +65,7 @@ QPointF QgsLayoutSnapper::snapPoint( QPointF point, double scaleFactor, bool &sn
verticalSnapLine->setVisible( false );
}
bool snappedYToGuides = false;
double newY = snapPointToGuides( point.y(), QgsLayoutGuide::Horizontal, scaleFactor, snappedYToGuides );
double newY = snapPointToGuides( point.y(), Qt::Horizontal, scaleFactor, snappedYToGuides );
if ( snappedYToGuides )
{
snapped = true;
@ -124,7 +124,7 @@ QRectF QgsLayoutSnapper::snapRect( const QRectF &rect, double scaleFactor, bool
// highest priority - guides
bool snappedXToGuides = false;
double deltaX = snapPointsToGuides( xCoords, QgsLayoutGuide::Vertical, scaleFactor, snappedXToGuides );
double deltaX = snapPointsToGuides( xCoords, Qt::Vertical, scaleFactor, snappedXToGuides );
if ( snappedXToGuides )
{
snapped = true;
@ -133,7 +133,7 @@ QRectF QgsLayoutSnapper::snapRect( const QRectF &rect, double scaleFactor, bool
verticalSnapLine->setVisible( false );
}
bool snappedYToGuides = false;
double deltaY = snapPointsToGuides( yCoords, QgsLayoutGuide::Horizontal, scaleFactor, snappedYToGuides );
double deltaY = snapPointsToGuides( yCoords, Qt::Horizontal, scaleFactor, snappedYToGuides );
if ( snappedYToGuides )
{
snapped = true;
@ -256,13 +256,13 @@ QPointF QgsLayoutSnapper::snapPointsToGrid( const QList<QPointF> &points, double
return delta;
}
double QgsLayoutSnapper::snapPointToGuides( double original, QgsLayoutGuide::Orientation orientation, double scaleFactor, bool &snapped ) const
double QgsLayoutSnapper::snapPointToGuides( double original, Qt::Orientation orientation, double scaleFactor, bool &snapped ) const
{
double delta = snapPointsToGuides( QList< double >() << original, orientation, scaleFactor, snapped );
return original + delta;
}
double QgsLayoutSnapper::snapPointsToGuides( const QList<double> &points, QgsLayoutGuide::Orientation orientation, double scaleFactor, bool &snapped ) const
double QgsLayoutSnapper::snapPointsToGuides( const QList<double> &points, Qt::Orientation orientation, double scaleFactor, bool &snapped ) const
{
snapped = false;
if ( !mLayout || !mSnapToGuides )

View File

@ -183,7 +183,7 @@ class CORE_EXPORT QgsLayoutSnapper: public QgsLayoutSerializableObject
*
* \see snapPointsToGuides()
*/
double snapPointToGuides( double original, QgsLayoutGuide::Orientation orientation, double scaleFactor, bool &snapped SIP_OUT ) const;
double snapPointToGuides( double original, Qt::Orientation orientation, double scaleFactor, bool &snapped SIP_OUT ) const;
/**
* Snaps a set of \a points to the guides. If the points
@ -200,7 +200,7 @@ class CORE_EXPORT QgsLayoutSnapper: public QgsLayoutSerializableObject
*
* \see snapPointToGuides()
*/
double snapPointsToGuides( const QList< double > &points, QgsLayoutGuide::Orientation orientation, double scaleFactor, bool &snapped SIP_OUT ) const;
double snapPointsToGuides( const QList< double > &points, Qt::Orientation orientation, double scaleFactor, bool &snapped SIP_OUT ) const;
/**
* Snaps an \a original layout coordinate to the item bounds. If the point

View File

@ -282,7 +282,7 @@ void QgsLayoutRuler::drawMarkerPos( QPainter *painter )
void QgsLayoutRuler::drawGuideMarkers( QPainter *p, QgsLayout *layout )
{
QList< QgsLayoutItemPage * > visiblePages = mView->visiblePages();
QList< QgsLayoutGuide * > guides = layout->guides().guides( mOrientation == Qt::Horizontal ? QgsLayoutGuide::Vertical : QgsLayoutGuide::Horizontal );
QList< QgsLayoutGuide * > guides = layout->guides().guides( mOrientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
p->save();
p->setRenderHint( QPainter::Antialiasing, true );
p->setPen( Qt::NoPen );
@ -365,7 +365,7 @@ QgsLayoutGuide *QgsLayoutRuler::guideAtPoint( QPoint localPoint ) const
{
QPointF layoutPoint = convertLocalPointToLayout( localPoint );
QList< QgsLayoutItemPage * > visiblePages = mView->visiblePages();
QList< QgsLayoutGuide * > guides = mView->currentLayout()->guides().guides( mOrientation == Qt::Horizontal ? QgsLayoutGuide::Vertical : QgsLayoutGuide::Horizontal );
QList< QgsLayoutGuide * > guides = mView->currentLayout()->guides().guides( mOrientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
QgsLayoutGuide *closestGuide = nullptr;
double minDelta = DBL_MAX;
Q_FOREACH ( QgsLayoutGuide *guide, guides )
@ -714,12 +714,12 @@ void QgsLayoutRuler::mouseReleaseEvent( QMouseEvent *event )
bool deleteGuide = false;
switch ( mDraggingGuide->orientation() )
{
case QgsLayoutGuide::Horizontal:
case Qt::Horizontal:
if ( layoutPoint.y() < page->scenePos().y() || layoutPoint.y() > page->scenePos().y() + page->rect().height() )
deleteGuide = true;
break;
case QgsLayoutGuide::Vertical:
case Qt::Vertical:
if ( layoutPoint.x() < page->scenePos().x() || layoutPoint.x() > page->scenePos().x() + page->rect().width() )
deleteGuide = true;
break;
@ -769,13 +769,13 @@ void QgsLayoutRuler::mouseReleaseEvent( QMouseEvent *event )
{
//mouse is creating a horizontal guide
double posOnPage = layout->pageCollection()->positionOnPage( scenePos ).y();
guide.reset( new QgsLayoutGuide( QgsLayoutGuide::Horizontal, QgsLayoutMeasurement( posOnPage, layout->units() ), page ) );
guide.reset( new QgsLayoutGuide( Qt::Horizontal, QgsLayoutMeasurement( posOnPage, layout->units() ), page ) );
break;
}
case Qt::Vertical:
{
//mouse is creating a vertical guide
guide.reset( new QgsLayoutGuide( QgsLayoutGuide::Vertical, QgsLayoutMeasurement( scenePos.x(), layout->units() ), page ) );
guide.reset( new QgsLayoutGuide( Qt::Vertical, QgsLayoutMeasurement( scenePos.x(), layout->units() ), page ) );
break;
}
}

View File

@ -55,7 +55,7 @@ class TestQgsLayout(unittest.TestCase):
grid = l.gridSettings()
grid.setResolution(QgsLayoutMeasurement(5, QgsUnitTypes.LayoutPoints))
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters),
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters),
l.pageCollection().page(0))
l.guides().addGuide(g1)
@ -76,7 +76,7 @@ class TestQgsLayout(unittest.TestCase):
self.assertEqual(collection2.page(0).pageSize().height(), 148)
self.assertEqual(l2.gridSettings().resolution().length(), 5.0)
self.assertEqual(l2.gridSettings().resolution().units(), QgsUnitTypes.LayoutPoints)
self.assertEqual(l2.guides().guidesOnPage(0)[0].orientation(), QgsLayoutGuide.Horizontal)
self.assertEqual(l2.guides().guidesOnPage(0)[0].orientation(), Qt.Horizontal)
self.assertEqual(l2.guides().guidesOnPage(0)[0].position().length(), 5.0)
self.assertEqual(l2.guides().guidesOnPage(0)[0].position().units(), QgsUnitTypes.LayoutCentimeters)
self.assertEqual(l2.snapper().snapTolerance(), 7)

View File

@ -23,7 +23,8 @@ from qgis.core import (QgsProject,
QgsLayoutItemPage,
QgsLayoutGuideCollection,
QgsLayoutGuideProxyModel)
from qgis.PyQt.QtCore import (QModelIndex)
from qgis.PyQt.QtCore import (Qt,
QModelIndex)
from qgis.PyQt.QtGui import (QPen,
QColor)
from qgis.PyQt.QtTest import QSignalSpy
@ -42,8 +43,8 @@ class TestQgsLayoutGuide(unittest.TestCase):
p = QgsProject()
l = QgsLayout(p)
l.initializeDefaults() # add a page
g = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), None)
self.assertEqual(g.orientation(), QgsLayoutGuide.Horizontal)
g = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), None)
self.assertEqual(g.orientation(), Qt.Horizontal)
self.assertEqual(g.position().length(), 5.0)
self.assertEqual(g.position().units(), QgsUnitTypes.LayoutCentimeters)
@ -64,7 +65,7 @@ class TestQgsLayoutGuide(unittest.TestCase):
p = QgsProject()
l = QgsLayout(p)
l.initializeDefaults() # add a page
g = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g.setLayout(l)
g.update()
@ -85,7 +86,7 @@ class TestQgsLayoutGuide(unittest.TestCase):
self.assertEqual(g.layoutPosition(), 15)
# vertical guide
g2 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g2.setLayout(l)
g2.update()
self.assertTrue(g2.item().isVisible())
@ -117,50 +118,50 @@ class TestQgsLayoutGuide(unittest.TestCase):
# no guides initially
self.assertEqual(guides.rowCount(QModelIndex()), 0)
self.assertFalse(guides.data(QModelIndex(), QgsLayoutGuideCollection.OrientationRole))
self.assertFalse(guides.guides(QgsLayoutGuide.Horizontal))
self.assertFalse(guides.guides(QgsLayoutGuide.Vertical))
self.assertFalse(guides.guides(Qt.Horizontal))
self.assertFalse(guides.guides(Qt.Vertical))
# add a guide
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
self.assertEqual(guides.rowCount(QModelIndex()), 1)
self.assertEqual(guides.data(guides.index(0, 0), QgsLayoutGuideCollection.OrientationRole), QgsLayoutGuide.Horizontal)
self.assertEqual(guides.data(guides.index(0, 0), QgsLayoutGuideCollection.OrientationRole), Qt.Horizontal)
self.assertEqual(guides.data(guides.index(0, 0), QgsLayoutGuideCollection.PositionRole), 5)
self.assertEqual(guides.data(guides.index(0, 0), QgsLayoutGuideCollection.UnitsRole), QgsUnitTypes.LayoutCentimeters)
self.assertEqual(guides.data(guides.index(0, 0), QgsLayoutGuideCollection.PageRole), 0)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1])
self.assertFalse(guides.guides(QgsLayoutGuide.Vertical))
self.assertEqual(guides.guides(Qt.Horizontal), [g1])
self.assertFalse(guides.guides(Qt.Vertical))
self.assertEqual(guides.guidesOnPage(0), [g1])
self.assertEqual(guides.guidesOnPage(1), [])
g2 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(15), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(15), l.pageCollection().page(0))
guides.addGuide(g2)
self.assertEqual(guides.rowCount(QModelIndex()), 2)
self.assertEqual(guides.data(guides.index(1, 0), QgsLayoutGuideCollection.OrientationRole), QgsLayoutGuide.Horizontal)
self.assertEqual(guides.data(guides.index(1, 0), QgsLayoutGuideCollection.OrientationRole), Qt.Horizontal)
self.assertEqual(guides.data(guides.index(1, 0), QgsLayoutGuideCollection.PositionRole), 15)
self.assertEqual(guides.data(guides.index(1, 0), QgsLayoutGuideCollection.UnitsRole), QgsUnitTypes.LayoutMillimeters)
self.assertEqual(guides.data(guides.index(1, 0), QgsLayoutGuideCollection.PageRole), 0)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1, g2])
self.assertFalse(guides.guides(QgsLayoutGuide.Vertical))
self.assertEqual(guides.guides(Qt.Horizontal), [g1, g2])
self.assertFalse(guides.guides(Qt.Vertical))
self.assertEqual(guides.guidesOnPage(0), [g1, g2])
page2 = QgsLayoutItemPage(l)
page2.setPageSize('A3')
l.pageCollection().addPage(page2)
g3 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(35), l.pageCollection().page(1))
g3 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(35), l.pageCollection().page(1))
guides.addGuide(g3)
self.assertEqual(guides.rowCount(QModelIndex()), 3)
self.assertEqual(guides.data(guides.index(2, 0), QgsLayoutGuideCollection.OrientationRole), QgsLayoutGuide.Vertical)
self.assertEqual(guides.data(guides.index(2, 0), QgsLayoutGuideCollection.OrientationRole), Qt.Vertical)
self.assertEqual(guides.data(guides.index(2, 0), QgsLayoutGuideCollection.PositionRole), 35)
self.assertEqual(guides.data(guides.index(2, 0), QgsLayoutGuideCollection.UnitsRole), QgsUnitTypes.LayoutMillimeters)
self.assertEqual(guides.data(guides.index(2, 0), QgsLayoutGuideCollection.PageRole), 1)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1, g2])
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal, 0), [g1, g2])
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal, 1), [])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical), [g3])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical, 0), [])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical, 1), [g3])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical, 2), [])
self.assertEqual(guides.guides(Qt.Horizontal), [g1, g2])
self.assertEqual(guides.guides(Qt.Horizontal, 0), [g1, g2])
self.assertEqual(guides.guides(Qt.Horizontal, 1), [])
self.assertEqual(guides.guides(Qt.Vertical), [g3])
self.assertEqual(guides.guides(Qt.Vertical, 0), [])
self.assertEqual(guides.guides(Qt.Vertical, 1), [g3])
self.assertEqual(guides.guides(Qt.Vertical, 2), [])
self.assertEqual(guides.guidesOnPage(0), [g1, g2])
self.assertEqual(guides.guidesOnPage(1), [g3])
@ -170,20 +171,20 @@ class TestQgsLayoutGuide(unittest.TestCase):
l.initializeDefaults()
guides = l.guides()
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
g2 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(15), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(15), l.pageCollection().page(0))
guides.addGuide(g2)
g3 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(35), l.pageCollection().page(0))
g3 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(35), l.pageCollection().page(0))
guides.addGuide(g3)
self.assertTrue(guides.removeRows(1, 1))
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical), [g3])
self.assertEqual(guides.guides(Qt.Horizontal), [g1])
self.assertEqual(guides.guides(Qt.Vertical), [g3])
self.assertTrue(guides.removeRows(0, 2))
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical), [])
self.assertEqual(guides.guides(Qt.Horizontal), [])
self.assertEqual(guides.guides(Qt.Vertical), [])
def testQgsLayoutGuideProxyModel(self):
p = QgsProject()
@ -194,11 +195,11 @@ class TestQgsLayoutGuide(unittest.TestCase):
l.pageCollection().addPage(page2)
guides = l.guides()
hoz_filter = QgsLayoutGuideProxyModel(None, QgsLayoutGuide.Horizontal, 0)
hoz_filter = QgsLayoutGuideProxyModel(None, Qt.Horizontal, 0)
hoz_filter.setSourceModel(guides)
hoz_page_1_filter = QgsLayoutGuideProxyModel(None, QgsLayoutGuide.Horizontal, 1)
hoz_page_1_filter = QgsLayoutGuideProxyModel(None, Qt.Horizontal, 1)
hoz_page_1_filter.setSourceModel(guides)
vert_filter = QgsLayoutGuideProxyModel(None, QgsLayoutGuide.Vertical, 0)
vert_filter = QgsLayoutGuideProxyModel(None, Qt.Vertical, 0)
vert_filter.setSourceModel(guides)
# no guides initially
@ -207,11 +208,11 @@ class TestQgsLayoutGuide(unittest.TestCase):
self.assertEqual(vert_filter.rowCount(QModelIndex()), 0)
# add some guides
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
g2 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(15), l.pageCollection().page(1))
g2 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(15), l.pageCollection().page(1))
guides.addGuide(g2)
g3 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(35), l.pageCollection().page(0))
g3 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(35), l.pageCollection().page(0))
guides.addGuide(g3)
self.assertEqual(hoz_filter.rowCount(QModelIndex()), 1)
@ -233,13 +234,13 @@ class TestQgsLayoutGuide(unittest.TestCase):
guides = l.guides()
# add a guide
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1])
self.assertEqual(guides.guides(Qt.Horizontal), [g1])
guides.removeGuide(None)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1])
self.assertEqual(guides.guides(Qt.Horizontal), [g1])
guides.removeGuide(g1)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [])
self.assertEqual(guides.guides(Qt.Horizontal), [])
def testClear(self):
p = QgsProject()
@ -248,13 +249,13 @@ class TestQgsLayoutGuide(unittest.TestCase):
guides = l.guides()
# add a guide
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
g2 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g2)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [g1, g2])
self.assertEqual(guides.guides(Qt.Horizontal), [g1, g2])
guides.clear()
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal), [])
self.assertEqual(guides.guides(Qt.Horizontal), [])
def testApplyToOtherPages(self):
p = QgsProject()
@ -266,36 +267,36 @@ class TestQgsLayoutGuide(unittest.TestCase):
guides = l.guides()
# add some guides
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5), l.pageCollection().page(0))
guides.addGuide(g1)
g2 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(6), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(6), l.pageCollection().page(0))
guides.addGuide(g2)
g3 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(190), l.pageCollection().page(0))
g3 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(190), l.pageCollection().page(0))
guides.addGuide(g3)
g4 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(1), l.pageCollection().page(1))
g4 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(1), l.pageCollection().page(1))
guides.addGuide(g4)
# apply guides from page 0 - should delete g4
guides.applyGuidesToAllOtherPages(0)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal, 0), [g1, g3])
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical, 0), [g2])
self.assertEqual(guides.guides(Qt.Horizontal, 0), [g1, g3])
self.assertEqual(guides.guides(Qt.Vertical, 0), [g2])
self.assertTrue(sip.isdeleted(g4))
# g3 is outside of page 2 bounds - should not be copied
self.assertEqual(len(guides.guides(QgsLayoutGuide.Horizontal, 1)), 1)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal, 1)[0].position().length(), 5)
self.assertEqual(len(guides.guides(QgsLayoutGuide.Vertical, 1)), 1)
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical, 1)[0].position().length(), 6)
self.assertEqual(len(guides.guides(Qt.Horizontal, 1)), 1)
self.assertEqual(guides.guides(Qt.Horizontal, 1)[0].position().length(), 5)
self.assertEqual(len(guides.guides(Qt.Vertical, 1)), 1)
self.assertEqual(guides.guides(Qt.Vertical, 1)[0].position().length(), 6)
# apply guides from page 1 to 0
guides.applyGuidesToAllOtherPages(1)
self.assertTrue(sip.isdeleted(g1))
self.assertTrue(sip.isdeleted(g2))
self.assertTrue(sip.isdeleted(g3))
self.assertEqual(len(guides.guides(QgsLayoutGuide.Horizontal, 0)), 1)
self.assertEqual(guides.guides(QgsLayoutGuide.Horizontal, 0)[0].position().length(), 5)
self.assertEqual(len(guides.guides(QgsLayoutGuide.Vertical, 0)), 1)
self.assertEqual(guides.guides(QgsLayoutGuide.Vertical, 0)[0].position().length(), 6)
self.assertEqual(len(guides.guides(Qt.Horizontal, 0)), 1)
self.assertEqual(guides.guides(Qt.Horizontal, 0)[0].position().length(), 5)
self.assertEqual(len(guides.guides(Qt.Vertical, 0)), 1)
self.assertEqual(guides.guides(Qt.Vertical, 0)[0].position().length(), 6)
def testSetVisible(self):
p = QgsProject()
@ -304,9 +305,9 @@ class TestQgsLayoutGuide(unittest.TestCase):
guides = l.guides()
# add some guides
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5), l.pageCollection().page(0))
guides.addGuide(g1)
g2 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(6), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(6), l.pageCollection().page(0))
guides.addGuide(g2)
guides.setVisible(False)
@ -323,9 +324,9 @@ class TestQgsLayoutGuide(unittest.TestCase):
guides = l.guides()
# add some guides
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(5, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
g2 = QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(6, QgsUnitTypes.LayoutInches), l.pageCollection().page(0))
g2 = QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(6, QgsUnitTypes.LayoutInches), l.pageCollection().page(0))
guides.addGuide(g2)
guides.setVisible(False)
@ -342,10 +343,10 @@ class TestQgsLayoutGuide(unittest.TestCase):
guide_list = guides2.guidesOnPage(0)
self.assertEqual(len(guide_list), 2)
self.assertEqual(guide_list[0].orientation(), QgsLayoutGuide.Horizontal)
self.assertEqual(guide_list[0].orientation(), Qt.Horizontal)
self.assertEqual(guide_list[0].position().length(), 5.0)
self.assertEqual(guide_list[0].position().units(), QgsUnitTypes.LayoutCentimeters)
self.assertEqual(guide_list[1].orientation(), QgsLayoutGuide.Vertical)
self.assertEqual(guide_list[1].orientation(), Qt.Vertical)
self.assertEqual(guide_list[1].position().length(), 6.0)
self.assertEqual(guide_list[1].position().units(), QgsUnitTypes.LayoutInches)
@ -356,7 +357,7 @@ class TestQgsLayoutGuide(unittest.TestCase):
guides = l.guides()
# add some guides
g1 = QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(1, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
g1 = QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(1, QgsUnitTypes.LayoutCentimeters), l.pageCollection().page(0))
guides.addGuide(g1)
# set position in layout units (mm)

View File

@ -201,34 +201,34 @@ class TestQgsLayoutSnapper(unittest.TestCase):
s.setSnapTolerance(1)
# no guides
point, snapped = s.snapPointToGuides(0.5, QgsLayoutGuide.Vertical, 1)
point, snapped = s.snapPointToGuides(0.5, Qt.Vertical, 1)
self.assertFalse(snapped)
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointToGuides(0.5, QgsLayoutGuide.Vertical, 1)
guides.addGuide(QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointToGuides(0.5, Qt.Vertical, 1)
self.assertTrue(snapped)
self.assertEqual(point, 1)
# outside tolerance
point, snapped = s.snapPointToGuides(5.5, QgsLayoutGuide.Vertical, 1)
point, snapped = s.snapPointToGuides(5.5, Qt.Vertical, 1)
self.assertFalse(snapped)
# snapping off
s.setSnapToGuides(False)
point, snapped = s.snapPointToGuides(0.5, QgsLayoutGuide.Vertical, 1)
point, snapped = s.snapPointToGuides(0.5, Qt.Vertical, 1)
self.assertFalse(snapped)
s.setSnapToGuides(True)
# snap to hoz
point, snapped = s.snapPointToGuides(0.5, QgsLayoutGuide.Horizontal, 1)
point, snapped = s.snapPointToGuides(0.5, Qt.Horizontal, 1)
self.assertFalse(snapped)
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointToGuides(0.5, QgsLayoutGuide.Horizontal, 1)
guides.addGuide(QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointToGuides(0.5, Qt.Horizontal, 1)
self.assertTrue(snapped)
self.assertEqual(point, 1)
# with different pixel scale
point, snapped = s.snapPointToGuides(0.5, QgsLayoutGuide.Horizontal, 3)
point, snapped = s.snapPointToGuides(0.5, Qt.Horizontal, 3)
self.assertFalse(snapped)
def testSnapPointsToGuides(self):
@ -244,45 +244,45 @@ class TestQgsLayoutSnapper(unittest.TestCase):
s.setSnapTolerance(1)
# no guides
delta, snapped = s.snapPointsToGuides([0.5], QgsLayoutGuide.Vertical, 1)
delta, snapped = s.snapPointsToGuides([0.5], Qt.Vertical, 1)
self.assertFalse(snapped)
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointsToGuides([0.7], QgsLayoutGuide.Vertical, 1)
guides.addGuide(QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointsToGuides([0.7], Qt.Vertical, 1)
self.assertTrue(snapped)
self.assertAlmostEqual(point, 0.3, 5)
point, snapped = s.snapPointsToGuides([0.7, 1.2], QgsLayoutGuide.Vertical, 1)
point, snapped = s.snapPointsToGuides([0.7, 1.2], Qt.Vertical, 1)
self.assertTrue(snapped)
self.assertAlmostEqual(point, -0.2, 5)
# outside tolerance
point, snapped = s.snapPointsToGuides([5.5], QgsLayoutGuide.Vertical, 1)
point, snapped = s.snapPointsToGuides([5.5], Qt.Vertical, 1)
self.assertFalse(snapped)
# snapping off
s.setSnapToGuides(False)
point, snapped = s.snapPointsToGuides([0.5], QgsLayoutGuide.Vertical, 1)
point, snapped = s.snapPointsToGuides([0.5], Qt.Vertical, 1)
self.assertFalse(snapped)
s.setSnapToGuides(True)
# snap to hoz
point, snapped = s.snapPointsToGuides([0.5], QgsLayoutGuide.Horizontal, 1)
point, snapped = s.snapPointsToGuides([0.5], Qt.Horizontal, 1)
self.assertFalse(snapped)
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointsToGuides([0.7], QgsLayoutGuide.Horizontal, 1)
guides.addGuide(QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(1), page))
point, snapped = s.snapPointsToGuides([0.7], Qt.Horizontal, 1)
self.assertTrue(snapped)
self.assertAlmostEqual(point, 0.3, 5)
point, snapped = s.snapPointsToGuides([0.7, 1.2], QgsLayoutGuide.Horizontal, 1)
point, snapped = s.snapPointsToGuides([0.7, 1.2], Qt.Horizontal, 1)
self.assertTrue(snapped)
self.assertAlmostEqual(point, -0.2, 5)
point, snapped = s.snapPointsToGuides([0.7, 0.9, 1.2], QgsLayoutGuide.Horizontal, 1)
point, snapped = s.snapPointsToGuides([0.7, 0.9, 1.2], Qt.Horizontal, 1)
self.assertTrue(snapped)
self.assertAlmostEqual(point, 0.1, 5)
# with different pixel scale
point, snapped = s.snapPointsToGuides([0.5, 1.5], QgsLayoutGuide.Horizontal, 3)
point, snapped = s.snapPointsToGuides([0.5, 1.5], Qt.Horizontal, 3)
self.assertFalse(snapped)
def testSnapPointToItems(self):
@ -306,7 +306,7 @@ class TestQgsLayoutSnapper(unittest.TestCase):
point, snapped = s.snapPointToItems(0.5, Qt.Horizontal, 1, [], line)
self.assertFalse(line.isVisible())
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(1), page))
guides.addGuide(QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(1), page))
# add an item
item1 = QgsLayoutItemMap(l)
@ -398,7 +398,7 @@ class TestQgsLayoutSnapper(unittest.TestCase):
point, snapped = s.snapPointsToItems([0.5], Qt.Horizontal, 1, [], line)
self.assertFalse(line.isVisible())
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Vertical, QgsLayoutMeasurement(1), page))
guides.addGuide(QgsLayoutGuide(Qt.Vertical, QgsLayoutMeasurement(1), page))
# add an item
item1 = QgsLayoutItemMap(l)
@ -502,7 +502,7 @@ class TestQgsLayoutSnapper(unittest.TestCase):
# test that guide takes precedence
s.setSnapToGrid(True)
s.setSnapToGuides(True)
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(0.5), page))
guides.addGuide(QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(0.5), page))
point, snapped = s.snapPoint(QPointF(1, 1), 1)
self.assertTrue(snapped)
self.assertEqual(point, QPointF(0, 0.5))
@ -561,7 +561,7 @@ class TestQgsLayoutSnapper(unittest.TestCase):
# test that guide takes precedence
s.setSnapToGrid(True)
s.setSnapToGuides(True)
guides.addGuide(QgsLayoutGuide(QgsLayoutGuide.Horizontal, QgsLayoutMeasurement(0.5), page))
guides.addGuide(QgsLayoutGuide(Qt.Horizontal, QgsLayoutMeasurement(0.5), page))
rect, snapped = s.snapRect(QRectF(1, 1, 2, 3), 1)
self.assertTrue(snapped)
self.assertEqual(rect, QRectF(0.0, 0.5, 2.0, 3.0))