From af12120260b65a4716544bab10c7e9f17f9199b5 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 13 Jul 2018 02:25:10 +0300 Subject: [PATCH] Band relocation has been fixed --- common.pri | 2 +- limereport/lrbanddesignintf.cpp | 13 +++++++++++++ limereport/lrbanddesignintf.h | 1 + limereport/lrbasedesignintf.cpp | 4 +++- limereport/lrpageitemdesignintf.cpp | 29 ++++++++++++++++++++++++++--- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/common.pri b/common.pri index 8f5d3b6..dd2e624 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 = 88 +LIMEREPORT_VERSION_RELEASE = 89 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 56c2642..00416b8 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -389,6 +389,19 @@ int BandDesignIntf::minChildIndex(BandDesignIntf::BandsType bandType){ return curIndex; } +int BandDesignIntf::minChildIndex(QSet ignoredBands) +{ + int curIndex = bandIndex(); + foreach(BandDesignIntf* childBand, childBands()){ + if (!ignoredBands.contains(childBand->bandType()) && childBand->bandIndex() < bandIndex()){ + curIndex = std::min(curIndex, childBand->maxChildIndex(ignoredBands)); + } + } + return curIndex; +} + + + QList BandDesignIntf::childrenByType(BandDesignIntf::BandsType type) { QList resList; diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 7bf8401..50dd643 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -167,6 +167,7 @@ public: bool isConnectedToBand(BandDesignIntf::BandsType bandType) const; int minChildIndex(BandsType bandType); + int minChildIndex(QSet ignoredBands = QSet()); int maxChildIndex(BandDesignIntf::BandsType bandType) const; int maxChildIndex(QSet ignoredBands = QSet()) const; diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 61c7283..052ed7c 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -964,7 +964,9 @@ void BaseDesignIntf::setGeometryProperty(QRectF rect) setWidth(rect.width()); if (rect.height() != geometry().height()) setHeight(rect.height()); - if (!isLoading()) notify("geometry",oldValue,rect); + if (!isLoading()) { + notify("geometry",oldValue,rect); + } } } diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 2e8de0b..9e5c4ce 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -595,9 +595,32 @@ void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry } } if (curIndex != band->bandIndex()){ - int swapIndex = bandToSwap->maxChildIndex(); - bandToSwap->changeBandIndex(band->bandIndex(),true); - band->changeBandIndex(swapIndex,true); + + int startIndex = std::min(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); +// } + + BandDesignIntf* firstMoveBand = (bandToSwap->bandIndex() > band->bandIndex()) ? bandToSwap: band; + + firstMoveBand->changeBandIndex(startIndex, true); + if (firstMoveBand == band){ + bandToSwap->changeBandIndex(firstMoveBand->maxChildIndex()+1,true); + } else { + band->changeBandIndex(firstMoveBand->maxChildIndex()+1, true); + } + +// int maxNewIndex = std::max(band->maxChildIndex(), bandToSwap->maxChildIndex()); +// if (maxNewIndex > endIndex){ +// foreach(BandDesignIntf* curBand, bandToMove){ +// curBand->setBandIndex(curBand->bandIndex()+(maxNewIndex - endIndex)); +// } +// } + } relocateBands();