0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-09-26 17:59:08 +03:00

Merge branch 'master' into feature/speed_up

# Conflicts:
#	limereport/lrbanddesignintf.cpp
#	limereport/lrreportengine.cpp
This commit is contained in:
Arin Alexander
2019-10-12 22:37:32 +03:00
29 changed files with 1146 additions and 171 deletions

View File

@@ -278,6 +278,7 @@ void PageDesignIntf::setPageItem(PageItemDesignIntf::Ptr pageItem)
void PageDesignIntf::setPageItems(QList<PageItemDesignIntf::Ptr> pages)
{
m_currentPage = 0;
if (!m_pageItem.isNull()) {
removeItem(m_pageItem.data());
m_pageItem.clear();
@@ -1459,15 +1460,24 @@ void PageDesignIntf::sendToBack()
}
}
bool PageDesignIntf::selectionContainsBand(){
foreach(QGraphicsItem * item,selectedItems()){
BandDesignIntf *band = dynamic_cast<BandDesignIntf *>(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<BaseDesignIntf *>(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 +1490,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent()))
{
bdItem->setPos(QPointF(dynamic_cast<BandDesignIntf*>(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 +1515,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent())){
bdItem->setPos(QPointF((dynamic_cast<BandDesignIntf*>(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 +1539,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<BaseDesignIntf *>(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 +1561,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent())){
bdItem->setPos(QPointF(bdItem->pos().x(), dynamic_cast<BandDesignIntf*>(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 +1584,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent())){
bdItem->setPos(QPointF(bdItem->pos().x(), (dynamic_cast<BandDesignIntf*>(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);
}
@@ -2136,7 +2178,7 @@ bool PosChangedCommand::doIt()
if (reportItem && (reportItem->pos() != m_newPos[i].pos)){
QPointF oldValue = reportItem->pos();
reportItem->setPos(m_newPos[i].pos);
emit reportItem->posChanged(reportItem, oldValue, reportItem->pos());
reportItem->emitPosChanged(oldValue, reportItem->pos());
}
}