From 11cb5346086e660d816180d840b4226579bb23c2 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 29 Jun 2019 18:11:00 +0300 Subject: [PATCH] Fix: geometry changing for locked items is prevented --- limereport/lrbasedesignintf.cpp | 8 ++++---- limereport/lrbasedesignintf.h | 6 +++--- limereport/lrpagedesignintf.cpp | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 52970c2..a05d48a 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -730,12 +730,12 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){ } } -bool BaseDesignIntf::isItemGeometryLocked() const +bool BaseDesignIntf::isGeometryLocked() const { return m_itemGeometryLocked; } -void BaseDesignIntf::setItemGeometryLocked(bool itemLocked) +void BaseDesignIntf::setGeometryLocked(bool itemLocked) { if (m_itemGeometryLocked != itemLocked){ m_itemGeometryLocked = itemLocked; @@ -1313,7 +1313,7 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QAction* lockGeometryAction = menu.addAction(tr("Lock item geometry")); lockGeometryAction->setCheckable(true); lockGeometryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); - lockGeometryAction->setChecked(isItemGeometryLocked()); + lockGeometryAction->setChecked(isGeometryLocked()); menu.addSeparator(); QAction* copyAction = menu.addAction(QIcon(":/report/images/copy"), tr("Copy")); @@ -1700,7 +1700,7 @@ SelectionMarker::SelectionMarker(QGraphicsItem* parent, BaseDesignIntf* owner) QColor SelectionMarker::color() const { - return owner()->isItemGeometryLocked() ? Qt::darkGray : Marker::color(); + return owner()->isGeometryLocked() ? Qt::darkGray : Marker::color(); } void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event) diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 646e00f..83890de 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -98,7 +98,7 @@ class BaseDesignIntf : Q_PROPERTY(int borderLineSize READ borderLineSize WRITE setBorderLineSize) Q_PROPERTY(bool isVisible READ isVisible WRITE setItemVisible DESIGNABLE false) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) - Q_PROPERTY(bool geometryLocked READ isItemGeometryLocked WRITE setItemGeometryLocked) + Q_PROPERTY(bool geometryLocked READ isGeometryLocked WRITE setGeometryLocked) friend class ReportRender; public: @@ -305,8 +305,8 @@ public: void setFillTransparentInDesignMode(bool fillTransparentInDesignMode); void emitPosChanged(QPointF oldPos, QPointF newPos); - bool isItemGeometryLocked() const; - void setItemGeometryLocked(bool itemLocked); + bool isGeometryLocked() const; + void setGeometryLocked(bool itemLocked); protected: diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index eade90c..720d7bb 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1464,7 +1464,7 @@ void PageDesignIntf::alignToLeft() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setPos(QPoint(m_firstSelectedItem->pos().x(), item->pos().y())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1481,7 +1481,7 @@ void PageDesignIntf::alignToRigth() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setPos(QPoint(m_firstSelectedItem->geometry().right() - bdItem->width(), bdItem->pos().y())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1498,7 +1498,7 @@ void PageDesignIntf::alignToVCenter() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setPos(QPoint((m_firstSelectedItem->geometry().right() - m_firstSelectedItem->width() / 2) - bdItem->width() / 2, bdItem->pos().y())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1515,7 +1515,7 @@ void PageDesignIntf::alignToTop() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setPos(QPoint(bdItem->pos().x(), m_firstSelectedItem->pos().y())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1532,7 +1532,7 @@ void PageDesignIntf::alignToBottom() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setPos(QPoint(bdItem->pos().x(), m_firstSelectedItem->geometry().bottom() - bdItem->height())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1549,7 +1549,7 @@ void PageDesignIntf::alignToHCenter() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setPos(QPoint(bdItem->pos().x(), (m_firstSelectedItem->geometry().bottom() - m_firstSelectedItem->height() / 2) - bdItem->height() / 2)); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1566,7 +1566,7 @@ void PageDesignIntf::sameWidth() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setWidth(m_firstSelectedItem->width()); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); @@ -1583,7 +1583,7 @@ void PageDesignIntf::sameHeight() CommandGroup::Ptr cm = CommandGroup::create(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) { + if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); bdItem->setHeight(m_firstSelectedItem->height()); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry());