From 62d898329cbd7887476153d898d2d840cd4165bc 2012-06-15 08:55:38 From: Tero Ahola Date: 2012-06-15 08:55:38 Subject: [PATCH] Minor modifications to properties of abstract, area and bar series --- diff --git a/examples/presenterchart/chartview.cpp b/examples/presenterchart/chartview.cpp index 9361b3f..c9d4bba 100644 --- a/examples/presenterchart/chartview.cpp +++ b/examples/presenterchart/chartview.cpp @@ -29,7 +29,7 @@ ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent), m_index(-1),m_chart(chart) { m_chart->setTitle("Charts presenter"); - m_chart->setBackgroundDropShadowEnabled(false); + m_chart->setDropShadowEnabled(false); QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); m_timer.setInterval(3000); diff --git a/examples/scatterchart/chartview.cpp b/examples/scatterchart/chartview.cpp index 31c80ed..4306dad 100644 --- a/examples/scatterchart/chartview.cpp +++ b/examples/scatterchart/chartview.cpp @@ -51,6 +51,6 @@ ChartView::ChartView(QWidget *parent) : chart()->addSeries(series0); chart()->addSeries(series1); chart()->setTitle("Simple scatterchart example"); - chart()->setBackgroundDropShadowEnabled(false); + chart()->setDropShadowEnabled(false); //![3] } diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index 4acc974..96e6a14 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -42,6 +42,44 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \clearfloat */ +/*! + \qmlproperty Theme ChartView::theme + Theme defines the visual appearance of the chart, including for example colors, fonts, line + widths and chart background. +*/ + +/*! + \qmlproperty Animation ChartView::animation + Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, + ChartView.SeriesAnimations or ChartView.AllAnimations. +*/ + +/*! + \qmlproperty string ChartView::title + The title of the chart, shown on top of the chart. +*/ + +/*! + \qmlproperty string ChartView::titleColor + The color of the title text. +*/ + +/*! + \qmlproperty Axis ChartView::axisX + The x-axis of the chart. +*/ + +/*! + \qmlproperty Axis ChartView::axisY + The default y-axis of the chart. +*/ + +/*! + \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) + The y-axis of the series. This is the same as the default y-axis of the chart, unless you have + explicitly defined the series to have a non-default y-axis. +*/ + DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) : QDeclarativeItem(parent), m_chart(new QChart(this)) @@ -66,15 +104,13 @@ void DeclarativeChart::childEvent(QChildEvent *event) void DeclarativeChart::componentComplete() { -// qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); foreach(QObject *child, children()) { if (qobject_cast(child)) { // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; + // TODO: how about optional y-axis? m_chart->addSeries(qobject_cast(child)); } } -// qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); - QDeclarativeItem::componentComplete(); } @@ -150,9 +186,9 @@ QAxis *DeclarativeChart::axisX() return m_chart->axisX(); } -QAxis *DeclarativeChart::axisY() +QAxis *DeclarativeChart::axisY(QAbstractSeries *series) { - return m_chart->axisY(); + return m_chart->axisY(series); } QLegend *DeclarativeChart::legend() @@ -222,15 +258,15 @@ int DeclarativeChart::count() void DeclarativeChart::setDropShadowEnabled(bool enabled) { - if (enabled != m_chart->isBackgroundDropShadowEnabled()) { - m_chart->setBackgroundDropShadowEnabled(enabled); + if (enabled != m_chart->isDropShadowEnabled()) { + m_chart->setDropShadowEnabled(enabled); dropShadowEnabledChanged(enabled); } } bool DeclarativeChart::dropShadowEnabled() { - return m_chart->isBackgroundDropShadowEnabled(); + return m_chart->isDropShadowEnabled(); } void DeclarativeChart::zoom(qreal factor) @@ -258,33 +294,6 @@ void DeclarativeChart::scrollDown(qreal pixels) m_chart->scroll(QPointF(0, -pixels)); } -//void DeclarativeChart::scrollLeft(qreal ticks) -//{ -// m_chart->scroll(QPointF(ticksToPixels(m_chart->axisX(), ticks), 0)); -//} - -//void DeclarativeChart::scrollRight(qreal ticks) -//{ -// m_chart->scroll(QPointF(-ticksToPixels(m_chart->axisX(), ticks), 0)); -//} - -//void DeclarativeChart::scrollUp(qreal ticks) -//{ -// m_chart->scroll(QPointF(0, ticksToPixels(m_chart->axisY(), ticks))); -//} - -//void DeclarativeChart::scrollDown(qreal ticks) -//{ -// m_chart->scroll(QPointF(0, -ticksToPixels(m_chart->axisY(), ticks))); -//} - -//qreal DeclarativeChart::ticksToPixels(QAxis *axis, qreal ticks) -//{ -// qreal tickCount = axis->max() - axis->min(); -// qreal tickPixels = (m_chart->size().width() - m_chart->margins().width() * 2) / tickCount; -// return tickPixels * ticks; -//} - QAbstractSeries *DeclarativeChart::series(int index) { if (index < m_chart->series().count()) { diff --git a/plugins/declarative/declarativechart.h b/plugins/declarative/declarativechart.h index bd7cae1..b223a22 100644 --- a/plugins/declarative/declarativechart.h +++ b/plugins/declarative/declarativechart.h @@ -99,7 +99,7 @@ public: void setTitle(QString title); QString title(); QAxis *axisX(); - QAxis *axisY(); + Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); QLegend *legend(); QVariantList axisXLabels(); void setAxisXLabels(QVariantList list); diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 8d9c66c..3161e31 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -47,14 +47,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn QLineSeries* QAreaSeries::upperSeries() const - \brief Returns upperSeries used to define one of area boundaries. + \property QAreaSeries::upperSeries + \brief The upper one of the two line series used to define area series boundaries. */ /*! - \fn QLineSeries* QAreaSeries::lowerSeries() const - \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries - this function return Null pointer. + \property QAreaSeries::lowerSeries + The lower one of the two line series used to define are series boundaries. Note if + QAreaSeries was counstucted wihtout a\ lowerSeries this is null. */ /*! diff --git a/src/areachart/qareaseries.h b/src/areachart/qareaseries.h index f82ea17..f5cfa25 100644 --- a/src/areachart/qareaseries.h +++ b/src/areachart/qareaseries.h @@ -33,6 +33,8 @@ class QAreaSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries { Q_OBJECT + Q_PROPERTY(QAbstractSeries *upperSeries READ upperSeries) + Q_PROPERTY(QAbstractSeries *lowerSeries READ lowerSeries) public: explicit QAreaSeries(QObject *parent = 0); diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index 17817bb..85ed393 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -75,7 +75,7 @@ void BarChartItem::handleDataStructureChanged() // Create new graphic items for bars for (int c = 0; c < m_series->d_func()->categoryCount(); c++) { - for (int s = 0; s < m_series->barsetCount(); s++) { + for (int s = 0; s < m_series->count(); s++) { QBarSet *set = m_series->d_func()->barsetAt(s); // Bars @@ -103,7 +103,7 @@ QVector BarChartItem::calculateLayout() // Use temporary qreals for accuracy qreal categoryCount = m_series->d_func()->categoryCount(); - qreal setCount = m_series->barsetCount(); + qreal setCount = m_series->count(); bool barsVisible = m_series->isVisible(); // Domain: diff --git a/src/barchart/groupedbarchartitem.cpp b/src/barchart/groupedbarchartitem.cpp index 5f5f818..bc462bc 100644 --- a/src/barchart/groupedbarchartitem.cpp +++ b/src/barchart/groupedbarchartitem.cpp @@ -37,7 +37,7 @@ QVector GroupedBarChartItem::calculateLayout() // Use temporary qreals for accuracy qreal categoryCount = m_series->d_func()->categoryCount(); - qreal setCount = m_series->barsetCount(); + qreal setCount = m_series->count(); bool barsVisible = m_series->isVisible(); // Domain: diff --git a/src/barchart/percentbarchartitem.cpp b/src/barchart/percentbarchartitem.cpp index a4d8ff6..5a45e38 100644 --- a/src/barchart/percentbarchartitem.cpp +++ b/src/barchart/percentbarchartitem.cpp @@ -37,7 +37,7 @@ QVector PercentBarChartItem::calculateLayout() // Use temporary qreals for accuracy qreal categoryCount = m_series->d_func()->categoryCount(); - qreal setCount = m_series->barsetCount(); + qreal setCount = m_series->count(); bool barsVisible = m_series->isVisible(); // Domain: diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 95380b2..8135964 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -88,7 +88,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QBarSeries::barsetCountChanged() + \fn void QBarSeries::countChanged() This signal is emitted when barset count has been changed, for example by append or remove. */ @@ -191,7 +191,7 @@ bool QBarSeries::append(QBarSet *set) QList sets; sets.append(set); emit barsetsAdded(sets); - emit barsetCountChanged(); + emit countChanged(); } return success; } @@ -208,7 +208,7 @@ bool QBarSeries::remove(QBarSet *set) QList sets; sets.append(set); emit barsetsRemoved(sets); - emit barsetCountChanged(); + emit countChanged(); } return success; } @@ -225,7 +225,7 @@ bool QBarSeries::append(QList sets) bool success = d->append(sets); if (success) { emit barsetsAdded(sets); - emit barsetCountChanged(); + emit countChanged(); } return success; } @@ -243,7 +243,7 @@ bool QBarSeries::insert(int index, QBarSet *set) QList sets; sets.append(set); emit barsetsAdded(sets); - emit barsetCountChanged(); + emit countChanged(); } return success; } @@ -258,14 +258,14 @@ void QBarSeries::clear() bool success = d->remove(sets); if (success) { emit barsetsRemoved(sets); - emit barsetCountChanged(); + emit countChanged(); } } /*! Returns number of sets in series. */ -int QBarSeries::barsetCount() const +int QBarSeries::count() const { Q_D(const QBarSeries); return d->m_barSets.count(); diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 82113fb..101e5fe 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -34,7 +34,7 @@ class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries { Q_OBJECT Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged) - Q_PROPERTY(int count READ barsetCount NOTIFY barsetCountChanged) + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) public: @@ -50,7 +50,7 @@ public: bool remove(QBarSet *set); bool append(QList sets); bool insert(int index, QBarSet *set); - int barsetCount() const; + int count() const; QList barSets() const; void clear(); @@ -64,7 +64,7 @@ Q_SIGNALS: void clicked(QBarSet *barset, int index); void hovered(QBarSet* barset, bool status); void barWidthChanged(); - void barsetCountChanged(); + void countChanged(); void labelsVisibleChanged(); void barsetsAdded(QList sets); diff --git a/src/barchart/stackedbarchartitem.cpp b/src/barchart/stackedbarchartitem.cpp index fb0c5e7..38c8eb2 100644 --- a/src/barchart/stackedbarchartitem.cpp +++ b/src/barchart/stackedbarchartitem.cpp @@ -37,7 +37,7 @@ QVector StackedBarChartItem::calculateLayout() QVector layout; // Use temporary qreals for accuracy qreal categoryCount = m_series->d_func()->categoryCount(); - qreal setCount = m_series->barsetCount(); + qreal setCount = m_series->count(); bool barsVisible = m_series->isVisible(); // Domain: diff --git a/src/charttheme.cpp b/src/charttheme.cpp index 1332072..4cd7d9e 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -110,7 +110,7 @@ void ChartTheme::decorate(QChart *chart) chart->setBackgroundBrush(m_chartBackgroundGradient); chart->setTitleFont(m_masterFont); chart->setTitleBrush(m_titleBrush); - chart->setBackgroundDropShadowEnabled(m_backgroundDropShadowEnabled); + chart->setDropShadowEnabled(m_backgroundDropShadowEnabled); } void ChartTheme::decorate(QLegend *legend) diff --git a/src/qabstractseries.cpp b/src/qabstractseries.cpp index 1486cc8..7638a42 100644 --- a/src/qabstractseries.cpp +++ b/src/qabstractseries.cpp @@ -51,8 +51,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn QSeriesType QAbstractSeries::type() const - \brief The type of the series. + \property QAbstractSeries::type + The type of the series. */ /*! diff --git a/src/qabstractseries.h b/src/qabstractseries.h index 9f9dbe8..4a19f52 100644 --- a/src/qabstractseries.h +++ b/src/qabstractseries.h @@ -35,6 +35,7 @@ class QTCOMMERCIALCHART_EXPORT QAbstractSeries : public QObject Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(SeriesType type READ type) Q_ENUMS(SeriesType) public: diff --git a/src/qchart.cpp b/src/qchart.cpp index 46fdb9b..00c7f29 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -424,7 +424,7 @@ bool QChart::isBackgroundVisible() const /*! Sets the background drop shadow effect state to \a enabled. */ -void QChart::setBackgroundDropShadowEnabled(bool enabled) +void QChart::setDropShadowEnabled(bool enabled) { d_ptr->m_presenter->createChartBackgroundItem(); d_ptr->m_presenter->m_backgroundItem->setDropShadowEnabled(enabled); @@ -433,7 +433,7 @@ void QChart::setBackgroundDropShadowEnabled(bool enabled) /*! Returns true if the drop shadow effect is enabled for the chart background. */ -bool QChart::isBackgroundDropShadowEnabled() const +bool QChart::isDropShadowEnabled() const { if (!d_ptr->m_presenter->m_backgroundItem) return false; diff --git a/src/qchart.h b/src/qchart.h index 12b6f59..cbd2836 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -85,9 +85,9 @@ public: QPen backgroundPen() const; void setBackgroundVisible(bool visible = true); bool isBackgroundVisible() const; - void setBackgroundDropShadowEnabled(bool enabled = true); - bool isBackgroundDropShadowEnabled() const; + void setDropShadowEnabled(bool enabled = true); + bool isDropShadowEnabled() const; void setAnimationOptions(AnimationOptions options); AnimationOptions animationOptions() const;