0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-26 01:24:39 +03:00

Band location has been fixed

# Conflicts:
#	limereport/lrbanddesignintf.h
This commit is contained in:
Arin Alexander 2017-06-29 00:57:41 +03:00
commit c40169146c
5 changed files with 75 additions and 17 deletions

View File

@ -172,7 +172,7 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
if (itemMode() & DesignMode){ if (itemMode() & DesignMode){
painter->save(); painter->save();
QString bandText = objectName(); QString bandText = objectName();
if (parentBand()) bandText+=QLatin1String(" connected to ")+parentBand()->objectName(); if (parentBand()) bandText+=tr(" connected to ")+parentBand()->objectName();
QFont font("Arial", 7 * Const::fontFACTOR, -1, true); QFont font("Arial", 7 * Const::fontFACTOR, -1, true);
QFontMetrics fontMetrics(font); QFontMetrics fontMetrics(font);
@ -230,9 +230,15 @@ void BandDesignIntf::setBandIndex(int value)
m_bandIndex=value; m_bandIndex=value;
} }
void BandDesignIntf::changeBandIndex(int value) void BandDesignIntf::changeBandIndex(int value, bool firstTime)
{ {
int indexOffset = value - m_bandIndex; int indexOffset;
if (firstTime && bandHeader())
value += 1;
indexOffset = value - m_bandIndex;
foreach(BandDesignIntf* band, childBands()){ foreach(BandDesignIntf* band, childBands()){
int newIndex = band->bandIndex()+indexOffset; int newIndex = band->bandIndex()+indexOffset;
band->changeBandIndex(newIndex); band->changeBandIndex(newIndex);
@ -294,6 +300,16 @@ bool BandDesignIntf::isConnectedToBand(BandDesignIntf::BandsType bandType) const
return false; return false;
} }
int BandDesignIntf::maxChildIndex(BandDesignIntf::BandsType bandType) const{
int curIndex = bandIndex();
foreach(BandDesignIntf* childBand, childBands()){
if ( (childBand->bandIndex() > bandIndex()) && (childBand->bandType() < bandType) ){
curIndex = std::max(curIndex,childBand->maxChildIndex());
}
}
return curIndex;
}
int BandDesignIntf::maxChildIndex(QSet<BandDesignIntf::BandsType> ignoredBands) const{ int BandDesignIntf::maxChildIndex(QSet<BandDesignIntf::BandsType> ignoredBands) const{
int curIndex = bandIndex(); int curIndex = bandIndex();
foreach(BandDesignIntf* childBand, childBands()){ foreach(BandDesignIntf* childBand, childBands()){

View File

@ -133,7 +133,7 @@ public:
virtual QColor selectionColor() const; virtual QColor selectionColor() const;
int bandIndex() const; int bandIndex() const;
void setBandIndex(int value); void setBandIndex(int value);
void changeBandIndex(int value); void changeBandIndex(int value, bool firstTime = false);
void setBandType(BandsType value){m_bandType=value;} void setBandType(BandsType value){m_bandType=value;}
QString datasourceName(); QString datasourceName();
@ -153,6 +153,7 @@ public:
bool isConnectedToBand(BandDesignIntf::BandsType bandType) const; bool isConnectedToBand(BandDesignIntf::BandsType bandType) const;
int minChildIndex(BandsType bandType); int minChildIndex(BandsType bandType);
int maxChildIndex(BandDesignIntf::BandsType bandType) const;
int maxChildIndex(QSet<BandsType> ignoredBands = QSet<BandDesignIntf::BandsType>()) const; int maxChildIndex(QSet<BandsType> ignoredBands = QSet<BandDesignIntf::BandsType>()) const;
BandDesignIntf* parentBand() const {return m_parentBand;} BandDesignIntf* parentBand() const {return m_parentBand;}

View File

@ -224,10 +224,16 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
int bandIndex=-1; int bandIndex=-1;
qSort(m_bands.begin(),m_bands.end(),bandSortBandLessThenByIndex); qSort(m_bands.begin(),m_bands.end(),bandSortBandLessThenByIndex);
foreach(BandDesignIntf* band,m_bands){ foreach(BandDesignIntf* band,m_bands){
if ((band->bandType()==BandDesignIntf::GroupHeader)&&(band->bandType()>bandType)) break; if ((band->bandType() == BandDesignIntf::GroupHeader) && ( band->bandType() > bandType)) break;
if ((band->bandType()<=bandType)){ if ((band->bandType() <= bandType)){
if (bandIndex<=band->bandIndex()) bandIndex=band->maxChildIndex()+1; if (bandIndex <= band->bandIndex()) {
} if (bandType != BandDesignIntf::Data){
bandIndex=band->maxChildIndex(bandType)+1;
} else {
bandIndex=band->maxChildIndex()+1;
}
}
} else { increaseBandIndex = true; break;}
} }
if (bandIndex==-1) { if (bandIndex==-1) {
@ -244,7 +250,7 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe
switch (bandType) { switch (bandType) {
case BandDesignIntf::SubDetailBand: case BandDesignIntf::SubDetailBand:
bandIndex = parentBand->maxChildIndex() + 1; bandIndex = parentBand->maxChildIndex(bandType) + 1;
increaseBandIndex = true; increaseBandIndex = true;
break; break;
case BandDesignIntf::SubDetailHeader: case BandDesignIntf::SubDetailHeader:
@ -412,7 +418,8 @@ void PageItemDesignIntf::relocateBands()
if (!(itemMode() & DesignMode)){ if (!(itemMode() & DesignMode)){
while ( (bandIndex < m_bands.count()) && while ( (bandIndex < m_bands.count()) &&
((m_bands[bandIndex]->bandType() == BandDesignIntf::TearOffBand) || ((m_bands[bandIndex]->bandType() == BandDesignIntf::TearOffBand) ||
(m_bands[bandIndex]->bandType() == BandDesignIntf::PageFooter)) (m_bands[bandIndex]->bandType() == BandDesignIntf::PageFooter) ||
m_bands[bandIndex]->bandType() == BandDesignIntf::ReportFooter )
){ ){
bandIndex++; bandIndex++;
} }
@ -636,8 +643,9 @@ void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry
} }
} }
if (curIndex != band->bandIndex()){ if (curIndex != band->bandIndex()){
bandToSwap->changeBandIndex(band->bandIndex()); int swapIndex = bandToSwap->maxChildIndex();
band->changeBandIndex(curIndex); bandToSwap->changeBandIndex(band->bandIndex(),true);
band->changeBandIndex(swapIndex,true);
} }
relocateBands(); relocateBands();

View File

@ -124,7 +124,16 @@ void QObjectPropertyModel::translatePropertyName()
tr("image"); tr("image");
tr("keepAspectRatio"); tr("keepAspectRatio");
tr("columnsCount"); tr("columnsCount");
tr("useAlternateBackgroundColor");
tr("printBeforePageHeader");
tr("maxScalePercent");
tr("printOnFirstPage");
tr("printOnLastPage");
tr("printAlways");
tr("repeatOnEachRow");
tr("condition");
tr("groupFieldName");
tr("keepGroupTogether");
} }
void QObjectPropertyModel::clearObjectsList() void QObjectPropertyModel::clearObjectsList()

View File

@ -1007,15 +1007,15 @@ p, li { white-space: pre-wrap; }
</message> </message>
<message> <message>
<source>condition</source> <source>condition</source>
<translation type="vanished">Условие</translation> <translation>Условие</translation>
</message> </message>
<message> <message>
<source>keepGroupTogether</source> <source>keepGroupTogether</source>
<translation type="vanished">Сохранять группу вместе</translation> <translation>Сохранять группу вместе</translation>
</message> </message>
<message> <message>
<source>groupFieldName</source> <source>groupFieldName</source>
<translation type="vanished">Столбец группы</translation> <translation>Столбец группы</translation>
</message> </message>
<message> <message>
<source>geometry</source> <source>geometry</source>
@ -1235,7 +1235,7 @@ p, li { white-space: pre-wrap; }
</message> </message>
<message> <message>
<source>printAlways</source> <source>printAlways</source>
<translation type="vanished">Печатать всегда</translation> <translation>Печатать всегда</translation>
</message> </message>
<message> <message>
<source>borderColor</source> <source>borderColor</source>
@ -1309,6 +1309,30 @@ p, li { white-space: pre-wrap; }
<source>pdf417CodeWords</source> <source>pdf417CodeWords</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>useAlternateBackgroundColor</source>
<translation>Использовать альтернативный цвет фона</translation>
</message>
<message>
<source>printBeforePageHeader</source>
<translation>Печатать перед заголовком страницы</translation>
</message>
<message>
<source>maxScalePercent</source>
<translation>Максимальный процент уменьшения</translation>
</message>
<message>
<source>printOnFirstPage</source>
<translation>Печатать на первой странице</translation>
</message>
<message>
<source>printOnLastPage</source>
<translation>Печатать на последней странице</translation>
</message>
<message>
<source>repeatOnEachRow</source>
<translation>Печатать на каждой странице</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::RectMMPropItem</name> <name>LimeReport::RectMMPropItem</name>