From 0e9b8055e9af52e2bc10352277dfa046001ab2a3 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 20 Jul 2018 11:48:01 +0300 Subject: [PATCH] Bands relocation has been fixed --- common.pri | 2 +- limereport/lrpageitemdesignintf.cpp | 39 ++++++++++++++++------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/common.pri b/common.pri index 5b0e9d1..4c68ba1 100644 --- a/common.pri +++ b/common.pri @@ -62,7 +62,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 93 +LIMEREPORT_VERSION_RELEASE = 94 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index a060aff..6ae6fc7 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -569,32 +569,37 @@ void PageItemDesignIntf::bandDeleted(QObject *band) } void PageItemDesignIntf::swapBands(BandDesignIntf* band, BandDesignIntf* bandToSwap){ - int firstStartIndex = std::min(band->minChildIndex(), bandToSwap->minChildIndex()); - int secondStartIndex = std::max(band->minChildIndex(), bandToSwap->minChildIndex()); -// int endIndex = std::max(band->maxChildIndex(), bandToSwap->maxChildIndex()); -// QList bandToMove; -// foreach(BandDesignIntf* curBand, m_bands){ -// if (curBand->bandIndex() > endIndex) -// bandToMove.append(curBand); -// } + int firstIndex = std::min(band->minChildIndex(), bandToSwap->minChildIndex()); + int secondIndex = std::max(band->minChildIndex(), bandToSwap->minChildIndex()); + int moveIndex = std::min(band->maxChildIndex(), bandToSwap->maxChildIndex()); + + QList bandToMove; + foreach(BandDesignIntf* curBand, m_bands){ + if ( curBand->bandIndex() > moveIndex && curBand->bandIndex() < secondIndex && + curBand->bandType() == BandDesignIntf::Data && + curBand != band && curBand != bandToSwap + ) + bandToMove.append(curBand); + } BandDesignIntf* firstMoveBand = (bandToSwap->bandIndex() > band->bandIndex()) ? bandToSwap: band; - firstMoveBand->changeBandIndex(firstStartIndex, true); + firstMoveBand->changeBandIndex(firstIndex, true); + moveIndex = firstMoveBand->maxChildIndex() + 1; + qSort(bandToMove.begin(), bandToMove.end(), bandIndexLessThen); + foreach(BandDesignIntf* curBand, bandToMove){ + curBand->changeBandIndex(moveIndex,true); + moveIndex = curBand->maxChildIndex() + 1; + } + if (firstMoveBand == band){ - bandToSwap->changeBandIndex(secondStartIndex,true); + bandToSwap->changeBandIndex(moveIndex,true); } else { - band->changeBandIndex(secondStartIndex, true); + band->changeBandIndex(moveIndex, true); } relocateBands(); -// int maxNewIndex = std::max(band->maxChildIndex(), bandToSwap->maxChildIndex()); -// if (maxNewIndex > endIndex){ -// foreach(BandDesignIntf* curBand, bandToMove){ -// curBand->setBandIndex(curBand->bandIndex()+(maxNewIndex - endIndex)); -// } -// } } void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry)