From 9c95206dfe0ffc57d84841b167f1e4b0e12b8a88 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 30 Jun 2017 13:21:16 +0300 Subject: [PATCH] Band names translation has been fixed --- limereport/lrbanddesignintf.cpp | 26 ++++++++++++++++++++------ limereport/lrbanddesignintf.h | 5 +++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 61bb5cf..47f398c 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -145,6 +145,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q m_bandNameLabel->setVisible(false); if (scene()) scene()->addItem(m_bandNameLabel); m_alternateBackgroundColor = backgroundColor(); + connect(this, SIGNAL(propertyObjectNameChanged(QString, QString)), + this, SLOT(slotPropertyObjectNameChanged(const QString&,const QString&))); } BandDesignIntf::~BandDesignIntf() @@ -166,7 +168,12 @@ int extractItemIndex(const BaseDesignIntf* item){ } QString BandDesignIntf::translateBandName(const BaseDesignIntf* item) const{ - return tr(extractClassName(item->metaObject()->className()).toLatin1())+QString::number(extractItemIndex(item)); + 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)); + } else { + return item->objectName(); + } } 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){ m_bandTypeText=value; - m_bandNameLabel->updateLabel(); + m_bandNameLabel->updateLabel(bandTitle()); } QSet BandDesignIntf::groupBands() @@ -670,7 +677,7 @@ QVariant BandDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co m_bandMarker->update(0,0, m_bandMarker->boundingRect().width(), m_bandMarker->boundingRect().width()); - m_bandNameLabel->updateLabel(); + m_bandNameLabel->updateLabel(bandTitle()); m_bandNameLabel->setVisible(value.toBool()); } @@ -724,6 +731,13 @@ void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgrou m_alternateBackgroundColor = alternateBackgroundColor; } +void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName) +{ + update(); + if (m_bandNameLabel) + m_bandNameLabel->updateLabel(newName); +} + bool BandDesignIntf::repeatOnEachRow() const { return m_repeatOnEachRow; @@ -878,7 +892,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p void BandDesignIntf::updateBandNameLabel() { - if (m_bandNameLabel) m_bandNameLabel->updateLabel(); + if (m_bandNameLabel) m_bandNameLabel->updateLabel(bandTitle()); } QColor BandDesignIntf::selectionColor() const @@ -921,7 +935,7 @@ QRectF BandNameLabel::boundingRect() const return m_rect; } -void BandNameLabel::updateLabel() +void BandNameLabel::updateLabel(const QString& bandName) { QFont font("Arial",7*Const::fontFACTOR,-1,true); QFontMetrics fontMetrics(font); @@ -929,7 +943,7 @@ void BandNameLabel::updateLabel() m_rect = QRectF( m_band->pos().x()+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(); } diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index e306742..1e60a13 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -74,7 +74,7 @@ public: explicit BandNameLabel(BandDesignIntf* band, QGraphicsItem* parent=0); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); QRectF boundingRect() const; - void updateLabel(); + void updateLabel(const QString &bandName); void hoverEnterEvent(QGraphicsSceneHoverEvent *event); private: QRectF m_rect; @@ -221,7 +221,7 @@ public: QColor alternateBackgroundColor() const; void setAlternateBackgroundColor(const QColor &alternateBackgroundColor); signals: - void bandRendered(BandDesignIntf* band); + void bandRendered(BandDesignIntf* band); protected: void trimToMaxHeight(int maxHeight); void setBandTypeText(const QString& value); @@ -245,6 +245,7 @@ protected: QString translateBandName(const BaseDesignIntf *item) const; private slots: void childBandDeleted(QObject* band); + void slotPropertyObjectNameChanged(const QString&,const QString&); private: QString m_bandTypeText; BandsType m_bandType;