@@ -1,27 +1,27 | |||||
1 | #include "declarativechart.h" |
|
1 | #include "declarativechart.h" | |
2 | #include <QPainter> |
|
2 | #include <QPainter> | |
3 |
|
3 | |||
4 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
4 | #ifndef QTQUICK2 | |
5 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
5 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
6 | : QDeclarativeItem(parent) |
|
6 | : QDeclarativeItem(parent) | |
7 | { |
|
7 | { | |
8 | // need to disable this flag to draw inside a QDeclarativeItem |
|
8 | // need to disable this flag to draw inside a QDeclarativeItem | |
9 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
9 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
10 | } |
|
10 | } | |
11 | #else |
|
11 | #else | |
12 | DeclarativeChart::DeclarativeChart(QQuickItem *parent) |
|
12 | DeclarativeChart::DeclarativeChart(QQuickItem *parent) | |
13 | : QQuickPaintedItem(parent) |
|
13 | : QQuickPaintedItem(parent) | |
14 | { |
|
14 | { | |
15 |
|
15 | |||
16 | } |
|
16 | } | |
17 | #endif |
|
17 | #endif | |
18 |
|
18 | |||
19 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
19 | #ifndef QTQUICK2 | |
20 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) |
|
20 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) | |
21 | #else |
|
21 | #else | |
22 | void DeclarativeChart::paint(QPainter *painter) |
|
22 | void DeclarativeChart::paint(QPainter *painter) | |
23 | #endif |
|
23 | #endif | |
24 | { |
|
24 | { | |
25 | drawChart(painter, boundingRect()); |
|
25 | drawChart(painter, boundingRect()); | |
26 | } |
|
26 | } | |
27 |
|
27 |
@@ -1,37 +1,37 | |||||
1 | #ifndef DECLARATIVECHART_H |
|
1 | #ifndef DECLARATIVECHART_H | |
2 | #define DECLARATIVECHART_H |
|
2 | #define DECLARATIVECHART_H | |
3 |
|
3 | |||
4 | #include <QtCore/QtGlobal> |
|
4 | #include <QtCore/QtGlobal> | |
5 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
5 | #ifndef QTQUICK2 | |
6 | #include <QDeclarativeItem> |
|
6 | #include <QDeclarativeItem> | |
7 | #else |
|
7 | #else | |
8 | #include <QtQuick/QQuickPaintedItem> |
|
8 | #include <QtQuick/QQuickPaintedItem> | |
9 | #endif |
|
9 | #endif | |
10 | #include <QColor> |
|
10 | #include <QColor> | |
11 | #include "../src/chart.h" |
|
11 | #include "../src/chart.h" | |
12 |
|
12 | |||
13 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
13 | #ifndef QTQUICK2 | |
14 | class DeclarativeChart : public QDeclarativeItem, public Chart |
|
14 | class DeclarativeChart : public QDeclarativeItem, public Chart | |
15 | #else |
|
15 | #else | |
16 | class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
16 | class DeclarativeChart : public QQuickPaintedItem, public Chart | |
17 | #endif |
|
17 | #endif | |
18 | { |
|
18 | { | |
19 | Q_OBJECT |
|
19 | Q_OBJECT | |
20 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
20 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
21 |
|
21 | |||
22 | public: |
|
22 | public: | |
23 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
23 | #ifndef QTQUICK2 | |
24 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
24 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
25 | #else |
|
25 | #else | |
26 | DeclarativeChart(QQuickItem *parent = 0); |
|
26 | DeclarativeChart(QQuickItem *parent = 0); | |
27 | #endif |
|
27 | #endif | |
28 |
|
28 | |||
29 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
29 | #ifndef QTQUICK2 | |
30 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
30 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
31 | #else |
|
31 | #else | |
32 | void paint(QPainter *painter); |
|
32 | void paint(QPainter *painter); | |
33 | #endif |
|
33 | #endif | |
34 | }; |
|
34 | }; | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | #endif // DECLARATIVECHART_H |
|
37 | #endif // DECLARATIVECHART_H |
@@ -1,26 +1,30 | |||||
1 | TEMPLATE = lib |
|
1 | TEMPLATE = lib | |
2 | TARGET = qmlchartplugin |
|
2 | TARGET = qmlchartplugin | |
3 |
|
3 | |||
4 | CONFIG += qt plugin |
|
4 | CONFIG += qt plugin | |
5 | QT += declarative |
|
5 | QT += declarative | |
6 |
|
6 | |||
|
7 | contains($$QT_MAJOR_VERSION, 5) { | |||
|
8 | DEFINES += QTQUICK2 | |||
|
9 | } | |||
|
10 | ||||
7 | OBJECTS_DIR = tmp |
|
11 | OBJECTS_DIR = tmp | |
8 | MOC_DIR = tmp |
|
12 | MOC_DIR = tmp | |
9 |
|
13 | |||
10 | SOURCES += \ |
|
14 | SOURCES += \ | |
11 | plugin.cpp \ |
|
15 | plugin.cpp \ | |
12 | declarativechart.cpp |
|
16 | declarativechart.cpp | |
13 | HEADERS += \ |
|
17 | HEADERS += \ | |
14 | declarativechart.h |
|
18 | declarativechart.h | |
15 | include(../src/chart.pri) |
|
19 | include(../src/chart.pri) | |
16 |
|
20 | |||
17 | TARGETPATH = com/digia/charts |
|
21 | TARGETPATH = com/digia/charts | |
18 |
|
22 | |||
19 | #DESTDIR = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
23 | #DESTDIR = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
20 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
24 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
21 |
|
25 | |||
22 | qmldir.files += $$PWD/qmldir |
|
26 | qmldir.files += $$PWD/qmldir | |
23 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
27 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
24 |
|
28 | |||
25 | INSTALLS += target qmldir |
|
29 | INSTALLS += target qmldir | |
26 |
|
30 |
General Comments 0
You need to be logged in to leave comments.
Login now