Band names translation has been fixed

Subdetail header render has been fixed
This commit is contained in:
Arin Alexander 2017-06-30 13:23:53 +03:00
commit a9455b81db
3 changed files with 29 additions and 13 deletions

View File

@ -145,6 +145,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_bandNameLabel->setVisible(false); m_bandNameLabel->setVisible(false);
if (scene()) scene()->addItem(m_bandNameLabel); if (scene()) scene()->addItem(m_bandNameLabel);
m_alternateBackgroundColor = backgroundColor(); m_alternateBackgroundColor = backgroundColor();
connect(this, SIGNAL(propertyObjectNameChanged(QString, QString)),
this, SLOT(slotPropertyObjectNameChanged(const QString&,const QString&)));
} }
BandDesignIntf::~BandDesignIntf() BandDesignIntf::~BandDesignIntf()
@ -166,7 +168,12 @@ int extractItemIndex(const BaseDesignIntf* item){
} }
QString BandDesignIntf::translateBandName(const BaseDesignIntf* item) const{ QString BandDesignIntf::translateBandName(const BaseDesignIntf* item) const{
QString defaultBandName = extractClassName(item->metaObject()->className()).toLatin1()+QString::number(extractItemIndex(item));
if (item->objectName().compare(defaultBandName) == 0){
return tr(extractClassName(item->metaObject()->className()).toLatin1())+QString::number(extractItemIndex(item)); return tr(extractClassName(item->metaObject()->className()).toLatin1())+QString::number(extractItemIndex(item));
} else {
return item->objectName();
}
} }
void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@ -612,7 +619,7 @@ void BandDesignIntf::trimToMaxHeight(int maxHeight)
void BandDesignIntf::setBandTypeText(const QString &value){ void BandDesignIntf::setBandTypeText(const QString &value){
m_bandTypeText=value; m_bandTypeText=value;
m_bandNameLabel->updateLabel(); m_bandNameLabel->updateLabel(bandTitle());
} }
QSet<BandDesignIntf::BandsType> BandDesignIntf::groupBands() QSet<BandDesignIntf::BandsType> BandDesignIntf::groupBands()
@ -670,7 +677,7 @@ QVariant BandDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co
m_bandMarker->update(0,0, m_bandMarker->update(0,0,
m_bandMarker->boundingRect().width(), m_bandMarker->boundingRect().width(),
m_bandMarker->boundingRect().width()); m_bandMarker->boundingRect().width());
m_bandNameLabel->updateLabel(); m_bandNameLabel->updateLabel(bandTitle());
m_bandNameLabel->setVisible(value.toBool()); m_bandNameLabel->setVisible(value.toBool());
} }
@ -724,6 +731,13 @@ void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgrou
m_alternateBackgroundColor = alternateBackgroundColor; m_alternateBackgroundColor = alternateBackgroundColor;
} }
void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName)
{
update();
if (m_bandNameLabel)
m_bandNameLabel->updateLabel(newName);
}
bool BandDesignIntf::repeatOnEachRow() const bool BandDesignIntf::repeatOnEachRow() const
{ {
return m_repeatOnEachRow; return m_repeatOnEachRow;
@ -878,7 +892,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
void BandDesignIntf::updateBandNameLabel() void BandDesignIntf::updateBandNameLabel()
{ {
if (m_bandNameLabel) m_bandNameLabel->updateLabel(); if (m_bandNameLabel) m_bandNameLabel->updateLabel(bandTitle());
} }
QColor BandDesignIntf::selectionColor() const QColor BandDesignIntf::selectionColor() const
@ -921,7 +935,7 @@ QRectF BandNameLabel::boundingRect() const
return m_rect; return m_rect;
} }
void BandNameLabel::updateLabel() void BandNameLabel::updateLabel(const QString& bandName)
{ {
QFont font("Arial",7*Const::fontFACTOR,-1,true); QFont font("Arial",7*Const::fontFACTOR,-1,true);
QFontMetrics fontMetrics(font); QFontMetrics fontMetrics(font);
@ -929,7 +943,7 @@ void BandNameLabel::updateLabel()
m_rect = QRectF( m_rect = QRectF(
m_band->pos().x()+10, m_band->pos().x()+10,
m_band->pos().y()-(fontMetrics.height()+10), m_band->pos().y()-(fontMetrics.height()+10),
fontMetrics.width(m_band->bandTitle())+20,fontMetrics.height()+10 fontMetrics.width(bandName)+20,fontMetrics.height()+10
); );
update(); update();
} }

