diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index 5d9fb34..dfa9875 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -28,7 +28,7 @@ m_domainIndex(0), m_marginSize(0), m_rect(QRectF(QPoint(0,0),m_chart->size())) { - setTheme(QChart::ChartThemeDefault); + setChartTheme(QChart::ChartThemeDefault); createConnections(); createDeafultAxis(); } @@ -203,7 +203,7 @@ void ChartPresenter::zoomReset() m_dataset->clearDomains(); } -void ChartPresenter::setTheme(QChart::ChartThemeId theme) +void ChartPresenter::setChartTheme(QChart::ChartTheme theme) { delete m_chartTheme; @@ -221,9 +221,19 @@ void ChartPresenter::setTheme(QChart::ChartThemeId theme) } -QChart::ChartThemeId ChartPresenter::theme() +QChart::ChartTheme ChartPresenter::chartTheme() { - return (QChart::ChartThemeId) 0; + return m_chartTheme->id(); +} + +void ChartPresenter::setAxisX(QChartAxis* axis) +{ + +} + +void ChartPresenter::addAxisY(QChartAxis* axis) +{ + } /* diff --git a/src/chartpresenter_p.h b/src/chartpresenter_p.h index 9660e79..e89ea17 100644 --- a/src/chartpresenter_p.h +++ b/src/chartpresenter_p.h @@ -21,13 +21,6 @@ class ChartPresenter: public QObject public: ChartPresenter(QChart* chart,ChartDataSet *dataset); virtual ~ChartPresenter(); -/* - void setAxisX(const QChartAxis& axis); - void setAxisY(const QChartAxis& axis); - void setAxisY(const QList& axis); - - -*/ void setMargin(int margin); int margin() const; @@ -37,9 +30,11 @@ public: void zoomOut(); void zoomReset(); - void setTheme(QChart::ChartThemeId theme); - QChart::ChartThemeId theme(); + void setChartTheme(QChart::ChartTheme theme); + QChart::ChartTheme chartTheme(); + void setAxisX(QChartAxis* axis); + void addAxisY(QChartAxis* axis); private: void createConnections(); void createDeafultAxis(); diff --git a/src/charttheme.cpp b/src/charttheme.cpp index fcb2507..b0d31bd 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -35,8 +35,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE m_gradientEndColor = QColor(QRgb(0xffafafaf)); */ -ChartTheme::ChartTheme() +ChartTheme::ChartTheme(QChart::ChartTheme id) { + m_id = id; m_seriesColor.append(QRgb(0xff000000)); m_seriesColor.append(QRgb(0xff707070)); m_gradientStartColor = QColor(QRgb(0xffffffff)); @@ -44,7 +45,7 @@ ChartTheme::ChartTheme() } -ChartTheme* ChartTheme::createTheme(QChart::ChartThemeId theme) +ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) { switch(theme) { case QChart::ChartThemeDefault: diff --git a/src/charttheme_p.h b/src/charttheme_p.h index d6f3219..835ed8c 100644 --- a/src/charttheme_p.h +++ b/src/charttheme_p.h @@ -21,9 +21,10 @@ class PercentBarGroup; class ChartTheme { protected: - explicit ChartTheme(); + explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault); public: - static ChartTheme* createTheme(QChart::ChartThemeId theme); + static ChartTheme* createTheme(QChart::ChartTheme theme); + QChart::ChartTheme id() const {return m_id;} void decorate(QChart* chart); void decorate(ChartItem* item, QChartSeries* series,int count); void decorate(LineChartItem* item, QLineChartSeries*, int count); @@ -32,6 +33,7 @@ public: void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count); protected: + QChart::ChartTheme m_id; QColor m_gradientStartColor; QColor m_gradientEndColor; QList m_seriesColor; diff --git a/src/qchart.cpp b/src/qchart.cpp index 890ce21..ec7326b 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -115,14 +115,14 @@ void QChart::setMargin(int margin) m_presenter->setMargin(margin); } -void QChart::setTheme(QChart::ChartThemeId theme) +void QChart::setChartTheme(QChart::ChartTheme theme) { - m_presenter->setTheme(theme); + m_presenter->setChartTheme(theme); } -QChart::ChartThemeId QChart::theme() +QChart::ChartTheme QChart::chartTheme() const { - return m_presenter->theme(); + return m_presenter->chartTheme(); } void QChart::zoomInToRect(const QRectF& rectangle) @@ -145,23 +145,13 @@ void QChart::zoomReset() m_presenter->zoomReset(); } -void QChart::setAxisX(const QChartAxis& axis) +void QChart::setAxisX(QChartAxis* axis) { - + m_presenter->setAxisX(axis); } -void QChart::setAxisY(const QChartAxis& axis) -{ - -} - -void QChart::setAxisY(const QList& axis) +void QChart::addAxisY(QChartAxis* axis) { - //TODO not implemented -} - -void QChart::setAxis(AxisItem *item, const QChartAxis& axis) -{ - + m_presenter->addAxisY(axis); } void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) diff --git a/src/qchart.h b/src/qchart.h index 8345aeb..7031ee9 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -33,8 +33,7 @@ class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget { Q_OBJECT public: - enum ChartThemeId { - ChartThemeInvalid = -1, + enum ChartTheme { /*! The default theme follows the GUI style of the Operating System */ ChartThemeDefault, ChartThemeVanilla, @@ -56,8 +55,8 @@ public: void setMargin(int margin); int margin() const; - void setTheme(QChart::ChartThemeId theme); - QChart::ChartThemeId theme(); + void setChartTheme(QChart::ChartTheme theme); + QChart::ChartTheme chartTheme() const; void setTitle(const QString& title,const QFont& font = QFont()); void setChartBackgroundBrush(const QBrush& brush); @@ -68,9 +67,8 @@ public: void zoomOut(); void zoomReset(); - void setAxisX(const QChartAxis& axis); - void setAxisY(const QChartAxis& axis); - void setAxisY(const QList& axis); + void setAxisX(QChartAxis* axis); + void addAxisY(QChartAxis* axis); protected: void resizeEvent(QGraphicsSceneResizeEvent *event); diff --git a/src/qchartview.cpp b/src/qchartview.cpp index 62f0a5d..5119e4d 100644 --- a/src/qchartview.cpp +++ b/src/qchartview.cpp @@ -189,10 +189,14 @@ void QChartView::keyPressEvent(QKeyEvent *event) } } -void QChartView::setTheme(QChart::ChartThemeId theme) +void QChartView::setChartTheme(QChart::ChartTheme theme) { - m_chart->setTheme(theme); + m_chart->setChartTheme(theme); } +QChart::ChartTheme QChartView::chartTheme() const +{ + return m_chart->chartTheme(); +} QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/qchartview.h b/src/qchartview.h index dbf36e4..991a423 100644 --- a/src/qchartview.h +++ b/src/qchartview.h @@ -42,7 +42,8 @@ public: void setRubberBandPolicy(const RubberBandPolicy ); RubberBandPolicy rubberBandPolicy() const; - void setTheme(QChart::ChartThemeId theme); + void setChartTheme(QChart::ChartTheme theme); + QChart::ChartTheme chartTheme() const; protected: void mousePressEvent(QMouseEvent *event); diff --git a/src/themes/chartthemegrayscale_p.h b/src/themes/chartthemegrayscale_p.h index 33443c2..fe15772 100644 --- a/src/themes/chartthemegrayscale_p.h +++ b/src/themes/chartthemegrayscale_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeGrayscale: public ChartTheme { public: - ChartThemeGrayscale() + ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale) { m_seriesColor.append(QRgb(0xFF869299)); m_seriesColor.append(QRgb(0xFFA5BDCC)); diff --git a/src/themes/chartthemeicy_p.h b/src/themes/chartthemeicy_p.h index 5477609..0794ced 100644 --- a/src/themes/chartthemeicy_p.h +++ b/src/themes/chartthemeicy_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeIcy: public ChartTheme { public: - ChartThemeIcy() + ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy) { m_seriesColor.append(QRgb(0xFF0D2673)); m_seriesColor.append(QRgb(0xFF2685BF)); diff --git a/src/themes/chartthemescientific_p.h b/src/themes/chartthemescientific_p.h index d4943d4..29ff3db 100644 --- a/src/themes/chartthemescientific_p.h +++ b/src/themes/chartthemescientific_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeScientific: public ChartTheme { public: - ChartThemeScientific() + ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific) { m_seriesColor.append(QRgb(0xFF000000)); m_seriesColor.append(QRgb(0xFFFFAD00)); diff --git a/src/themes/chartthemevanilla_p.h b/src/themes/chartthemevanilla_p.h index 4b6dd37..a77924f 100644 --- a/src/themes/chartthemevanilla_p.h +++ b/src/themes/chartthemevanilla_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeVanilla: public ChartTheme { public: - ChartThemeVanilla() + ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla) { m_seriesColor.append(QColor(217, 197, 116)); m_seriesColor.append(QColor(214, 168, 150));