##// END OF EJS Templates
Added axis to QML api
Tero Ahola -
r1096:1c6e297eef84
parent child
Show More
@@ -0,0 +1,69
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "declarativeaxis.h"
22 #include "declarativechart.h"
23 #include <QAxis>
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
27 DeclarativeAxis::DeclarativeAxis(QObject *parent) :
28 QAxis(parent),
29 m_role(DeclarativeAxis::RoleX)
30 {
31 }
32
33 void DeclarativeAxis::classBegin()
34 {
35 }
36
37 void DeclarativeAxis::componentComplete()
38 {
39 DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
40 if (declarativeChart) {
41 QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
42 Q_ASSERT(chart);
43 QAxis *axis = 0;
44 if (m_role == RoleX)
45 axis = chart->axisX();
46 else
47 axis = chart->axisY();
48 Q_ASSERT(axis);
49 // TODO?
50 //foreach(DeclarativeCategory catecory, categories());
51 //axis->categories()->insert(0, "Jun");
52 // axis->categories()->insert(1, "Jul");
53 // axis->categories()->insert(2, "Aug");
54 // axis->categories()->insert(3, "Sep");
55 // axis->categories()->insert(4, "Oct");
56 // axis->categories()->insert(5, "Nov");
57 //axis->categories()->insert(6, "Dec");
58 }
59 }
60
61 void DeclarativeAxis::setRole(AxisRole role)
62 {
63 // TODO: apply the role to possible parent chart
64 m_role = role;
65 }
66
67 #include "moc_declarativeaxis.cpp"
68
69 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,58
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #ifndef DECLARATIVE_AXIS_H
22 #define DECLARATIVE_AXIS_H
23
24 #include "qchartglobal.h"
25 #include <QAxis>
26 #include <QDeclarativeParserStatus>
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
30 class DeclarativeAxis: public QAxis, public QDeclarativeParserStatus
31 {
32 Q_INTERFACES(QDeclarativeParserStatus)
33 Q_OBJECT
34 Q_PROPERTY(AxisRole role READ role WRITE setRole /*NOTIFY roleChanged*/)
35 Q_ENUMS(AxisRole)
36
37 public:
38 enum AxisRole {
39 RoleX = 0,
40 RoleY
41 };
42
43 public:
44 explicit DeclarativeAxis(QObject *parent = 0);
45
46 public: // from QDeclarativeParserStatus
47 virtual void classBegin();
48 virtual void componentComplete();
49
50 public:
51 void setRole(AxisRole role);
52 AxisRole role() { return m_role; }
53 AxisRole m_role;
54 };
55
56 QTCOMMERCIALCHART_END_NAMESPACE
57
58 #endif // DECLARATIVE_AXIS_H
@@ -28,7 +28,6 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
28 m_chart(new QChart(this)),
28 m_chart(new QChart(this)),
29 m_legend(LegendDisabled)
29 m_legend(LegendDisabled)
30 {
30 {
31 m_chart->setAnimationOptions(QChart::SeriesAnimations);
32 setFlag(QGraphicsItem::ItemHasNoContents, false);
31 setFlag(QGraphicsItem::ItemHasNoContents, false);
33 }
32 }
34
33
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -22,6 +22,7
22 #include <QtDeclarative/qdeclarative.h>
22 #include <QtDeclarative/qdeclarative.h>
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "declarativechart.h"
24 #include "declarativechart.h"
25 #include "declarativeaxis.h"
25 #include "declarativexypoint.h"
26 #include "declarativexypoint.h"
26 #include "declarativelineseries.h"
27 #include "declarativelineseries.h"
27 #include "declarativesplineseries.h"
28 #include "declarativesplineseries.h"
@@ -41,6 +42,7 public:
41 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
42 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
42
43
43 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart");
44 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart");
45 qmlRegisterType<DeclarativeAxis>(uri, 1, 0, "Axis");
44 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
46 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
45 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
47 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
46 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
48 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
@@ -21,8 +21,9 RCC_DIR = $$CHART_BUILD_DIR/plugin
21 SOURCES += \
21 SOURCES += \
22 plugin.cpp \
22 plugin.cpp \
23 declarativechart.cpp \
23 declarativechart.cpp \
24 declarativexyseries.cpp \
24 declarativeaxis.cpp \
25 declarativexypoint.cpp \
25 declarativexypoint.cpp \
26 declarativexyseries.cpp \
26 declarativelineseries.cpp \
27 declarativelineseries.cpp \
27 declarativesplineseries.cpp \
28 declarativesplineseries.cpp \
28 declarativeareaseries.cpp \
29 declarativeareaseries.cpp \
@@ -31,8 +32,9 SOURCES += \
31 declarativebarseries.cpp
32 declarativebarseries.cpp
32 HEADERS += \
33 HEADERS += \
33 declarativechart.h \
34 declarativechart.h \
34 declarativexyseries.h \
35 declarativeaxis.h \
35 declarativexypoint.h \
36 declarativexypoint.h \
37 declarativexyseries.h \
36 declarativelineseries.h \
38 declarativelineseries.h \
37 declarativesplineseries.h \
39 declarativesplineseries.h \
38 declarativeareaseries.h \
40 declarativeareaseries.h \
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -33,6 +33,8 class QAxisPrivate;
33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible)
37
36 public:
38 public:
37
39
38 QAxis(QObject *parent =0);
40 QAxis(QObject *parent =0);
General Comments 0
You need to be logged in to leave comments. Login now