diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 879b4bc..bdbd593 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -245,6 +245,16 @@ void BandDesignIntf::setBandIndex(int value) m_bandIndex=value; } +void BandDesignIntf::changeBandIndex(int value) +{ + int indexOffset = value - m_bandIndex; + foreach(BandDesignIntf* band, childBands()){ + int newIndex = band->bandIndex()+indexOffset; + band->changeBandIndex(newIndex); + } + setBandIndex(value); +} + bool BandDesignIntf::isUnique() const { return true; @@ -829,6 +839,11 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight); } +void BandDesignIntf::updateBandNameLabel() +{ + if (m_bandNameLabel) m_bandNameLabel->updateLabel(); +} + QColor BandDesignIntf::selectionColor() const { return Qt::yellow; @@ -847,16 +862,19 @@ BandNameLabel::BandNameLabel(BandDesignIntf *band, QGraphicsItem *parent) void BandNameLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); painter->setFont(QFont("Arial",7*Const::fontFACTOR,-1,true)); painter->setOpacity(1); QPen pen(Const::BAND_NAME_BORDER_COLOR); - pen.setWidth(2); + //pen.setWidth(2); painter->setBrush(Qt::yellow); painter->setPen(pen); - painter->drawRect(m_rect); + painter->drawRoundedRect(m_rect,8,8); painter->setOpacity(0.8); painter->setPen(Qt::black); painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle()); + painter->restore(); Q_UNUSED(option) Q_UNUSED(widget) } diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index be7af45..9410fc6 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -125,11 +125,12 @@ public: virtual QIcon bandIcon() const; virtual bool isUnique() const; void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0); + void updateBandNameLabel(); virtual QColor selectionColor() const; int bandIndex() const; void setBandIndex(int value); - + void changeBandIndex(int value); void setBandType(BandsType value){m_bandType=value;} QString datasourceName(); @@ -231,8 +232,7 @@ protected: void setMarkerColor(QColor color); void checkEmptyTable(); void setColumnsCount(int value); - void setColumnsFillDirection(BandColumnsLayoutType value); - + void setColumnsFillDirection(BandColumnsLayoutType value); private slots: void childBandDeleted(QObject* band); private: diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index ac4f486..0d19a7b 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -341,7 +341,6 @@ void PageItemDesignIntf::relocateBands() posByColumn[0]+=m_bands[0]->height()+bandSpace; } if(m_bands.count()>1){ - for(int i=0;i<(m_bands.count()-1);i++){ if ((m_bands[i+1]->bandType()!=BandDesignIntf::PageFooter) || (itemMode() & DesignMode)){ if (m_bands[i+1]->columnsCount()>1 && @@ -360,7 +359,9 @@ void PageItemDesignIntf::relocateBands() posByColumn[m_bands[i+1]->columnIndex()] += m_bands[i+1]->height()+bandSpace; } } - + } + foreach(BandDesignIntf* band, m_bands){ + if (band->isSelected()) band->updateBandNameLabel(); } } } @@ -515,8 +516,37 @@ void PageItemDesignIntf::bandDeleted(QObject *band) relocateBands(); } -void PageItemDesignIntf::bandGeometryChanged(QObject *, QRectF /*newGeometry*/, QRectF /*oldGeometry*/) +void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry) { + BandDesignIntf* band = dynamic_cast(object); + int curIndex = band->bandIndex(); + BandDesignIntf* bandToSwap = 0; + foreach(BandDesignIntf* curBand, bands()){ + if (newGeometry.y()>oldGeometry.y()) { + if (curBand->bandType() == band->bandType() + && curIndexbandIndex() + && (curBand->pos().y()+(curBand->height()/2))parentBand() == band->parentBand()) + { + curIndex = curBand->bandIndex(); + bandToSwap = curBand; + } + } else { + if (curBand->bandType() == band->bandType() + && curIndex>curBand->bandIndex() + && (curBand->pos().y()+(curBand->height()/2))>newGeometry.y() + && curBand->parentBand() == band->parentBand()) + { + curIndex = curBand->bandIndex(); + bandToSwap = curBand; + } + } + } + if (curIndex != band->bandIndex()){ + bandToSwap->changeBandIndex(band->bandIndex()); + band->changeBandIndex(curIndex); + } + relocateBands(); } diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 0f27de7..ba01820 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -114,7 +114,7 @@ public: bool canContainChildren(){ return true;} protected slots: void bandDeleted(QObject* band); - void bandGeometryChanged(QObject* /*object*/, QRectF newGeometry, QRectF oldGeometry); + void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); protected: void collectionLoadFinished(const QString& collectionName); QRectF& pageRect(){return m_pageRect;}