diff --git a/common.pri b/common.pri index e2a07e5..fa50060 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 11 +LIMEREPORT_VERSION_RELEASE = 12 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 89a18f4..3e0ad34 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1459,15 +1459,24 @@ void PageDesignIntf::sendToBack() } } +bool PageDesignIntf::selectionContainsBand(){ + foreach(QGraphicsItem * item,selectedItems()){ + BandDesignIntf *band = dynamic_cast(item); + if (band) return true; + } + return false; +} + void PageDesignIntf::alignToLeft() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(m_firstSelectedItem->pos().x(), item->pos().y())); + bdItem->setPos(QPointF(moveInBand ? 0 : m_firstSelectedItem->pos().x(), item->pos().y())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1480,11 +1489,19 @@ void PageDesignIntf::alignToRigth() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(m_firstSelectedItem->geometry().right() - bdItem->width(), bdItem->pos().y())); + if (moveInBand && dynamic_cast(bdItem->parent())) + { + bdItem->setPos(QPointF(dynamic_cast(bdItem->parent())->geometry().width() - bdItem->width(), + bdItem->pos().y())); + } else { + qreal x = m_firstSelectedItem->geometry().right() - bdItem->width(); + bdItem->setPos(QPointF(x+1, bdItem->pos().y())); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1497,11 +1514,18 @@ void PageDesignIntf::alignToVCenter() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint((m_firstSelectedItem->geometry().right() - m_firstSelectedItem->width() / 2) - bdItem->width() / 2, bdItem->pos().y())); + if (moveInBand && dynamic_cast(bdItem->parent())){ + bdItem->setPos(QPointF((dynamic_cast(bdItem->parent())->geometry().width() / 2) - bdItem->width() / 2, + bdItem->pos().y())); + } else { + qreal x = (m_firstSelectedItem->geometry().right() - m_firstSelectedItem->width() / 2) - bdItem->width() / 2; + bdItem->setPos(QPointF(x+1, bdItem->pos().y())); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1514,11 +1538,16 @@ void PageDesignIntf::alignToTop() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(bdItem->pos().x(), m_firstSelectedItem->pos().y())); + if (moveInBand){ + bdItem->setPos(QPointF(0, m_firstSelectedItem->pos().y())); + } else { + bdItem->setPos(QPointF(bdItem->pos().x(), m_firstSelectedItem->pos().y())); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1531,11 +1560,17 @@ void PageDesignIntf::alignToBottom() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(bdItem->pos().x(), m_firstSelectedItem->geometry().bottom() - bdItem->height())); + if (moveInBand && dynamic_cast(bdItem->parent())){ + bdItem->setPos(QPointF(bdItem->pos().x(), dynamic_cast(bdItem->parent())->height() - bdItem->height())); + } else { + qreal y = m_firstSelectedItem->geometry().bottom() - bdItem->height(); + bdItem->setPos(QPointF(bdItem->pos().x(), y+1)); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1548,11 +1583,17 @@ void PageDesignIntf::alignToHCenter() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(bdItem->pos().x(), (m_firstSelectedItem->geometry().bottom() - m_firstSelectedItem->height() / 2) - bdItem->height() / 2)); + if (moveInBand && dynamic_cast(bdItem->parent())){ + bdItem->setPos(QPointF(bdItem->pos().x(), (dynamic_cast(bdItem->parent())->height() / 2) - bdItem->height() / 2)); + } else { + qreal y = (m_firstSelectedItem->geometry().bottom() - m_firstSelectedItem->height() / 2) - bdItem->height() / 2; + bdItem->setPos(QPointF(bdItem->pos().x(), y+1)); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index d94abfe..b02a2de 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -282,6 +282,7 @@ namespace LimeReport { void changeSelectedGroupProperty(const QString& name,const QVariant& value); void activateItemToJoin(QRectF itemRect, QList& items); void selectAllChildren(BaseDesignIntf* item); + bool selectionContainsBand(); private: enum JoinType{Width, Height}; LimeReport::PageItemDesignIntf::Ptr m_pageItem; @@ -322,6 +323,7 @@ namespace LimeReport { bool m_magneticMovement; ReportSettings* m_reportSettings; PageItemDesignIntf* m_currentPage; + }; class AbstractPageCommand : public CommandIf{