diff --git a/src/barchart/qbarmodelmapper.cpp b/src/barchart/qbarmodelmapper.cpp index d190dca..483ec57 100644 --- a/src/barchart/qbarmodelmapper.cpp +++ b/src/barchart/qbarmodelmapper.cpp @@ -329,7 +329,7 @@ void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) { QBarSet* bar = m_series->barSets().at(section - m_firstBarSetSection); if (bar) - bar->setName(m_model->headerData(section, orientation).toString()); + bar->setLabel(m_model->headerData(section, orientation).toString()); } } } diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 8d157cb..d8fb8d2 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -155,6 +155,7 @@ void QBarSeries::setBarWidth(qreal width) { Q_D(QBarSeries); d->setBarWidth(width); + emit barWidthChanged(); } /*! @@ -179,6 +180,7 @@ bool QBarSeries::append(QBarSet *set) QList sets; sets.append(set); emit barsetsAdded(sets); + emit barsetCountChanged(); } return success; } @@ -195,6 +197,7 @@ bool QBarSeries::remove(QBarSet *set) QList sets; sets.append(set); emit barsetsRemoved(sets); + emit barsetCountChanged(); } return success; } @@ -211,6 +214,7 @@ bool QBarSeries::append(QList sets) bool success = d->append(sets); if (success) { emit barsetsAdded(sets); + emit barsetCountChanged(); } return success; } @@ -228,6 +232,7 @@ bool QBarSeries::insert(int index, QBarSet *set) QList sets; sets.append(set); emit barsetsAdded(sets); + emit barsetCountChanged(); } return success; } @@ -242,6 +247,7 @@ void QBarSeries::clear() bool success = d->remove(sets); if (success) { emit barsetsRemoved(sets); + emit barsetCountChanged(); } } diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index ce87e42..82113fb 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -33,9 +33,9 @@ class QBarSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries { Q_OBJECT - Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) - Q_PROPERTY(int count READ barsetCount) - Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible) + Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged) + Q_PROPERTY(int count READ barsetCount NOTIFY barsetCountChanged) + Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) public: explicit QBarSeries(QObject *parent = 0); @@ -63,6 +63,8 @@ protected: Q_SIGNALS: void clicked(QBarSet *barset, int index); void hovered(QBarSet* barset, bool status); + void barWidthChanged(); + void barsetCountChanged(); void labelsVisibleChanged(); void barsetsAdded(QList sets); diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index a249d15..c0a02f3 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -38,8 +38,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \property QBarSet::name - \brief Defines the name of the barSet. + \property QBarSet::label + \brief Defines the label of the barSet. */ /*! @@ -63,11 +63,11 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QBarSet::nameChanged() + \fn void QBarSet::labelChanged() - This signal is emitted when the name of the barSet has changed. + This signal is emitted when the label of the barSet has changed. - \sa name + \sa label */ /*! @@ -87,12 +87,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QBarSet::labelChanged() - - This signal is emitted when the label of the barSet has changed. -*/ - -/*! \fn void QBarSet::labelBrushChanged() This signal is emitted when the brush of the barSet's label has changed. @@ -139,11 +133,11 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE void valueChanged(int index); /*! - Constructs QBarSet with a name of \a name and with parent of \a parent + Constructs QBarSet with a label of \a label and with parent of \a parent */ -QBarSet::QBarSet(const QString name, QObject *parent) +QBarSet::QBarSet(const QString label, QObject *parent) : QObject(parent) - ,d_ptr(new QBarSetPrivate(name,this)) + ,d_ptr(new QBarSetPrivate(label,this)) { } @@ -156,20 +150,20 @@ QBarSet::~QBarSet() } /*! - Sets new \a name for set. + Sets new \a label for set. */ -void QBarSet::setName(const QString name) +void QBarSet::setLabel(const QString label) { - d_ptr->m_name = name; - emit nameChanged(); + d_ptr->m_label = label; + emit labelChanged(); } /*! - Returns name of the set. + Returns label of the set. */ -QString QBarSet::name() const +QString QBarSet::label() const { - return d_ptr->m_name; + return d_ptr->m_label; } /*! @@ -421,9 +415,9 @@ QFont QBarSet::labelFont() const //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -QBarSetPrivate::QBarSetPrivate(const QString name, QBarSet *parent) : QObject(parent), +QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), q_ptr(parent), - m_name(name) + m_label(label) { } diff --git a/src/barchart/qbarset.h b/src/barchart/qbarset.h index 6591fae..cbe3320 100644 --- a/src/barchart/qbarset.h +++ b/src/barchart/qbarset.h @@ -32,18 +32,18 @@ class QBarSetPrivate; class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject { Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QPen pen READ pen WRITE setPen) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush) - Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush) - Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont) + Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) + Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) + Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) + Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) public: - explicit QBarSet(const QString name, QObject *parent = 0); + explicit QBarSet(const QString label, QObject *parent = 0); virtual ~QBarSet(); - void setName(const QString name); - QString name() const; + void setLabel(const QString label); + QString label() const; void append(const QPointF value); void append(const QList values); @@ -76,7 +76,6 @@ public: QFont labelFont() const; Q_SIGNALS: - void nameChanged(); void penChanged(); void brushChanged(); void labelChanged(); diff --git a/src/barchart/qbarset_p.h b/src/barchart/qbarset_p.h index 49a128e..9762853 100644 --- a/src/barchart/qbarset_p.h +++ b/src/barchart/qbarset_p.h @@ -43,7 +43,7 @@ class QBarSetPrivate : public QObject Q_OBJECT public: - QBarSetPrivate(const QString name, QBarSet *parent); + QBarSetPrivate(const QString label, QBarSet *parent); ~QBarSetPrivate(); void append(QPointF value); @@ -63,7 +63,7 @@ Q_SIGNALS: public: QBarSet * const q_ptr; - QString m_name; + QString m_label; QList m_values; QPen m_pen; QBrush m_brush; diff --git a/src/legend/legendmarker.cpp b/src/legend/legendmarker.cpp index 951283e..497fdee 100644 --- a/src/legend/legendmarker.cpp +++ b/src/legend/legendmarker.cpp @@ -71,9 +71,9 @@ QBrush LegendMarker::brush() const return m_rectItem->brush(); } -void LegendMarker::setLabel(const QString name) +void LegendMarker::setLabel(const QString label) { - m_textItem->setText(name); + m_textItem->setText(label); updateLayout(); } @@ -149,7 +149,7 @@ m_barset(barset) void BarLegendMarker::updated() { setBrush(m_barset->brush()); - setLabel(m_barset->name()); + setLabel(m_barset->label()); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/tests/auto/qbarset/tst_qbarset.cpp b/tests/auto/qbarset/tst_qbarset.cpp index c146185..081730b 100644 --- a/tests/auto/qbarset/tst_qbarset.cpp +++ b/tests/auto/qbarset/tst_qbarset.cpp @@ -38,8 +38,8 @@ public slots: private slots: void qbarset_data(); void qbarset(); - void name_data(); - void name(); + void label_data(); + void label(); void append_data(); void append(); void appendOperator_data(); @@ -74,7 +74,7 @@ void tst_QBarSet::cleanupTestCase() void tst_QBarSet::init() { - m_barset = new QBarSet(QString("Name")); + m_barset = new QBarSet(QString("label")); } void tst_QBarSet::cleanup() @@ -89,29 +89,29 @@ void tst_QBarSet::qbarset_data() void tst_QBarSet::qbarset() { - QBarSet barset(QString("Name")); - QCOMPARE(barset.name(), QString("Name")); + QBarSet barset(QString("label")); + QCOMPARE(barset.label(), QString("label")); QCOMPARE(barset.count(), 0); QVERIFY(qFuzzyIsNull(barset.sum())); } -void tst_QBarSet::name_data() +void tst_QBarSet::label_data() { - QTest::addColumn ("name"); + QTest::addColumn ("label"); QTest::addColumn ("result"); - QTest::newRow("name0") << QString("name0") << QString("name0"); - QTest::newRow("name1") << QString("name1") << QString("name1"); + QTest::newRow("label0") << QString("label0") << QString("label0"); + QTest::newRow("label1") << QString("label1") << QString("label1"); } -void tst_QBarSet::name() +void tst_QBarSet::label() { - QFETCH(QString, name); + QFETCH(QString, label); QFETCH(QString, result); - QSignalSpy nameSpy(m_barset,SIGNAL(nameChanged())); - m_barset->setName(name); - QCOMPARE(m_barset->name(), result); - QVERIFY(nameSpy.count() == 1); + QSignalSpy labelSpy(m_barset,SIGNAL(labelChanged())); + m_barset->setLabel(label); + QCOMPARE(m_barset->label(), result); + QVERIFY(labelSpy.count() == 1); } void tst_QBarSet::append_data()