View File

@ -74,7 +74,7 @@ public:
explicit BandNameLabel(BandDesignIntf* band, QGraphicsItem* parent=0); explicit BandNameLabel(BandDesignIntf* band, QGraphicsItem* parent=0);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const; QRectF boundingRect() const;
void updateLabel(); void updateLabel(const QString &bandName);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
private: private:
QRectF m_rect; QRectF m_rect;
@ -245,6 +245,7 @@ protected:
QString translateBandName(const BaseDesignIntf *item) const; QString translateBandName(const BaseDesignIntf *item) const;
private slots: private slots:
void childBandDeleted(QObject* band); void childBandDeleted(QObject* band);
void slotPropertyObjectNameChanged(const QString&,const QString&);
private: private:
QString m_bandTypeText; QString m_bandTypeText;
BandsType m_bandType; BandsType m_bandType;

View File

@ -430,7 +430,6 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign
if (patternBand->isFooter()) if (patternBand->isFooter())
m_lastRenderedFooter = patternBand; m_lastRenderedFooter = patternBand;
bandClone->setBackgroundColor( bandClone->setBackgroundColor(
(datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt() %2 !=0 ? (datasources()->variable(QLatin1String("line_")+patternBand->objectName().toLower()).toInt() %2 !=0 ?
bandClone->backgroundColor(): bandClone->backgroundColor():
@ -505,6 +504,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
IDataSource* bandDatasource = 0; IDataSource* bandDatasource = 0;
m_lastRenderedFooter = 0; m_lastRenderedFooter = 0;
if (!dataBand->datasourceName().isEmpty()) if (!dataBand->datasourceName().isEmpty())
bandDatasource = datasources()->dataSource(dataBand->datasourceName()); bandDatasource = datasources()->dataSource(dataBand->datasourceName());
@ -524,7 +524,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage()) if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage())
m_reprintableBands.append(dataBand->bandHeader()); m_reprintableBands.append(dataBand->bandHeader());
renderChildHeader(dataBand,PrintNotAlwaysPrintable); //renderChildHeader(dataBand,PrintNotAlwaysPrintable);
renderGroupHeader(dataBand, bandDatasource, true); renderGroupHeader(dataBand, bandDatasource, true);
bool firstTime = true; bool firstTime = true;
@ -658,7 +658,8 @@ void ReportRender::renderChildHeader(BandDesignIntf *parent, BandPrintMode print
if (band->metaObject()->indexOfProperty("printAlways")>0){ if (band->metaObject()->indexOfProperty("printAlways")>0){
printAlways=band->property("printAlways").toBool(); printAlways=band->property("printAlways").toBool();
} }
if (printAlways == (printMode==PrintAlwaysPrintable) ) renderBand(band, 0, StartNewPageAsNeeded); if ((band != m_lastRenderedHeader) && (printAlways == (printMode == PrintAlwaysPrintable)) )
renderBand(band, 0, StartNewPageAsNeeded);
} }
} }
@ -682,9 +683,9 @@ void ReportRender::renderChildBands(BandDesignIntf *parentBand)
if (!band->datasourceName().isEmpty()) if (!band->datasourceName().isEmpty())
ds = m_datasources->dataSource(band->datasourceName()); ds = m_datasources->dataSource(band->datasourceName());
if (ds) ds->first(); if (ds) ds->first();
renderChildHeader(band,PrintAlwaysPrintable); //renderChildHeader(band,PrintAlwaysPrintable);
renderDataBand(band); renderDataBand(band);
renderChildFooter(band,PrintAlwaysPrintable); //renderChildFooter(band,PrintAlwaysPrintable);
closeFooterGroup(band); closeFooterGroup(band);
} }
} }