@@ -1,120 +1,118 | |||||
1 | ##################### LIB ################################################# |
|
1 | ##################### LIB ################################################# | |
2 |
|
2 | |||
3 | LIBRARY_NAME = QtCommercialChart |
|
3 | LIBRARY_NAME = QtCommercialChart | |
4 | CONFIG(debug, debug|release) { |
|
4 | CONFIG(debug, debug|release) { | |
5 | mac: LIBRARY_NAME = $$join(LIBRARY_NAME,,,_debug) |
|
5 | mac: LIBRARY_NAME = $$join(LIBRARY_NAME,,,_debug) | |
6 | win32: LIBRARY_NAME = $$join(LIBRARY_NAME,,,d) |
|
6 | win32: LIBRARY_NAME = $$join(LIBRARY_NAME,,,d) | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | LIBS += -l$$LIBRARY_NAME |
|
9 | LIBS += -l$$LIBRARY_NAME | |
10 |
|
10 | |||
11 | # This will undefine Q_DECL_EXPORT/Q_DECL_IMPORT at qchartglobal.h |
|
11 | # This will undefine Q_DECL_EXPORT/Q_DECL_IMPORT at qchartglobal.h | |
12 | # They should not be used for staticlib builds. |
|
12 | # They should not be used for staticlib builds. | |
13 | staticlib:DEFINES+=QTCOMMERCIALCHART_STATICLIB |
|
13 | staticlib:DEFINES+=QTCOMMERCIALCHART_STATICLIB | |
14 |
|
14 | |||
15 | #################### COVERAGE ################################################################# |
|
15 | #################### COVERAGE ################################################################# | |
16 | coverage: CONFIG += debug |
|
16 | coverage: CONFIG += debug | |
17 |
|
17 | |||
18 | ##################### SHADOW CONFIG ################################################# |
|
18 | ##################### SHADOW CONFIG ################################################# | |
19 |
|
19 | |||
20 | !contains($${PWD}, $${OUT_PWD}){ |
|
20 | !contains($${PWD}, $${OUT_PWD}){ | |
21 | search = "$$PWD:::" |
|
21 | search = "$$PWD:::" | |
22 |
temp = $$split(search,"/") |
|
22 | temp = $$split(search,"/") | |
23 | temp = $$last(temp) |
|
23 | temp = $$last(temp) | |
24 | path = $$replace(search,$$temp,'') |
|
24 | path = $$replace(search,$$temp,'') | |
25 | temp = $$split(OUT_PWD,$$path) |
|
25 | temp = $$split(OUT_PWD,$$path) | |
26 | temp = $$split(temp,'/') |
|
26 | temp = $$split(temp,'/') | |
27 | temp = $$first(temp) |
|
27 | temp = $$first(temp) | |
28 | path = "$${path}$${temp}" |
|
28 | path = "$${path}$${temp}" | |
29 |
SHADOW=$$path |
|
29 | SHADOW=$$path | |
30 | }else{ |
|
30 | }else{ | |
31 | SHADOW=$$PWD |
|
31 | SHADOW=$$PWD | |
32 |
CONFIG-=development_build |
|
32 | CONFIG-=development_build | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | ##################### BUILD PATHS ################################################## |
|
35 | ##################### BUILD PATHS ################################################## | |
36 |
|
36 | |||
37 | CHART_BUILD_PUBLIC_HEADER_DIR = $$SHADOW/include |
|
37 | CHART_BUILD_PUBLIC_HEADER_DIR = $$SHADOW/include | |
38 | CHART_BUILD_PRIVATE_HEADER_DIR = $$CHART_BUILD_PUBLIC_HEADER_DIR/private |
|
38 | CHART_BUILD_PRIVATE_HEADER_DIR = $$CHART_BUILD_PUBLIC_HEADER_DIR/private | |
39 | CHART_BUILD_LIB_DIR = $$SHADOW/lib |
|
39 | CHART_BUILD_LIB_DIR = $$SHADOW/lib | |
40 | CHART_BUILD_DIR = $$SHADOW/build |
|
40 | CHART_BUILD_DIR = $$SHADOW/build | |
41 | CHART_BUILD_BIN_DIR = $$SHADOW/bin |
|
41 | CHART_BUILD_BIN_DIR = $$SHADOW/bin | |
42 | CHART_BUILD_QML_PLUGIN_DIR = $$CHART_BUILD_BIN_DIR |
|
42 | CHART_BUILD_QML_PLUGIN_DIR = $$CHART_BUILD_BIN_DIR | |
43 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR |
|
43 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR | |
44 | CHART_BUILD_DOC_DIR = $$SHADOW/doc |
|
44 | CHART_BUILD_DOC_DIR = $$SHADOW/doc | |
45 |
|
45 | |||
46 | CONFIG(release,debug|release){ |
|
46 | CONFIG(release,debug|release){ | |
47 | CHART_BUILD_LIB_DIR = $$CHART_BUILD_LIB_DIR/release |
|
47 | CHART_BUILD_LIB_DIR = $$CHART_BUILD_LIB_DIR/release | |
48 | CHART_BUILD_BIN_DIR = $$CHART_BUILD_BIN_DIR/release |
|
48 | CHART_BUILD_BIN_DIR = $$CHART_BUILD_BIN_DIR/release | |
49 | CHART_BUILD_QML_PLUGIN_DIR = $$CHART_BUILD_QML_PLUGIN_DIR/release/QtCommercial/Chart |
|
49 | CHART_BUILD_QML_PLUGIN_DIR = $$CHART_BUILD_QML_PLUGIN_DIR/release/QtCommercial/Chart | |
50 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR |
|
50 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 |
|
53 | |||
54 | CONFIG(debug,debug|release){ |
|
54 | CONFIG(debug,debug|release){ | |
55 | CHART_BUILD_LIB_DIR = $$CHART_BUILD_LIB_DIR/debug |
|
55 | CHART_BUILD_LIB_DIR = $$CHART_BUILD_LIB_DIR/debug | |
56 | CHART_BUILD_BIN_DIR = $$CHART_BUILD_BIN_DIR/debug |
|
56 | CHART_BUILD_BIN_DIR = $$CHART_BUILD_BIN_DIR/debug | |
57 | CHART_BUILD_QML_PLUGIN_DIR = $$CHART_BUILD_QML_PLUGIN_DIR/debug/QtCommercial/Chart |
|
57 | CHART_BUILD_QML_PLUGIN_DIR = $$CHART_BUILD_QML_PLUGIN_DIR/debug/QtCommercial/Chart | |
58 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR |
|
58 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR | |
59 | } |
|
59 | } | |
60 | # Use own folders for debug and release builds |
|
60 | # Use own folders for debug and release builds | |
61 |
|
61 | |||
62 | CONFIG(debug, debug|release):CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/debug) |
|
62 | CONFIG(debug, debug|release):CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/debug) | |
63 | CONFIG(release, debug|release): CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/release) |
|
63 | CONFIG(release, debug|release): CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/release) | |
64 |
|
64 | |||
65 |
|
65 | |||
66 | win32:{ |
|
66 | win32:{ | |
67 | CHART_BUILD_PUBLIC_HEADER_DIR = $$replace(CHART_BUILD_PUBLIC_HEADER_DIR, "/","\\") |
|
67 | CHART_BUILD_PUBLIC_HEADER_DIR = $$replace(CHART_BUILD_PUBLIC_HEADER_DIR, "/","\\") | |
68 | CHART_BUILD_PRIVATE_HEADER_DIR = $$replace(CHART_BUILD_PRIVATE_HEADER_DIR, "/","\\") |
|
68 | CHART_BUILD_PRIVATE_HEADER_DIR = $$replace(CHART_BUILD_PRIVATE_HEADER_DIR, "/","\\") | |
69 | CHART_BUILD_BUILD_DIR = $$replace(CHART_BUILD_BUILD_DIR, "/","\\") |
|
69 | CHART_BUILD_BUILD_DIR = $$replace(CHART_BUILD_BUILD_DIR, "/","\\") | |
70 | CHART_BUILD_BIN_DIR = $$replace(CHART_BUILD_BIN_DIR, "/","\\") |
|
70 | CHART_BUILD_BIN_DIR = $$replace(CHART_BUILD_BIN_DIR, "/","\\") | |
71 | CHART_BUILD_QML_PLUGIN_DIR = $$replace(CHART_BUILD_QML_PLUGIN_DIR, "/","\\") |
|
71 | CHART_BUILD_QML_PLUGIN_DIR = $$replace(CHART_BUILD_QML_PLUGIN_DIR, "/","\\") | |
72 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$replace(CHART_BUILD_DESIGNER_PLUGIN_DIR, "/","\\") |
|
72 | CHART_BUILD_DESIGNER_PLUGIN_DIR = $$replace(CHART_BUILD_DESIGNER_PLUGIN_DIR, "/","\\") | |
73 | CHART_BUILD_DOC_DIR = $$replace(CHART_BUILD_DOC_DIR, "/","\\") |
|
73 | CHART_BUILD_DOC_DIR = $$replace(CHART_BUILD_DOC_DIR, "/","\\") | |
74 | CHART_BUILD_LIB_DIR = $$replace(CHART_BUILD_LIB_DIR, "/","\\") |
|
74 | CHART_BUILD_LIB_DIR = $$replace(CHART_BUILD_LIB_DIR, "/","\\") | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | mac: { |
|
77 | mac: { | |
78 | # Some Qt versions use an incompatible configuration on OSX which makes the build fail. |
|
78 | # Some Qt versions use an incompatible configuration on OSX which makes the build fail. | |
79 | # As a work-around, set the minimum OSX version to 10.5. |
|
79 | # As a work-around, set the minimum OSX version to 10.5. | |
80 | QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5 |
|
80 | QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5 | |
81 | QMAKE_LFLAGS *= -mmacosx-version-min=10.5 |
|
81 | QMAKE_LFLAGS *= -mmacosx-version-min=10.5 | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | linux-arm*: { |
|
84 | linux-arm*: { | |
85 | DEFINES+=QT_ON_ARM |
|
85 | DEFINES+=QT_ON_ARM | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | greaterThan(QT_MAJOR_VERSION, 4): DEFINES += QT5_QUICK_1 |
|
|||
89 |
|
||||
90 | ##################### INCLUDES ############################################################ |
|
88 | ##################### INCLUDES ############################################################ | |
91 |
|
89 | |||
92 |
|
90 | |||
93 | INCLUDEPATH += $$CHART_BUILD_PUBLIC_HEADER_DIR |
|
91 | INCLUDEPATH += $$CHART_BUILD_PUBLIC_HEADER_DIR | |
94 |
|
92 | |||
95 | !win32: { |
|
93 | !win32: { | |
96 | LIBS += -L$$CHART_BUILD_LIB_DIR -Wl,-rpath,$$CHART_BUILD_LIB_DIR |
|
94 | LIBS += -L$$CHART_BUILD_LIB_DIR -Wl,-rpath,$$CHART_BUILD_LIB_DIR | |
97 | } else { |
|
95 | } else { | |
98 | win32-msvc*: { |
|
96 | win32-msvc*: { | |
99 | # hack fix for error: |
|
97 | # hack fix for error: | |
100 | # "LINK : fatal error LNK1146: no argument specified with option '/LIBPATH:'" |
|
98 | # "LINK : fatal error LNK1146: no argument specified with option '/LIBPATH:'" | |
101 | QMAKE_LIBDIR += $$CHART_BUILD_LIB_DIR |
|
99 | QMAKE_LIBDIR += $$CHART_BUILD_LIB_DIR | |
102 | } else { |
|
100 | } else { | |
103 | LIBS += -L$$CHART_BUILD_LIB_DIR |
|
101 | LIBS += -L$$CHART_BUILD_LIB_DIR | |
104 | } |
|
102 | } | |
105 | } |
|
103 | } | |
106 |
|
104 | |||
107 | ##################### DEVELOPMENT BUILD ################################################### |
|
105 | ##################### DEVELOPMENT BUILD ################################################### | |
108 |
|
106 | |||
109 | development_build: { |
|
107 | development_build: { | |
110 | DEFINES+=DEVELOPMENT_BUILD |
|
108 | DEFINES+=DEVELOPMENT_BUILD | |
111 | CONFIG+=debug_and_release |
|
109 | CONFIG+=debug_and_release | |
112 | CONFIG+=build_all |
|
110 | CONFIG+=build_all | |
113 | } |
|
111 | } | |
114 |
|
112 | |||
115 | ##################### UNIT TESTS ############################################################## |
|
113 | ##################### UNIT TESTS ############################################################## | |
116 |
|
114 | |||
117 | CONFIG(debug, debug|release) { |
|
115 | CONFIG(debug, debug|release) { | |
118 | DEFINES+=BUILD_PRIVATE_UNIT_TESTS |
|
116 | DEFINES+=BUILD_PRIVATE_UNIT_TESTS | |
119 | } |
|
117 | } | |
120 |
|
118 |
@@ -1,40 +1,36 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include <QtQuick1/QDeclarativeEngine> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
26 | #endif |
|
|||
27 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
28 |
|
24 | |||
29 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
30 | { |
|
26 | { | |
31 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
32 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
33 |
|
29 | |||
34 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
35 | viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml")); |
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml")); | |
36 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
32 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
37 | viewer->showExpanded(); |
|
33 | viewer->showExpanded(); | |
38 |
|
34 | |||
39 | return app->exec(); |
|
35 | return app->exec(); | |
40 | } |
|
36 | } |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,40 +1,36 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include <QtQuick1/QDeclarativeEngine> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
26 | #endif |
|
|||
27 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
28 |
|
24 | |||
29 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
30 | { |
|
26 | { | |
31 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
32 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
33 |
|
29 | |||
34 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
35 | viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); |
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); | |
36 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
32 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
37 | viewer->showExpanded(); |
|
33 | viewer->showExpanded(); | |
38 |
|
34 | |||
39 | return app->exec(); |
|
35 | return app->exec(); | |
40 | } |
|
36 | } |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,40 +1,36 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include <QtQuick1/QDeclarativeEngine> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
26 | #endif |
|
|||
27 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
28 |
|
24 | |||
29 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
30 | { |
|
26 | { | |
31 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
32 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
33 |
|
29 | |||
34 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
35 | viewer->setSource(QUrl("qrc:/qml/qmlcustomizations/loader.qml")); |
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlcustomizations/loader.qml")); | |
36 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
32 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
37 | viewer->showExpanded(); |
|
33 | viewer->showExpanded(); | |
38 |
|
34 | |||
39 | return app->exec(); |
|
35 | return app->exec(); | |
40 | } |
|
36 | } |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,40 +1,36 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include <QtQuick1/QDeclarativeEngine> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
26 | #endif |
|
|||
27 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
28 |
|
24 | |||
29 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
30 | { |
|
26 | { | |
31 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
32 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
33 |
|
29 | |||
34 | //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
30 | //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
35 | viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); |
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); | |
36 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
32 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
37 | viewer->showExpanded(); |
|
33 | viewer->showExpanded(); | |
38 |
|
34 | |||
39 | return app->exec(); |
|
35 | return app->exec(); | |
40 | } |
|
36 | } |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,54 +1,48 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative> | |
23 | #include <QtQuick1/qdeclarative.h> |
|
23 | #include <QtDeclarative/QDeclarativeEngine> | |
24 | #include <QtQuick1/QDeclarativeEngine> |
|
|||
25 | #else |
|
|||
26 | #include <QtDeclarative> |
|
|||
27 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
28 | #endif |
|
|||
29 | //#include <QtDeclarative> |
|
|||
30 | #include <QAbstractItemModel> |
|
24 | #include <QAbstractItemModel> | |
31 | #include "declarativemodel.h" |
|
25 | #include "declarativemodel.h" | |
32 | #include "customtablemodel.h" |
|
26 | #include "customtablemodel.h" | |
33 | #include "qmlapplicationviewer.h" |
|
27 | #include "qmlapplicationviewer.h" | |
34 |
|
28 | |||
35 | const char *uri = "QmlCustomModel"; |
|
29 | const char *uri = "QmlCustomModel"; | |
36 |
|
30 | |||
37 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
31 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
38 | { |
|
32 | { | |
39 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
33 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
40 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
34 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
41 |
|
35 | |||
42 | // @uri QmlCustomModel |
|
36 | // @uri QmlCustomModel | |
43 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
37 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
44 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
38 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
45 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "CustomModel"); |
|
39 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "CustomModel"); | |
46 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "CustomModelElement"); |
|
40 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "CustomModelElement"); | |
47 |
|
41 | |||
48 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
42 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
49 | viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml")); |
|
43 | viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml")); | |
50 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
44 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
51 | viewer->showExpanded(); |
|
45 | viewer->showExpanded(); | |
52 |
|
46 | |||
53 | return app->exec(); |
|
47 | return app->exec(); | |
54 | } |
|
48 | } |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,180 +1,173 | |||||
1 | // checksum 0x3fbf version 0x70013 |
|
1 | // checksum 0x3fbf version 0x70013 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #ifdef QT5_QUICK_1 |
|
16 | #include <QtDeclarative/QDeclarativeComponent> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeEngine> | |
18 |
|
|
18 | #include <QtDeclarative/QDeclarativeContext> | |
19 | #include <QtQuick1/QDeclarativeContext> |
|
|||
20 | #else |
|
|||
21 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
23 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
24 | #endif |
|
|||
25 |
|
||||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
19 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
20 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
21 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
22 | #include <MDeclarativeCache> | |
30 | #endif |
|
23 | #endif | |
31 |
|
24 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
25 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
26 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
27 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
28 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
29 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
30 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
31 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
32 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
33 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
34 | #endif | |
42 |
|
35 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
36 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
37 | struct QmlJsDebuggingEnabler | |
45 | { |
|
38 | { | |
46 | QmlJsDebuggingEnabler() |
|
39 | QmlJsDebuggingEnabler() | |
47 | { |
|
40 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
41 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
42 | } | |
50 | }; |
|
43 | }; | |
51 |
|
44 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
45 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
46 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
47 | |||
55 | #endif // QMLJSDEBUGGER |
|
48 | #endif // QMLJSDEBUGGER | |
56 |
|
49 | |||
57 | class QmlApplicationViewerPrivate |
|
50 | class QmlApplicationViewerPrivate | |
58 | { |
|
51 | { | |
59 | QString mainQmlFile; |
|
52 | QString mainQmlFile; | |
60 | friend class QmlApplicationViewer; |
|
53 | friend class QmlApplicationViewer; | |
61 | static QString adjustPath(const QString &path); |
|
54 | static QString adjustPath(const QString &path); | |
62 | }; |
|
55 | }; | |
63 |
|
56 | |||
64 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
57 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
65 | { |
|
58 | { | |
66 | #ifdef Q_OS_UNIX |
|
59 | #ifdef Q_OS_UNIX | |
67 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
68 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
69 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
70 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
71 | #else |
|
64 | #else | |
72 | const QString pathInInstallDir = |
|
65 | const QString pathInInstallDir = | |
73 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
66 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
67 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
68 | return pathInInstallDir; | |
76 | #endif |
|
69 | #endif | |
77 | #endif |
|
70 | #endif | |
78 | return path; |
|
71 | return path; | |
79 | } |
|
72 | } | |
80 |
|
73 | |||
81 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
74 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
82 | : QDeclarativeView(parent) |
|
75 | : QDeclarativeView(parent) | |
83 | , d(new QmlApplicationViewerPrivate()) |
|
76 | , d(new QmlApplicationViewerPrivate()) | |
84 | { |
|
77 | { | |
85 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
78 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
86 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
79 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
80 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
81 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
82 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
83 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
84 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
85 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
86 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
87 | #endif | |
95 | #endif |
|
88 | #endif | |
96 | } |
|
89 | } | |
97 |
|
90 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
91 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
92 | { | |
100 | delete d; |
|
93 | delete d; | |
101 | } |
|
94 | } | |
102 |
|
95 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
96 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
97 | { | |
105 | return new QmlApplicationViewer(); |
|
98 | return new QmlApplicationViewer(); | |
106 | } |
|
99 | } | |
107 |
|
100 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
101 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
102 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
103 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
104 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
112 | } |
|
105 | } | |
113 |
|
106 | |||
114 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
107 | void QmlApplicationViewer::addImportPath(const QString &path) | |
115 | { |
|
108 | { | |
116 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
109 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
117 | } |
|
110 | } | |
118 |
|
111 | |||
119 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
112 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
120 | //{ |
|
113 | //{ | |
121 | //#if defined(Q_OS_SYMBIAN) |
|
114 | //#if defined(Q_OS_SYMBIAN) | |
122 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
115 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
123 | // if (orientation != ScreenOrientationAuto) { |
|
116 | // if (orientation != ScreenOrientationAuto) { | |
124 | // const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); |
|
117 | // const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); | |
125 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
118 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
126 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
119 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
127 | // return; |
|
120 | // return; | |
128 | // } |
|
121 | // } | |
129 | // } |
|
122 | // } | |
130 | //#endif // Q_OS_SYMBIAN |
|
123 | //#endif // Q_OS_SYMBIAN | |
131 |
|
124 | |||
132 | // Qt::WidgetAttribute attribute; |
|
125 | // Qt::WidgetAttribute attribute; | |
133 | // switch (orientation) { |
|
126 | // switch (orientation) { | |
134 | //#if QT_VERSION < 0x040702 |
|
127 | //#if QT_VERSION < 0x040702 | |
135 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
128 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
136 | // case ScreenOrientationLockPortrait: |
|
129 | // case ScreenOrientationLockPortrait: | |
137 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
130 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
138 | // break; |
|
131 | // break; | |
139 | // case ScreenOrientationLockLandscape: |
|
132 | // case ScreenOrientationLockLandscape: | |
140 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
133 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
141 | // break; |
|
134 | // break; | |
142 | // default: |
|
135 | // default: | |
143 | // case ScreenOrientationAuto: |
|
136 | // case ScreenOrientationAuto: | |
144 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
137 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
145 | // break; |
|
138 | // break; | |
146 | //#else // QT_VERSION < 0x040702 |
|
139 | //#else // QT_VERSION < 0x040702 | |
147 | // case ScreenOrientationLockPortrait: |
|
140 | // case ScreenOrientationLockPortrait: | |
148 | // attribute = Qt::WA_LockPortraitOrientation; |
|
141 | // attribute = Qt::WA_LockPortraitOrientation; | |
149 | // break; |
|
142 | // break; | |
150 | // case ScreenOrientationLockLandscape: |
|
143 | // case ScreenOrientationLockLandscape: | |
151 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
144 | // attribute = Qt::WA_LockLandscapeOrientation; | |
152 | // break; |
|
145 | // break; | |
153 | // default: |
|
146 | // default: | |
154 | // case ScreenOrientationAuto: |
|
147 | // case ScreenOrientationAuto: | |
155 | // attribute = Qt::WA_AutoOrientation; |
|
148 | // attribute = Qt::WA_AutoOrientation; | |
156 | // break; |
|
149 | // break; | |
157 | //#endif // QT_VERSION < 0x040702 |
|
150 | //#endif // QT_VERSION < 0x040702 | |
158 | // }; |
|
151 | // }; | |
159 | // setAttribute(attribute, true); |
|
152 | // setAttribute(attribute, true); | |
160 | //} |
|
153 | //} | |
161 |
|
154 | |||
162 | void QmlApplicationViewer::showExpanded() |
|
155 | void QmlApplicationViewer::showExpanded() | |
163 | { |
|
156 | { | |
164 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
157 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
165 | showFullScreen(); |
|
158 | showFullScreen(); | |
166 | #elif defined(Q_WS_MAEMO_5) |
|
159 | #elif defined(Q_WS_MAEMO_5) | |
167 | showMaximized(); |
|
160 | showMaximized(); | |
168 | #else |
|
161 | #else | |
169 | show(); |
|
162 | show(); | |
170 | #endif |
|
163 | #endif | |
171 | } |
|
164 | } | |
172 |
|
165 | |||
173 | QApplication *createApplication(int &argc, char **argv) |
|
166 | QApplication *createApplication(int &argc, char **argv) | |
174 | { |
|
167 | { | |
175 | #ifdef HARMATTAN_BOOSTER |
|
168 | #ifdef HARMATTAN_BOOSTER | |
176 | return MDeclarativeCache::qApplication(argc, argv); |
|
169 | return MDeclarativeCache::qApplication(argc, argv); | |
177 | #else |
|
170 | #else | |
178 | return new QApplication(argc, argv); |
|
171 | return new QApplication(argc, argv); | |
179 | #endif |
|
172 | #endif | |
180 | } |
|
173 | } |
@@ -1,50 +1,46 | |||||
1 | // checksum 0x734b version 0x70013 |
|
1 | // checksum 0x734b version 0x70013 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | class QmlApplicationViewerPrivate *d; |
|
41 | class QmlApplicationViewerPrivate *d; | |
46 | }; |
|
42 | }; | |
47 |
|
43 | |||
48 | QApplication *createApplication(int &argc, char **argv); |
|
44 | QApplication *createApplication(int &argc, char **argv); | |
49 |
|
45 | |||
50 | #endif // QMLAPPLICATIONVIEWER_H |
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,152 +1,148 | |||||
1 | # checksum 0x5b42 version 0x70013 |
|
1 | # checksum 0x5b42 version 0x70013 | |
2 | # This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
2 | # This file was generated by the Qt Quick Application wizard of Qt Creator. | |
3 | # The code below adds the QmlApplicationViewer to the project and handles the |
|
3 | # The code below adds the QmlApplicationViewer to the project and handles the | |
4 | # activation of QML debugging. |
|
4 | # activation of QML debugging. | |
5 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
5 | # It is recommended not to modify this file, since newer versions of Qt Creator | |
6 | # may offer an updated version of it. |
|
6 | # may offer an updated version of it. | |
7 |
|
7 | |||
8 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
8 | QT += declarative | |
9 | QT += quick1 |
|
|||
10 | } else { |
|
|||
11 | QT += declarative |
|
|||
12 | } |
|
|||
13 |
|
9 | |||
14 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
10 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
15 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
11 | HEADERS += $$PWD/qmlapplicationviewer.h | |
16 | INCLUDEPATH += $$PWD |
|
12 | INCLUDEPATH += $$PWD | |
17 |
|
13 | |||
18 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
14 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
19 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
15 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
20 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
16 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
21 | } else { |
|
17 | } else { | |
22 | DEFINES -= QMLJSDEBUGGER |
|
18 | DEFINES -= QMLJSDEBUGGER | |
23 | } |
|
19 | } | |
24 |
|
20 | |||
25 | contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { |
|
21 | contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { | |
26 | DEFINES += HARMATTAN_BOOSTER |
|
22 | DEFINES += HARMATTAN_BOOSTER | |
27 | } |
|
23 | } | |
28 | # This file was generated by an application wizard of Qt Creator. |
|
24 | # This file was generated by an application wizard of Qt Creator. | |
29 | # The code below handles deployment to Symbian and Maemo, aswell as copying |
|
25 | # The code below handles deployment to Symbian and Maemo, aswell as copying | |
30 | # of the application data to shadow build directories on desktop. |
|
26 | # of the application data to shadow build directories on desktop. | |
31 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
27 | # It is recommended not to modify this file, since newer versions of Qt Creator | |
32 | # may offer an updated version of it. |
|
28 | # may offer an updated version of it. | |
33 |
|
29 | |||
34 | defineTest(qtcAddDeployment) { |
|
30 | defineTest(qtcAddDeployment) { | |
35 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
31 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
36 | item = item$${deploymentfolder} |
|
32 | item = item$${deploymentfolder} | |
37 | itemsources = $${item}.sources |
|
33 | itemsources = $${item}.sources | |
38 | $$itemsources = $$eval($${deploymentfolder}.source) |
|
34 | $$itemsources = $$eval($${deploymentfolder}.source) | |
39 | itempath = $${item}.path |
|
35 | itempath = $${item}.path | |
40 | $$itempath= $$eval($${deploymentfolder}.target) |
|
36 | $$itempath= $$eval($${deploymentfolder}.target) | |
41 | export($$itemsources) |
|
37 | export($$itemsources) | |
42 | export($$itempath) |
|
38 | export($$itempath) | |
43 | DEPLOYMENT += $$item |
|
39 | DEPLOYMENT += $$item | |
44 | } |
|
40 | } | |
45 |
|
41 | |||
46 | MAINPROFILEPWD = $$PWD |
|
42 | MAINPROFILEPWD = $$PWD | |
47 |
|
43 | |||
48 | symbian { |
|
44 | symbian { | |
49 | isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg |
|
45 | isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg | |
50 | isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 |
|
46 | isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 | |
51 | } else:win32 { |
|
47 | } else:win32 { | |
52 | copyCommand = |
|
48 | copyCommand = | |
53 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
49 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
54 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
50 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) | |
55 | source = $$replace(source, /, \\) |
|
51 | source = $$replace(source, /, \\) | |
56 | sourcePathSegments = $$split(source, \\) |
|
52 | sourcePathSegments = $$split(source, \\) | |
57 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) |
|
53 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) | |
58 | target = $$replace(target, /, \\) |
|
54 | target = $$replace(target, /, \\) | |
59 | target ~= s,\\\\\\.?\\\\,\\, |
|
55 | target ~= s,\\\\\\.?\\\\,\\, | |
60 | !isEqual(source,$$target) { |
|
56 | !isEqual(source,$$target) { | |
61 | !isEmpty(copyCommand):copyCommand += && |
|
57 | !isEmpty(copyCommand):copyCommand += && | |
62 | isEqual(QMAKE_DIR_SEP, \\) { |
|
58 | isEqual(QMAKE_DIR_SEP, \\) { | |
63 | copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" |
|
59 | copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" | |
64 | } else { |
|
60 | } else { | |
65 | source = $$replace(source, \\\\, /) |
|
61 | source = $$replace(source, \\\\, /) | |
66 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
62 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) | |
67 | target = $$replace(target, \\\\, /) |
|
63 | target = $$replace(target, \\\\, /) | |
68 | copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" |
|
64 | copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" | |
69 | } |
|
65 | } | |
70 | } |
|
66 | } | |
71 | } |
|
67 | } | |
72 | !isEmpty(copyCommand) { |
|
68 | !isEmpty(copyCommand) { | |
73 | copyCommand = @echo Copying application data... && $$copyCommand |
|
69 | copyCommand = @echo Copying application data... && $$copyCommand | |
74 | copydeploymentfolders.commands = $$copyCommand |
|
70 | copydeploymentfolders.commands = $$copyCommand | |
75 | first.depends = $(first) copydeploymentfolders |
|
71 | first.depends = $(first) copydeploymentfolders | |
76 | export(first.depends) |
|
72 | export(first.depends) | |
77 | export(copydeploymentfolders.commands) |
|
73 | export(copydeploymentfolders.commands) | |
78 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
74 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders | |
79 | } |
|
75 | } | |
80 | } else:unix { |
|
76 | } else:unix { | |
81 | maemo5 { |
|
77 | maemo5 { | |
82 | desktopfile.files = $${TARGET}.desktop |
|
78 | desktopfile.files = $${TARGET}.desktop | |
83 | desktopfile.path = /usr/share/applications/hildon |
|
79 | desktopfile.path = /usr/share/applications/hildon | |
84 | icon.files = $${TARGET}64.png |
|
80 | icon.files = $${TARGET}64.png | |
85 | icon.path = /usr/share/icons/hicolor/64x64/apps |
|
81 | icon.path = /usr/share/icons/hicolor/64x64/apps | |
86 | } else:!isEmpty(MEEGO_VERSION_MAJOR) { |
|
82 | } else:!isEmpty(MEEGO_VERSION_MAJOR) { | |
87 | desktopfile.files = $${TARGET}_harmattan.desktop |
|
83 | desktopfile.files = $${TARGET}_harmattan.desktop | |
88 | desktopfile.path = /usr/share/applications |
|
84 | desktopfile.path = /usr/share/applications | |
89 | icon.files = $${TARGET}80.png |
|
85 | icon.files = $${TARGET}80.png | |
90 | icon.path = /usr/share/icons/hicolor/80x80/apps |
|
86 | icon.path = /usr/share/icons/hicolor/80x80/apps | |
91 | } else { # Assumed to be a Desktop Unix |
|
87 | } else { # Assumed to be a Desktop Unix | |
92 | copyCommand = |
|
88 | copyCommand = | |
93 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
89 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
94 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
90 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) | |
95 | source = $$replace(source, \\\\, /) |
|
91 | source = $$replace(source, \\\\, /) | |
96 | macx { |
|
92 | macx { | |
97 | target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) |
|
93 | target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) | |
98 | } else { |
|
94 | } else { | |
99 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
95 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) | |
100 | } |
|
96 | } | |
101 | target = $$replace(target, \\\\, /) |
|
97 | target = $$replace(target, \\\\, /) | |
102 | sourcePathSegments = $$split(source, /) |
|
98 | sourcePathSegments = $$split(source, /) | |
103 | targetFullPath = $$target/$$last(sourcePathSegments) |
|
99 | targetFullPath = $$target/$$last(sourcePathSegments) | |
104 | targetFullPath ~= s,/\\.?/,/, |
|
100 | targetFullPath ~= s,/\\.?/,/, | |
105 | !isEqual(source,$$targetFullPath) { |
|
101 | !isEqual(source,$$targetFullPath) { | |
106 | !isEmpty(copyCommand):copyCommand += && |
|
102 | !isEmpty(copyCommand):copyCommand += && | |
107 | copyCommand += $(MKDIR) \"$$target\" |
|
103 | copyCommand += $(MKDIR) \"$$target\" | |
108 | copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" |
|
104 | copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" | |
109 | } |
|
105 | } | |
110 | } |
|
106 | } | |
111 | !isEmpty(copyCommand) { |
|
107 | !isEmpty(copyCommand) { | |
112 | copyCommand = @echo Copying application data... && $$copyCommand |
|
108 | copyCommand = @echo Copying application data... && $$copyCommand | |
113 | copydeploymentfolders.commands = $$copyCommand |
|
109 | copydeploymentfolders.commands = $$copyCommand | |
114 | first.depends = $(first) copydeploymentfolders |
|
110 | first.depends = $(first) copydeploymentfolders | |
115 | export(first.depends) |
|
111 | export(first.depends) | |
116 | export(copydeploymentfolders.commands) |
|
112 | export(copydeploymentfolders.commands) | |
117 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
113 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders | |
118 | } |
|
114 | } | |
119 | } |
|
115 | } | |
120 | installPrefix = /opt/$${TARGET} |
|
116 | installPrefix = /opt/$${TARGET} | |
121 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
117 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
122 | item = item$${deploymentfolder} |
|
118 | item = item$${deploymentfolder} | |
123 | itemfiles = $${item}.files |
|
119 | itemfiles = $${item}.files | |
124 | $$itemfiles = $$eval($${deploymentfolder}.source) |
|
120 | $$itemfiles = $$eval($${deploymentfolder}.source) | |
125 | itempath = $${item}.path |
|
121 | itempath = $${item}.path | |
126 | $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) |
|
122 | $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) | |
127 | export($$itemfiles) |
|
123 | export($$itemfiles) | |
128 | export($$itempath) |
|
124 | export($$itempath) | |
129 | INSTALLS += $$item |
|
125 | INSTALLS += $$item | |
130 | } |
|
126 | } | |
131 |
|
127 | |||
132 | !isEmpty(desktopfile.path) { |
|
128 | !isEmpty(desktopfile.path) { | |
133 | export(icon.files) |
|
129 | export(icon.files) | |
134 | export(icon.path) |
|
130 | export(icon.path) | |
135 | export(desktopfile.files) |
|
131 | export(desktopfile.files) | |
136 | export(desktopfile.path) |
|
132 | export(desktopfile.path) | |
137 | INSTALLS += icon desktopfile |
|
133 | INSTALLS += icon desktopfile | |
138 | } |
|
134 | } | |
139 |
|
135 | |||
140 | target.path = $${installPrefix}/bin |
|
136 | target.path = $${installPrefix}/bin | |
141 | export(target.path) |
|
137 | export(target.path) | |
142 | INSTALLS += target |
|
138 | INSTALLS += target | |
143 | } |
|
139 | } | |
144 |
|
140 | |||
145 | export (ICON) |
|
141 | export (ICON) | |
146 | export (INSTALLS) |
|
142 | export (INSTALLS) | |
147 | export (DEPLOYMENT) |
|
143 | export (DEPLOYMENT) | |
148 | export (TARGET.EPOCHEAPSIZE) |
|
144 | export (TARGET.EPOCHEAPSIZE) | |
149 | export (TARGET.CAPABILITY) |
|
145 | export (TARGET.CAPABILITY) | |
150 | export (LIBS) |
|
146 | export (LIBS) | |
151 | export (QMAKE_EXTRA_TARGETS) |
|
147 | export (QMAKE_EXTRA_TARGETS) | |
152 | } |
|
148 | } |
@@ -1,43 +1,39 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeContext> | |
23 | #include <QtQuick1/QDeclarativeContext> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
26 | #endif |
|
|||
27 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
28 | #include "datasource.h" |
|
24 | #include "datasource.h" | |
29 |
|
25 | |||
30 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
31 | { |
|
27 | { | |
32 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
33 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
34 |
|
30 | |||
35 | DataSource dataSource(viewer.data()); |
|
31 | DataSource dataSource(viewer.data()); | |
36 | viewer->rootContext()->setContextProperty("dataSource", &dataSource); |
|
32 | viewer->rootContext()->setContextProperty("dataSource", &dataSource); | |
37 |
|
33 | |||
38 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
34 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
39 | viewer->setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); |
|
35 | viewer->setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); | |
40 | viewer->showExpanded(); |
|
36 | viewer->showExpanded(); | |
41 |
|
37 | |||
42 | return app->exec(); |
|
38 | return app->exec(); | |
43 | } |
|
39 | } |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,48 +1,44 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeContext> | |
23 | #include <QtQuick1/QDeclarativeContext> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
26 | #endif |
|
|||
27 | #include <QDebug> |
|
23 | #include <QDebug> | |
28 | #include "qmlapplicationviewer.h" |
|
24 | #include "qmlapplicationviewer.h" | |
29 |
|
25 | |||
30 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
31 | { |
|
27 | { | |
32 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
33 |
|
29 | |||
34 | QmlApplicationViewer viewer; |
|
30 | QmlApplicationViewer viewer; | |
35 | // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
36 | QString appKey; |
|
32 | QString appKey; | |
37 | if (argc > 1) { |
|
33 | if (argc > 1) { | |
38 | appKey = argv[1]; |
|
34 | appKey = argv[1]; | |
39 | qDebug() << "App key for worldweatheronline.com:" << appKey; |
|
35 | qDebug() << "App key for worldweatheronline.com:" << appKey; | |
40 | } else { |
|
36 | } else { | |
41 | qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data."; |
|
37 | qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data."; | |
42 | } |
|
38 | } | |
43 | viewer.rootContext()->setContextProperty("weatherAppKey", appKey); |
|
39 | viewer.rootContext()->setContextProperty("weatherAppKey", appKey); | |
44 | viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml")); |
|
40 | viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml")); | |
45 | viewer.setRenderHint(QPainter::Antialiasing, true); |
|
41 | viewer.setRenderHint(QPainter::Antialiasing, true); | |
46 | viewer.showExpanded(); |
|
42 | viewer.showExpanded(); | |
47 | return app->exec(); |
|
43 | return app->exec(); | |
48 | } |
|
44 | } |
@@ -1,180 +1,174 | |||||
1 | // checksum 0x3fbf version 0x70013 |
|
1 | // checksum 0x3fbf version 0x70013 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
60 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
61 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
62 | }; |
|
56 | }; | |
63 |
|
57 | |||
64 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
65 | { |
|
59 | { | |
66 | #ifdef Q_OS_UNIX |
|
60 | #ifdef Q_OS_UNIX | |
67 | #ifdef Q_OS_MAC |
|
61 | #ifdef Q_OS_MAC | |
68 | if (!QDir::isAbsolutePath(path)) |
|
62 | if (!QDir::isAbsolutePath(path)) | |
69 | return QString::fromLatin1("%1/../Resources/%2") |
|
63 | return QString::fromLatin1("%1/../Resources/%2") | |
70 | .arg(QCoreApplication::applicationDirPath(), path); |
|
64 | .arg(QCoreApplication::applicationDirPath(), path); | |
71 | #else |
|
65 | #else | |
72 | const QString pathInInstallDir = |
|
66 | const QString pathInInstallDir = | |
73 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
67 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
68 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
69 | return pathInInstallDir; | |
76 | #endif |
|
70 | #endif | |
77 | #endif |
|
71 | #endif | |
78 | return path; |
|
72 | return path; | |
79 | } |
|
73 | } | |
80 |
|
74 | |||
81 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
75 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
82 | : QDeclarativeView(parent) |
|
76 | : QDeclarativeView(parent) | |
83 | , d(new QmlApplicationViewerPrivate()) |
|
77 | , d(new QmlApplicationViewerPrivate()) | |
84 | { |
|
78 | { | |
85 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
79 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
86 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
80 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
81 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
82 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
83 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
84 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
85 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
86 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
87 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
88 | #endif | |
95 | #endif |
|
89 | #endif | |
96 | } |
|
90 | } | |
97 |
|
91 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
92 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
93 | { | |
100 | delete d; |
|
94 | delete d; | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
97 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
98 | { | |
105 | return new QmlApplicationViewer(); |
|
99 | return new QmlApplicationViewer(); | |
106 | } |
|
100 | } | |
107 |
|
101 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
102 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
103 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
104 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
105 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
112 | } |
|
106 | } | |
113 |
|
107 | |||
114 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
108 | void QmlApplicationViewer::addImportPath(const QString &path) | |
115 | { |
|
109 | { | |
116 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
110 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
117 | } |
|
111 | } | |
118 |
|
112 | |||
119 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
113 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
120 | //{ |
|
114 | //{ | |
121 | //#if defined(Q_OS_SYMBIAN) |
|
115 | //#if defined(Q_OS_SYMBIAN) | |
122 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
116 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
123 | // if (orientation != ScreenOrientationAuto) { |
|
117 | // if (orientation != ScreenOrientationAuto) { | |
124 | // const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); |
|
118 | // const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); | |
125 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
119 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
126 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
120 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
127 | // return; |
|
121 | // return; | |
128 | // } |
|
122 | // } | |
129 | // } |
|
123 | // } | |
130 | //#endif // Q_OS_SYMBIAN |
|
124 | //#endif // Q_OS_SYMBIAN | |
131 |
|
125 | |||
132 | // Qt::WidgetAttribute attribute; |
|
126 | // Qt::WidgetAttribute attribute; | |
133 | // switch (orientation) { |
|
127 | // switch (orientation) { | |
134 | //#if QT_VERSION < 0x040702 |
|
128 | //#if QT_VERSION < 0x040702 | |
135 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
136 | // case ScreenOrientationLockPortrait: |
|
130 | // case ScreenOrientationLockPortrait: | |
137 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
138 | // break; |
|
132 | // break; | |
139 | // case ScreenOrientationLockLandscape: |
|
133 | // case ScreenOrientationLockLandscape: | |
140 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
141 | // break; |
|
135 | // break; | |
142 | // default: |
|
136 | // default: | |
143 | // case ScreenOrientationAuto: |
|
137 | // case ScreenOrientationAuto: | |
144 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
145 | // break; |
|
139 | // break; | |
146 | //#else // QT_VERSION < 0x040702 |
|
140 | //#else // QT_VERSION < 0x040702 | |
147 | // case ScreenOrientationLockPortrait: |
|
141 | // case ScreenOrientationLockPortrait: | |
148 | // attribute = Qt::WA_LockPortraitOrientation; |
|
142 | // attribute = Qt::WA_LockPortraitOrientation; | |
149 | // break; |
|
143 | // break; | |
150 | // case ScreenOrientationLockLandscape: |
|
144 | // case ScreenOrientationLockLandscape: | |
151 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | // attribute = Qt::WA_LockLandscapeOrientation; | |
152 | // break; |
|
146 | // break; | |
153 | // default: |
|
147 | // default: | |
154 | // case ScreenOrientationAuto: |
|
148 | // case ScreenOrientationAuto: | |
155 | // attribute = Qt::WA_AutoOrientation; |
|
149 | // attribute = Qt::WA_AutoOrientation; | |
156 | // break; |
|
150 | // break; | |
157 | //#endif // QT_VERSION < 0x040702 |
|
151 | //#endif // QT_VERSION < 0x040702 | |
158 | // }; |
|
152 | // }; | |
159 | // setAttribute(attribute, true); |
|
153 | // setAttribute(attribute, true); | |
160 | //} |
|
154 | //} | |
161 |
|
155 | |||
162 | void QmlApplicationViewer::showExpanded() |
|
156 | void QmlApplicationViewer::showExpanded() | |
163 | { |
|
157 | { | |
164 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
158 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
165 | showFullScreen(); |
|
159 | showFullScreen(); | |
166 | #elif defined(Q_WS_MAEMO_5) |
|
160 | #elif defined(Q_WS_MAEMO_5) | |
167 | showMaximized(); |
|
161 | showMaximized(); | |
168 | #else |
|
162 | #else | |
169 | show(); |
|
163 | show(); | |
170 | #endif |
|
164 | #endif | |
171 | } |
|
165 | } | |
172 |
|
166 | |||
173 | QApplication *createApplication(int &argc, char **argv) |
|
167 | QApplication *createApplication(int &argc, char **argv) | |
174 | { |
|
168 | { | |
175 | #ifdef HARMATTAN_BOOSTER |
|
169 | #ifdef HARMATTAN_BOOSTER | |
176 | return MDeclarativeCache::qApplication(argc, argv); |
|
170 | return MDeclarativeCache::qApplication(argc, argv); | |
177 | #else |
|
171 | #else | |
178 | return new QApplication(argc, argv); |
|
172 | return new QApplication(argc, argv); | |
179 | #endif |
|
173 | #endif | |
180 | } |
|
174 | } |
@@ -1,152 +1,148 | |||||
1 | # checksum 0x5b42 version 0x70013 |
|
1 | # checksum 0x5b42 version 0x70013 | |
2 | # This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
2 | # This file was generated by the Qt Quick Application wizard of Qt Creator. | |
3 | # The code below adds the QmlApplicationViewer to the project and handles the |
|
3 | # The code below adds the QmlApplicationViewer to the project and handles the | |
4 | # activation of QML debugging. |
|
4 | # activation of QML debugging. | |
5 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
5 | # It is recommended not to modify this file, since newer versions of Qt Creator | |
6 | # may offer an updated version of it. |
|
6 | # may offer an updated version of it. | |
7 |
|
7 | |||
8 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
8 | QT += declarative | |
9 | QT += quick1 |
|
|||
10 | } else { |
|
|||
11 | QT += declarative |
|
|||
12 | } |
|
|||
13 |
|
9 | |||
14 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
10 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
15 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
11 | HEADERS += $$PWD/qmlapplicationviewer.h | |
16 | INCLUDEPATH += $$PWD |
|
12 | INCLUDEPATH += $$PWD | |
17 |
|
13 | |||
18 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
14 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
19 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
15 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
20 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
16 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
21 | } else { |
|
17 | } else { | |
22 | DEFINES -= QMLJSDEBUGGER |
|
18 | DEFINES -= QMLJSDEBUGGER | |
23 | } |
|
19 | } | |
24 |
|
20 | |||
25 | contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { |
|
21 | contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { | |
26 | DEFINES += HARMATTAN_BOOSTER |
|
22 | DEFINES += HARMATTAN_BOOSTER | |
27 | } |
|
23 | } | |
28 | # This file was generated by an application wizard of Qt Creator. |
|
24 | # This file was generated by an application wizard of Qt Creator. | |
29 | # The code below handles deployment to Symbian and Maemo, aswell as copying |
|
25 | # The code below handles deployment to Symbian and Maemo, aswell as copying | |
30 | # of the application data to shadow build directories on desktop. |
|
26 | # of the application data to shadow build directories on desktop. | |
31 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
27 | # It is recommended not to modify this file, since newer versions of Qt Creator | |
32 | # may offer an updated version of it. |
|
28 | # may offer an updated version of it. | |
33 |
|
29 | |||
34 | defineTest(qtcAddDeployment) { |
|
30 | defineTest(qtcAddDeployment) { | |
35 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
31 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
36 | item = item$${deploymentfolder} |
|
32 | item = item$${deploymentfolder} | |
37 | itemsources = $${item}.sources |
|
33 | itemsources = $${item}.sources | |
38 | $$itemsources = $$eval($${deploymentfolder}.source) |
|
34 | $$itemsources = $$eval($${deploymentfolder}.source) | |
39 | itempath = $${item}.path |
|
35 | itempath = $${item}.path | |
40 | $$itempath= $$eval($${deploymentfolder}.target) |
|
36 | $$itempath= $$eval($${deploymentfolder}.target) | |
41 | export($$itemsources) |
|
37 | export($$itemsources) | |
42 | export($$itempath) |
|
38 | export($$itempath) | |
43 | DEPLOYMENT += $$item |
|
39 | DEPLOYMENT += $$item | |
44 | } |
|
40 | } | |
45 |
|
41 | |||
46 | MAINPROFILEPWD = $$PWD |
|
42 | MAINPROFILEPWD = $$PWD | |
47 |
|
43 | |||
48 | symbian { |
|
44 | symbian { | |
49 | isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg |
|
45 | isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg | |
50 | isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 |
|
46 | isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 | |
51 | } else:win32 { |
|
47 | } else:win32 { | |
52 | copyCommand = |
|
48 | copyCommand = | |
53 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
49 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
54 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
50 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) | |
55 | source = $$replace(source, /, \\) |
|
51 | source = $$replace(source, /, \\) | |
56 | sourcePathSegments = $$split(source, \\) |
|
52 | sourcePathSegments = $$split(source, \\) | |
57 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) |
|
53 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) | |
58 | target = $$replace(target, /, \\) |
|
54 | target = $$replace(target, /, \\) | |
59 | target ~= s,\\\\\\.?\\\\,\\, |
|
55 | target ~= s,\\\\\\.?\\\\,\\, | |
60 | !isEqual(source,$$target) { |
|
56 | !isEqual(source,$$target) { | |
61 | !isEmpty(copyCommand):copyCommand += && |
|
57 | !isEmpty(copyCommand):copyCommand += && | |
62 | isEqual(QMAKE_DIR_SEP, \\) { |
|
58 | isEqual(QMAKE_DIR_SEP, \\) { | |
63 | copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" |
|
59 | copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" | |
64 | } else { |
|
60 | } else { | |
65 | source = $$replace(source, \\\\, /) |
|
61 | source = $$replace(source, \\\\, /) | |
66 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
62 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) | |
67 | target = $$replace(target, \\\\, /) |
|
63 | target = $$replace(target, \\\\, /) | |
68 | copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" |
|
64 | copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" | |
69 | } |
|
65 | } | |
70 | } |
|
66 | } | |
71 | } |
|
67 | } | |
72 | !isEmpty(copyCommand) { |
|
68 | !isEmpty(copyCommand) { | |
73 | copyCommand = @echo Copying application data... && $$copyCommand |
|
69 | copyCommand = @echo Copying application data... && $$copyCommand | |
74 | copydeploymentfolders.commands = $$copyCommand |
|
70 | copydeploymentfolders.commands = $$copyCommand | |
75 | first.depends = $(first) copydeploymentfolders |
|
71 | first.depends = $(first) copydeploymentfolders | |
76 | export(first.depends) |
|
72 | export(first.depends) | |
77 | export(copydeploymentfolders.commands) |
|
73 | export(copydeploymentfolders.commands) | |
78 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
74 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders | |
79 | } |
|
75 | } | |
80 | } else:unix { |
|
76 | } else:unix { | |
81 | maemo5 { |
|
77 | maemo5 { | |
82 | desktopfile.files = $${TARGET}.desktop |
|
78 | desktopfile.files = $${TARGET}.desktop | |
83 | desktopfile.path = /usr/share/applications/hildon |
|
79 | desktopfile.path = /usr/share/applications/hildon | |
84 | icon.files = $${TARGET}64.png |
|
80 | icon.files = $${TARGET}64.png | |
85 | icon.path = /usr/share/icons/hicolor/64x64/apps |
|
81 | icon.path = /usr/share/icons/hicolor/64x64/apps | |
86 | } else:!isEmpty(MEEGO_VERSION_MAJOR) { |
|
82 | } else:!isEmpty(MEEGO_VERSION_MAJOR) { | |
87 | desktopfile.files = $${TARGET}_harmattan.desktop |
|
83 | desktopfile.files = $${TARGET}_harmattan.desktop | |
88 | desktopfile.path = /usr/share/applications |
|
84 | desktopfile.path = /usr/share/applications | |
89 | icon.files = $${TARGET}80.png |
|
85 | icon.files = $${TARGET}80.png | |
90 | icon.path = /usr/share/icons/hicolor/80x80/apps |
|
86 | icon.path = /usr/share/icons/hicolor/80x80/apps | |
91 | } else { # Assumed to be a Desktop Unix |
|
87 | } else { # Assumed to be a Desktop Unix | |
92 | copyCommand = |
|
88 | copyCommand = | |
93 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
89 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
94 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
90 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) | |
95 | source = $$replace(source, \\\\, /) |
|
91 | source = $$replace(source, \\\\, /) | |
96 | macx { |
|
92 | macx { | |
97 | target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) |
|
93 | target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) | |
98 | } else { |
|
94 | } else { | |
99 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
95 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) | |
100 | } |
|
96 | } | |
101 | target = $$replace(target, \\\\, /) |
|
97 | target = $$replace(target, \\\\, /) | |
102 | sourcePathSegments = $$split(source, /) |
|
98 | sourcePathSegments = $$split(source, /) | |
103 | targetFullPath = $$target/$$last(sourcePathSegments) |
|
99 | targetFullPath = $$target/$$last(sourcePathSegments) | |
104 | targetFullPath ~= s,/\\.?/,/, |
|
100 | targetFullPath ~= s,/\\.?/,/, | |
105 | !isEqual(source,$$targetFullPath) { |
|
101 | !isEqual(source,$$targetFullPath) { | |
106 | !isEmpty(copyCommand):copyCommand += && |
|
102 | !isEmpty(copyCommand):copyCommand += && | |
107 | copyCommand += $(MKDIR) \"$$target\" |
|
103 | copyCommand += $(MKDIR) \"$$target\" | |
108 | copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" |
|
104 | copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" | |
109 | } |
|
105 | } | |
110 | } |
|
106 | } | |
111 | !isEmpty(copyCommand) { |
|
107 | !isEmpty(copyCommand) { | |
112 | copyCommand = @echo Copying application data... && $$copyCommand |
|
108 | copyCommand = @echo Copying application data... && $$copyCommand | |
113 | copydeploymentfolders.commands = $$copyCommand |
|
109 | copydeploymentfolders.commands = $$copyCommand | |
114 | first.depends = $(first) copydeploymentfolders |
|
110 | first.depends = $(first) copydeploymentfolders | |
115 | export(first.depends) |
|
111 | export(first.depends) | |
116 | export(copydeploymentfolders.commands) |
|
112 | export(copydeploymentfolders.commands) | |
117 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
113 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders | |
118 | } |
|
114 | } | |
119 | } |
|
115 | } | |
120 | installPrefix = /opt/$${TARGET} |
|
116 | installPrefix = /opt/$${TARGET} | |
121 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
117 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
122 | item = item$${deploymentfolder} |
|
118 | item = item$${deploymentfolder} | |
123 | itemfiles = $${item}.files |
|
119 | itemfiles = $${item}.files | |
124 | $$itemfiles = $$eval($${deploymentfolder}.source) |
|
120 | $$itemfiles = $$eval($${deploymentfolder}.source) | |
125 | itempath = $${item}.path |
|
121 | itempath = $${item}.path | |
126 | $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) |
|
122 | $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) | |
127 | export($$itemfiles) |
|
123 | export($$itemfiles) | |
128 | export($$itempath) |
|
124 | export($$itempath) | |
129 | INSTALLS += $$item |
|
125 | INSTALLS += $$item | |
130 | } |
|
126 | } | |
131 |
|
127 | |||
132 | !isEmpty(desktopfile.path) { |
|
128 | !isEmpty(desktopfile.path) { | |
133 | export(icon.files) |
|
129 | export(icon.files) | |
134 | export(icon.path) |
|
130 | export(icon.path) | |
135 | export(desktopfile.files) |
|
131 | export(desktopfile.files) | |
136 | export(desktopfile.path) |
|
132 | export(desktopfile.path) | |
137 | INSTALLS += icon desktopfile |
|
133 | INSTALLS += icon desktopfile | |
138 | } |
|
134 | } | |
139 |
|
135 | |||
140 | target.path = $${installPrefix}/bin |
|
136 | target.path = $${installPrefix}/bin | |
141 | export(target.path) |
|
137 | export(target.path) | |
142 | INSTALLS += target |
|
138 | INSTALLS += target | |
143 | } |
|
139 | } | |
144 |
|
140 | |||
145 | export (ICON) |
|
141 | export (ICON) | |
146 | export (INSTALLS) |
|
142 | export (INSTALLS) | |
147 | export (DEPLOYMENT) |
|
143 | export (DEPLOYMENT) | |
148 | export (TARGET.EPOCHEAPSIZE) |
|
144 | export (TARGET.EPOCHEAPSIZE) | |
149 | export (TARGET.CAPABILITY) |
|
145 | export (TARGET.CAPABILITY) | |
150 | export (LIBS) |
|
146 | export (LIBS) | |
151 | export (QMAKE_EXTRA_TARGETS) |
|
147 | export (QMAKE_EXTRA_TARGETS) | |
152 | } |
|
148 | } |
@@ -1,40 +1,36 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #ifdef QT5_QUICK_1 |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include <QtQuick1/QDeclarativeEngine> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
26 | #endif |
|
|||
27 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
28 |
|
24 | |||
29 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
30 | { |
|
26 | { | |
31 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
32 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
33 |
|
29 | |||
34 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
35 | viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); |
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); | |
36 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
32 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
37 | viewer->showExpanded(); |
|
33 | viewer->showExpanded(); | |
38 |
|
34 | |||
39 | return app->exec(); |
|
35 | return app->exec(); | |
40 | } |
|
36 | } |
@@ -1,207 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 |
|
||||
25 | #include <QApplication> |
|
18 | #include <QApplication> | |
26 |
|
19 | |||
27 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
28 |
|
21 | |||
29 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
30 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
31 | #endif |
|
24 | #endif | |
32 |
|
25 | |||
33 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
34 |
|
27 | |||
35 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
36 |
|
29 | |||
37 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
38 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
39 | #endif |
|
32 | #endif | |
40 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
41 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
42 | #endif |
|
35 | #endif | |
43 |
|
36 | |||
44 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
45 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
46 | { |
|
39 | { | |
47 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
48 | { |
|
41 | { | |
49 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
50 | } |
|
43 | } | |
51 | }; |
|
44 | }; | |
52 |
|
45 | |||
53 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
54 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
55 |
|
48 | |||
56 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
57 |
|
50 | |||
58 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
59 | { |
|
52 | { | |
60 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
61 |
|
54 | |||
62 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
63 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
64 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
65 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
66 | }; |
|
59 | }; | |
67 |
|
60 | |||
68 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
69 | { |
|
62 | { | |
70 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
71 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
72 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
73 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
74 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
75 | #else |
|
68 | #else | |
76 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
77 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
78 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
79 |
|
72 | |||
80 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
81 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
82 | #endif |
|
75 | #endif | |
83 | #endif |
|
76 | #endif | |
84 | return path; |
|
77 | return path; | |
85 | } |
|
78 | } | |
86 |
|
79 | |||
87 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
88 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
89 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
90 | { |
|
83 | { | |
91 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
92 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
93 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
94 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
95 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
96 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
97 | #endif |
|
90 | #endif | |
98 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
99 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
100 | #endif |
|
93 | #endif | |
101 | #endif |
|
94 | #endif | |
102 | } |
|
95 | } | |
103 |
|
96 | |||
104 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
105 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
106 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
107 | { |
|
100 | { | |
108 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
109 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
110 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
111 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
112 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
113 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
114 | #endif |
|
107 | #endif | |
115 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
116 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
117 | #endif |
|
110 | #endif | |
118 | #endif |
|
111 | #endif | |
119 | } |
|
112 | } | |
120 |
|
113 | |||
121 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
122 | { |
|
115 | { | |
123 | delete d; |
|
116 | delete d; | |
124 | } |
|
117 | } | |
125 |
|
118 | |||
126 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
127 | { |
|
120 | { | |
128 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
129 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
130 | #else |
|
123 | #else | |
131 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
132 | #endif |
|
125 | #endif | |
133 | } |
|
126 | } | |
134 |
|
127 | |||
135 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
136 | { |
|
129 | { | |
137 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
138 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
139 | } |
|
132 | } | |
140 |
|
133 | |||
141 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
142 | { |
|
135 | { | |
143 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
144 | } |
|
137 | } | |
145 |
|
138 | |||
146 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
147 | //{ |
|
140 | //{ | |
148 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
149 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
150 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
151 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
152 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
153 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
154 | // return; |
|
147 | // return; | |
155 | // } |
|
148 | // } | |
156 | // } |
|
149 | // } | |
157 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
158 |
|
151 | |||
159 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
160 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
161 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
162 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
163 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
164 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
165 | // break; |
|
158 | // break; | |
166 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
167 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
168 | // break; |
|
161 | // break; | |
169 | // default: |
|
162 | // default: | |
170 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
171 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
172 | // break; |
|
165 | // break; | |
173 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
174 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
175 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
176 | // break; |
|
169 | // break; | |
177 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
178 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
179 | // break; |
|
172 | // break; | |
180 | // default: |
|
173 | // default: | |
181 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
182 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
183 | // break; |
|
176 | // break; | |
184 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
185 | // }; |
|
178 | // }; | |
186 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
187 | //} |
|
180 | //} | |
188 |
|
181 | |||
189 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
190 | { |
|
183 | { | |
191 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
192 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
193 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
194 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
195 | #else |
|
188 | #else | |
196 | d->view->show(); |
|
189 | d->view->show(); | |
197 | #endif |
|
190 | #endif | |
198 | } |
|
191 | } | |
199 |
|
192 | |||
200 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
201 | { |
|
194 | { | |
202 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
203 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
204 | #else |
|
197 | #else | |
205 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
206 | #endif |
|
199 | #endif | |
207 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,54 +1,50 | |||||
1 | !include( ../plugins.pri ) { |
|
1 | !include( ../plugins.pri ) { | |
2 | error( "Couldn't find the plugins.pri file!" ) |
|
2 | error( "Couldn't find the plugins.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | TARGET = qtcommercialchartqml |
|
5 | TARGET = qtcommercialchartqml | |
6 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
6 | QT += declarative | |
7 | QT += quick1 |
|
|||
8 | } else { |
|
|||
9 | QT += declarative |
|
|||
10 | } |
|
|||
11 | DESTDIR = $$CHART_BUILD_QML_PLUGIN_DIR |
|
7 | DESTDIR = $$CHART_BUILD_QML_PLUGIN_DIR | |
12 | INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR |
|
8 | INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR | |
13 |
|
9 | |||
14 | CONFIG(debug, debug|release) { |
|
10 | CONFIG(debug, debug|release) { | |
15 | mac: TARGET = $$join(TARGET,,,_debug) |
|
11 | mac: TARGET = $$join(TARGET,,,_debug) | |
16 | win32: TARGET = $$join(TARGET,,,d) |
|
12 | win32: TARGET = $$join(TARGET,,,d) | |
17 | } |
|
13 | } | |
18 |
|
14 | |||
19 | SOURCES += \ |
|
15 | SOURCES += \ | |
20 | plugin.cpp \ |
|
16 | plugin.cpp \ | |
21 | declarativechart.cpp \ |
|
17 | declarativechart.cpp \ | |
22 | declarativexypoint.cpp \ |
|
18 | declarativexypoint.cpp \ | |
23 | declarativexyseries.cpp \ |
|
19 | declarativexyseries.cpp \ | |
24 | declarativelineseries.cpp \ |
|
20 | declarativelineseries.cpp \ | |
25 | declarativesplineseries.cpp \ |
|
21 | declarativesplineseries.cpp \ | |
26 | declarativeareaseries.cpp \ |
|
22 | declarativeareaseries.cpp \ | |
27 | declarativescatterseries.cpp \ |
|
23 | declarativescatterseries.cpp \ | |
28 | declarativepieseries.cpp \ |
|
24 | declarativepieseries.cpp \ | |
29 | declarativebarseries.cpp \ |
|
25 | declarativebarseries.cpp \ | |
30 | declarativecategoryaxis.cpp \ |
|
26 | declarativecategoryaxis.cpp \ | |
31 | declarativemargins.cpp |
|
27 | declarativemargins.cpp | |
32 |
|
28 | |||
33 | HEADERS += \ |
|
29 | HEADERS += \ | |
34 | declarativechart.h \ |
|
30 | declarativechart.h \ | |
35 | declarativexypoint.h \ |
|
31 | declarativexypoint.h \ | |
36 | declarativexyseries.h \ |
|
32 | declarativexyseries.h \ | |
37 | declarativelineseries.h \ |
|
33 | declarativelineseries.h \ | |
38 | declarativesplineseries.h \ |
|
34 | declarativesplineseries.h \ | |
39 | declarativeareaseries.h \ |
|
35 | declarativeareaseries.h \ | |
40 | declarativescatterseries.h \ |
|
36 | declarativescatterseries.h \ | |
41 | declarativepieseries.h \ |
|
37 | declarativepieseries.h \ | |
42 | declarativebarseries.h \ |
|
38 | declarativebarseries.h \ | |
43 | declarativecategoryaxis.h \ |
|
39 | declarativecategoryaxis.h \ | |
44 | declarativemargins.h |
|
40 | declarativemargins.h | |
45 |
|
41 | |||
46 | TARGETPATH = QtCommercial/Chart |
|
42 | TARGETPATH = QtCommercial/Chart | |
47 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
43 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
48 | qmldir.files += $$PWD/qmldir |
|
44 | qmldir.files += $$PWD/qmldir | |
49 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
45 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
50 | INSTALLS += target qmldir |
|
46 | INSTALLS += target qmldir | |
51 |
|
47 | |||
52 | FILE = $$PWD/qmldir |
|
48 | FILE = $$PWD/qmldir | |
53 | win32:{FILE = $$replace(FILE, "/","\\")} |
|
49 | win32:{FILE = $$replace(FILE, "/","\\")} | |
54 | QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_QML_PLUGIN_DIR |
|
50 | QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_QML_PLUGIN_DIR |
@@ -1,313 +1,308 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEBARSERIES_H |
|
21 | #ifndef DECLARATIVEBARSERIES_H | |
22 | #define DECLARATIVEBARSERIES_H |
|
22 | #define DECLARATIVEBARSERIES_H | |
23 |
|
23 | |||
24 | #include "qbarseries.h" |
|
24 | #include "qbarseries.h" | |
25 | #include "qstackedbarseries.h" |
|
25 | #include "qstackedbarseries.h" | |
26 | #include "qpercentbarseries.h" |
|
26 | #include "qpercentbarseries.h" | |
27 | #include "qhorizontalbarseries.h" |
|
27 | #include "qhorizontalbarseries.h" | |
28 | #include "qhorizontalstackedbarseries.h" |
|
28 | #include "qhorizontalstackedbarseries.h" | |
29 | #include "qhorizontalpercentbarseries.h" |
|
29 | #include "qhorizontalpercentbarseries.h" | |
30 | #include "qbarset.h" |
|
30 | #include "qbarset.h" | |
31 | #ifdef QT5_QUICK_1 |
|
31 | #include <QtDeclarative/QDeclarativeItem> | |
32 |
|
|
32 | #include <QtDeclarative/QDeclarativeParserStatus> | |
33 | #include <QtQuick1/QDeclarativeParserStatus> |
|
|||
34 | #else |
|
|||
35 | #include <QtDeclarative/QDeclarativeItem> |
|
|||
36 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
|||
37 | #endif |
|
|||
38 |
|
33 | |||
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
40 |
|
35 | |||
41 | class QChart; |
|
36 | class QChart; | |
42 |
|
37 | |||
43 | class DeclarativeBarSet : public QBarSet |
|
38 | class DeclarativeBarSet : public QBarSet | |
44 | { |
|
39 | { | |
45 | Q_OBJECT |
|
40 | Q_OBJECT | |
46 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
41 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
47 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
42 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
48 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
43 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
49 |
|
44 | |||
50 | public: |
|
45 | public: | |
51 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
46 | explicit DeclarativeBarSet(QObject *parent = 0); | |
52 | QVariantList values(); |
|
47 | QVariantList values(); | |
53 | void setValues(QVariantList values); |
|
48 | void setValues(QVariantList values); | |
54 | qreal borderWidth() const; |
|
49 | qreal borderWidth() const; | |
55 | void setBorderWidth(qreal borderWidth); |
|
50 | void setBorderWidth(qreal borderWidth); | |
56 |
|
51 | |||
57 | public: // From QBarSet |
|
52 | public: // From QBarSet | |
58 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
53 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
59 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } |
|
54 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } | |
60 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } |
|
55 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } | |
61 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } |
|
56 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } | |
62 |
|
57 | |||
63 | Q_SIGNALS: |
|
58 | Q_SIGNALS: | |
64 | void countChanged(int count); |
|
59 | void countChanged(int count); | |
65 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
60 | Q_REVISION(1) void borderWidthChanged(qreal width); | |
66 |
|
61 | |||
67 | private Q_SLOTS: |
|
62 | private Q_SLOTS: | |
68 | void handleCountChanged(int index, int count); |
|
63 | void handleCountChanged(int index, int count); | |
69 | }; |
|
64 | }; | |
70 |
|
65 | |||
71 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus |
|
66 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
72 | { |
|
67 | { | |
73 | Q_OBJECT |
|
68 | Q_OBJECT | |
74 | Q_INTERFACES(QDeclarativeParserStatus) |
|
69 | Q_INTERFACES(QDeclarativeParserStatus) | |
75 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
70 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
76 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
71 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
77 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
72 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
78 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
73 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
79 |
|
74 | |||
80 | public: |
|
75 | public: | |
81 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
76 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
82 | QAbstractAxis *axisX() { return m_axisX; } |
|
77 | QAbstractAxis *axisX() { return m_axisX; } | |
83 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
78 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
84 | QAbstractAxis *axisY() { return m_axisY; } |
|
79 | QAbstractAxis *axisY() { return m_axisY; } | |
85 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
80 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
86 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
81 | QDeclarativeListProperty<QObject> seriesChildren(); | |
87 |
|
82 | |||
88 | public: |
|
83 | public: | |
89 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
84 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
90 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
85 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
91 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
86 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
92 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } |
|
87 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } | |
93 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } |
|
88 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } | |
94 |
|
89 | |||
95 | public: // from QDeclarativeParserStatus |
|
90 | public: // from QDeclarativeParserStatus | |
96 | void classBegin(); |
|
91 | void classBegin(); | |
97 | void componentComplete(); |
|
92 | void componentComplete(); | |
98 |
|
93 | |||
99 | Q_SIGNALS: |
|
94 | Q_SIGNALS: | |
100 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
95 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
101 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
96 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
102 |
|
97 | |||
103 | public Q_SLOTS: |
|
98 | public Q_SLOTS: | |
104 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
99 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
105 |
|
100 | |||
106 | private: |
|
101 | private: | |
107 | QAbstractAxis *m_axisX; |
|
102 | QAbstractAxis *m_axisX; | |
108 | QAbstractAxis *m_axisY; |
|
103 | QAbstractAxis *m_axisY; | |
109 | }; |
|
104 | }; | |
110 |
|
105 | |||
111 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
106 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
112 | { |
|
107 | { | |
113 | Q_OBJECT |
|
108 | Q_OBJECT | |
114 | Q_INTERFACES(QDeclarativeParserStatus) |
|
109 | Q_INTERFACES(QDeclarativeParserStatus) | |
115 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
110 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
116 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
111 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
117 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
112 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
118 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
113 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
119 |
|
114 | |||
120 | public: |
|
115 | public: | |
121 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
116 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
122 | QAbstractAxis *axisX() { return m_axisX; } |
|
117 | QAbstractAxis *axisX() { return m_axisX; } | |
123 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
118 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
124 | QAbstractAxis *axisY() { return m_axisY; } |
|
119 | QAbstractAxis *axisY() { return m_axisY; } | |
125 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
120 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
126 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
121 | QDeclarativeListProperty<QObject> seriesChildren(); | |
127 |
|
122 | |||
128 | public: |
|
123 | public: | |
129 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
124 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
130 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
125 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
131 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
126 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
132 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } |
|
127 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } | |
133 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } |
|
128 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } | |
134 |
|
129 | |||
135 | public: // from QDeclarativeParserStatus |
|
130 | public: // from QDeclarativeParserStatus | |
136 | void classBegin(); |
|
131 | void classBegin(); | |
137 | void componentComplete(); |
|
132 | void componentComplete(); | |
138 |
|
133 | |||
139 | Q_SIGNALS: |
|
134 | Q_SIGNALS: | |
140 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
135 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
141 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
136 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
142 |
|
137 | |||
143 | public Q_SLOTS: |
|
138 | public Q_SLOTS: | |
144 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
139 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
145 |
|
140 | |||
146 | private: |
|
141 | private: | |
147 | QAbstractAxis *m_axisX; |
|
142 | QAbstractAxis *m_axisX; | |
148 | QAbstractAxis *m_axisY; |
|
143 | QAbstractAxis *m_axisY; | |
149 | }; |
|
144 | }; | |
150 |
|
145 | |||
151 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
146 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
152 | { |
|
147 | { | |
153 | Q_OBJECT |
|
148 | Q_OBJECT | |
154 | Q_INTERFACES(QDeclarativeParserStatus) |
|
149 | Q_INTERFACES(QDeclarativeParserStatus) | |
155 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
150 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
156 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
151 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
157 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
152 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
158 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
153 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
159 |
|
154 | |||
160 | public: |
|
155 | public: | |
161 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
156 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
162 | QAbstractAxis *axisX() { return m_axisX; } |
|
157 | QAbstractAxis *axisX() { return m_axisX; } | |
163 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
158 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
164 | QAbstractAxis *axisY() { return m_axisY; } |
|
159 | QAbstractAxis *axisY() { return m_axisY; } | |
165 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
160 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
166 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
161 | QDeclarativeListProperty<QObject> seriesChildren(); | |
167 |
|
162 | |||
168 | public: |
|
163 | public: | |
169 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
164 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
170 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
165 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
171 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
166 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
172 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } |
|
167 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } | |
173 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } |
|
168 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } | |
174 |
|
169 | |||
175 | public: // from QDeclarativeParserStatus |
|
170 | public: // from QDeclarativeParserStatus | |
176 | void classBegin(); |
|
171 | void classBegin(); | |
177 | void componentComplete(); |
|
172 | void componentComplete(); | |
178 |
|
173 | |||
179 | Q_SIGNALS: |
|
174 | Q_SIGNALS: | |
180 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
175 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
181 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
176 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
182 |
|
177 | |||
183 | public Q_SLOTS: |
|
178 | public Q_SLOTS: | |
184 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
179 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
185 |
|
180 | |||
186 | private: |
|
181 | private: | |
187 | QAbstractAxis *m_axisX; |
|
182 | QAbstractAxis *m_axisX; | |
188 | QAbstractAxis *m_axisY; |
|
183 | QAbstractAxis *m_axisY; | |
189 | }; |
|
184 | }; | |
190 |
|
185 | |||
191 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus |
|
186 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus | |
192 | { |
|
187 | { | |
193 | Q_OBJECT |
|
188 | Q_OBJECT | |
194 | Q_INTERFACES(QDeclarativeParserStatus) |
|
189 | Q_INTERFACES(QDeclarativeParserStatus) | |
195 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
190 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
196 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
191 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
197 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
192 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
198 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
193 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
199 |
|
194 | |||
200 | public: |
|
195 | public: | |
201 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); |
|
196 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); | |
202 | QAbstractAxis *axisX() { return m_axisX; } |
|
197 | QAbstractAxis *axisX() { return m_axisX; } | |
203 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
198 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
204 | QAbstractAxis *axisY() { return m_axisY; } |
|
199 | QAbstractAxis *axisY() { return m_axisY; } | |
205 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
200 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
206 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
201 | QDeclarativeListProperty<QObject> seriesChildren(); | |
207 |
|
202 | |||
208 | public: |
|
203 | public: | |
209 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
204 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
210 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
205 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
211 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
206 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
212 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); } |
|
207 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); } | |
213 | Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); } |
|
208 | Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); } | |
214 |
|
209 | |||
215 | public: // from QDeclarativeParserStatus |
|
210 | public: // from QDeclarativeParserStatus | |
216 | void classBegin(); |
|
211 | void classBegin(); | |
217 | void componentComplete(); |
|
212 | void componentComplete(); | |
218 |
|
213 | |||
219 | Q_SIGNALS: |
|
214 | Q_SIGNALS: | |
220 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
215 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
221 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
216 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
222 |
|
217 | |||
223 | public Q_SLOTS: |
|
218 | public Q_SLOTS: | |
224 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
219 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
225 |
|
220 | |||
226 | private: |
|
221 | private: | |
227 | QAbstractAxis *m_axisX; |
|
222 | QAbstractAxis *m_axisX; | |
228 | QAbstractAxis *m_axisY; |
|
223 | QAbstractAxis *m_axisY; | |
229 | }; |
|
224 | }; | |
230 |
|
225 | |||
231 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus |
|
226 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus | |
232 | { |
|
227 | { | |
233 | Q_OBJECT |
|
228 | Q_OBJECT | |
234 | Q_INTERFACES(QDeclarativeParserStatus) |
|
229 | Q_INTERFACES(QDeclarativeParserStatus) | |
235 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
230 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
236 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
231 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
237 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
232 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
238 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
233 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
239 |
|
234 | |||
240 | public: |
|
235 | public: | |
241 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); |
|
236 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); | |
242 | QAbstractAxis *axisX() { return m_axisX; } |
|
237 | QAbstractAxis *axisX() { return m_axisX; } | |
243 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
238 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
244 | QAbstractAxis *axisY() { return m_axisY; } |
|
239 | QAbstractAxis *axisY() { return m_axisY; } | |
245 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
240 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
246 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
241 | QDeclarativeListProperty<QObject> seriesChildren(); | |
247 |
|
242 | |||
248 | public: |
|
243 | public: | |
249 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
244 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
250 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
245 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
251 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
246 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
252 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); } |
|
247 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); } | |
253 | Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); } |
|
248 | Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); } | |
254 |
|
249 | |||
255 | public: // from QDeclarativeParserStatus |
|
250 | public: // from QDeclarativeParserStatus | |
256 | void classBegin(); |
|
251 | void classBegin(); | |
257 | void componentComplete(); |
|
252 | void componentComplete(); | |
258 |
|
253 | |||
259 | Q_SIGNALS: |
|
254 | Q_SIGNALS: | |
260 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
255 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
261 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
256 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
262 |
|
257 | |||
263 | public Q_SLOTS: |
|
258 | public Q_SLOTS: | |
264 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
259 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
265 |
|
260 | |||
266 | private: |
|
261 | private: | |
267 | QAbstractAxis *m_axisX; |
|
262 | QAbstractAxis *m_axisX; | |
268 | QAbstractAxis *m_axisY; |
|
263 | QAbstractAxis *m_axisY; | |
269 | }; |
|
264 | }; | |
270 |
|
265 | |||
271 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus |
|
266 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus | |
272 | { |
|
267 | { | |
273 | Q_OBJECT |
|
268 | Q_OBJECT | |
274 | Q_INTERFACES(QDeclarativeParserStatus) |
|
269 | Q_INTERFACES(QDeclarativeParserStatus) | |
275 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
270 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
276 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
271 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
277 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
272 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
278 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
273 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
279 |
|
274 | |||
280 | public: |
|
275 | public: | |
281 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); |
|
276 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); | |
282 | QAbstractAxis *axisX() { return m_axisX; } |
|
277 | QAbstractAxis *axisX() { return m_axisX; } | |
283 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
278 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
284 | QAbstractAxis *axisY() { return m_axisY; } |
|
279 | QAbstractAxis *axisY() { return m_axisY; } | |
285 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
280 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
286 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
281 | QDeclarativeListProperty<QObject> seriesChildren(); | |
287 |
|
282 | |||
288 | public: |
|
283 | public: | |
289 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
284 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
290 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
285 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
291 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
286 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
292 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); } |
|
287 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); } | |
293 | Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); } |
|
288 | Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); } | |
294 |
|
289 | |||
295 | public: // from QDeclarativeParserStatus |
|
290 | public: // from QDeclarativeParserStatus | |
296 | void classBegin(); |
|
291 | void classBegin(); | |
297 | void componentComplete(); |
|
292 | void componentComplete(); | |
298 |
|
293 | |||
299 | Q_SIGNALS: |
|
294 | Q_SIGNALS: | |
300 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
295 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
301 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
296 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
302 |
|
297 | |||
303 | public Q_SLOTS: |
|
298 | public Q_SLOTS: | |
304 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
299 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
305 |
|
300 | |||
306 | private: |
|
301 | private: | |
307 | QAbstractAxis *m_axisX; |
|
302 | QAbstractAxis *m_axisX; | |
308 | QAbstractAxis *m_axisY; |
|
303 | QAbstractAxis *m_axisY; | |
309 | }; |
|
304 | }; | |
310 |
|
305 | |||
311 | QTCOMMERCIALCHART_END_NAMESPACE |
|
306 | QTCOMMERCIALCHART_END_NAMESPACE | |
312 |
|
307 | |||
313 | #endif // DECLARATIVEBARSERIES_H |
|
308 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,80 +1,75 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECATEGORYAXIS_H |
|
21 | #ifndef DECLARATIVECATEGORYAXIS_H | |
22 | #define DECLARATIVECATEGORYAXIS_H |
|
22 | #define DECLARATIVECATEGORYAXIS_H | |
23 |
|
23 | |||
24 | #include "qcategoryaxis.h" |
|
24 | #include "qcategoryaxis.h" | |
25 | #ifdef QT5_QUICK_1 |
|
25 | #include <QtDeclarative/QDeclarativeListProperty> | |
26 |
|
|
26 | #include <QtDeclarative/QDeclarativeParserStatus> | |
27 | #include <QtQuick1/QDeclarativeParserStatus> |
|
|||
28 | #else |
|
|||
29 | #include <QtDeclarative/QDeclarativeListProperty> |
|
|||
30 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
|||
31 | #endif |
|
|||
32 |
|
27 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
29 | |||
35 | class DeclarativeCategoryRange : public QObject |
|
30 | class DeclarativeCategoryRange : public QObject | |
36 | { |
|
31 | { | |
37 | Q_OBJECT |
|
32 | Q_OBJECT | |
38 | Q_PROPERTY(qreal endValue READ endValue WRITE setEndValue) |
|
33 | Q_PROPERTY(qreal endValue READ endValue WRITE setEndValue) | |
39 | Q_PROPERTY(QString label READ label WRITE setLabel) |
|
34 | Q_PROPERTY(QString label READ label WRITE setLabel) | |
40 |
|
35 | |||
41 | public: |
|
36 | public: | |
42 | explicit DeclarativeCategoryRange(QObject *parent = 0); |
|
37 | explicit DeclarativeCategoryRange(QObject *parent = 0); | |
43 | qreal endValue() { return m_endValue; } |
|
38 | qreal endValue() { return m_endValue; } | |
44 | void setEndValue(qreal endValue) { m_endValue = endValue; } |
|
39 | void setEndValue(qreal endValue) { m_endValue = endValue; } | |
45 | QString label() { return m_label; } |
|
40 | QString label() { return m_label; } | |
46 | void setLabel(QString label) { m_label = label; } |
|
41 | void setLabel(QString label) { m_label = label; } | |
47 |
|
42 | |||
48 | private: |
|
43 | private: | |
49 | qreal m_endValue; |
|
44 | qreal m_endValue; | |
50 | QString m_label; |
|
45 | QString m_label; | |
51 | }; |
|
46 | }; | |
52 |
|
47 | |||
53 | class DeclarativeCategoryAxis : public QCategoryAxis, public QDeclarativeParserStatus |
|
48 | class DeclarativeCategoryAxis : public QCategoryAxis, public QDeclarativeParserStatus | |
54 | { |
|
49 | { | |
55 | Q_OBJECT |
|
50 | Q_OBJECT | |
56 | Q_INTERFACES(QDeclarativeParserStatus) |
|
51 | Q_INTERFACES(QDeclarativeParserStatus) | |
57 | Q_PROPERTY(QDeclarativeListProperty<QObject> axisChildren READ axisChildren) |
|
52 | Q_PROPERTY(QDeclarativeListProperty<QObject> axisChildren READ axisChildren) | |
58 | Q_CLASSINFO("DefaultProperty", "axisChildren") |
|
53 | Q_CLASSINFO("DefaultProperty", "axisChildren") | |
59 |
|
54 | |||
60 | public: |
|
55 | public: | |
61 | explicit DeclarativeCategoryAxis(QObject *parent = 0); |
|
56 | explicit DeclarativeCategoryAxis(QObject *parent = 0); | |
62 | QDeclarativeListProperty<QObject> axisChildren(); |
|
57 | QDeclarativeListProperty<QObject> axisChildren(); | |
63 |
|
58 | |||
64 | public: // from QDeclarativeParserStatus |
|
59 | public: // from QDeclarativeParserStatus | |
65 | void classBegin(); |
|
60 | void classBegin(); | |
66 | void componentComplete(); |
|
61 | void componentComplete(); | |
67 |
|
62 | |||
68 | public Q_SLOTS: |
|
63 | public Q_SLOTS: | |
69 | Q_INVOKABLE void append(const QString &label, qreal categoryEndValue); |
|
64 | Q_INVOKABLE void append(const QString &label, qreal categoryEndValue); | |
70 | Q_INVOKABLE void remove(const QString &label); |
|
65 | Q_INVOKABLE void remove(const QString &label); | |
71 | Q_INVOKABLE void replace(const QString &oldLabel, const QString &newLabel); |
|
66 | Q_INVOKABLE void replace(const QString &oldLabel, const QString &newLabel); | |
72 | static void appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
67 | static void appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
73 |
|
68 | |||
74 | private: |
|
69 | private: | |
75 | static bool endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2); |
|
70 | static bool endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2); | |
76 | }; |
|
71 | }; | |
77 |
|
72 | |||
78 | QTCOMMERCIALCHART_END_NAMESPACE |
|
73 | QTCOMMERCIALCHART_END_NAMESPACE | |
79 |
|
74 | |||
80 | #endif // DECLARATIVECATEGORYAXIS_H |
|
75 | #endif // DECLARATIVECATEGORYAXIS_H |
@@ -1,175 +1,172 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #ifdef QT5_QUICK_1 |
|
25 | #include <QtDeclarative/QDeclarativeItem> | |
26 | #include <QtQuick1/QDeclarativeItem> |
|
26 | ||
27 | #else |
|
|||
28 | #include <QtDeclarative/QDeclarativeItem> |
|
|||
29 | #endif |
|
|||
30 | #include "qchart.h" |
|
27 | #include "qchart.h" | |
31 |
|
28 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
30 | |||
34 | class DeclarativeMargins; |
|
31 | class DeclarativeMargins; | |
35 | class Domain; |
|
32 | class Domain; | |
36 |
|
33 | |||
37 | class DeclarativeChart : public QDeclarativeItem |
|
34 | class DeclarativeChart : public QDeclarativeItem | |
38 | { |
|
35 | { | |
39 | Q_OBJECT |
|
36 | Q_OBJECT | |
40 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
37 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
41 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
38 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
42 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
39 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
43 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
40 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
44 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
41 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
45 | Q_PROPERTY(QLegend *legend READ legend) |
|
42 | Q_PROPERTY(QLegend *legend READ legend) | |
46 | Q_PROPERTY(int count READ count) |
|
43 | Q_PROPERTY(int count READ count) | |
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
44 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
45 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
49 | Q_PROPERTY(qreal topMargin READ topMargin) |
|
46 | Q_PROPERTY(qreal topMargin READ topMargin) | |
50 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) |
|
47 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) | |
51 | Q_PROPERTY(qreal leftMargin READ leftMargin) |
|
48 | Q_PROPERTY(qreal leftMargin READ leftMargin) | |
52 | Q_PROPERTY(qreal rightMargin READ rightMargin) |
|
49 | Q_PROPERTY(qreal rightMargin READ rightMargin) | |
53 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) |
|
50 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) | |
54 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) |
|
51 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) | |
55 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
52 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) | |
56 | Q_ENUMS(Animation) |
|
53 | Q_ENUMS(Animation) | |
57 | Q_ENUMS(Theme) |
|
54 | Q_ENUMS(Theme) | |
58 | Q_ENUMS(SeriesType) |
|
55 | Q_ENUMS(SeriesType) | |
59 |
|
56 | |||
60 | public: |
|
57 | public: | |
61 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
58 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
62 | enum Theme { |
|
59 | enum Theme { | |
63 | ChartThemeLight = 0, |
|
60 | ChartThemeLight = 0, | |
64 | ChartThemeBlueCerulean, |
|
61 | ChartThemeBlueCerulean, | |
65 | ChartThemeDark, |
|
62 | ChartThemeDark, | |
66 | ChartThemeBrownSand, |
|
63 | ChartThemeBrownSand, | |
67 | ChartThemeBlueNcs, |
|
64 | ChartThemeBlueNcs, | |
68 | ChartThemeHighContrast, |
|
65 | ChartThemeHighContrast, | |
69 | ChartThemeBlueIcy |
|
66 | ChartThemeBlueIcy | |
70 | }; |
|
67 | }; | |
71 |
|
68 | |||
72 | enum Animation { |
|
69 | enum Animation { | |
73 | NoAnimation = 0x0, |
|
70 | NoAnimation = 0x0, | |
74 | GridAxisAnimations = 0x1, |
|
71 | GridAxisAnimations = 0x1, | |
75 | SeriesAnimations = 0x2, |
|
72 | SeriesAnimations = 0x2, | |
76 | AllAnimations = 0x3 |
|
73 | AllAnimations = 0x3 | |
77 | }; |
|
74 | }; | |
78 |
|
75 | |||
79 | enum SeriesType { |
|
76 | enum SeriesType { | |
80 | SeriesTypeLine, |
|
77 | SeriesTypeLine, | |
81 | SeriesTypeArea, |
|
78 | SeriesTypeArea, | |
82 | SeriesTypeBar, |
|
79 | SeriesTypeBar, | |
83 | SeriesTypeStackedBar, |
|
80 | SeriesTypeStackedBar, | |
84 | SeriesTypePercentBar, |
|
81 | SeriesTypePercentBar, | |
85 | SeriesTypePie, |
|
82 | SeriesTypePie, | |
86 | SeriesTypeScatter, |
|
83 | SeriesTypeScatter, | |
87 | SeriesTypeSpline, |
|
84 | SeriesTypeSpline, | |
88 | SeriesTypeHorizontalBar, |
|
85 | SeriesTypeHorizontalBar, | |
89 | SeriesTypeHorizontalStackedBar, |
|
86 | SeriesTypeHorizontalStackedBar, | |
90 | SeriesTypeHorizontalPercentBar |
|
87 | SeriesTypeHorizontalPercentBar | |
91 | }; |
|
88 | }; | |
92 |
|
89 | |||
93 | public: |
|
90 | public: | |
94 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
91 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
95 | ~DeclarativeChart(); |
|
92 | ~DeclarativeChart(); | |
96 |
|
93 | |||
97 | public: // From QDeclarativeItem/QGraphicsItem |
|
94 | public: // From QDeclarativeItem/QGraphicsItem | |
98 | void childEvent(QChildEvent *event); |
|
95 | void childEvent(QChildEvent *event); | |
99 | void componentComplete(); |
|
96 | void componentComplete(); | |
100 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
97 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
101 |
|
98 | |||
102 | public: |
|
99 | public: | |
103 | void setTheme(DeclarativeChart::Theme theme); |
|
100 | void setTheme(DeclarativeChart::Theme theme); | |
104 | DeclarativeChart::Theme theme(); |
|
101 | DeclarativeChart::Theme theme(); | |
105 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
102 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
106 | DeclarativeChart::Animation animationOptions(); |
|
103 | DeclarativeChart::Animation animationOptions(); | |
107 | void setTitle(QString title); |
|
104 | void setTitle(QString title); | |
108 | QString title(); |
|
105 | QString title(); | |
109 | QLegend *legend(); |
|
106 | QLegend *legend(); | |
110 | QFont titleFont() const; |
|
107 | QFont titleFont() const; | |
111 | void setTitleFont(const QFont &font); |
|
108 | void setTitleFont(const QFont &font); | |
112 | void setTitleColor(QColor color); |
|
109 | void setTitleColor(QColor color); | |
113 | QColor titleColor(); |
|
110 | QColor titleColor(); | |
114 | void setBackgroundColor(QColor color); |
|
111 | void setBackgroundColor(QColor color); | |
115 | QColor backgroundColor(); |
|
112 | QColor backgroundColor(); | |
116 | int count(); |
|
113 | int count(); | |
117 | void setDropShadowEnabled(bool enabled); |
|
114 | void setDropShadowEnabled(bool enabled); | |
118 | bool dropShadowEnabled(); |
|
115 | bool dropShadowEnabled(); | |
119 | qreal topMargin(); |
|
116 | qreal topMargin(); | |
120 | qreal bottomMargin(); |
|
117 | qreal bottomMargin(); | |
121 | qreal leftMargin(); |
|
118 | qreal leftMargin(); | |
122 | qreal rightMargin(); |
|
119 | qreal rightMargin(); | |
123 | void createDefaultAxes(QAbstractSeries *series); |
|
120 | void createDefaultAxes(QAbstractSeries *series); | |
124 |
//TODO this is deprec |
|
121 | //TODO this is deprecated: | |
125 | DeclarativeMargins *minimumMargins() { return m_margins; } |
|
122 | DeclarativeMargins *minimumMargins() { return m_margins; } | |
126 |
|
123 | |||
127 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } |
|
124 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } | |
128 | QRectF plotArea() { return m_chart->plotArea(); } |
|
125 | QRectF plotArea() { return m_chart->plotArea(); } | |
129 |
|
126 | |||
130 | public: |
|
127 | public: | |
131 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
128 | Q_INVOKABLE QAbstractSeries *series(int index); | |
132 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
129 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
133 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
130 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
134 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); |
|
131 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); | |
135 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); |
|
132 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); | |
136 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } |
|
133 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } | |
137 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
134 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
138 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
135 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
139 | Q_INVOKABLE void createDefaultAxes(); |
|
136 | Q_INVOKABLE void createDefaultAxes(); | |
140 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); |
|
137 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); | |
141 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); |
|
138 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); | |
142 | Q_INVOKABLE void zoom(qreal factor); |
|
139 | Q_INVOKABLE void zoom(qreal factor); | |
143 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
140 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
144 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
141 | Q_INVOKABLE void scrollRight(qreal pixels); | |
145 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
142 | Q_INVOKABLE void scrollUp(qreal pixels); | |
146 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
143 | Q_INVOKABLE void scrollDown(qreal pixels); | |
147 |
|
144 | |||
148 | Q_SIGNALS: |
|
145 | Q_SIGNALS: | |
149 | void axisLabelsChanged(); |
|
146 | void axisLabelsChanged(); | |
150 | void titleColorChanged(QColor color); |
|
147 | void titleColorChanged(QColor color); | |
151 | void backgroundColorChanged(); |
|
148 | void backgroundColorChanged(); | |
152 | void dropShadowEnabledChanged(bool enabled); |
|
149 | void dropShadowEnabledChanged(bool enabled); | |
153 | void minimumMarginsChanged(); |
|
150 | void minimumMarginsChanged(); | |
154 | Q_REVISION(2) void marginsChanged(); |
|
151 | Q_REVISION(2) void marginsChanged(); | |
155 | void plotAreaChanged(QRectF plotArea); |
|
152 | void plotAreaChanged(QRectF plotArea); | |
156 | void seriesAdded(QAbstractSeries *series); |
|
153 | void seriesAdded(QAbstractSeries *series); | |
157 | void seriesRemoved(QAbstractSeries *series); |
|
154 | void seriesRemoved(QAbstractSeries *series); | |
158 |
|
155 | |||
159 | public Q_SLOTS: |
|
156 | public Q_SLOTS: | |
160 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
157 | void changeMinimumMargins(int top, int bottom, int left, int right); | |
161 | void handleAxisXSet(QAbstractAxis *axis); |
|
158 | void handleAxisXSet(QAbstractAxis *axis); | |
162 | void handleAxisYSet(QAbstractAxis *axis); |
|
159 | void handleAxisYSet(QAbstractAxis *axis); | |
163 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); |
|
160 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); | |
164 |
|
161 | |||
165 | private: |
|
162 | private: | |
166 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
163 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
167 | // multi inheritance, so we now have a QChart as a member instead |
|
164 | // multi inheritance, so we now have a QChart as a member instead | |
168 | QChart *m_chart; |
|
165 | QChart *m_chart; | |
169 | //QMargins m_chartMargins; |
|
166 | //QMargins m_chartMargins; | |
170 | DeclarativeMargins *m_margins; |
|
167 | DeclarativeMargins *m_margins; | |
171 | }; |
|
168 | }; | |
172 |
|
169 | |||
173 | QTCOMMERCIALCHART_END_NAMESPACE |
|
170 | QTCOMMERCIALCHART_END_NAMESPACE | |
174 |
|
171 | |||
175 | #endif // DECLARATIVECHART_H |
|
172 | #endif // DECLARATIVECHART_H |
@@ -1,95 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVELINESERIES_H |
|
21 | #ifndef DECLARATIVELINESERIES_H | |
22 | #define DECLARATIVELINESERIES_H |
|
22 | #define DECLARATIVELINESERIES_H | |
23 |
|
23 | |||
24 | #include "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
26 | #ifdef QT5_QUICK_1 |
|
26 | #include <QtDeclarative/QDeclarativeListProperty> | |
27 |
|
|
27 | #include <QtDeclarative/QDeclarativeParserStatus> | |
28 | #include <QtQuick1/QDeclarativeParserStatus> |
|
|||
29 | #else |
|
|||
30 | #include <QtDeclarative/QDeclarativeListProperty> |
|
|||
31 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
|||
32 | #endif |
|
|||
33 |
|
28 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
30 | |||
36 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
31 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
37 | { |
|
32 | { | |
38 | Q_OBJECT |
|
33 | Q_OBJECT | |
39 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
40 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
41 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
42 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
43 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
38 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) | |
44 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
39 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) | |
45 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
|
40 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) | |
46 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
41 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
47 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
42 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
48 |
|
43 | |||
49 | public: |
|
44 | public: | |
50 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
45 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
51 | QXYSeries *xySeries() { return this; } |
|
46 | QXYSeries *xySeries() { return this; } | |
52 | QAbstractAxis *axisX() { return m_axisX; } |
|
47 | QAbstractAxis *axisX() { return m_axisX; } | |
53 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
48 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
54 | QAbstractAxis *axisY() { return m_axisY; } |
|
49 | QAbstractAxis *axisY() { return m_axisY; } | |
55 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
50 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
56 | qreal width() const; |
|
51 | qreal width() const; | |
57 | void setWidth(qreal width); |
|
52 | void setWidth(qreal width); | |
58 | Qt::PenStyle style() const; |
|
53 | Qt::PenStyle style() const; | |
59 | void setStyle(Qt::PenStyle style); |
|
54 | void setStyle(Qt::PenStyle style); | |
60 | Qt::PenCapStyle capStyle() const; |
|
55 | Qt::PenCapStyle capStyle() const; | |
61 | void setCapStyle(Qt::PenCapStyle capStyle); |
|
56 | void setCapStyle(Qt::PenCapStyle capStyle); | |
62 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
57 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
63 |
|
58 | |||
64 | public: // from QDeclarativeParserStatus |
|
59 | public: // from QDeclarativeParserStatus | |
65 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
60 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
66 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
61 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
67 |
|
62 | |||
68 | public: |
|
63 | public: | |
69 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } |
|
64 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
70 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } |
|
65 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
71 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } |
|
66 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
72 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } |
|
67 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
73 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } |
|
68 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
74 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } |
|
69 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
75 |
|
70 | |||
76 | Q_SIGNALS: |
|
71 | Q_SIGNALS: | |
77 | void countChanged(int count); |
|
72 | void countChanged(int count); | |
78 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
73 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
79 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
74 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
80 | Q_REVISION(1) void widthChanged(qreal width); |
|
75 | Q_REVISION(1) void widthChanged(qreal width); | |
81 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
76 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); | |
82 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
|
77 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); | |
83 |
|
78 | |||
84 | public Q_SLOTS: |
|
79 | public Q_SLOTS: | |
85 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
80 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
86 | void handleCountChanged(int index); |
|
81 | void handleCountChanged(int index); | |
87 |
|
82 | |||
88 | private: |
|
83 | private: | |
89 | QAbstractAxis *m_axisX; |
|
84 | QAbstractAxis *m_axisX; | |
90 | QAbstractAxis *m_axisY; |
|
85 | QAbstractAxis *m_axisY; | |
91 | }; |
|
86 | }; | |
92 |
|
87 | |||
93 | QTCOMMERCIALCHART_END_NAMESPACE |
|
88 | QTCOMMERCIALCHART_END_NAMESPACE | |
94 |
|
89 | |||
95 | #endif // DECLARATIVELINESERIES_H |
|
90 | #endif // DECLARATIVELINESERIES_H |
@@ -1,68 +1,63 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEPIESERIES_H |
|
21 | #ifndef DECLARATIVEPIESERIES_H | |
22 | #define DECLARATIVEPIESERIES_H |
|
22 | #define DECLARATIVEPIESERIES_H | |
23 |
|
23 | |||
24 | #include "qpieseries.h" |
|
24 | #include "qpieseries.h" | |
25 | #ifdef QT5_QUICK_1 |
|
25 | #include <QtDeclarative/QDeclarativeItem> | |
26 |
|
|
26 | #include <QtDeclarative/QDeclarativeParserStatus> | |
27 | #include <QtQuick1/QDeclarativeParserStatus> |
|
|||
28 | #else |
|
|||
29 | #include <QtDeclarative/QDeclarativeItem> |
|
|||
30 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
|||
31 | #endif |
|
|||
32 |
|
27 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 | class QPieSlice; |
|
29 | class QPieSlice; | |
35 |
|
30 | |||
36 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus |
|
31 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus | |
37 | { |
|
32 | { | |
38 | Q_OBJECT |
|
33 | Q_OBJECT | |
39 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
40 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
35 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
41 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
36 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
42 |
|
37 | |||
43 | public: |
|
38 | public: | |
44 | explicit DeclarativePieSeries(QDeclarativeItem *parent = 0); |
|
39 | explicit DeclarativePieSeries(QDeclarativeItem *parent = 0); | |
45 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
40 | QDeclarativeListProperty<QObject> seriesChildren(); | |
46 | Q_INVOKABLE QPieSlice *at(int index); |
|
41 | Q_INVOKABLE QPieSlice *at(int index); | |
47 | Q_INVOKABLE QPieSlice *find(QString label); |
|
42 | Q_INVOKABLE QPieSlice *find(QString label); | |
48 | Q_INVOKABLE QPieSlice *append(QString label, qreal value); |
|
43 | Q_INVOKABLE QPieSlice *append(QString label, qreal value); | |
49 | Q_INVOKABLE bool remove(QPieSlice *slice); |
|
44 | Q_INVOKABLE bool remove(QPieSlice *slice); | |
50 | Q_INVOKABLE void clear(); |
|
45 | Q_INVOKABLE void clear(); | |
51 |
|
46 | |||
52 | public: |
|
47 | public: | |
53 | void classBegin(); |
|
48 | void classBegin(); | |
54 | void componentComplete(); |
|
49 | void componentComplete(); | |
55 |
|
50 | |||
56 | Q_SIGNALS: |
|
51 | Q_SIGNALS: | |
57 | void sliceAdded(QPieSlice *slice); |
|
52 | void sliceAdded(QPieSlice *slice); | |
58 | void sliceRemoved(QPieSlice *slice); |
|
53 | void sliceRemoved(QPieSlice *slice); | |
59 |
|
54 | |||
60 | public Q_SLOTS: |
|
55 | public Q_SLOTS: | |
61 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
56 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
62 | void handleAdded(QList<QPieSlice *> slices); |
|
57 | void handleAdded(QList<QPieSlice *> slices); | |
63 | void handleRemoved(QList<QPieSlice *> slices); |
|
58 | void handleRemoved(QList<QPieSlice *> slices); | |
64 | }; |
|
59 | }; | |
65 |
|
60 | |||
66 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE | |
67 |
|
62 | |||
68 | #endif // DECLARATIVEPIESERIES_H |
|
63 | #endif // DECLARATIVEPIESERIES_H |
@@ -1,87 +1,82 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESCATTERSERIES_H |
|
21 | #ifndef DECLARATIVESCATTERSERIES_H | |
22 | #define DECLARATIVESCATTERSERIES_H |
|
22 | #define DECLARATIVESCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include "qscatterseries.h" |
|
24 | #include "qscatterseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
26 | #ifdef QT5_QUICK_1 |
|
26 | #include <QtDeclarative/QDeclarativeListProperty> | |
27 |
|
|
27 | #include <QtDeclarative/QDeclarativeParserStatus> | |
28 | #include <QtQuick1/QDeclarativeParserStatus> |
|
|||
29 | #else |
|
|||
30 | #include <QtDeclarative/QDeclarativeListProperty> |
|
|||
31 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
|||
32 | #endif |
|
|||
33 |
|
28 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
30 | |||
36 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
31 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
37 | { |
|
32 | { | |
38 | Q_OBJECT |
|
33 | Q_OBJECT | |
39 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
40 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
41 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
42 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
43 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
38 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
44 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
39 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
45 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
40 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
46 |
|
41 | |||
47 | public: |
|
42 | public: | |
48 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
43 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
49 | QXYSeries *xySeries() { return this; } |
|
44 | QXYSeries *xySeries() { return this; } | |
50 | QAbstractAxis *axisX() { return m_axisX; } |
|
45 | QAbstractAxis *axisX() { return m_axisX; } | |
51 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
46 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
52 | QAbstractAxis *axisY() { return m_axisY; } |
|
47 | QAbstractAxis *axisY() { return m_axisY; } | |
53 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
48 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
54 | qreal borderWidth() const; |
|
49 | qreal borderWidth() const; | |
55 | void setBorderWidth(qreal borderWidth); |
|
50 | void setBorderWidth(qreal borderWidth); | |
56 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
51 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
57 |
|
52 | |||
58 | public: // from QDeclarativeParserStatus |
|
53 | public: // from QDeclarativeParserStatus | |
59 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
54 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
60 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
55 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
61 |
|
56 | |||
62 | public: |
|
57 | public: | |
63 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } |
|
58 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
64 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } |
|
59 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
65 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } |
|
60 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
66 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } |
|
61 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
67 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } |
|
62 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
68 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } |
|
63 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
69 |
|
64 | |||
70 | Q_SIGNALS: |
|
65 | Q_SIGNALS: | |
71 | void countChanged(int count); |
|
66 | void countChanged(int count); | |
72 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
67 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
73 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
68 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
74 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
69 | Q_REVISION(1) void borderWidthChanged(qreal width); | |
75 |
|
70 | |||
76 | public Q_SLOTS: |
|
71 | public Q_SLOTS: | |
77 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
72 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
78 | void handleCountChanged(int index); |
|
73 | void handleCountChanged(int index); | |
79 |
|
74 | |||
80 | private: |
|
75 | private: | |
81 | QAbstractAxis *m_axisX; |
|
76 | QAbstractAxis *m_axisX; | |
82 | QAbstractAxis *m_axisY; |
|
77 | QAbstractAxis *m_axisY; | |
83 | }; |
|
78 | }; | |
84 |
|
79 | |||
85 | QTCOMMERCIALCHART_END_NAMESPACE |
|
80 | QTCOMMERCIALCHART_END_NAMESPACE | |
86 |
|
81 | |||
87 | #endif // DECLARATIVESCATTERSERIES_H |
|
82 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,95 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESPLINESERIES_H |
|
21 | #ifndef DECLARATIVESPLINESERIES_H | |
22 | #define DECLARATIVESPLINESERIES_H |
|
22 | #define DECLARATIVESPLINESERIES_H | |
23 |
|
23 | |||
24 | #include "qsplineseries.h" |
|
24 | #include "qsplineseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
26 | #ifdef QT5_QUICK_1 |
|
26 | #include <QtDeclarative/QDeclarativeListProperty> | |
27 |
|
|
27 | #include <QtDeclarative/QDeclarativeParserStatus> | |
28 | #include <QtQuick1/QDeclarativeParserStatus> |
|
|||
29 | #else |
|
|||
30 | #include <QtDeclarative/QDeclarativeListProperty> |
|
|||
31 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
|||
32 | #endif |
|
|||
33 |
|
28 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
30 | |||
36 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
31 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
37 | { |
|
32 | { | |
38 | Q_OBJECT |
|
33 | Q_OBJECT | |
39 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
40 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
41 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
42 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
43 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
38 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) | |
44 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
39 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) | |
45 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
|
40 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) | |
46 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
41 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
47 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
42 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
48 |
|
43 | |||
49 | public: |
|
44 | public: | |
50 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
45 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
51 | QXYSeries *xySeries() { return this; } |
|
46 | QXYSeries *xySeries() { return this; } | |
52 | QAbstractAxis *axisX() { return m_axisX; } |
|
47 | QAbstractAxis *axisX() { return m_axisX; } | |
53 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
48 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
54 | QAbstractAxis *axisY() { return m_axisY; } |
|
49 | QAbstractAxis *axisY() { return m_axisY; } | |
55 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
50 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
56 | qreal width() const; |
|
51 | qreal width() const; | |
57 | void setWidth(qreal width); |
|
52 | void setWidth(qreal width); | |
58 | Qt::PenStyle style() const; |
|
53 | Qt::PenStyle style() const; | |
59 | void setStyle(Qt::PenStyle style); |
|
54 | void setStyle(Qt::PenStyle style); | |
60 | Qt::PenCapStyle capStyle() const; |
|
55 | Qt::PenCapStyle capStyle() const; | |
61 | void setCapStyle(Qt::PenCapStyle capStyle); |
|
56 | void setCapStyle(Qt::PenCapStyle capStyle); | |
62 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
57 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
63 |
|
58 | |||
64 | public: // from QDeclarativeParserStatus |
|
59 | public: // from QDeclarativeParserStatus | |
65 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
60 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
66 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
61 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
67 |
|
62 | |||
68 | public: |
|
63 | public: | |
69 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } |
|
64 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
70 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } |
|
65 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
71 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } |
|
66 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
72 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } |
|
67 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
73 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } |
|
68 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
74 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } |
|
69 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
75 |
|
70 | |||
76 | Q_SIGNALS: |
|
71 | Q_SIGNALS: | |
77 | void countChanged(int count); |
|
72 | void countChanged(int count); | |
78 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
73 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
79 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
74 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
80 | Q_REVISION(1) void widthChanged(qreal width); |
|
75 | Q_REVISION(1) void widthChanged(qreal width); | |
81 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
76 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); | |
82 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
|
77 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); | |
83 |
|
78 | |||
84 | public Q_SLOTS: |
|
79 | public Q_SLOTS: | |
85 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
80 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
86 | void handleCountChanged(int index); |
|
81 | void handleCountChanged(int index); | |
87 |
|
82 | |||
88 | public: |
|
83 | public: | |
89 | QAbstractAxis *m_axisX; |
|
84 | QAbstractAxis *m_axisX; | |
90 | QAbstractAxis *m_axisY; |
|
85 | QAbstractAxis *m_axisY; | |
91 | }; |
|
86 | }; | |
92 |
|
87 | |||
93 | QTCOMMERCIALCHART_END_NAMESPACE |
|
88 | QTCOMMERCIALCHART_END_NAMESPACE | |
94 |
|
89 | |||
95 | #endif // DECLARATIVESPLINESERIES_H |
|
90 | #endif // DECLARATIVESPLINESERIES_H |
@@ -1,158 +1,151 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifdef QT5_QUICK_1 |
|
|||
22 | #include <QtQuick1/qdeclarativeextensionplugin.h> |
|
|||
23 | #include <QtQuick1/qdeclarative.h> |
|
|||
24 | #else |
|
|||
25 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
|||
26 | #include <QtDeclarative/qdeclarative.h> |
|
|||
27 | #endif |
|
|||
28 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
29 | #include "qabstractaxis.h" |
|
22 | #include "qabstractaxis.h" | |
30 | #include "qvalueaxis.h" |
|
23 | #include "qvalueaxis.h" | |
31 | #include "declarativecategoryaxis.h" |
|
24 | #include "declarativecategoryaxis.h" | |
32 | #include "qbarcategoryaxis.h" |
|
25 | #include "qbarcategoryaxis.h" | |
33 | #include "declarativechart.h" |
|
26 | #include "declarativechart.h" | |
34 | #include "declarativexypoint.h" |
|
27 | #include "declarativexypoint.h" | |
35 | #include "declarativelineseries.h" |
|
28 | #include "declarativelineseries.h" | |
36 | #include "declarativesplineseries.h" |
|
29 | #include "declarativesplineseries.h" | |
37 | #include "declarativeareaseries.h" |
|
30 | #include "declarativeareaseries.h" | |
38 | #include "declarativescatterseries.h" |
|
31 | #include "declarativescatterseries.h" | |
39 | #include "declarativebarseries.h" |
|
32 | #include "declarativebarseries.h" | |
40 | #include "declarativepieseries.h" |
|
33 | #include "declarativepieseries.h" | |
41 | #include "qvxymodelmapper.h" |
|
34 | #include "qvxymodelmapper.h" | |
42 | #include "qhxymodelmapper.h" |
|
35 | #include "qhxymodelmapper.h" | |
43 | #include "qhpiemodelmapper.h" |
|
36 | #include "qhpiemodelmapper.h" | |
44 | #include "qvpiemodelmapper.h" |
|
37 | #include "qvpiemodelmapper.h" | |
45 | #include "qhbarmodelmapper.h" |
|
38 | #include "qhbarmodelmapper.h" | |
46 | #include "qvbarmodelmapper.h" |
|
39 | #include "qvbarmodelmapper.h" | |
47 | #include "declarativemargins.h" |
|
40 | #include "declarativemargins.h" | |
48 | #include <QAbstractItemModel> |
|
|||
49 |
|
||||
50 | #ifndef QT_ON_ARM |
|
41 | #ifndef QT_ON_ARM | |
51 | #include "qdatetimeaxis.h" |
|
42 | #include "qdatetimeaxis.h" | |
52 | #endif |
|
43 | #endif | |
|
44 | #include <QAbstractItemModel> | |||
|
45 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |||
|
46 | #include <QtDeclarative/qdeclarative.h> | |||
53 |
|
47 | |||
54 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
48 | QTCOMMERCIALCHART_USE_NAMESPACE | |
55 |
|
49 | |||
56 | Q_DECLARE_METATYPE(QList<QPieSlice *>) |
|
50 | Q_DECLARE_METATYPE(QList<QPieSlice *>) | |
57 | Q_DECLARE_METATYPE(QList<QBarSet *>) |
|
51 | Q_DECLARE_METATYPE(QList<QBarSet *>) | |
58 |
|
52 | |||
59 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
53 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
60 |
|
54 | |||
61 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
55 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
62 | { |
|
56 | { | |
63 | Q_OBJECT |
|
57 | Q_OBJECT | |
64 |
|
58 | |||
65 | #ifdef QT5_QUICK_1 |
|
59 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
66 | // TODO: fix the metadata |
|
60 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface") | |
67 | Q_PLUGIN_METADATA(IID "org.qt-project.foo") |
|
|||
68 | #endif |
|
61 | #endif | |
69 |
|
62 | |||
70 | public: |
|
63 | public: | |
71 | virtual void registerTypes(const char *uri) |
|
64 | virtual void registerTypes(const char *uri) | |
72 | { |
|
65 | { | |
73 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
66 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
74 |
|
67 | |||
75 | qRegisterMetaType<QList<QPieSlice *> >(); |
|
68 | qRegisterMetaType<QList<QPieSlice *> >(); | |
76 | qRegisterMetaType<QList<QBarSet *> >(); |
|
69 | qRegisterMetaType<QList<QBarSet *> >(); | |
77 |
|
70 | |||
78 | // QtCommercial.Chart 1.0 |
|
71 | // QtCommercial.Chart 1.0 | |
79 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
72 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
80 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
73 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | |
81 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
74 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
82 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
75 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
83 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
76 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
84 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
77 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
85 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
78 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
86 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
79 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
87 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
80 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
88 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
81 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
89 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
82 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
90 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
83 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
91 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
84 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
92 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
85 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
93 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
86 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
94 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
87 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
95 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
88 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
96 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
89 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
97 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
90 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); | |
98 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
91 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); | |
99 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
92 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
100 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
93 | QLatin1String("Trying to create uncreatable: Legend.")); | |
101 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
94 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
102 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
95 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
103 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
96 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
104 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
97 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
105 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
98 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
106 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
99 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
107 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
100 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
108 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
101 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
109 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
102 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
110 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
103 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
111 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
104 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
112 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
105 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
113 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
106 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |
114 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
107 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
115 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
108 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
116 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
109 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
117 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", |
|
110 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", | |
118 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
111 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | |
119 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
112 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
120 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
113 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); | |
121 |
|
114 | |||
122 | // QtCommercial.Chart 1.1 |
|
115 | // QtCommercial.Chart 1.1 | |
123 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
|
116 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); | |
124 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); |
|
117 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); | |
125 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); |
|
118 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); | |
126 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); |
|
119 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); | |
127 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); |
|
120 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); | |
128 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); |
|
121 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); | |
129 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); |
|
122 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); | |
130 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); |
|
123 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); | |
131 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); |
|
124 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); | |
132 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); |
|
125 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); | |
133 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); |
|
126 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); | |
134 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); |
|
127 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); | |
135 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); |
|
128 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); | |
136 | #ifndef QT_ON_ARM |
|
129 | #ifndef QT_ON_ARM | |
137 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); |
|
130 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); | |
138 | #endif |
|
131 | #endif | |
139 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); |
|
132 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); | |
140 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); |
|
133 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); | |
141 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); |
|
134 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); | |
142 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", |
|
135 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", | |
143 | QLatin1String("Trying to create uncreatable: Margins.")); |
|
136 | QLatin1String("Trying to create uncreatable: Margins.")); | |
144 |
|
137 | |||
145 | // QtCommercial.Chart 1.2 |
|
138 | // QtCommercial.Chart 1.2 | |
146 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
139 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); | |
147 | } |
|
140 | } | |
148 | }; |
|
141 | }; | |
149 |
|
142 | |||
150 | #include "plugin.moc" |
|
143 | #include "plugin.moc" | |
151 |
|
144 | |||
152 | QTCOMMERCIALCHART_END_NAMESPACE |
|
145 | QTCOMMERCIALCHART_END_NAMESPACE | |
153 |
|
146 | |||
154 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
147 | QTCOMMERCIALCHART_USE_NAMESPACE | |
155 |
|
148 | |||
156 | #ifndef QT5_QUICK_1 |
|
149 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) | |
157 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
150 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) | |
158 | #endif |
|
151 | #endif |
@@ -1,90 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchartsplugin.h" |
|
21 | #include "qchartsplugin.h" | |
22 | #include "qchartview.h" |
|
22 | #include "qchartview.h" | |
23 | #include <QtPlugin> |
|
23 | #include <QtPlugin> | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
26 | |||
27 | QChartsPlugin::QChartsPlugin(QObject *parent) : |
|
27 | QChartsPlugin::QChartsPlugin(QObject *parent) : | |
28 | QObject(parent) |
|
28 | QObject(parent) | |
29 | { |
|
29 | { | |
30 | // TODO Auto-generated constructor stub |
|
30 | // TODO Auto-generated constructor stub | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QChartsPlugin::~QChartsPlugin() |
|
33 | QChartsPlugin::~QChartsPlugin() | |
34 | { |
|
34 | { | |
35 | // TODO Auto-generated destructor stub |
|
35 | // TODO Auto-generated destructor stub | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QString QChartsPlugin::name() const |
|
38 | QString QChartsPlugin::name() const | |
39 | { |
|
39 | { | |
40 | return "QChartView"; |
|
40 | return "QChartView"; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | QString QChartsPlugin::includeFile() const |
|
43 | QString QChartsPlugin::includeFile() const | |
44 | { |
|
44 | { | |
45 | #ifdef linux |
|
45 | #ifdef linux | |
46 | QString myNewLine = "\n"; |
|
46 | QString myNewLine = "\n"; | |
47 | #endif |
|
47 | #endif | |
48 | #ifdef WIN32 |
|
48 | #ifdef WIN32 | |
49 | QString myNewLine = "\n\r"; |
|
49 | QString myNewLine = "\n\r"; | |
50 | #endif |
|
50 | #endif | |
51 | #ifdef __APPLE__ |
|
51 | #ifdef __APPLE__ | |
52 | QString myNewLine = "\n"; |
|
52 | QString myNewLine = "\n"; | |
53 | #endif |
|
53 | #endif | |
54 | return "<qchartview.h>" + myNewLine + "#include <chartsnamespace.h>"; |
|
54 | return "<qchartview.h>" + myNewLine + "#include <chartsnamespace.h>"; | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | QString QChartsPlugin::group() const |
|
57 | QString QChartsPlugin::group() const | |
58 | { |
|
58 | { | |
59 | return tr("QCharts Widgets"); |
|
59 | return tr("QCharts Widgets"); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | QIcon QChartsPlugin::icon() const |
|
62 | QIcon QChartsPlugin::icon() const | |
63 | { |
|
63 | { | |
64 | return QIcon(":/images/qcharts.png"); |
|
64 | return QIcon(":/images/qcharts.png"); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | QString QChartsPlugin::toolTip() const |
|
67 | QString QChartsPlugin::toolTip() const | |
68 | { |
|
68 | { | |
69 | return tr("An qcharts view widget"); |
|
69 | return tr("An qcharts view widget"); | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | QString QChartsPlugin::whatsThis() const |
|
72 | QString QChartsPlugin::whatsThis() const | |
73 | { |
|
73 | { | |
74 | return tr("This widget is presents QChartView widget"); |
|
74 | return tr("This widget is presents QChartView widget"); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | bool QChartsPlugin::isContainer() const |
|
77 | bool QChartsPlugin::isContainer() const | |
78 | { |
|
78 | { | |
79 | return false; |
|
79 | return false; | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | QWidget *QChartsPlugin::createWidget(QWidget *parent) |
|
82 | QWidget *QChartsPlugin::createWidget(QWidget *parent) | |
83 | { |
|
83 | { | |
84 | return new QChartView(new QChart(), parent); |
|
84 | return new QChartView(new QChart(), parent); | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | #ifndef QT5_QUICK_1 |
|
87 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) | |
88 | Q_EXPORT_PLUGIN2(qtcommercialchart, QChartsPlugin) |
|
88 | Q_EXPORT_PLUGIN2(qtcommercialchart, QChartsPlugin) | |
89 | #endif |
|
89 | #endif | |
90 |
|
90 |
@@ -1,49 +1,49 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHARTSPLUGIN_H |
|
21 | #ifndef QCHARTSPLUGIN_H | |
22 | #define QCHARTSPLUGIN_H |
|
22 | #define QCHARTSPLUGIN_H | |
23 |
|
23 | |||
24 | #include <QDesignerCustomWidgetInterface> |
|
24 | #include <QDesignerCustomWidgetInterface> | |
25 |
|
25 | |||
26 | class QChartsPlugin: public QObject, public QDesignerCustomWidgetInterface |
|
26 | class QChartsPlugin: public QObject, public QDesignerCustomWidgetInterface | |
27 | { |
|
27 | { | |
28 |
|
28 | |||
29 | #ifdef QT5_QUICK_1 |
|
29 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
30 |
Q_PLUGIN_METADATA(IID "org.qt-project. |
|
30 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") | |
31 | #endif |
|
31 | #endif | |
32 |
|
32 | |||
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_INTERFACES(QDesignerCustomWidgetInterface) |
|
34 | Q_INTERFACES(QDesignerCustomWidgetInterface) | |
35 | public: |
|
35 | public: | |
36 | QChartsPlugin(QObject *parent = 0); |
|
36 | QChartsPlugin(QObject *parent = 0); | |
37 | ~QChartsPlugin(); |
|
37 | ~QChartsPlugin(); | |
38 |
|
38 | |||
39 | QString name() const; |
|
39 | QString name() const; | |
40 | QString includeFile() const; |
|
40 | QString includeFile() const; | |
41 | QString group() const; |
|
41 | QString group() const; | |
42 | QIcon icon() const; |
|
42 | QIcon icon() const; | |
43 | QString toolTip() const; |
|
43 | QString toolTip() const; | |
44 | QString whatsThis() const; |
|
44 | QString whatsThis() const; | |
45 | bool isContainer() const; |
|
45 | bool isContainer() const; | |
46 | QWidget *createWidget(QWidget *parent); |
|
46 | QWidget *createWidget(QWidget *parent); | |
47 | }; |
|
47 | }; | |
48 |
|
48 | |||
49 | #endif /* QCHARTSPLUGIN_H */ |
|
49 | #endif /* QCHARTSPLUGIN_H */ |
@@ -1,648 +1,644 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 | #ifndef BUILD_PRIVATE_UNIT_TESTS |
|
20 | #ifndef BUILD_PRIVATE_UNIT_TESTS | |
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 |
|
22 | |||
23 | class tst_ChartDataSet: public QObject { |
|
23 | class tst_ChartDataSet: public QObject { | |
24 |
|
24 | |||
25 | Q_OBJECT |
|
25 | Q_OBJECT | |
26 |
|
26 | |||
27 | private Q_SLOTS: |
|
27 | private Q_SLOTS: | |
28 | void skip(); |
|
28 | void skip(); | |
29 |
|
29 | |||
30 | }; |
|
30 | }; | |
31 |
|
31 | |||
32 | void tst_ChartDataSet::skip() |
|
32 | void tst_ChartDataSet::skip() | |
33 | { |
|
33 | { | |
34 | #ifdef QT5_QUICK_1 |
|
|||
35 | QSKIP("This test requires the debug version of library"); |
|
|||
36 | #else |
|
|||
37 | QSKIP("This test requires the debug version of library", SkipAll); |
|
34 | QSKIP("This test requires the debug version of library", SkipAll); | |
38 | #endif |
|
|||
39 | } |
|
35 | } | |
40 |
|
36 | |||
41 | QTEST_MAIN(tst_ChartDataSet) |
|
37 | QTEST_MAIN(tst_ChartDataSet) | |
42 | #include "tst_chartdataset.moc" |
|
38 | #include "tst_chartdataset.moc" | |
43 |
|
39 | |||
44 | #else |
|
40 | #else | |
45 |
|
41 | |||
46 | #include <QtTest/QtTest> |
|
42 | #include <QtTest/QtTest> | |
47 | #include <qabstractaxis.h> |
|
43 | #include <qabstractaxis.h> | |
48 | #include <qvalueaxis.h> |
|
44 | #include <qvalueaxis.h> | |
49 | #include <qbarcategoryaxis.h> |
|
45 | #include <qbarcategoryaxis.h> | |
50 | #include <qlineseries.h> |
|
46 | #include <qlineseries.h> | |
51 | #include <qareaseries.h> |
|
47 | #include <qareaseries.h> | |
52 | #include <qscatterseries.h> |
|
48 | #include <qscatterseries.h> | |
53 | #include <qsplineseries.h> |
|
49 | #include <qsplineseries.h> | |
54 | #include <qpieseries.h> |
|
50 | #include <qpieseries.h> | |
55 | #include <qbarseries.h> |
|
51 | #include <qbarseries.h> | |
56 | #include <qpercentbarseries.h> |
|
52 | #include <qpercentbarseries.h> | |
57 | #include <qstackedbarseries.h> |
|
53 | #include <qstackedbarseries.h> | |
58 | #include <private/chartdataset_p.h> |
|
54 | #include <private/chartdataset_p.h> | |
59 | #include <private/domain_p.h> |
|
55 | #include <private/domain_p.h> | |
60 | #include <tst_definitions.h> |
|
56 | #include <tst_definitions.h> | |
61 |
|
57 | |||
62 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
58 | QTCOMMERCIALCHART_USE_NAMESPACE | |
63 |
|
59 | |||
64 | Q_DECLARE_METATYPE(Domain *) |
|
60 | Q_DECLARE_METATYPE(Domain *) | |
65 | Q_DECLARE_METATYPE(QAbstractAxis *) |
|
61 | Q_DECLARE_METATYPE(QAbstractAxis *) | |
66 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
62 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
67 | Q_DECLARE_METATYPE(QList<QAbstractSeries *>) |
|
63 | Q_DECLARE_METATYPE(QList<QAbstractSeries *>) | |
68 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) |
|
64 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) | |
69 | Q_DECLARE_METATYPE(QLineSeries *) |
|
65 | Q_DECLARE_METATYPE(QLineSeries *) | |
70 |
|
66 | |||
71 | class tst_ChartDataSet: public QObject { |
|
67 | class tst_ChartDataSet: public QObject { | |
72 |
|
68 | |||
73 | Q_OBJECT |
|
69 | Q_OBJECT | |
74 |
|
70 | |||
75 | public Q_SLOTS: |
|
71 | public Q_SLOTS: | |
76 |
|
|
72 | void initTestCase(); | |
77 |
|
|
73 | void cleanupTestCase(); | |
78 |
|
|
74 | void init(); | |
79 |
|
|
75 | void cleanup(); | |
80 |
|
76 | |||
81 | private Q_SLOTS: |
|
77 | private Q_SLOTS: | |
82 |
|
|
78 | void chartdataset_data(); | |
83 |
|
|
79 | void chartdataset(); | |
84 |
|
|
80 | void addSeries_data(); | |
85 |
|
|
81 | void addSeries(); | |
86 | void setAxisX_data(); |
|
82 | void setAxisX_data(); | |
87 | void setAxisX(); |
|
83 | void setAxisX(); | |
88 | void setAxisY_data(); |
|
84 | void setAxisY_data(); | |
89 | void setAxisY(); |
|
85 | void setAxisY(); | |
90 |
|
|
86 | void removeSeries_data(); | |
91 |
|
|
87 | void removeSeries(); | |
92 |
|
|
88 | void removeAllSeries_data(); | |
93 |
|
|
89 | void removeAllSeries(); | |
94 | void seriesCount_data(); |
|
90 | void seriesCount_data(); | |
95 |
|
|
91 | void seriesCount(); | |
96 | void seriesIndex_data(); |
|
92 | void seriesIndex_data(); | |
97 |
|
|
93 | void seriesIndex(); | |
98 |
|
|
94 | void domain_data(); | |
99 |
|
|
95 | void domain(); | |
100 | void zoomInDomain_data(); |
|
96 | void zoomInDomain_data(); | |
101 |
|
|
97 | void zoomInDomain(); | |
102 | void zoomOutDomain_data(); |
|
98 | void zoomOutDomain_data(); | |
103 | void zoomOutDomain(); |
|
99 | void zoomOutDomain(); | |
104 | void scrollDomain_data(); |
|
100 | void scrollDomain_data(); | |
105 | void scrollDomain(); |
|
101 | void scrollDomain(); | |
106 |
|
102 | |||
107 | private: |
|
103 | private: | |
108 | ChartDataSet* m_dataset; |
|
104 | ChartDataSet* m_dataset; | |
109 | }; |
|
105 | }; | |
110 |
|
106 | |||
111 | void tst_ChartDataSet::initTestCase() |
|
107 | void tst_ChartDataSet::initTestCase() | |
112 | { |
|
108 | { | |
113 | qRegisterMetaType<Domain*>(); |
|
109 | qRegisterMetaType<Domain*>(); | |
114 |
|
|
110 | qRegisterMetaType<QAbstractAxis*>(); | |
115 | qRegisterMetaType<QAbstractSeries*>(); |
|
111 | qRegisterMetaType<QAbstractSeries*>(); | |
116 | } |
|
112 | } | |
117 |
|
113 | |||
118 | void tst_ChartDataSet::cleanupTestCase() |
|
114 | void tst_ChartDataSet::cleanupTestCase() | |
119 | { |
|
115 | { | |
120 | } |
|
116 | } | |
121 |
|
117 | |||
122 | void tst_ChartDataSet::init() |
|
118 | void tst_ChartDataSet::init() | |
123 | { |
|
119 | { | |
124 | m_dataset = new ChartDataSet(); |
|
120 | m_dataset = new ChartDataSet(); | |
125 | } |
|
121 | } | |
126 |
|
122 | |||
127 |
|
123 | |||
128 | void tst_ChartDataSet::cleanup() |
|
124 | void tst_ChartDataSet::cleanup() | |
129 | { |
|
125 | { | |
130 | QList<QAbstractSeries*> series = m_dataset->series(); |
|
126 | QList<QAbstractSeries*> series = m_dataset->series(); | |
131 | foreach (QAbstractSeries* serie, series) |
|
127 | foreach (QAbstractSeries* serie, series) | |
132 | { |
|
128 | { | |
133 | m_dataset->removeSeries(serie); |
|
129 | m_dataset->removeSeries(serie); | |
134 | } |
|
130 | } | |
135 | } |
|
131 | } | |
136 |
|
132 | |||
137 | void tst_ChartDataSet::chartdataset_data() |
|
133 | void tst_ChartDataSet::chartdataset_data() | |
138 | { |
|
134 | { | |
139 | } |
|
135 | } | |
140 |
|
136 | |||
141 | void tst_ChartDataSet::chartdataset() |
|
137 | void tst_ChartDataSet::chartdataset() | |
142 | { |
|
138 | { | |
143 |
|
|
139 | QVERIFY(m_dataset->axisX(0) == 0); | |
144 |
|
|
140 | QVERIFY(m_dataset->axisY(0) == 0); | |
145 |
|
|
141 | QLineSeries* series = new QLineSeries(this); | |
146 |
|
|
142 | QCOMPARE(m_dataset->seriesIndex(series),-1); | |
147 |
|
|
143 | QVERIFY(m_dataset->domain(series) == 0); | |
148 |
|
|
144 | QVERIFY(m_dataset->axisX(series) == 0); | |
149 |
|
|
145 | QVERIFY(m_dataset->axisY(series) == 0); | |
150 |
|
|
146 | m_dataset->createDefaultAxes(); | |
151 | } |
|
147 | } | |
152 |
|
148 | |||
153 |
|
149 | |||
154 | void tst_ChartDataSet::addSeries_data() |
|
150 | void tst_ChartDataSet::addSeries_data() | |
155 | { |
|
151 | { | |
156 |
|
|
152 | QTest::addColumn<QAbstractSeries*>("series"); | |
157 |
|
153 | |||
158 | QAbstractSeries* line = new QLineSeries(this); |
|
154 | QAbstractSeries* line = new QLineSeries(this); | |
159 | QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line)); |
|
155 | QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line)); | |
160 | QAbstractSeries* scatter = new QScatterSeries(this); |
|
156 | QAbstractSeries* scatter = new QScatterSeries(this); | |
161 | QAbstractSeries* spline = new QSplineSeries(this); |
|
157 | QAbstractSeries* spline = new QSplineSeries(this); | |
162 | QAbstractSeries* pie = new QPieSeries(this); |
|
158 | QAbstractSeries* pie = new QPieSeries(this); | |
163 | QAbstractSeries* bar = new QBarSeries(this); |
|
159 | QAbstractSeries* bar = new QBarSeries(this); | |
164 | QAbstractSeries* percent = new QPercentBarSeries(this); |
|
160 | QAbstractSeries* percent = new QPercentBarSeries(this); | |
165 | QAbstractSeries* stacked = new QStackedBarSeries(this); |
|
161 | QAbstractSeries* stacked = new QStackedBarSeries(this); | |
166 |
|
162 | |||
167 |
|
|
163 | QTest::newRow("line") << line; | |
168 |
|
|
164 | QTest::newRow("area") << area; | |
169 |
|
|
165 | QTest::newRow("scatter") << scatter; | |
170 |
|
|
166 | QTest::newRow("spline") << spline; | |
171 |
|
|
167 | QTest::newRow("pie") << pie; | |
172 | QTest::newRow("bar") << bar; |
|
168 | QTest::newRow("bar") << bar; | |
173 |
|
|
169 | QTest::newRow("percent") << percent; | |
174 |
|
|
170 | QTest::newRow("stacked") << stacked; | |
175 | } |
|
171 | } | |
176 |
|
172 | |||
177 | void tst_ChartDataSet::addSeries() |
|
173 | void tst_ChartDataSet::addSeries() | |
178 | { |
|
174 | { | |
179 |
|
175 | |||
180 | QFETCH(QAbstractSeries*, series); |
|
176 | QFETCH(QAbstractSeries*, series); | |
181 |
|
177 | |||
182 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
178 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
183 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
179 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
184 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
180 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
185 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
181 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
186 |
|
182 | |||
187 | m_dataset->addSeries(series); |
|
183 | m_dataset->addSeries(series); | |
188 | m_dataset->createDefaultAxes(); |
|
184 | m_dataset->createDefaultAxes(); | |
189 | if(series->type()==QAbstractSeries::SeriesTypePie){ |
|
185 | if(series->type()==QAbstractSeries::SeriesTypePie){ | |
190 | TRY_COMPARE(spy0.count(), 0); |
|
186 | TRY_COMPARE(spy0.count(), 0); | |
191 | }else{ |
|
187 | }else{ | |
192 | TRY_COMPARE(spy0.count(), 2); |
|
188 | TRY_COMPARE(spy0.count(), 2); | |
193 | } |
|
189 | } | |
194 | TRY_COMPARE(spy1.count(), 0); |
|
190 | TRY_COMPARE(spy1.count(), 0); | |
195 | TRY_COMPARE(spy2.count(), 1); |
|
191 | TRY_COMPARE(spy2.count(), 1); | |
196 | TRY_COMPARE(spy3.count(), 0); |
|
192 | TRY_COMPARE(spy3.count(), 0); | |
197 | } |
|
193 | } | |
198 |
|
194 | |||
199 |
|
195 | |||
200 | void tst_ChartDataSet::setAxisX_data() |
|
196 | void tst_ChartDataSet::setAxisX_data() | |
201 | { |
|
197 | { | |
202 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); |
|
198 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); | |
203 | QTest::addColumn<QList<QAbstractAxis*> >("axisList"); |
|
199 | QTest::addColumn<QList<QAbstractAxis*> >("axisList"); | |
204 | QTest::addColumn<int>("axisCount"); |
|
200 | QTest::addColumn<int>("axisCount"); | |
205 |
|
201 | |||
206 | QAbstractSeries* line = new QLineSeries(this); |
|
202 | QAbstractSeries* line = new QLineSeries(this); | |
207 | QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line)); |
|
203 | QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line)); | |
208 | QAbstractSeries* scatter = new QScatterSeries(this); |
|
204 | QAbstractSeries* scatter = new QScatterSeries(this); | |
209 | QAbstractSeries* spline = new QSplineSeries(this); |
|
205 | QAbstractSeries* spline = new QSplineSeries(this); | |
210 | /*QAbstractSeries* pie = */new QPieSeries(this); |
|
206 | /*QAbstractSeries* pie = */new QPieSeries(this); | |
211 | /*QAbstractSeries* bar = */new QBarSeries(this); |
|
207 | /*QAbstractSeries* bar = */new QBarSeries(this); | |
212 | /*QAbstractSeries* percent = */new QPercentBarSeries(this); |
|
208 | /*QAbstractSeries* percent = */new QPercentBarSeries(this); | |
213 | /*QAbstractSeries* stacked = */new QStackedBarSeries(this); |
|
209 | /*QAbstractSeries* stacked = */new QStackedBarSeries(this); | |
214 |
|
210 | |||
215 | QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2") |
|
211 | QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2") | |
216 | << (QList<QAbstractSeries*>() << line << spline << scatter) |
|
212 | << (QList<QAbstractSeries*>() << line << spline << scatter) | |
217 | << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this)) << 3; |
|
213 | << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this)) << 3; | |
218 |
|
214 | |||
219 | QTest::newRow("area: axis 0") << (QList<QAbstractSeries*>() << area) |
|
215 | QTest::newRow("area: axis 0") << (QList<QAbstractSeries*>() << area) | |
220 | << (QList<QAbstractAxis*>() << new QValueAxis(this)) << 1; |
|
216 | << (QList<QAbstractAxis*>() << new QValueAxis(this)) << 1; | |
221 |
|
217 | |||
222 | QList<QAbstractAxis*> axes0; |
|
218 | QList<QAbstractAxis*> axes0; | |
223 | axes0 << new QValueAxis(this) << new QValueAxis(this); |
|
219 | axes0 << new QValueAxis(this) << new QValueAxis(this); | |
224 | axes0 << axes0.last(); |
|
220 | axes0 << axes0.last(); | |
225 | QTest::newRow("line,spline,scatter: axis 0 axis1 axis 1") |
|
221 | QTest::newRow("line,spline,scatter: axis 0 axis1 axis 1") | |
226 | << (QList<QAbstractSeries*>() << line << spline << scatter) |
|
222 | << (QList<QAbstractSeries*>() << line << spline << scatter) | |
227 | << axes0 << 2; |
|
223 | << axes0 << 2; | |
228 | //TODO: add more test cases |
|
224 | //TODO: add more test cases | |
229 | } |
|
225 | } | |
230 |
|
226 | |||
231 | void tst_ChartDataSet::setAxisX() |
|
227 | void tst_ChartDataSet::setAxisX() | |
232 | { |
|
228 | { | |
233 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
229 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
234 | QFETCH(QList<QAbstractAxis*>, axisList); |
|
230 | QFETCH(QList<QAbstractAxis*>, axisList); | |
235 | QFETCH(int, axisCount); |
|
231 | QFETCH(int, axisCount); | |
236 |
|
232 | |||
237 | Q_ASSERT(seriesList.count() == axisList.count()); |
|
233 | Q_ASSERT(seriesList.count() == axisList.count()); | |
238 |
|
234 | |||
239 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
235 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
240 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
236 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
241 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
237 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
242 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
238 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
243 |
|
239 | |||
244 | foreach (QAbstractSeries* series, seriesList){ |
|
240 | foreach (QAbstractSeries* series, seriesList){ | |
245 | m_dataset->addSeries(series); |
|
241 | m_dataset->addSeries(series); | |
246 | } |
|
242 | } | |
247 |
|
243 | |||
248 | TRY_COMPARE(spy0.count(), 0); |
|
244 | TRY_COMPARE(spy0.count(), 0); | |
249 | TRY_COMPARE(spy1.count(), 0); |
|
245 | TRY_COMPARE(spy1.count(), 0); | |
250 | TRY_COMPARE(spy2.count(), seriesList.count()); |
|
246 | TRY_COMPARE(spy2.count(), seriesList.count()); | |
251 | TRY_COMPARE(spy3.count(), 0); |
|
247 | TRY_COMPARE(spy3.count(), 0); | |
252 |
|
248 | |||
253 | QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
249 | QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
254 | QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
250 | QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
255 | QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
251 | QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
256 | QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
252 | QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
257 |
|
253 | |||
258 | for(int i=0 ; i < seriesList.count(); i++){ |
|
254 | for(int i=0 ; i < seriesList.count(); i++){ | |
259 | m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Horizontal); |
|
255 | m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Horizontal); | |
260 | } |
|
256 | } | |
261 |
|
257 | |||
262 | TRY_COMPARE(spy4.count(), axisCount); |
|
258 | TRY_COMPARE(spy4.count(), axisCount); | |
263 | TRY_COMPARE(spy5.count(), 0); |
|
259 | TRY_COMPARE(spy5.count(), 0); | |
264 | TRY_COMPARE(spy6.count(), 0); |
|
260 | TRY_COMPARE(spy6.count(), 0); | |
265 | TRY_COMPARE(spy7.count(), 0); |
|
261 | TRY_COMPARE(spy7.count(), 0); | |
266 |
|
262 | |||
267 | for(int i=0 ; i < seriesList.count(); i++){ |
|
263 | for(int i=0 ; i < seriesList.count(); i++){ | |
268 | QVERIFY(m_dataset->axisX(seriesList.at(i)) == axisList.at(i)); |
|
264 | QVERIFY(m_dataset->axisX(seriesList.at(i)) == axisList.at(i)); | |
269 | } |
|
265 | } | |
270 | } |
|
266 | } | |
271 |
|
267 | |||
272 | void tst_ChartDataSet::setAxisY_data() |
|
268 | void tst_ChartDataSet::setAxisY_data() | |
273 | { |
|
269 | { | |
274 | setAxisX_data(); |
|
270 | setAxisX_data(); | |
275 | } |
|
271 | } | |
276 |
|
272 | |||
277 | void tst_ChartDataSet::setAxisY() |
|
273 | void tst_ChartDataSet::setAxisY() | |
278 | { |
|
274 | { | |
279 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
275 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
280 | QFETCH(QList<QAbstractAxis*>, axisList); |
|
276 | QFETCH(QList<QAbstractAxis*>, axisList); | |
281 | QFETCH(int, axisCount); |
|
277 | QFETCH(int, axisCount); | |
282 |
|
278 | |||
283 | Q_ASSERT(seriesList.count() == axisList.count()); |
|
279 | Q_ASSERT(seriesList.count() == axisList.count()); | |
284 |
|
280 | |||
285 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
281 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
286 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
282 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
287 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
283 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
288 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
284 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
289 |
|
285 | |||
290 | foreach (QAbstractSeries* series, seriesList){ |
|
286 | foreach (QAbstractSeries* series, seriesList){ | |
291 | m_dataset->addSeries(series); |
|
287 | m_dataset->addSeries(series); | |
292 | } |
|
288 | } | |
293 |
|
289 | |||
294 | TRY_COMPARE(spy0.count(), 0); |
|
290 | TRY_COMPARE(spy0.count(), 0); | |
295 | TRY_COMPARE(spy1.count(), 0); |
|
291 | TRY_COMPARE(spy1.count(), 0); | |
296 | TRY_COMPARE(spy2.count(), seriesList.count()); |
|
292 | TRY_COMPARE(spy2.count(), seriesList.count()); | |
297 | TRY_COMPARE(spy3.count(), 0); |
|
293 | TRY_COMPARE(spy3.count(), 0); | |
298 |
|
294 | |||
299 | QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
295 | QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
300 | QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
296 | QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
301 | QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
297 | QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
302 | QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
298 | QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
303 |
|
299 | |||
304 | for(int i=0 ; i < seriesList.count(); i++){ |
|
300 | for(int i=0 ; i < seriesList.count(); i++){ | |
305 | m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Vertical); |
|
301 | m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Vertical); | |
306 | } |
|
302 | } | |
307 |
|
303 | |||
308 | TRY_COMPARE(spy4.count(), axisCount); |
|
304 | TRY_COMPARE(spy4.count(), axisCount); | |
309 | TRY_COMPARE(spy5.count(), 0); |
|
305 | TRY_COMPARE(spy5.count(), 0); | |
310 | TRY_COMPARE(spy6.count(), 0); |
|
306 | TRY_COMPARE(spy6.count(), 0); | |
311 | TRY_COMPARE(spy7.count(), 0); |
|
307 | TRY_COMPARE(spy7.count(), 0); | |
312 |
|
308 | |||
313 | for(int i=0 ; i < seriesList.count(); i++){ |
|
309 | for(int i=0 ; i < seriesList.count(); i++){ | |
314 | QVERIFY(m_dataset->axisY(seriesList.at(i)) == axisList.at(i)); |
|
310 | QVERIFY(m_dataset->axisY(seriesList.at(i)) == axisList.at(i)); | |
315 | } |
|
311 | } | |
316 | } |
|
312 | } | |
317 |
|
313 | |||
318 | void tst_ChartDataSet::removeSeries_data() |
|
314 | void tst_ChartDataSet::removeSeries_data() | |
319 | { |
|
315 | { | |
320 | addSeries_data(); |
|
316 | addSeries_data(); | |
321 | } |
|
317 | } | |
322 |
|
318 | |||
323 | void tst_ChartDataSet::removeSeries() |
|
319 | void tst_ChartDataSet::removeSeries() | |
324 | { |
|
320 | { | |
325 | QFETCH(QAbstractSeries*, series); |
|
321 | QFETCH(QAbstractSeries*, series); | |
326 |
|
322 | |||
327 | m_dataset->addSeries(series); |
|
323 | m_dataset->addSeries(series); | |
328 | m_dataset->createDefaultAxes(); |
|
324 | m_dataset->createDefaultAxes(); | |
329 |
|
325 | |||
330 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
326 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
331 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
327 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
332 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
328 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
333 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
329 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
334 |
|
330 | |||
335 | m_dataset->removeSeries(series); |
|
331 | m_dataset->removeSeries(series); | |
336 |
|
332 | |||
337 | TRY_COMPARE(spy0.count(), 0); |
|
333 | TRY_COMPARE(spy0.count(), 0); | |
338 | if (series->type() == QAbstractSeries::SeriesTypePie) { |
|
334 | if (series->type() == QAbstractSeries::SeriesTypePie) { | |
339 | TRY_COMPARE(spy1.count(), 0); |
|
335 | TRY_COMPARE(spy1.count(), 0); | |
340 | } |
|
336 | } | |
341 | else { |
|
337 | else { | |
342 | TRY_COMPARE(spy1.count(), 2); |
|
338 | TRY_COMPARE(spy1.count(), 2); | |
343 | } |
|
339 | } | |
344 | TRY_COMPARE(spy2.count(), 0); |
|
340 | TRY_COMPARE(spy2.count(), 0); | |
345 | TRY_COMPARE(spy3.count(), 1); |
|
341 | TRY_COMPARE(spy3.count(), 1); | |
346 | } |
|
342 | } | |
347 |
|
343 | |||
348 | void tst_ChartDataSet::removeAllSeries_data() |
|
344 | void tst_ChartDataSet::removeAllSeries_data() | |
349 | { |
|
345 | { | |
350 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); |
|
346 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); | |
351 | QTest::addColumn<QList<QAbstractAxis*> >("axisList"); |
|
347 | QTest::addColumn<QList<QAbstractAxis*> >("axisList"); | |
352 | QTest::addColumn<int>("axisCount"); |
|
348 | QTest::addColumn<int>("axisCount"); | |
353 |
|
349 | |||
354 | QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2") |
|
350 | QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2") | |
355 | << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QSplineSeries(this) |
|
351 | << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QSplineSeries(this) | |
356 | << new QScatterSeries(this)) |
|
352 | << new QScatterSeries(this)) | |
357 | << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this) |
|
353 | << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this) | |
358 | << new QValueAxis(this)) << 3; |
|
354 | << new QValueAxis(this)) << 3; | |
359 | //TODO: |
|
355 | //TODO: | |
360 | } |
|
356 | } | |
361 |
|
357 | |||
362 | void tst_ChartDataSet::removeAllSeries() |
|
358 | void tst_ChartDataSet::removeAllSeries() | |
363 | { |
|
359 | { | |
364 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
360 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
365 | QFETCH(QList<QAbstractAxis*>, axisList); |
|
361 | QFETCH(QList<QAbstractAxis*>, axisList); | |
366 | QFETCH(int, axisCount); |
|
362 | QFETCH(int, axisCount); | |
367 |
|
363 | |||
368 | foreach (QAbstractSeries* series, seriesList) { |
|
364 | foreach (QAbstractSeries* series, seriesList) { | |
369 | m_dataset->addSeries(series); |
|
365 | m_dataset->addSeries(series); | |
370 | } |
|
366 | } | |
371 |
|
367 | |||
372 | for (int i = 0; i < seriesList.count(); i++) { |
|
368 | for (int i = 0; i < seriesList.count(); i++) { | |
373 | m_dataset->setAxis(seriesList.at(i), axisList.at(i),Qt::Horizontal); |
|
369 | m_dataset->setAxis(seriesList.at(i), axisList.at(i),Qt::Horizontal); | |
374 | } |
|
370 | } | |
375 |
|
371 | |||
376 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
372 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
377 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
373 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
378 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
374 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
379 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
375 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
380 |
|
376 | |||
381 | m_dataset->removeAllSeries(); |
|
377 | m_dataset->removeAllSeries(); | |
382 |
|
378 | |||
383 | TRY_COMPARE(spy0.count(), 0); |
|
379 | TRY_COMPARE(spy0.count(), 0); | |
384 | TRY_COMPARE(spy1.count(), axisCount); |
|
380 | TRY_COMPARE(spy1.count(), axisCount); | |
385 | TRY_COMPARE(spy2.count(), 0); |
|
381 | TRY_COMPARE(spy2.count(), 0); | |
386 | TRY_COMPARE(spy3.count(), seriesList.count()); |
|
382 | TRY_COMPARE(spy3.count(), seriesList.count()); | |
387 | } |
|
383 | } | |
388 |
|
384 | |||
389 |
|
385 | |||
390 | void tst_ChartDataSet::seriesCount_data() |
|
386 | void tst_ChartDataSet::seriesCount_data() | |
391 | { |
|
387 | { | |
392 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); |
|
388 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); | |
393 | QTest::addColumn<int>("seriesCount"); |
|
389 | QTest::addColumn<int>("seriesCount"); | |
394 |
|
390 | |||
395 | QTest::newRow("line,line, line, spline 3") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ) << 3; |
|
391 | QTest::newRow("line,line, line, spline 3") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ) << 3; | |
396 | QTest::newRow("scatter,scatter, line, line 2") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ) << 2; |
|
392 | QTest::newRow("scatter,scatter, line, line 2") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ) << 2; | |
397 | } |
|
393 | } | |
398 |
|
394 | |||
399 | void tst_ChartDataSet::seriesCount() |
|
395 | void tst_ChartDataSet::seriesCount() | |
400 | { |
|
396 | { | |
401 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
397 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
402 | QFETCH(int, seriesCount); |
|
398 | QFETCH(int, seriesCount); | |
403 |
|
399 | |||
404 | foreach (QAbstractSeries* series, seriesList){ |
|
400 | foreach (QAbstractSeries* series, seriesList){ | |
405 | m_dataset->addSeries(series); |
|
401 | m_dataset->addSeries(series); | |
406 | } |
|
402 | } | |
407 |
|
403 | |||
408 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
404 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
409 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
405 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
410 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
406 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
411 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
407 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
412 |
|
408 | |||
413 | QCOMPARE(m_dataset->seriesCount(seriesList.at(0)->type()),seriesCount); |
|
409 | QCOMPARE(m_dataset->seriesCount(seriesList.at(0)->type()),seriesCount); | |
414 | TRY_COMPARE(spy0.count(), 0); |
|
410 | TRY_COMPARE(spy0.count(), 0); | |
415 | TRY_COMPARE(spy1.count(), 0); |
|
411 | TRY_COMPARE(spy1.count(), 0); | |
416 | TRY_COMPARE(spy2.count(), 0); |
|
412 | TRY_COMPARE(spy2.count(), 0); | |
417 | TRY_COMPARE(spy3.count(), 0); |
|
413 | TRY_COMPARE(spy3.count(), 0); | |
418 | } |
|
414 | } | |
419 |
|
415 | |||
420 | void tst_ChartDataSet::seriesIndex_data() |
|
416 | void tst_ChartDataSet::seriesIndex_data() | |
421 | { |
|
417 | { | |
422 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); |
|
418 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); | |
423 |
|
419 | |||
424 | QTest::newRow("line,line, line, spline") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); |
|
420 | QTest::newRow("line,line, line, spline") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); | |
425 | QTest::newRow("scatter,scatter, line, line") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ); |
|
421 | QTest::newRow("scatter,scatter, line, line") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ); | |
426 | } |
|
422 | } | |
427 |
|
423 | |||
428 | void tst_ChartDataSet::seriesIndex() |
|
424 | void tst_ChartDataSet::seriesIndex() | |
429 | { |
|
425 | { | |
430 |
|
426 | |||
431 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
427 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
432 |
|
428 | |||
433 | foreach (QAbstractSeries* series, seriesList) { |
|
429 | foreach (QAbstractSeries* series, seriesList) { | |
434 | m_dataset->addSeries(series); |
|
430 | m_dataset->addSeries(series); | |
435 | } |
|
431 | } | |
436 |
|
432 | |||
437 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
433 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
438 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
434 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
439 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
435 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
440 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
436 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
441 |
|
437 | |||
442 | for (int i = 0; i < seriesList.count(); i++) { |
|
438 | for (int i = 0; i < seriesList.count(); i++) { | |
443 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
439 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
444 | } |
|
440 | } | |
445 |
|
441 | |||
446 | TRY_COMPARE(spy0.count(), 0); |
|
442 | TRY_COMPARE(spy0.count(), 0); | |
447 | TRY_COMPARE(spy1.count(), 0); |
|
443 | TRY_COMPARE(spy1.count(), 0); | |
448 | TRY_COMPARE(spy2.count(), 0); |
|
444 | TRY_COMPARE(spy2.count(), 0); | |
449 | TRY_COMPARE(spy3.count(), 0); |
|
445 | TRY_COMPARE(spy3.count(), 0); | |
450 |
|
446 | |||
451 | foreach (QAbstractSeries* series, seriesList) { |
|
447 | foreach (QAbstractSeries* series, seriesList) { | |
452 | m_dataset->removeSeries(series); |
|
448 | m_dataset->removeSeries(series); | |
453 | } |
|
449 | } | |
454 |
|
450 | |||
455 | for (int i = 0; i < seriesList.count(); i++) { |
|
451 | for (int i = 0; i < seriesList.count(); i++) { | |
456 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); |
|
452 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); | |
457 | } |
|
453 | } | |
458 |
|
454 | |||
459 | foreach (QAbstractSeries* series, seriesList) { |
|
455 | foreach (QAbstractSeries* series, seriesList) { | |
460 | m_dataset->addSeries(series); |
|
456 | m_dataset->addSeries(series); | |
461 | } |
|
457 | } | |
462 |
|
458 | |||
463 | for (int i = 0; i < seriesList.count(); i++) { |
|
459 | for (int i = 0; i < seriesList.count(); i++) { | |
464 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
460 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
465 | } |
|
461 | } | |
466 |
|
462 | |||
467 | m_dataset->removeSeries(seriesList.at(1)); |
|
463 | m_dataset->removeSeries(seriesList.at(1)); | |
468 |
|
464 | |||
469 | for (int i = 0; i < seriesList.count(); i++) { |
|
465 | for (int i = 0; i < seriesList.count(); i++) { | |
470 | if (i != 1) |
|
466 | if (i != 1) | |
471 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
467 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
472 | else |
|
468 | else | |
473 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); |
|
469 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); | |
474 | } |
|
470 | } | |
475 |
|
471 | |||
476 | m_dataset->addSeries(seriesList.at(1)); |
|
472 | m_dataset->addSeries(seriesList.at(1)); | |
477 |
|
473 | |||
478 | for (int i = 0; i < seriesList.count(); i++) { |
|
474 | for (int i = 0; i < seriesList.count(); i++) { | |
479 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
475 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
480 | } |
|
476 | } | |
481 |
|
477 | |||
482 | m_dataset->removeSeries(seriesList.at(2)); |
|
478 | m_dataset->removeSeries(seriesList.at(2)); | |
483 |
|
479 | |||
484 | for (int i = 0; i < seriesList.count(); i++) { |
|
480 | for (int i = 0; i < seriesList.count(); i++) { | |
485 | if (i != 2) |
|
481 | if (i != 2) | |
486 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
482 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
487 | else |
|
483 | else | |
488 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); |
|
484 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); | |
489 | } |
|
485 | } | |
490 |
|
486 | |||
491 | m_dataset->removeSeries(seriesList.at(0)); |
|
487 | m_dataset->removeSeries(seriesList.at(0)); | |
492 |
|
488 | |||
493 | for (int i = 0; i < seriesList.count(); i++) { |
|
489 | for (int i = 0; i < seriesList.count(); i++) { | |
494 | if (i != 2 && i != 0) |
|
490 | if (i != 2 && i != 0) | |
495 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
491 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
496 | else |
|
492 | else | |
497 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); |
|
493 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); | |
498 | } |
|
494 | } | |
499 |
|
495 | |||
500 | m_dataset->addSeries(seriesList.at(2)); |
|
496 | m_dataset->addSeries(seriesList.at(2)); | |
501 | m_dataset->addSeries(seriesList.at(0)); |
|
497 | m_dataset->addSeries(seriesList.at(0)); | |
502 |
|
498 | |||
503 | for (int i = 0; i < seriesList.count(); i++) { |
|
499 | for (int i = 0; i < seriesList.count(); i++) { | |
504 | if (i == 2) |
|
500 | if (i == 2) | |
505 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 0); |
|
501 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 0); | |
506 | else if (i == 0) |
|
502 | else if (i == 0) | |
507 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 2); |
|
503 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 2); | |
508 | else |
|
504 | else | |
509 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); |
|
505 | QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); | |
510 | } |
|
506 | } | |
511 |
|
507 | |||
512 | } |
|
508 | } | |
513 |
|
509 | |||
514 | void tst_ChartDataSet::domain_data() |
|
510 | void tst_ChartDataSet::domain_data() | |
515 | { |
|
511 | { | |
516 | addSeries_data(); |
|
512 | addSeries_data(); | |
517 | } |
|
513 | } | |
518 |
|
514 | |||
519 | void tst_ChartDataSet::domain() |
|
515 | void tst_ChartDataSet::domain() | |
520 | { |
|
516 | { | |
521 | QFETCH(QAbstractSeries*, series); |
|
517 | QFETCH(QAbstractSeries*, series); | |
522 |
|
518 | |||
523 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); |
|
519 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); | |
524 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); |
|
520 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); | |
525 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
521 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
526 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
522 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
527 |
|
523 | |||
528 | m_dataset->addSeries(series); |
|
524 | m_dataset->addSeries(series); | |
529 | QVERIFY(m_dataset->domain(series)); |
|
525 | QVERIFY(m_dataset->domain(series)); | |
530 |
|
526 | |||
531 |
|
527 | |||
532 | TRY_COMPARE(spy0.count(), 0); |
|
528 | TRY_COMPARE(spy0.count(), 0); | |
533 | TRY_COMPARE(spy1.count(), 0); |
|
529 | TRY_COMPARE(spy1.count(), 0); | |
534 | TRY_COMPARE(spy2.count(), 1); |
|
530 | TRY_COMPARE(spy2.count(), 1); | |
535 |
|
531 | |||
536 | QList<QVariant> arguments = spy2.takeFirst(); |
|
532 | QList<QVariant> arguments = spy2.takeFirst(); | |
537 | Domain *domain = (Domain *) arguments.at(1).value<Domain *>(); |
|
533 | Domain *domain = (Domain *) arguments.at(1).value<Domain *>(); | |
538 | QVERIFY(m_dataset->domain(series) == domain); |
|
534 | QVERIFY(m_dataset->domain(series) == domain); | |
539 |
|
535 | |||
540 | TRY_COMPARE(spy3.count(), 0); |
|
536 | TRY_COMPARE(spy3.count(), 0); | |
541 |
|
537 | |||
542 | } |
|
538 | } | |
543 |
|
539 | |||
544 | void tst_ChartDataSet::zoomInDomain_data() |
|
540 | void tst_ChartDataSet::zoomInDomain_data() | |
545 | { |
|
541 | { | |
546 | QTest::addColumn<bool >("sameAxis"); |
|
542 | QTest::addColumn<bool >("sameAxis"); | |
547 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); |
|
543 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); | |
548 | QTest::newRow("sameAxis: line,line, line, spline") << true << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); |
|
544 | QTest::newRow("sameAxis: line,line, line, spline") << true << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); | |
549 | QTest::newRow("separeateAxis: line,line, line, spline") << false << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); |
|
545 | QTest::newRow("separeateAxis: line,line, line, spline") << false << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); | |
550 | } |
|
546 | } | |
551 |
|
547 | |||
552 | void tst_ChartDataSet::zoomInDomain() |
|
548 | void tst_ChartDataSet::zoomInDomain() | |
553 | { |
|
549 | { | |
554 | QFETCH(bool, sameAxis); |
|
550 | QFETCH(bool, sameAxis); | |
555 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
551 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
556 |
|
552 | |||
557 | foreach (QAbstractSeries* series, seriesList) { |
|
553 | foreach (QAbstractSeries* series, seriesList) { | |
558 | m_dataset->addSeries(series); |
|
554 | m_dataset->addSeries(series); | |
559 | } |
|
555 | } | |
560 |
|
556 | |||
561 | if(sameAxis) m_dataset->createDefaultAxes(); |
|
557 | if(sameAxis) m_dataset->createDefaultAxes(); | |
562 |
|
558 | |||
563 | QList<QSignalSpy*> spyList; |
|
559 | QList<QSignalSpy*> spyList; | |
564 |
|
560 | |||
565 | foreach (QAbstractSeries* series, seriesList) { |
|
561 | foreach (QAbstractSeries* series, seriesList) { | |
566 | spyList << new QSignalSpy(m_dataset->domain(series),SIGNAL(updated())); |
|
562 | spyList << new QSignalSpy(m_dataset->domain(series),SIGNAL(updated())); | |
567 | } |
|
563 | } | |
568 |
|
564 | |||
569 | m_dataset->zoomInDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); |
|
565 | m_dataset->zoomInDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); | |
570 |
|
566 | |||
571 | foreach (QSignalSpy* spy, spyList) { |
|
567 | foreach (QSignalSpy* spy, spyList) { | |
572 | TRY_COMPARE(spy->count(), 1); |
|
568 | TRY_COMPARE(spy->count(), 1); | |
573 | } |
|
569 | } | |
574 |
|
570 | |||
575 | qDeleteAll(spyList); |
|
571 | qDeleteAll(spyList); | |
576 | } |
|
572 | } | |
577 |
|
573 | |||
578 |
|
574 | |||
579 |
|
575 | |||
580 | void tst_ChartDataSet::zoomOutDomain_data() |
|
576 | void tst_ChartDataSet::zoomOutDomain_data() | |
581 | { |
|
577 | { | |
582 | zoomInDomain_data(); |
|
578 | zoomInDomain_data(); | |
583 | } |
|
579 | } | |
584 |
|
580 | |||
585 | void tst_ChartDataSet::zoomOutDomain() |
|
581 | void tst_ChartDataSet::zoomOutDomain() | |
586 | { |
|
582 | { | |
587 | QFETCH(bool, sameAxis); |
|
583 | QFETCH(bool, sameAxis); | |
588 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
584 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
589 |
|
585 | |||
590 | foreach (QAbstractSeries* series, seriesList) { |
|
586 | foreach (QAbstractSeries* series, seriesList) { | |
591 | m_dataset->addSeries(series); |
|
587 | m_dataset->addSeries(series); | |
592 | } |
|
588 | } | |
593 |
|
589 | |||
594 | if (sameAxis) |
|
590 | if (sameAxis) | |
595 | m_dataset->createDefaultAxes(); |
|
591 | m_dataset->createDefaultAxes(); | |
596 |
|
592 | |||
597 | QList<QSignalSpy*> spyList; |
|
593 | QList<QSignalSpy*> spyList; | |
598 |
|
594 | |||
599 | foreach (QAbstractSeries* series, seriesList) { |
|
595 | foreach (QAbstractSeries* series, seriesList) { | |
600 | spyList << new QSignalSpy(m_dataset->domain(series), SIGNAL(updated())); |
|
596 | spyList << new QSignalSpy(m_dataset->domain(series), SIGNAL(updated())); | |
601 | } |
|
597 | } | |
602 |
|
598 | |||
603 | m_dataset->zoomOutDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); |
|
599 | m_dataset->zoomOutDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); | |
604 |
|
600 | |||
605 | foreach (QSignalSpy* spy, spyList) { |
|
601 | foreach (QSignalSpy* spy, spyList) { | |
606 | TRY_COMPARE(spy->count(), 1); |
|
602 | TRY_COMPARE(spy->count(), 1); | |
607 | } |
|
603 | } | |
608 |
|
604 | |||
609 | qDeleteAll (spyList); |
|
605 | qDeleteAll (spyList); | |
610 | } |
|
606 | } | |
611 |
|
607 | |||
612 | void tst_ChartDataSet::scrollDomain_data() |
|
608 | void tst_ChartDataSet::scrollDomain_data() | |
613 | { |
|
609 | { | |
614 | zoomInDomain_data(); |
|
610 | zoomInDomain_data(); | |
615 | } |
|
611 | } | |
616 |
|
612 | |||
617 | void tst_ChartDataSet::scrollDomain() |
|
613 | void tst_ChartDataSet::scrollDomain() | |
618 | { |
|
614 | { | |
619 | QFETCH(bool, sameAxis); |
|
615 | QFETCH(bool, sameAxis); | |
620 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
616 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
621 |
|
617 | |||
622 | foreach (QAbstractSeries* series, seriesList) { |
|
618 | foreach (QAbstractSeries* series, seriesList) { | |
623 | m_dataset->addSeries(series); |
|
619 | m_dataset->addSeries(series); | |
624 | } |
|
620 | } | |
625 |
|
621 | |||
626 | if (sameAxis) |
|
622 | if (sameAxis) | |
627 | m_dataset->createDefaultAxes(); |
|
623 | m_dataset->createDefaultAxes(); | |
628 |
|
624 | |||
629 | QList<QSignalSpy*> spyList; |
|
625 | QList<QSignalSpy*> spyList; | |
630 |
|
626 | |||
631 | foreach (QAbstractSeries* series, seriesList) { |
|
627 | foreach (QAbstractSeries* series, seriesList) { | |
632 | spyList |
|
628 | spyList | |
633 | << new QSignalSpy(m_dataset->domain(series), |
|
629 | << new QSignalSpy(m_dataset->domain(series), | |
634 | SIGNAL(updated())); |
|
630 | SIGNAL(updated())); | |
635 | } |
|
631 | } | |
636 |
|
632 | |||
637 | m_dataset->scrollDomain(10, 10, QSize(1000, 1000)); |
|
633 | m_dataset->scrollDomain(10, 10, QSize(1000, 1000)); | |
638 |
|
634 | |||
639 | foreach (QSignalSpy* spy, spyList) { |
|
635 | foreach (QSignalSpy* spy, spyList) { | |
640 | TRY_COMPARE(spy->count(), 1); |
|
636 | TRY_COMPARE(spy->count(), 1); | |
641 | } |
|
637 | } | |
642 |
|
638 | |||
643 | qDeleteAll(spyList); |
|
639 | qDeleteAll(spyList); | |
644 | } |
|
640 | } | |
645 |
|
641 | |||
646 | QTEST_MAIN(tst_ChartDataSet) |
|
642 | QTEST_MAIN(tst_ChartDataSet) | |
647 | #include "tst_chartdataset.moc" |
|
643 | #include "tst_chartdataset.moc" | |
648 | #endif |
|
644 | #endif |
@@ -1,707 +1,703 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 | #ifndef BUILD_PRIVATE_UNIT_TESTS |
|
20 | #ifndef BUILD_PRIVATE_UNIT_TESTS | |
21 |
|
21 | |||
22 | #include <QtTest/QtTest> |
|
22 | #include <QtTest/QtTest> | |
23 |
|
23 | |||
24 | class tst_Domain: public QObject { |
|
24 | class tst_Domain: public QObject { | |
25 |
|
25 | |||
26 | Q_OBJECT |
|
26 | Q_OBJECT | |
27 |
|
27 | |||
28 | private Q_SLOTS: |
|
28 | private Q_SLOTS: | |
29 | void skip(); |
|
29 | void skip(); | |
30 |
|
30 | |||
31 | }; |
|
31 | }; | |
32 |
|
32 | |||
33 | void tst_Domain::skip() |
|
33 | void tst_Domain::skip() | |
34 | { |
|
34 | { | |
35 | #ifdef QT5_QUICK_1 |
|
|||
36 | QSKIP("This test requires the debug version of library"); |
|
|||
37 | #else |
|
|||
38 | QSKIP("This test requires the debug version of library", SkipAll); |
|
35 | QSKIP("This test requires the debug version of library", SkipAll); | |
39 | #endif |
|
|||
40 | } |
|
36 | } | |
41 |
|
37 | |||
42 | QTEST_MAIN(tst_Domain) |
|
38 | QTEST_MAIN(tst_Domain) | |
43 | #include "tst_domain.moc" |
|
39 | #include "tst_domain.moc" | |
44 |
|
40 | |||
45 | #else |
|
41 | #else | |
46 |
|
42 | |||
47 | #include <QtTest/QtTest> |
|
43 | #include <QtTest/QtTest> | |
48 | #include <private/domain_p.h> |
|
44 | #include <private/domain_p.h> | |
49 | #include <private/qabstractaxis_p.h> |
|
45 | #include <private/qabstractaxis_p.h> | |
50 | #include <tst_definitions.h> |
|
46 | #include <tst_definitions.h> | |
51 |
|
47 | |||
52 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
48 | QTCOMMERCIALCHART_USE_NAMESPACE | |
53 |
|
49 | |||
54 | Q_DECLARE_METATYPE(Domain*) |
|
50 | Q_DECLARE_METATYPE(Domain*) | |
55 | Q_DECLARE_METATYPE(QSizeF) |
|
51 | Q_DECLARE_METATYPE(QSizeF) | |
56 |
|
52 | |||
57 |
|
53 | |||
58 | class AxisMock: public QAbstractAxisPrivate |
|
54 | class AxisMock: public QAbstractAxisPrivate | |
59 | { |
|
55 | { | |
60 | Q_OBJECT |
|
56 | Q_OBJECT | |
61 | public: |
|
57 | public: | |
62 | AxisMock(Qt::Orientation orientation):QAbstractAxisPrivate(0){ setOrientation(orientation);}; |
|
58 | AxisMock(Qt::Orientation orientation):QAbstractAxisPrivate(0){ setOrientation(orientation);}; | |
63 | ChartAxis* createGraphics(ChartPresenter* presenter) |
|
59 | ChartAxis* createGraphics(ChartPresenter* presenter) | |
64 | { |
|
60 | { | |
65 | Q_UNUSED(presenter); |
|
61 | Q_UNUSED(presenter); | |
66 | return 0; |
|
62 | return 0; | |
67 | }; |
|
63 | }; | |
68 | void intializeDomain(Domain* domain) |
|
64 | void intializeDomain(Domain* domain) | |
69 | { |
|
65 | { | |
70 | Q_UNUSED(domain); |
|
66 | Q_UNUSED(domain); | |
71 | }; |
|
67 | }; | |
72 | void setMin(const QVariant &min) |
|
68 | void setMin(const QVariant &min) | |
73 | { |
|
69 | { | |
74 | Q_UNUSED(min); |
|
70 | Q_UNUSED(min); | |
75 | } |
|
71 | } | |
76 | qreal min() { return m_min;} |
|
72 | qreal min() { return m_min;} | |
77 | void setMax(const QVariant &max) |
|
73 | void setMax(const QVariant &max) | |
78 | { |
|
74 | { | |
79 | Q_UNUSED(max); |
|
75 | Q_UNUSED(max); | |
80 | } |
|
76 | } | |
81 | qreal max() { return m_max; } |
|
77 | qreal max() { return m_max; } | |
82 | void setRange(const QVariant &min, const QVariant &max) |
|
78 | void setRange(const QVariant &min, const QVariant &max) | |
83 | { |
|
79 | { | |
84 | Q_UNUSED(min); |
|
80 | Q_UNUSED(min); | |
85 | Q_UNUSED(max); |
|
81 | Q_UNUSED(max); | |
86 | }; |
|
82 | }; | |
87 |
|
83 | |||
88 | int count () const { return m_count; } |
|
84 | int count () const { return m_count; } | |
89 |
|
85 | |||
90 | void handleDomainUpdated(){}; |
|
86 | void handleDomainUpdated(){}; | |
91 | public: |
|
87 | public: | |
92 | int m_count; |
|
88 | int m_count; | |
93 | qreal m_min; |
|
89 | qreal m_min; | |
94 | qreal m_max; |
|
90 | qreal m_max; | |
95 | }; |
|
91 | }; | |
96 |
|
92 | |||
97 | class tst_Domain: public QObject |
|
93 | class tst_Domain: public QObject | |
98 | { |
|
94 | { | |
99 | Q_OBJECT |
|
95 | Q_OBJECT | |
100 |
|
96 | |||
101 | public Q_SLOTS: |
|
97 | public Q_SLOTS: | |
102 | void initTestCase(); |
|
98 | void initTestCase(); | |
103 | void cleanupTestCase(); |
|
99 | void cleanupTestCase(); | |
104 | void init(); |
|
100 | void init(); | |
105 | void cleanup(); |
|
101 | void cleanup(); | |
106 |
|
102 | |||
107 | private Q_SLOTS: |
|
103 | private Q_SLOTS: | |
108 | void domain(); |
|
104 | void domain(); | |
109 | void handleAxisUpdatedX_data(); |
|
105 | void handleAxisUpdatedX_data(); | |
110 | void handleAxisUpdatedX(); |
|
106 | void handleAxisUpdatedX(); | |
111 | void handleAxisUpdatedY_data(); |
|
107 | void handleAxisUpdatedY_data(); | |
112 | void handleAxisUpdatedY(); |
|
108 | void handleAxisUpdatedY(); | |
113 | void isEmpty_data(); |
|
109 | void isEmpty_data(); | |
114 | void isEmpty(); |
|
110 | void isEmpty(); | |
115 | void maxX_data(); |
|
111 | void maxX_data(); | |
116 | void maxX(); |
|
112 | void maxX(); | |
117 | void maxY_data(); |
|
113 | void maxY_data(); | |
118 | void maxY(); |
|
114 | void maxY(); | |
119 | void minX_data(); |
|
115 | void minX_data(); | |
120 | void minX(); |
|
116 | void minX(); | |
121 | void minY_data(); |
|
117 | void minY_data(); | |
122 | void minY(); |
|
118 | void minY(); | |
123 | void operatorEquals_data(); |
|
119 | void operatorEquals_data(); | |
124 | void operatorEquals(); |
|
120 | void operatorEquals(); | |
125 | void setRange_data(); |
|
121 | void setRange_data(); | |
126 | void setRange(); |
|
122 | void setRange(); | |
127 | void setRangeX_data(); |
|
123 | void setRangeX_data(); | |
128 | void setRangeX(); |
|
124 | void setRangeX(); | |
129 | void setRangeY_data(); |
|
125 | void setRangeY_data(); | |
130 | void setRangeY(); |
|
126 | void setRangeY(); | |
131 | void spanX_data(); |
|
127 | void spanX_data(); | |
132 | void spanX(); |
|
128 | void spanX(); | |
133 | void spanY_data(); |
|
129 | void spanY_data(); | |
134 | void spanY(); |
|
130 | void spanY(); | |
135 | void zoom_data(); |
|
131 | void zoom_data(); | |
136 | void zoom(); |
|
132 | void zoom(); | |
137 | void move_data(); |
|
133 | void move_data(); | |
138 | void move(); |
|
134 | void move(); | |
139 | }; |
|
135 | }; | |
140 |
|
136 | |||
141 | void tst_Domain::initTestCase() |
|
137 | void tst_Domain::initTestCase() | |
142 | { |
|
138 | { | |
143 | } |
|
139 | } | |
144 |
|
140 | |||
145 | void tst_Domain::cleanupTestCase() |
|
141 | void tst_Domain::cleanupTestCase() | |
146 | { |
|
142 | { | |
147 | } |
|
143 | } | |
148 |
|
144 | |||
149 | void tst_Domain::init() |
|
145 | void tst_Domain::init() | |
150 | { |
|
146 | { | |
151 | } |
|
147 | } | |
152 |
|
148 | |||
153 | void tst_Domain::cleanup() |
|
149 | void tst_Domain::cleanup() | |
154 | { |
|
150 | { | |
155 | } |
|
151 | } | |
156 |
|
152 | |||
157 | void tst_Domain::domain() |
|
153 | void tst_Domain::domain() | |
158 | { |
|
154 | { | |
159 | Domain domain; |
|
155 | Domain domain; | |
160 |
|
156 | |||
161 | QCOMPARE(domain.isEmpty(), true); |
|
157 | QCOMPARE(domain.isEmpty(), true); | |
162 | QCOMPARE(domain.maxX(), 0.0); |
|
158 | QCOMPARE(domain.maxX(), 0.0); | |
163 | QCOMPARE(domain.maxY(), 0.0); |
|
159 | QCOMPARE(domain.maxY(), 0.0); | |
164 | QCOMPARE(domain.minX(), 0.0); |
|
160 | QCOMPARE(domain.minX(), 0.0); | |
165 | QCOMPARE(domain.minY(), 0.0); |
|
161 | QCOMPARE(domain.minY(), 0.0); | |
166 | } |
|
162 | } | |
167 |
|
163 | |||
168 | void tst_Domain::handleAxisUpdatedX_data() |
|
164 | void tst_Domain::handleAxisUpdatedX_data() | |
169 | { |
|
165 | { | |
170 | QTest::addColumn<qreal>("min"); |
|
166 | QTest::addColumn<qreal>("min"); | |
171 | QTest::addColumn<qreal>("max"); |
|
167 | QTest::addColumn<qreal>("max"); | |
172 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
168 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
173 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
169 | QTest::newRow("0 1") << 0.0 << 1.0; | |
174 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
170 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
175 | } |
|
171 | } | |
176 |
|
172 | |||
177 | void tst_Domain::handleAxisUpdatedX() |
|
173 | void tst_Domain::handleAxisUpdatedX() | |
178 | { |
|
174 | { | |
179 | QFETCH(qreal, min); |
|
175 | QFETCH(qreal, min); | |
180 | QFETCH(qreal, max); |
|
176 | QFETCH(qreal, max); | |
181 |
|
177 | |||
182 | Domain domain; |
|
178 | Domain domain; | |
183 |
|
179 | |||
184 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
180 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
185 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
181 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
186 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
182 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
187 |
|
183 | |||
188 | AxisMock axis(Qt::Horizontal); |
|
184 | AxisMock axis(Qt::Horizontal); | |
189 | QObject::connect(&axis,SIGNAL(updated()),&domain,SLOT(handleAxisUpdated())); |
|
185 | QObject::connect(&axis,SIGNAL(updated()),&domain,SLOT(handleAxisUpdated())); | |
190 | axis.m_min=min; |
|
186 | axis.m_min=min; | |
191 | axis.m_max=max; |
|
187 | axis.m_max=max; | |
192 | axis.emitUpdated(); |
|
188 | axis.emitUpdated(); | |
193 |
|
189 | |||
194 | QVERIFY(qFuzzyCompare(domain.minX(), min)); |
|
190 | QVERIFY(qFuzzyCompare(domain.minX(), min)); | |
195 | QVERIFY(qFuzzyCompare(domain.maxX(), max)); |
|
191 | QVERIFY(qFuzzyCompare(domain.maxX(), max)); | |
196 |
|
192 | |||
197 | QList<QVariant> arg1 = spy1.first(); |
|
193 | QList<QVariant> arg1 = spy1.first(); | |
198 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); |
|
194 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); | |
199 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); |
|
195 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); | |
200 |
|
196 | |||
201 | TRY_COMPARE(spy0.count(), 1); |
|
197 | TRY_COMPARE(spy0.count(), 1); | |
202 | TRY_COMPARE(spy1.count(), 1); |
|
198 | TRY_COMPARE(spy1.count(), 1); | |
203 | TRY_COMPARE(spy2.count(), 0); |
|
199 | TRY_COMPARE(spy2.count(), 0); | |
204 |
|
200 | |||
205 | } |
|
201 | } | |
206 |
|
202 | |||
207 | void tst_Domain::handleAxisUpdatedY_data() |
|
203 | void tst_Domain::handleAxisUpdatedY_data() | |
208 | { |
|
204 | { | |
209 | QTest::addColumn<qreal>("min"); |
|
205 | QTest::addColumn<qreal>("min"); | |
210 | QTest::addColumn<qreal>("max"); |
|
206 | QTest::addColumn<qreal>("max"); | |
211 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
207 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
212 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
208 | QTest::newRow("0 1") << 0.0 << 1.0; | |
213 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
209 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
214 | } |
|
210 | } | |
215 |
|
211 | |||
216 | void tst_Domain::handleAxisUpdatedY() |
|
212 | void tst_Domain::handleAxisUpdatedY() | |
217 | { |
|
213 | { | |
218 | QFETCH(qreal, min); |
|
214 | QFETCH(qreal, min); | |
219 | QFETCH(qreal, max); |
|
215 | QFETCH(qreal, max); | |
220 |
|
216 | |||
221 | Domain domain; |
|
217 | Domain domain; | |
222 |
|
218 | |||
223 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
219 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
224 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
220 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
225 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
221 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
226 |
|
222 | |||
227 | AxisMock axis(Qt::Vertical); |
|
223 | AxisMock axis(Qt::Vertical); | |
228 | QObject::connect(&axis, SIGNAL(updated()), &domain, SLOT(handleAxisUpdated())); |
|
224 | QObject::connect(&axis, SIGNAL(updated()), &domain, SLOT(handleAxisUpdated())); | |
229 | axis.m_min = min; |
|
225 | axis.m_min = min; | |
230 | axis.m_max = max; |
|
226 | axis.m_max = max; | |
231 | axis.emitUpdated(); |
|
227 | axis.emitUpdated(); | |
232 |
|
228 | |||
233 | QVERIFY(qFuzzyCompare(domain.minY(), min)); |
|
229 | QVERIFY(qFuzzyCompare(domain.minY(), min)); | |
234 | QVERIFY(qFuzzyCompare(domain.maxY(), max)); |
|
230 | QVERIFY(qFuzzyCompare(domain.maxY(), max)); | |
235 |
|
231 | |||
236 | QList<QVariant> arg1 = spy2.first(); |
|
232 | QList<QVariant> arg1 = spy2.first(); | |
237 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); |
|
233 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); | |
238 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); |
|
234 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); | |
239 |
|
235 | |||
240 | TRY_COMPARE(spy0.count(), 1); |
|
236 | TRY_COMPARE(spy0.count(), 1); | |
241 | TRY_COMPARE(spy1.count(), 0); |
|
237 | TRY_COMPARE(spy1.count(), 0); | |
242 | TRY_COMPARE(spy2.count(), 1); |
|
238 | TRY_COMPARE(spy2.count(), 1); | |
243 | } |
|
239 | } | |
244 |
|
240 | |||
245 | void tst_Domain::isEmpty_data() |
|
241 | void tst_Domain::isEmpty_data() | |
246 | { |
|
242 | { | |
247 | QTest::addColumn<qreal>("minX"); |
|
243 | QTest::addColumn<qreal>("minX"); | |
248 | QTest::addColumn<qreal>("maxX"); |
|
244 | QTest::addColumn<qreal>("maxX"); | |
249 | QTest::addColumn<qreal>("minY"); |
|
245 | QTest::addColumn<qreal>("minY"); | |
250 | QTest::addColumn<qreal>("maxY"); |
|
246 | QTest::addColumn<qreal>("maxY"); | |
251 | QTest::addColumn<bool>("isEmpty"); |
|
247 | QTest::addColumn<bool>("isEmpty"); | |
252 | QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; |
|
248 | QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; | |
253 | QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; |
|
249 | QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; | |
254 | QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; |
|
250 | QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; | |
255 | QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; |
|
251 | QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; | |
256 | } |
|
252 | } | |
257 |
|
253 | |||
258 | void tst_Domain::isEmpty() |
|
254 | void tst_Domain::isEmpty() | |
259 | { |
|
255 | { | |
260 | QFETCH(qreal, minX); |
|
256 | QFETCH(qreal, minX); | |
261 | QFETCH(qreal, maxX); |
|
257 | QFETCH(qreal, maxX); | |
262 | QFETCH(qreal, minY); |
|
258 | QFETCH(qreal, minY); | |
263 | QFETCH(qreal, maxY); |
|
259 | QFETCH(qreal, maxY); | |
264 | QFETCH(bool, isEmpty); |
|
260 | QFETCH(bool, isEmpty); | |
265 |
|
261 | |||
266 | Domain domain; |
|
262 | Domain domain; | |
267 | domain.setRange(minX, maxX, minY, maxY); |
|
263 | domain.setRange(minX, maxX, minY, maxY); | |
268 | QCOMPARE(domain.isEmpty(), isEmpty); |
|
264 | QCOMPARE(domain.isEmpty(), isEmpty); | |
269 | } |
|
265 | } | |
270 |
|
266 | |||
271 | void tst_Domain::maxX_data() |
|
267 | void tst_Domain::maxX_data() | |
272 | { |
|
268 | { | |
273 | QTest::addColumn<qreal>("maxX1"); |
|
269 | QTest::addColumn<qreal>("maxX1"); | |
274 | QTest::addColumn<qreal>("maxX2"); |
|
270 | QTest::addColumn<qreal>("maxX2"); | |
275 | QTest::addColumn<int>("count"); |
|
271 | QTest::addColumn<int>("count"); | |
276 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
272 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
277 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
273 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
278 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
274 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
279 | } |
|
275 | } | |
280 |
|
276 | |||
281 | void tst_Domain::maxX() |
|
277 | void tst_Domain::maxX() | |
282 | { |
|
278 | { | |
283 | QFETCH(qreal, maxX1); |
|
279 | QFETCH(qreal, maxX1); | |
284 | QFETCH(qreal, maxX2); |
|
280 | QFETCH(qreal, maxX2); | |
285 | QFETCH(int, count); |
|
281 | QFETCH(int, count); | |
286 |
|
282 | |||
287 | Domain domain; |
|
283 | Domain domain; | |
288 |
|
284 | |||
289 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
285 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
290 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
286 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
291 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
287 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
292 |
|
288 | |||
293 | domain.setMaxX(maxX1); |
|
289 | domain.setMaxX(maxX1); | |
294 | QCOMPARE(domain.maxX(), maxX1); |
|
290 | QCOMPARE(domain.maxX(), maxX1); | |
295 | domain.setMaxX(maxX2); |
|
291 | domain.setMaxX(maxX2); | |
296 | QCOMPARE(domain.maxX(), maxX2); |
|
292 | QCOMPARE(domain.maxX(), maxX2); | |
297 |
|
293 | |||
298 | TRY_COMPARE(spy0.count(), count); |
|
294 | TRY_COMPARE(spy0.count(), count); | |
299 | TRY_COMPARE(spy1.count(), count); |
|
295 | TRY_COMPARE(spy1.count(), count); | |
300 | TRY_COMPARE(spy2.count(), 0); |
|
296 | TRY_COMPARE(spy2.count(), 0); | |
301 |
|
297 | |||
302 | } |
|
298 | } | |
303 |
|
299 | |||
304 | void tst_Domain::maxY_data() |
|
300 | void tst_Domain::maxY_data() | |
305 | { |
|
301 | { | |
306 | QTest::addColumn<qreal>("maxY1"); |
|
302 | QTest::addColumn<qreal>("maxY1"); | |
307 | QTest::addColumn<qreal>("maxY2"); |
|
303 | QTest::addColumn<qreal>("maxY2"); | |
308 | QTest::addColumn<int>("count"); |
|
304 | QTest::addColumn<int>("count"); | |
309 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
305 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
310 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
306 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
311 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
307 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
312 | } |
|
308 | } | |
313 |
|
309 | |||
314 | void tst_Domain::maxY() |
|
310 | void tst_Domain::maxY() | |
315 | { |
|
311 | { | |
316 | QFETCH(qreal, maxY1); |
|
312 | QFETCH(qreal, maxY1); | |
317 | QFETCH(qreal, maxY2); |
|
313 | QFETCH(qreal, maxY2); | |
318 | QFETCH(int, count); |
|
314 | QFETCH(int, count); | |
319 |
|
315 | |||
320 | Domain domain; |
|
316 | Domain domain; | |
321 |
|
317 | |||
322 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
318 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
323 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
319 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
324 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
320 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
325 |
|
321 | |||
326 | domain.setMaxY(maxY1); |
|
322 | domain.setMaxY(maxY1); | |
327 | QCOMPARE(domain.maxY(), maxY1); |
|
323 | QCOMPARE(domain.maxY(), maxY1); | |
328 | domain.setMaxY(maxY2); |
|
324 | domain.setMaxY(maxY2); | |
329 | QCOMPARE(domain.maxY(), maxY2); |
|
325 | QCOMPARE(domain.maxY(), maxY2); | |
330 |
|
326 | |||
331 | TRY_COMPARE(spy0.count(), count); |
|
327 | TRY_COMPARE(spy0.count(), count); | |
332 | TRY_COMPARE(spy1.count(), 0); |
|
328 | TRY_COMPARE(spy1.count(), 0); | |
333 | TRY_COMPARE(spy2.count(), count); |
|
329 | TRY_COMPARE(spy2.count(), count); | |
334 | } |
|
330 | } | |
335 |
|
331 | |||
336 | void tst_Domain::minX_data() |
|
332 | void tst_Domain::minX_data() | |
337 | { |
|
333 | { | |
338 | QTest::addColumn<qreal>("minX1"); |
|
334 | QTest::addColumn<qreal>("minX1"); | |
339 | QTest::addColumn<qreal>("minX2"); |
|
335 | QTest::addColumn<qreal>("minX2"); | |
340 | QTest::addColumn<int>("count"); |
|
336 | QTest::addColumn<int>("count"); | |
341 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
337 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
342 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
338 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
343 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
339 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
344 | } |
|
340 | } | |
345 |
|
341 | |||
346 | void tst_Domain::minX() |
|
342 | void tst_Domain::minX() | |
347 | { |
|
343 | { | |
348 | QFETCH(qreal, minX1); |
|
344 | QFETCH(qreal, minX1); | |
349 | QFETCH(qreal, minX2); |
|
345 | QFETCH(qreal, minX2); | |
350 | QFETCH(int, count); |
|
346 | QFETCH(int, count); | |
351 |
|
347 | |||
352 | Domain domain; |
|
348 | Domain domain; | |
353 |
|
349 | |||
354 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
350 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
355 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
351 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
356 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
352 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
357 |
|
353 | |||
358 | domain.setMinX(minX1); |
|
354 | domain.setMinX(minX1); | |
359 | QCOMPARE(domain.minX(), minX1); |
|
355 | QCOMPARE(domain.minX(), minX1); | |
360 | domain.setMinX(minX2); |
|
356 | domain.setMinX(minX2); | |
361 | QCOMPARE(domain.minX(), minX2); |
|
357 | QCOMPARE(domain.minX(), minX2); | |
362 |
|
358 | |||
363 | TRY_COMPARE(spy0.count(), count); |
|
359 | TRY_COMPARE(spy0.count(), count); | |
364 | TRY_COMPARE(spy1.count(), count); |
|
360 | TRY_COMPARE(spy1.count(), count); | |
365 | TRY_COMPARE(spy2.count(), 0); |
|
361 | TRY_COMPARE(spy2.count(), 0); | |
366 | } |
|
362 | } | |
367 |
|
363 | |||
368 | void tst_Domain::minY_data() |
|
364 | void tst_Domain::minY_data() | |
369 | { |
|
365 | { | |
370 | QTest::addColumn<qreal>("minY1"); |
|
366 | QTest::addColumn<qreal>("minY1"); | |
371 | QTest::addColumn<qreal>("minY2"); |
|
367 | QTest::addColumn<qreal>("minY2"); | |
372 | QTest::addColumn<int>("count"); |
|
368 | QTest::addColumn<int>("count"); | |
373 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
369 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
374 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
370 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
375 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
371 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
376 | } |
|
372 | } | |
377 |
|
373 | |||
378 | void tst_Domain::minY() |
|
374 | void tst_Domain::minY() | |
379 | { |
|
375 | { | |
380 | QFETCH(qreal, minY1); |
|
376 | QFETCH(qreal, minY1); | |
381 | QFETCH(qreal, minY2); |
|
377 | QFETCH(qreal, minY2); | |
382 | QFETCH(int, count); |
|
378 | QFETCH(int, count); | |
383 |
|
379 | |||
384 | Domain domain; |
|
380 | Domain domain; | |
385 |
|
381 | |||
386 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
382 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
387 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
383 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
388 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
384 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
389 |
|
385 | |||
390 | domain.setMinY(minY1); |
|
386 | domain.setMinY(minY1); | |
391 | QCOMPARE(domain.minY(), minY1); |
|
387 | QCOMPARE(domain.minY(), minY1); | |
392 | domain.setMinY(minY2); |
|
388 | domain.setMinY(minY2); | |
393 | QCOMPARE(domain.minY(), minY2); |
|
389 | QCOMPARE(domain.minY(), minY2); | |
394 |
|
390 | |||
395 | TRY_COMPARE(spy0.count(), count); |
|
391 | TRY_COMPARE(spy0.count(), count); | |
396 | TRY_COMPARE(spy1.count(), 0); |
|
392 | TRY_COMPARE(spy1.count(), 0); | |
397 | TRY_COMPARE(spy2.count(), count); |
|
393 | TRY_COMPARE(spy2.count(), count); | |
398 | } |
|
394 | } | |
399 |
|
395 | |||
400 | void tst_Domain::operatorEquals_data() |
|
396 | void tst_Domain::operatorEquals_data() | |
401 | { |
|
397 | { | |
402 |
|
398 | |||
403 | QTest::addColumn<Domain*>("domain1"); |
|
399 | QTest::addColumn<Domain*>("domain1"); | |
404 | QTest::addColumn<Domain*>("domain2"); |
|
400 | QTest::addColumn<Domain*>("domain2"); | |
405 | QTest::addColumn<bool>("equals"); |
|
401 | QTest::addColumn<bool>("equals"); | |
406 | QTest::addColumn<bool>("notEquals"); |
|
402 | QTest::addColumn<bool>("notEquals"); | |
407 | Domain* a; |
|
403 | Domain* a; | |
408 | Domain* b; |
|
404 | Domain* b; | |
409 | a = new Domain(); |
|
405 | a = new Domain(); | |
410 | a->setRange(0, 100, 0, 100); |
|
406 | a->setRange(0, 100, 0, 100); | |
411 | b = new Domain(); |
|
407 | b = new Domain(); | |
412 | b->setRange(0, 100, 0, 100); |
|
408 | b->setRange(0, 100, 0, 100); | |
413 | QTest::newRow("equals") << a << b << true << false; |
|
409 | QTest::newRow("equals") << a << b << true << false; | |
414 | a = new Domain(); |
|
410 | a = new Domain(); | |
415 | a->setRange(0, 100, 0, 100); |
|
411 | a->setRange(0, 100, 0, 100); | |
416 | b = new Domain(); |
|
412 | b = new Domain(); | |
417 | b->setRange(0, 100, 0, 1); |
|
413 | b->setRange(0, 100, 0, 1); | |
418 | QTest::newRow("equals") << a << b << false << true; |
|
414 | QTest::newRow("equals") << a << b << false << true; | |
419 | a = new Domain(); |
|
415 | a = new Domain(); | |
420 | a->setRange(0, 100, 0, 100); |
|
416 | a->setRange(0, 100, 0, 100); | |
421 | b = new Domain(); |
|
417 | b = new Domain(); | |
422 | b->setRange(0, 1, 0, 100); |
|
418 | b->setRange(0, 1, 0, 100); | |
423 | QTest::newRow("equals") << a << b << false << true; |
|
419 | QTest::newRow("equals") << a << b << false << true; | |
424 |
|
420 | |||
425 | } |
|
421 | } | |
426 |
|
422 | |||
427 | void tst_Domain::operatorEquals() |
|
423 | void tst_Domain::operatorEquals() | |
428 | { |
|
424 | { | |
429 | QFETCH(Domain*, domain1); |
|
425 | QFETCH(Domain*, domain1); | |
430 | QFETCH(Domain*, domain2); |
|
426 | QFETCH(Domain*, domain2); | |
431 | QFETCH(bool, equals); |
|
427 | QFETCH(bool, equals); | |
432 | QFETCH(bool, notEquals); |
|
428 | QFETCH(bool, notEquals); | |
433 |
|
429 | |||
434 | Domain domain; |
|
430 | Domain domain; | |
435 |
|
431 | |||
436 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
432 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
437 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
433 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
438 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
434 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
439 |
|
435 | |||
440 | QCOMPARE(*domain1==*domain2, equals); |
|
436 | QCOMPARE(*domain1==*domain2, equals); | |
441 | QCOMPARE(*domain1!=*domain2, notEquals); |
|
437 | QCOMPARE(*domain1!=*domain2, notEquals); | |
442 |
|
438 | |||
443 | TRY_COMPARE(spy0.count(), 0); |
|
439 | TRY_COMPARE(spy0.count(), 0); | |
444 | TRY_COMPARE(spy1.count(), 0); |
|
440 | TRY_COMPARE(spy1.count(), 0); | |
445 | TRY_COMPARE(spy2.count(), 0); |
|
441 | TRY_COMPARE(spy2.count(), 0); | |
446 | } |
|
442 | } | |
447 |
|
443 | |||
448 | void tst_Domain::setRange_data() |
|
444 | void tst_Domain::setRange_data() | |
449 | { |
|
445 | { | |
450 | QTest::addColumn<qreal>("minX"); |
|
446 | QTest::addColumn<qreal>("minX"); | |
451 | QTest::addColumn<qreal>("maxX"); |
|
447 | QTest::addColumn<qreal>("maxX"); | |
452 | QTest::addColumn<qreal>("minY"); |
|
448 | QTest::addColumn<qreal>("minY"); | |
453 | QTest::addColumn<qreal>("maxY"); |
|
449 | QTest::addColumn<qreal>("maxY"); | |
454 | QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; |
|
450 | QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; | |
455 | QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; |
|
451 | QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; | |
456 | QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; |
|
452 | QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; | |
457 | } |
|
453 | } | |
458 |
|
454 | |||
459 | void tst_Domain::setRange() |
|
455 | void tst_Domain::setRange() | |
460 | { |
|
456 | { | |
461 | QFETCH(qreal, minX); |
|
457 | QFETCH(qreal, minX); | |
462 | QFETCH(qreal, maxX); |
|
458 | QFETCH(qreal, maxX); | |
463 | QFETCH(qreal, minY); |
|
459 | QFETCH(qreal, minY); | |
464 | QFETCH(qreal, maxY); |
|
460 | QFETCH(qreal, maxY); | |
465 |
|
461 | |||
466 | Domain domain; |
|
462 | Domain domain; | |
467 |
|
463 | |||
468 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
464 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
469 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
465 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
470 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
466 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
471 |
|
467 | |||
472 | domain.setRange(minX, maxX, minY, maxY); |
|
468 | domain.setRange(minX, maxX, minY, maxY); | |
473 |
|
469 | |||
474 | QCOMPARE(domain.minX(), minX); |
|
470 | QCOMPARE(domain.minX(), minX); | |
475 | QCOMPARE(domain.maxX(), maxX); |
|
471 | QCOMPARE(domain.maxX(), maxX); | |
476 | QCOMPARE(domain.minY(), minY); |
|
472 | QCOMPARE(domain.minY(), minY); | |
477 | QCOMPARE(domain.maxY(), maxY); |
|
473 | QCOMPARE(domain.maxY(), maxY); | |
478 |
|
474 | |||
479 | TRY_COMPARE(spy0.count(), 1); |
|
475 | TRY_COMPARE(spy0.count(), 1); | |
480 | TRY_COMPARE(spy1.count(), 1); |
|
476 | TRY_COMPARE(spy1.count(), 1); | |
481 | TRY_COMPARE(spy2.count(), 1); |
|
477 | TRY_COMPARE(spy2.count(), 1); | |
482 |
|
478 | |||
483 | } |
|
479 | } | |
484 |
|
480 | |||
485 | void tst_Domain::setRangeX_data() |
|
481 | void tst_Domain::setRangeX_data() | |
486 | { |
|
482 | { | |
487 | QTest::addColumn<qreal>("min"); |
|
483 | QTest::addColumn<qreal>("min"); | |
488 | QTest::addColumn<qreal>("max"); |
|
484 | QTest::addColumn<qreal>("max"); | |
489 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
485 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
490 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
486 | QTest::newRow("0 1") << 0.0 << 1.0; | |
491 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
487 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
492 | } |
|
488 | } | |
493 |
|
489 | |||
494 | void tst_Domain::setRangeX() |
|
490 | void tst_Domain::setRangeX() | |
495 | { |
|
491 | { | |
496 | QFETCH(qreal, min); |
|
492 | QFETCH(qreal, min); | |
497 | QFETCH(qreal, max); |
|
493 | QFETCH(qreal, max); | |
498 |
|
494 | |||
499 | Domain domain; |
|
495 | Domain domain; | |
500 |
|
496 | |||
501 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
497 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
502 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
498 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
503 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
499 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
504 |
|
500 | |||
505 | domain.setRangeX(min, max); |
|
501 | domain.setRangeX(min, max); | |
506 |
|
502 | |||
507 | QVERIFY(qFuzzyCompare(domain.minX(), min)); |
|
503 | QVERIFY(qFuzzyCompare(domain.minX(), min)); | |
508 | QVERIFY(qFuzzyCompare(domain.maxX(), max)); |
|
504 | QVERIFY(qFuzzyCompare(domain.maxX(), max)); | |
509 |
|
505 | |||
510 | QList<QVariant> arg1 = spy1.first(); |
|
506 | QList<QVariant> arg1 = spy1.first(); | |
511 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); |
|
507 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); | |
512 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); |
|
508 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); | |
513 |
|
509 | |||
514 | TRY_COMPARE(spy0.count(), 1); |
|
510 | TRY_COMPARE(spy0.count(), 1); | |
515 | TRY_COMPARE(spy1.count(), 1); |
|
511 | TRY_COMPARE(spy1.count(), 1); | |
516 | TRY_COMPARE(spy2.count(), 0); |
|
512 | TRY_COMPARE(spy2.count(), 0); | |
517 | } |
|
513 | } | |
518 |
|
514 | |||
519 | void tst_Domain::setRangeY_data() |
|
515 | void tst_Domain::setRangeY_data() | |
520 | { |
|
516 | { | |
521 | QTest::addColumn<qreal>("min"); |
|
517 | QTest::addColumn<qreal>("min"); | |
522 | QTest::addColumn<qreal>("max"); |
|
518 | QTest::addColumn<qreal>("max"); | |
523 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
519 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
524 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
520 | QTest::newRow("0 1") << 0.0 << 1.0; | |
525 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
521 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
526 | } |
|
522 | } | |
527 |
|
523 | |||
528 | void tst_Domain::setRangeY() |
|
524 | void tst_Domain::setRangeY() | |
529 | { |
|
525 | { | |
530 | QFETCH(qreal, min); |
|
526 | QFETCH(qreal, min); | |
531 | QFETCH(qreal, max); |
|
527 | QFETCH(qreal, max); | |
532 |
|
528 | |||
533 | Domain domain; |
|
529 | Domain domain; | |
534 |
|
530 | |||
535 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
531 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
536 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
532 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
537 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
533 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
538 |
|
534 | |||
539 | domain.setRangeY(min, max); |
|
535 | domain.setRangeY(min, max); | |
540 |
|
536 | |||
541 | QVERIFY(qFuzzyCompare(domain.minY(), min)); |
|
537 | QVERIFY(qFuzzyCompare(domain.minY(), min)); | |
542 | QVERIFY(qFuzzyCompare(domain.maxY(), max)); |
|
538 | QVERIFY(qFuzzyCompare(domain.maxY(), max)); | |
543 |
|
539 | |||
544 | QList<QVariant> arg1 = spy2.first(); |
|
540 | QList<QVariant> arg1 = spy2.first(); | |
545 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); |
|
541 | QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); | |
546 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); |
|
542 | QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); | |
547 |
|
543 | |||
548 | TRY_COMPARE(spy0.count(), 1); |
|
544 | TRY_COMPARE(spy0.count(), 1); | |
549 | TRY_COMPARE(spy1.count(), 0); |
|
545 | TRY_COMPARE(spy1.count(), 0); | |
550 | TRY_COMPARE(spy2.count(), 1); |
|
546 | TRY_COMPARE(spy2.count(), 1); | |
551 | } |
|
547 | } | |
552 |
|
548 | |||
553 | void tst_Domain::spanX_data() |
|
549 | void tst_Domain::spanX_data() | |
554 | { |
|
550 | { | |
555 | QTest::addColumn<qreal>("minX"); |
|
551 | QTest::addColumn<qreal>("minX"); | |
556 | QTest::addColumn<qreal>("maxX"); |
|
552 | QTest::addColumn<qreal>("maxX"); | |
557 | QTest::addColumn<qreal>("spanX"); |
|
553 | QTest::addColumn<qreal>("spanX"); | |
558 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
554 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
559 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
555 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
560 | } |
|
556 | } | |
561 |
|
557 | |||
562 | void tst_Domain::spanX() |
|
558 | void tst_Domain::spanX() | |
563 | { |
|
559 | { | |
564 | QFETCH(qreal, minX); |
|
560 | QFETCH(qreal, minX); | |
565 | QFETCH(qreal, maxX); |
|
561 | QFETCH(qreal, maxX); | |
566 | QFETCH(qreal, spanX); |
|
562 | QFETCH(qreal, spanX); | |
567 |
|
563 | |||
568 | Domain domain; |
|
564 | Domain domain; | |
569 |
|
565 | |||
570 | domain.setRangeX(minX, maxX); |
|
566 | domain.setRangeX(minX, maxX); | |
571 |
|
567 | |||
572 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
568 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
573 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
569 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
574 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
570 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
575 |
|
571 | |||
576 | QCOMPARE(domain.spanX(), spanX); |
|
572 | QCOMPARE(domain.spanX(), spanX); | |
577 |
|
573 | |||
578 | TRY_COMPARE(spy0.count(), 0); |
|
574 | TRY_COMPARE(spy0.count(), 0); | |
579 | TRY_COMPARE(spy1.count(), 0); |
|
575 | TRY_COMPARE(spy1.count(), 0); | |
580 | TRY_COMPARE(spy2.count(), 0); |
|
576 | TRY_COMPARE(spy2.count(), 0); | |
581 | } |
|
577 | } | |
582 |
|
578 | |||
583 | void tst_Domain::spanY_data() |
|
579 | void tst_Domain::spanY_data() | |
584 | { |
|
580 | { | |
585 | QTest::addColumn<qreal>("minY"); |
|
581 | QTest::addColumn<qreal>("minY"); | |
586 | QTest::addColumn<qreal>("maxY"); |
|
582 | QTest::addColumn<qreal>("maxY"); | |
587 | QTest::addColumn<qreal>("spanY"); |
|
583 | QTest::addColumn<qreal>("spanY"); | |
588 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
584 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
589 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
585 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
590 | } |
|
586 | } | |
591 |
|
587 | |||
592 | void tst_Domain::spanY() |
|
588 | void tst_Domain::spanY() | |
593 | { |
|
589 | { | |
594 | QFETCH(qreal, minY); |
|
590 | QFETCH(qreal, minY); | |
595 | QFETCH(qreal, maxY); |
|
591 | QFETCH(qreal, maxY); | |
596 | QFETCH(qreal, spanY); |
|
592 | QFETCH(qreal, spanY); | |
597 |
|
593 | |||
598 | Domain domain; |
|
594 | Domain domain; | |
599 |
|
595 | |||
600 | domain.setRangeY(minY, maxY); |
|
596 | domain.setRangeY(minY, maxY); | |
601 |
|
597 | |||
602 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
598 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
603 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
599 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
604 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
600 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
605 |
|
601 | |||
606 | QCOMPARE(domain.spanY(), spanY); |
|
602 | QCOMPARE(domain.spanY(), spanY); | |
607 |
|
603 | |||
608 | TRY_COMPARE(spy0.count(), 0); |
|
604 | TRY_COMPARE(spy0.count(), 0); | |
609 | TRY_COMPARE(spy1.count(), 0); |
|
605 | TRY_COMPARE(spy1.count(), 0); | |
610 | TRY_COMPARE(spy2.count(), 0); |
|
606 | TRY_COMPARE(spy2.count(), 0); | |
611 | } |
|
607 | } | |
612 |
|
608 | |||
613 | void tst_Domain::zoom_data() |
|
609 | void tst_Domain::zoom_data() | |
614 | { |
|
610 | { | |
615 | QTest::addColumn<QRectF>("rect0"); |
|
611 | QTest::addColumn<QRectF>("rect0"); | |
616 | QTest::addColumn<QSizeF>("size0"); |
|
612 | QTest::addColumn<QSizeF>("size0"); | |
617 | QTest::addColumn<QRectF>("rect1"); |
|
613 | QTest::addColumn<QRectF>("rect1"); | |
618 | QTest::addColumn<QSizeF>("size1"); |
|
614 | QTest::addColumn<QSizeF>("size1"); | |
619 | QTest::addColumn<QRectF>("rect2"); |
|
615 | QTest::addColumn<QRectF>("rect2"); | |
620 | QTest::addColumn<QSizeF>("size2"); |
|
616 | QTest::addColumn<QSizeF>("size2"); | |
621 | QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) |
|
617 | QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) | |
622 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) |
|
618 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
623 | << QSizeF(1000, 1000); |
|
619 | << QSizeF(1000, 1000); | |
624 | QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) |
|
620 | QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) | |
625 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) |
|
621 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
626 | << QSizeF(1000, 1000); |
|
622 | << QSizeF(1000, 1000); | |
627 | QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) |
|
623 | QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) | |
628 | << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); |
|
624 | << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); | |
629 | } |
|
625 | } | |
630 |
|
626 | |||
631 | void tst_Domain::zoom() |
|
627 | void tst_Domain::zoom() | |
632 | { |
|
628 | { | |
633 | QFETCH(QRectF, rect0); |
|
629 | QFETCH(QRectF, rect0); | |
634 | QFETCH(QSizeF, size0); |
|
630 | QFETCH(QSizeF, size0); | |
635 | QFETCH(QRectF, rect1); |
|
631 | QFETCH(QRectF, rect1); | |
636 | QFETCH(QSizeF, size1); |
|
632 | QFETCH(QSizeF, size1); | |
637 | QFETCH(QRectF, rect2); |
|
633 | QFETCH(QRectF, rect2); | |
638 | QFETCH(QSizeF, size2); |
|
634 | QFETCH(QSizeF, size2); | |
639 |
|
635 | |||
640 | Domain domain; |
|
636 | Domain domain; | |
641 |
|
637 | |||
642 | domain.setRange(0, 1000, 0, 1000); |
|
638 | domain.setRange(0, 1000, 0, 1000); | |
643 |
|
639 | |||
644 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
640 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
645 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
641 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
646 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
642 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
647 |
|
643 | |||
648 | Domain domain0; |
|
644 | Domain domain0; | |
649 | domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); |
|
645 | domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
650 | domain.zoomIn(rect0, size0); |
|
646 | domain.zoomIn(rect0, size0); | |
651 | Domain domain1; |
|
647 | Domain domain1; | |
652 | domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); |
|
648 | domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
653 | domain.zoomIn(rect1, size1); |
|
649 | domain.zoomIn(rect1, size1); | |
654 | Domain domain2; |
|
650 | Domain domain2; | |
655 | domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); |
|
651 | domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
656 | domain.zoomIn(rect2, size2); |
|
652 | domain.zoomIn(rect2, size2); | |
657 | domain.zoomOut(rect2, size2); |
|
653 | domain.zoomOut(rect2, size2); | |
658 | QCOMPARE(domain == domain2, true); |
|
654 | QCOMPARE(domain == domain2, true); | |
659 | domain.zoomOut(rect1, size1); |
|
655 | domain.zoomOut(rect1, size1); | |
660 | QCOMPARE(domain == domain1, true); |
|
656 | QCOMPARE(domain == domain1, true); | |
661 | domain.zoomOut(rect0, size0); |
|
657 | domain.zoomOut(rect0, size0); | |
662 | QCOMPARE(domain == domain0, true); |
|
658 | QCOMPARE(domain == domain0, true); | |
663 | TRY_COMPARE(spy0.count(), 6); |
|
659 | TRY_COMPARE(spy0.count(), 6); | |
664 | TRY_COMPARE(spy1.count(), 6); |
|
660 | TRY_COMPARE(spy1.count(), 6); | |
665 | TRY_COMPARE(spy2.count(), 6); |
|
661 | TRY_COMPARE(spy2.count(), 6); | |
666 | } |
|
662 | } | |
667 |
|
663 | |||
668 | void tst_Domain::move_data() |
|
664 | void tst_Domain::move_data() | |
669 | { |
|
665 | { | |
670 | QTest::addColumn<int>("dx"); |
|
666 | QTest::addColumn<int>("dx"); | |
671 | QTest::addColumn<int>("dy"); |
|
667 | QTest::addColumn<int>("dy"); | |
672 | QTest::addColumn<QSizeF>("size"); |
|
668 | QTest::addColumn<QSizeF>("size"); | |
673 | QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); |
|
669 | QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); | |
674 | QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); |
|
670 | QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); | |
675 | QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); |
|
671 | QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); | |
676 | QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); |
|
672 | QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); | |
677 | QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); |
|
673 | QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); | |
678 | QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); |
|
674 | QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); | |
679 | } |
|
675 | } | |
680 |
|
676 | |||
681 | void tst_Domain::move() |
|
677 | void tst_Domain::move() | |
682 | { |
|
678 | { | |
683 | QFETCH(int, dx); |
|
679 | QFETCH(int, dx); | |
684 | QFETCH(int, dy); |
|
680 | QFETCH(int, dy); | |
685 | QFETCH(QSizeF, size); |
|
681 | QFETCH(QSizeF, size); | |
686 | Domain domain; |
|
682 | Domain domain; | |
687 |
|
683 | |||
688 | domain.setRange(0, size.width(), 0, size.height()); |
|
684 | domain.setRange(0, size.width(), 0, size.height()); | |
689 |
|
685 | |||
690 | QSignalSpy spy0(&domain, SIGNAL(updated())); |
|
686 | QSignalSpy spy0(&domain, SIGNAL(updated())); | |
691 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); |
|
687 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); | |
692 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); |
|
688 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); | |
693 |
|
689 | |||
694 | domain.move(dx, dy, size); |
|
690 | domain.move(dx, dy, size); | |
695 |
|
691 | |||
696 | Domain result; |
|
692 | Domain result; | |
697 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); |
|
693 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); | |
698 |
|
694 | |||
699 | QCOMPARE(domain == result, true); |
|
695 | QCOMPARE(domain == result, true); | |
700 | TRY_COMPARE(spy0.count(), 1); |
|
696 | TRY_COMPARE(spy0.count(), 1); | |
701 | TRY_COMPARE(spy1.count(), (dx != 0 ? 1 : 0)); |
|
697 | TRY_COMPARE(spy1.count(), (dx != 0 ? 1 : 0)); | |
702 | TRY_COMPARE(spy2.count(), (dy != 0 ? 1 : 0)); |
|
698 | TRY_COMPARE(spy2.count(), (dy != 0 ? 1 : 0)); | |
703 | } |
|
699 | } | |
704 |
|
700 | |||
705 | QTEST_MAIN(tst_Domain) |
|
701 | QTEST_MAIN(tst_Domain) | |
706 | #include "tst_domain.moc" |
|
702 | #include "tst_domain.moc" | |
707 | #endif |
|
703 | #endif |
@@ -1,81 +1,66 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef TST_DEFINITIONS_H |
|
21 | #ifndef TST_DEFINITIONS_H | |
22 | #define TST_DEFINITIONS_H |
|
22 | #define TST_DEFINITIONS_H | |
23 |
|
23 | |||
24 | #include <QtTest/QtTest> |
|
24 | #include <QtTest/QtTest> | |
25 | #include <QPushButton> |
|
25 | #include <QPushButton> | |
26 |
|
26 | |||
27 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
27 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
28 | namespace QTest |
|
28 | namespace QTest | |
29 | { |
|
29 | { | |
30 | // This was deprecated in Qt5. This is a small hack for the sake of compatibility. |
|
30 | // This was deprecated in Qt5. This is a small hack for the sake of compatibility. | |
31 | inline static bool qWaitForWindowShown(QWidget *window) |
|
31 | inline static bool qWaitForWindowShown(QWidget *window) | |
32 | { |
|
32 | { | |
33 | return QTest::qWaitForWindowExposed(window); |
|
33 | return QTest::qWaitForWindowExposed(window); | |
34 | } |
|
34 | } | |
35 | } |
|
35 | } | |
36 | #endif |
|
36 | #endif | |
37 |
|
37 | |||
38 | #define TRY_COMPARE(actual, expected) { \ |
|
38 | #define TRY_COMPARE(actual, expected) { \ | |
39 | do { \ |
|
39 | do { \ | |
40 | const int timeout(1000); \ |
|
40 | const int timeout(1000); \ | |
41 | const int waitStep(30); \ |
|
41 | const int waitStep(30); \ | |
42 | /* always wait before comparing to catch possible extra signals */ \ |
|
42 | /* always wait before comparing to catch possible extra signals */ \ | |
43 | QTest::qWait(waitStep); \ |
|
43 | QTest::qWait(waitStep); \ | |
44 | for (int time(0); (actual != expected) && (time < timeout); time += waitStep) \ |
|
44 | for (int time(0); (actual != expected) && (time < timeout); time += waitStep) \ | |
45 | QTest::qWait(waitStep); \ |
|
45 | QTest::qWait(waitStep); \ | |
46 | QCOMPARE(actual, expected); \ |
|
46 | QCOMPARE(actual, expected); \ | |
47 | } while (0); \ |
|
47 | } while (0); \ | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | // Some bamboo clients have trouble passing mouse events to the test application. |
|
50 | // Some bamboo clients have trouble passing mouse events to the test application. | |
51 | // This can be used to skip those tests so that they don't show up as a failure |
|
51 | // This can be used to skip those tests so that they don't show up as a failure | |
52 | // in the test report. |
|
52 | // in the test report. | |
53 | #ifdef QT5_QUICK_1 |
|
|||
54 | #define SKIP_IF_CANNOT_TEST_MOUSE_EVENTS() { \ |
|
|||
55 | do { \ |
|
|||
56 | QPushButton b; \ |
|
|||
57 | b.resize(100, 100); \ |
|
|||
58 | b.show(); \ |
|
|||
59 | QTest::qWaitForWindowShown(&b); \ |
|
|||
60 | QSignalSpy spy(&b, SIGNAL(clicked())); \ |
|
|||
61 | QTest::mouseClick(&b, Qt::LeftButton, 0, b.rect().center()); \ |
|
|||
62 | if (spy.count() == 0) \ |
|
|||
63 | QSKIP("Cannot test mouse events in this environment"); \ |
|
|||
64 | } while (0); \ |
|
|||
65 | } |
|
|||
66 | #else |
|
|||
67 | #define SKIP_IF_CANNOT_TEST_MOUSE_EVENTS() { \ |
|
53 | #define SKIP_IF_CANNOT_TEST_MOUSE_EVENTS() { \ | |
68 | do { \ |
|
54 | do { \ | |
69 | QPushButton b; \ |
|
55 | QPushButton b; \ | |
70 | b.resize(100, 100); \ |
|
56 | b.resize(100, 100); \ | |
71 | b.show(); \ |
|
57 | b.show(); \ | |
72 | QTest::qWaitForWindowShown(&b); \ |
|
58 | QTest::qWaitForWindowShown(&b); \ | |
73 | QSignalSpy spy(&b, SIGNAL(clicked())); \ |
|
59 | QSignalSpy spy(&b, SIGNAL(clicked())); \ | |
74 | QTest::mouseClick(&b, Qt::LeftButton, 0, b.rect().center()); \ |
|
60 | QTest::mouseClick(&b, Qt::LeftButton, 0, b.rect().center()); \ | |
75 | if (spy.count() == 0) \ |
|
61 | if (spy.count() == 0) \ | |
76 | QSKIP("Cannot test mouse events in this environment", SkipAll); \ |
|
62 | QSKIP("Cannot test mouse events in this environment", SkipAll); \ | |
77 | } while (0); \ |
|
63 | } while (0); \ | |
78 | } |
|
64 | } | |
79 | #endif |
|
|||
80 |
|
65 | |||
81 | #endif // TST_DEFINITIONS_H |
|
66 | #endif // TST_DEFINITIONS_H |
@@ -1,863 +1,847 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "tst_qabstractaxis.h" |
|
21 | #include "tst_qabstractaxis.h" | |
22 |
|
22 | |||
23 | Q_DECLARE_METATYPE(QPen) |
|
23 | Q_DECLARE_METATYPE(QPen) | |
24 | Q_DECLARE_METATYPE(Qt::Orientation) |
|
24 | Q_DECLARE_METATYPE(Qt::Orientation) | |
25 |
|
25 | |||
26 | void tst_QAbstractAxis::initTestCase() |
|
26 | void tst_QAbstractAxis::initTestCase() | |
27 | { |
|
27 | { | |
28 | } |
|
28 | } | |
29 |
|
29 | |||
30 | void tst_QAbstractAxis::cleanupTestCase() |
|
30 | void tst_QAbstractAxis::cleanupTestCase() | |
31 | { |
|
31 | { | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series) |
|
34 | void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series) | |
35 | { |
|
35 | { | |
36 | m_axis = axis; |
|
36 | m_axis = axis; | |
37 | m_series = series; |
|
37 | m_series = series; | |
38 | m_view = new QChartView(new QChart()); |
|
38 | m_view = new QChartView(new QChart()); | |
39 | m_chart = m_view->chart(); |
|
39 | m_chart = m_view->chart(); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void tst_QAbstractAxis::cleanup() |
|
42 | void tst_QAbstractAxis::cleanup() | |
43 | { |
|
43 | { | |
44 | delete m_view; |
|
44 | delete m_view; | |
45 | m_view = 0; |
|
45 | m_view = 0; | |
46 | m_chart = 0; |
|
46 | m_chart = 0; | |
47 | m_axis = 0; |
|
47 | m_axis = 0; | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | void tst_QAbstractAxis::qabstractaxis() |
|
50 | void tst_QAbstractAxis::qabstractaxis() | |
51 | { |
|
51 | { | |
52 | QCOMPARE(m_axis->linePen(), QPen()); |
|
52 | QCOMPARE(m_axis->linePen(), QPen()); | |
53 | //TODO QCOMPARE(m_axis->axisPenColor(), QColor()); |
|
53 | //TODO QCOMPARE(m_axis->axisPenColor(), QColor()); | |
54 | QCOMPARE(m_axis->gridLinePen(), QPen()); |
|
54 | QCOMPARE(m_axis->gridLinePen(), QPen()); | |
55 | QCOMPARE(m_axis->isLineVisible(), true); |
|
55 | QCOMPARE(m_axis->isLineVisible(), true); | |
56 | QCOMPARE(m_axis->isGridLineVisible(), true); |
|
56 | QCOMPARE(m_axis->isGridLineVisible(), true); | |
57 | QCOMPARE(m_axis->isVisible(), false); |
|
57 | QCOMPARE(m_axis->isVisible(), false); | |
58 | QCOMPARE(m_axis->labelsAngle(), 0); |
|
58 | QCOMPARE(m_axis->labelsAngle(), 0); | |
59 | QCOMPARE(m_axis->labelsBrush(), QBrush()); |
|
59 | QCOMPARE(m_axis->labelsBrush(), QBrush()); | |
60 | //TODO QCOMPARE(m_axis->labelsColor(), QColor()); |
|
60 | //TODO QCOMPARE(m_axis->labelsColor(), QColor()); | |
61 | QCOMPARE(m_axis->labelsFont(), QFont()); |
|
61 | QCOMPARE(m_axis->labelsFont(), QFont()); | |
62 | QCOMPARE(m_axis->labelsPen(), QPen()); |
|
62 | QCOMPARE(m_axis->labelsPen(), QPen()); | |
63 | QCOMPARE(m_axis->labelsVisible(), true); |
|
63 | QCOMPARE(m_axis->labelsVisible(), true); | |
64 | QCOMPARE(m_axis->orientation(), Qt::Orientation(0)); |
|
64 | QCOMPARE(m_axis->orientation(), Qt::Orientation(0)); | |
65 | m_axis->setLineVisible(false); |
|
65 | m_axis->setLineVisible(false); | |
66 | m_axis->setLinePen(QPen()); |
|
66 | m_axis->setLinePen(QPen()); | |
67 | m_axis->setLinePenColor(QColor()); |
|
67 | m_axis->setLinePenColor(QColor()); | |
68 | m_axis->setGridLinePen(QPen()); |
|
68 | m_axis->setGridLinePen(QPen()); | |
69 | m_axis->setGridLineVisible(false); |
|
69 | m_axis->setGridLineVisible(false); | |
70 | m_axis->setLabelsAngle(-1); |
|
70 | m_axis->setLabelsAngle(-1); | |
71 | m_axis->setLabelsBrush(QBrush()); |
|
71 | m_axis->setLabelsBrush(QBrush()); | |
72 | m_axis->setLabelsColor(QColor()); |
|
72 | m_axis->setLabelsColor(QColor()); | |
73 | m_axis->setLabelsFont(QFont()); |
|
73 | m_axis->setLabelsFont(QFont()); | |
74 | m_axis->setLabelsPen(QPen()); |
|
74 | m_axis->setLabelsPen(QPen()); | |
75 | m_axis->setLabelsVisible(false); |
|
75 | m_axis->setLabelsVisible(false); | |
76 | m_axis->setMax(QVariant()); |
|
76 | m_axis->setMax(QVariant()); | |
77 | m_axis->setMin(QVariant()); |
|
77 | m_axis->setMin(QVariant()); | |
78 | m_axis->setRange(QVariant(), QVariant()); |
|
78 | m_axis->setRange(QVariant(), QVariant()); | |
79 | m_axis->setShadesBorderColor(QColor()); |
|
79 | m_axis->setShadesBorderColor(QColor()); | |
80 | m_axis->setShadesBrush(QBrush()); |
|
80 | m_axis->setShadesBrush(QBrush()); | |
81 | m_axis->setShadesColor(QColor()); |
|
81 | m_axis->setShadesColor(QColor()); | |
82 | m_axis->setShadesPen(QPen()); |
|
82 | m_axis->setShadesPen(QPen()); | |
83 | m_axis->setShadesVisible(false); |
|
83 | m_axis->setShadesVisible(false); | |
84 | m_axis->setVisible(false); |
|
84 | m_axis->setVisible(false); | |
85 | //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor()); |
|
85 | //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor()); | |
86 | //TODO QCOMPARE(m_axis->shadesBrush(), QBrush()); |
|
86 | //TODO QCOMPARE(m_axis->shadesBrush(), QBrush()); | |
87 | //TODO QCOMPARE(m_axis->shadesColor(), QColor()); |
|
87 | //TODO QCOMPARE(m_axis->shadesColor(), QColor()); | |
88 | QCOMPARE(m_axis->shadesPen(), QPen()); |
|
88 | QCOMPARE(m_axis->shadesPen(), QPen()); | |
89 | QCOMPARE(m_axis->shadesVisible(), false); |
|
89 | QCOMPARE(m_axis->shadesVisible(), false); | |
90 | m_axis->show(); |
|
90 | m_axis->show(); | |
91 | m_axis->hide(); |
|
91 | m_axis->hide(); | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | void tst_QAbstractAxis::axisPen_data() |
|
94 | void tst_QAbstractAxis::axisPen_data() | |
95 | { |
|
95 | { | |
96 | QTest::addColumn<QPen>("axisPen"); |
|
96 | QTest::addColumn<QPen>("axisPen"); | |
97 | QTest::newRow("null") << QPen(); |
|
97 | QTest::newRow("null") << QPen(); | |
98 | QTest::newRow("blue") << QPen(Qt::blue); |
|
98 | QTest::newRow("blue") << QPen(Qt::blue); | |
99 | QTest::newRow("black") << QPen(Qt::black); |
|
99 | QTest::newRow("black") << QPen(Qt::black); | |
100 | QTest::newRow("red") << QPen(Qt::red); |
|
100 | QTest::newRow("red") << QPen(Qt::red); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | void tst_QAbstractAxis::axisPen() |
|
103 | void tst_QAbstractAxis::axisPen() | |
104 | { |
|
104 | { | |
105 | QFETCH(QPen, axisPen); |
|
105 | QFETCH(QPen, axisPen); | |
106 |
|
106 | |||
107 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
107 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
108 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
108 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
109 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
109 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
110 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
110 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
111 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
111 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
112 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
112 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
113 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
113 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
114 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
114 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
115 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
115 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
116 |
|
116 | |||
117 | m_axis->setLinePen(axisPen); |
|
117 | m_axis->setLinePen(axisPen); | |
118 | QCOMPARE(m_axis->linePen(), axisPen); |
|
118 | QCOMPARE(m_axis->linePen(), axisPen); | |
119 |
|
119 | |||
120 | QCOMPARE(spy0.count(), 0); |
|
120 | QCOMPARE(spy0.count(), 0); | |
121 | QCOMPARE(spy1.count(), 0); |
|
121 | QCOMPARE(spy1.count(), 0); | |
122 | QCOMPARE(spy2.count(), 0); |
|
122 | QCOMPARE(spy2.count(), 0); | |
123 | QCOMPARE(spy3.count(), 0); |
|
123 | QCOMPARE(spy3.count(), 0); | |
124 | QCOMPARE(spy4.count(), 0); |
|
124 | QCOMPARE(spy4.count(), 0); | |
125 | QCOMPARE(spy5.count(), 0); |
|
125 | QCOMPARE(spy5.count(), 0); | |
126 | QCOMPARE(spy6.count(), 0); |
|
126 | QCOMPARE(spy6.count(), 0); | |
127 | QCOMPARE(spy7.count(), 0); |
|
127 | QCOMPARE(spy7.count(), 0); | |
128 | QCOMPARE(spy8.count(), 0); |
|
128 | QCOMPARE(spy8.count(), 0); | |
129 |
|
129 | |||
130 | m_chart->setAxisX(m_axis, m_series); |
|
130 | m_chart->setAxisX(m_axis, m_series); | |
131 | m_view->show(); |
|
131 | m_view->show(); | |
132 | QTest::qWaitForWindowShown(m_view); |
|
132 | QTest::qWaitForWindowShown(m_view); | |
133 | //TODO QCOMPARE(m_axis->axisPen(), axisPen); |
|
133 | //TODO QCOMPARE(m_axis->axisPen(), axisPen); | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | void tst_QAbstractAxis::axisPenColor_data() |
|
136 | void tst_QAbstractAxis::axisPenColor_data() | |
137 | { |
|
137 | { | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | void tst_QAbstractAxis::axisPenColor() |
|
140 | void tst_QAbstractAxis::axisPenColor() | |
141 | { |
|
141 | { | |
142 | #ifdef QT5_QUICK_1 |
|
142 | QSKIP("Test is not implemented. This is deprecated function", SkipAll); | |
143 | QSKIP("Test is not implemented. This is depreciated function"); |
|
|||
144 | #else |
|
|||
145 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
|||
146 | #endif |
|
|||
147 | } |
|
143 | } | |
148 |
|
144 | |||
149 | void tst_QAbstractAxis::gridLinePen_data() |
|
145 | void tst_QAbstractAxis::gridLinePen_data() | |
150 | { |
|
146 | { | |
151 |
|
147 | |||
152 | QTest::addColumn<QPen>("gridLinePen"); |
|
148 | QTest::addColumn<QPen>("gridLinePen"); | |
153 | QTest::newRow("null") << QPen(); |
|
149 | QTest::newRow("null") << QPen(); | |
154 | QTest::newRow("blue") << QPen(Qt::blue); |
|
150 | QTest::newRow("blue") << QPen(Qt::blue); | |
155 | QTest::newRow("black") << QPen(Qt::black); |
|
151 | QTest::newRow("black") << QPen(Qt::black); | |
156 | QTest::newRow("red") << QPen(Qt::red); |
|
152 | QTest::newRow("red") << QPen(Qt::red); | |
157 |
|
153 | |||
158 | } |
|
154 | } | |
159 |
|
155 | |||
160 | void tst_QAbstractAxis::gridLinePen() |
|
156 | void tst_QAbstractAxis::gridLinePen() | |
161 | { |
|
157 | { | |
162 | QFETCH(QPen, gridLinePen); |
|
158 | QFETCH(QPen, gridLinePen); | |
163 |
|
159 | |||
164 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
160 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
165 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
161 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
166 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
162 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
167 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
163 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
168 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
164 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
169 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
165 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
170 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
166 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
171 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
167 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
172 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
168 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
173 |
|
169 | |||
174 | m_axis->setGridLinePen(gridLinePen); |
|
170 | m_axis->setGridLinePen(gridLinePen); | |
175 | QCOMPARE(m_axis->gridLinePen(), gridLinePen); |
|
171 | QCOMPARE(m_axis->gridLinePen(), gridLinePen); | |
176 |
|
172 | |||
177 | QCOMPARE(spy0.count(), 0); |
|
173 | QCOMPARE(spy0.count(), 0); | |
178 | QCOMPARE(spy1.count(), 0); |
|
174 | QCOMPARE(spy1.count(), 0); | |
179 | QCOMPARE(spy2.count(), 0); |
|
175 | QCOMPARE(spy2.count(), 0); | |
180 | QCOMPARE(spy3.count(), 0); |
|
176 | QCOMPARE(spy3.count(), 0); | |
181 | QCOMPARE(spy4.count(), 0); |
|
177 | QCOMPARE(spy4.count(), 0); | |
182 | QCOMPARE(spy5.count(), 0); |
|
178 | QCOMPARE(spy5.count(), 0); | |
183 | QCOMPARE(spy6.count(), 0); |
|
179 | QCOMPARE(spy6.count(), 0); | |
184 | QCOMPARE(spy7.count(), 0); |
|
180 | QCOMPARE(spy7.count(), 0); | |
185 | QCOMPARE(spy8.count(), 0); |
|
181 | QCOMPARE(spy8.count(), 0); | |
186 |
|
182 | |||
187 | m_chart->setAxisX(m_axis, m_series); |
|
183 | m_chart->setAxisX(m_axis, m_series); | |
188 | m_view->show(); |
|
184 | m_view->show(); | |
189 | QTest::qWaitForWindowShown(m_view); |
|
185 | QTest::qWaitForWindowShown(m_view); | |
190 | //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen); |
|
186 | //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen); | |
191 | } |
|
187 | } | |
192 |
|
188 | |||
193 | void tst_QAbstractAxis::lineVisible_data() |
|
189 | void tst_QAbstractAxis::lineVisible_data() | |
194 | { |
|
190 | { | |
195 | QTest::addColumn<bool>("lineVisible"); |
|
191 | QTest::addColumn<bool>("lineVisible"); | |
196 | QTest::newRow("true") << true; |
|
192 | QTest::newRow("true") << true; | |
197 | QTest::newRow("false") << false; |
|
193 | QTest::newRow("false") << false; | |
198 | } |
|
194 | } | |
199 |
|
195 | |||
200 | void tst_QAbstractAxis::lineVisible() |
|
196 | void tst_QAbstractAxis::lineVisible() | |
201 | { |
|
197 | { | |
202 | QFETCH(bool, lineVisible); |
|
198 | QFETCH(bool, lineVisible); | |
203 |
|
199 | |||
204 | m_axis->setLineVisible(!lineVisible); |
|
200 | m_axis->setLineVisible(!lineVisible); | |
205 |
|
201 | |||
206 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
202 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
207 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
203 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
208 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
204 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
209 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
205 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
210 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
206 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
211 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
207 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
212 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
208 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
213 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
209 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
214 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
210 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
215 |
|
211 | |||
216 | m_axis->setLineVisible(lineVisible); |
|
212 | m_axis->setLineVisible(lineVisible); | |
217 | QCOMPARE(m_axis->isLineVisible(), lineVisible); |
|
213 | QCOMPARE(m_axis->isLineVisible(), lineVisible); | |
218 |
|
214 | |||
219 | QCOMPARE(spy0.count(), 1); |
|
215 | QCOMPARE(spy0.count(), 1); | |
220 | QCOMPARE(spy1.count(), 0); |
|
216 | QCOMPARE(spy1.count(), 0); | |
221 | QCOMPARE(spy2.count(), 0); |
|
217 | QCOMPARE(spy2.count(), 0); | |
222 | QCOMPARE(spy3.count(), 0); |
|
218 | QCOMPARE(spy3.count(), 0); | |
223 | QCOMPARE(spy4.count(), 0); |
|
219 | QCOMPARE(spy4.count(), 0); | |
224 | QCOMPARE(spy5.count(), 0); |
|
220 | QCOMPARE(spy5.count(), 0); | |
225 | QCOMPARE(spy6.count(), 0); |
|
221 | QCOMPARE(spy6.count(), 0); | |
226 | QCOMPARE(spy7.count(), 0); |
|
222 | QCOMPARE(spy7.count(), 0); | |
227 | QCOMPARE(spy8.count(), 0); |
|
223 | QCOMPARE(spy8.count(), 0); | |
228 |
|
224 | |||
229 | m_chart->setAxisX(m_axis, m_series); |
|
225 | m_chart->setAxisX(m_axis, m_series); | |
230 | m_view->show(); |
|
226 | m_view->show(); | |
231 | QTest::qWaitForWindowShown(m_view); |
|
227 | QTest::qWaitForWindowShown(m_view); | |
232 | QCOMPARE(m_axis->isLineVisible(), lineVisible); |
|
228 | QCOMPARE(m_axis->isLineVisible(), lineVisible); | |
233 | } |
|
229 | } | |
234 |
|
230 | |||
235 | void tst_QAbstractAxis::gridLineVisible_data() |
|
231 | void tst_QAbstractAxis::gridLineVisible_data() | |
236 | { |
|
232 | { | |
237 | QTest::addColumn<bool>("gridLineVisible"); |
|
233 | QTest::addColumn<bool>("gridLineVisible"); | |
238 | QTest::newRow("true") << true; |
|
234 | QTest::newRow("true") << true; | |
239 | QTest::newRow("false") << false; |
|
235 | QTest::newRow("false") << false; | |
240 | } |
|
236 | } | |
241 |
|
237 | |||
242 | void tst_QAbstractAxis::gridLineVisible() |
|
238 | void tst_QAbstractAxis::gridLineVisible() | |
243 | { |
|
239 | { | |
244 | QFETCH(bool, gridLineVisible); |
|
240 | QFETCH(bool, gridLineVisible); | |
245 |
|
241 | |||
246 | m_axis->setGridLineVisible(!gridLineVisible); |
|
242 | m_axis->setGridLineVisible(!gridLineVisible); | |
247 |
|
243 | |||
248 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
244 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
249 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
245 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
250 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
246 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
251 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
247 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
252 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
248 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
253 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
249 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
254 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
250 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
255 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
251 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
256 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
252 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
257 |
|
253 | |||
258 | m_axis->setGridLineVisible(gridLineVisible); |
|
254 | m_axis->setGridLineVisible(gridLineVisible); | |
259 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); |
|
255 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); | |
260 |
|
256 | |||
261 | QCOMPARE(spy0.count(), 0); |
|
257 | QCOMPARE(spy0.count(), 0); | |
262 | QCOMPARE(spy1.count(), 0); |
|
258 | QCOMPARE(spy1.count(), 0); | |
263 | QCOMPARE(spy2.count(), 1); |
|
259 | QCOMPARE(spy2.count(), 1); | |
264 | QCOMPARE(spy3.count(), 0); |
|
260 | QCOMPARE(spy3.count(), 0); | |
265 | QCOMPARE(spy4.count(), 0); |
|
261 | QCOMPARE(spy4.count(), 0); | |
266 | QCOMPARE(spy5.count(), 0); |
|
262 | QCOMPARE(spy5.count(), 0); | |
267 | QCOMPARE(spy6.count(), 0); |
|
263 | QCOMPARE(spy6.count(), 0); | |
268 | QCOMPARE(spy7.count(), 0); |
|
264 | QCOMPARE(spy7.count(), 0); | |
269 | QCOMPARE(spy8.count(), 0); |
|
265 | QCOMPARE(spy8.count(), 0); | |
270 |
|
266 | |||
271 | m_chart->setAxisX(m_axis, m_series); |
|
267 | m_chart->setAxisX(m_axis, m_series); | |
272 | m_view->show(); |
|
268 | m_view->show(); | |
273 | QTest::qWaitForWindowShown(m_view); |
|
269 | QTest::qWaitForWindowShown(m_view); | |
274 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); |
|
270 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); | |
275 |
|
271 | |||
276 | } |
|
272 | } | |
277 |
|
273 | |||
278 | void tst_QAbstractAxis::visible_data() |
|
274 | void tst_QAbstractAxis::visible_data() | |
279 | { |
|
275 | { | |
280 | QTest::addColumn<bool>("visible"); |
|
276 | QTest::addColumn<bool>("visible"); | |
281 | QTest::newRow("true") << true; |
|
277 | QTest::newRow("true") << true; | |
282 | QTest::newRow("false") << false; |
|
278 | QTest::newRow("false") << false; | |
283 | } |
|
279 | } | |
284 |
|
280 | |||
285 | void tst_QAbstractAxis::visible() |
|
281 | void tst_QAbstractAxis::visible() | |
286 | { |
|
282 | { | |
287 | QFETCH(bool, visible); |
|
283 | QFETCH(bool, visible); | |
288 |
|
284 | |||
289 | m_axis->setVisible(!visible); |
|
285 | m_axis->setVisible(!visible); | |
290 |
|
286 | |||
291 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
287 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
292 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
288 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
293 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
289 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
294 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
290 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
295 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
291 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
296 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
292 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
297 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
293 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
298 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
294 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
299 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
295 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
300 |
|
296 | |||
301 | m_axis->setVisible(visible); |
|
297 | m_axis->setVisible(visible); | |
302 | QCOMPARE(m_axis->isVisible(), visible); |
|
298 | QCOMPARE(m_axis->isVisible(), visible); | |
303 |
|
299 | |||
304 | QCOMPARE(spy0.count(), 0); |
|
300 | QCOMPARE(spy0.count(), 0); | |
305 | QCOMPARE(spy1.count(), 0); |
|
301 | QCOMPARE(spy1.count(), 0); | |
306 | QCOMPARE(spy2.count(), 0); |
|
302 | QCOMPARE(spy2.count(), 0); | |
307 | QCOMPARE(spy3.count(), 0); |
|
303 | QCOMPARE(spy3.count(), 0); | |
308 | QCOMPARE(spy4.count(), 0); |
|
304 | QCOMPARE(spy4.count(), 0); | |
309 | QCOMPARE(spy5.count(), 0); |
|
305 | QCOMPARE(spy5.count(), 0); | |
310 | QCOMPARE(spy6.count(), 0); |
|
306 | QCOMPARE(spy6.count(), 0); | |
311 | QCOMPARE(spy7.count(), 0); |
|
307 | QCOMPARE(spy7.count(), 0); | |
312 | QCOMPARE(spy8.count(), 1); |
|
308 | QCOMPARE(spy8.count(), 1); | |
313 |
|
309 | |||
314 | m_chart->setAxisX(m_axis, m_series); |
|
310 | m_chart->setAxisX(m_axis, m_series); | |
315 | m_view->show(); |
|
311 | m_view->show(); | |
316 | QTest::qWaitForWindowShown(m_view); |
|
312 | QTest::qWaitForWindowShown(m_view); | |
317 | QCOMPARE(m_axis->isVisible(), true); |
|
313 | QCOMPARE(m_axis->isVisible(), true); | |
318 | } |
|
314 | } | |
319 |
|
315 | |||
320 | void tst_QAbstractAxis::labelsAngle_data() |
|
316 | void tst_QAbstractAxis::labelsAngle_data() | |
321 | { |
|
317 | { | |
322 | QTest::addColumn<int>("labelsAngle"); |
|
318 | QTest::addColumn<int>("labelsAngle"); | |
323 | QTest::newRow("0") << 0; |
|
319 | QTest::newRow("0") << 0; | |
324 | QTest::newRow("45") << 45; |
|
320 | QTest::newRow("45") << 45; | |
325 | QTest::newRow("90") << 90; |
|
321 | QTest::newRow("90") << 90; | |
326 | } |
|
322 | } | |
327 |
|
323 | |||
328 | void tst_QAbstractAxis::labelsAngle() |
|
324 | void tst_QAbstractAxis::labelsAngle() | |
329 | { |
|
325 | { | |
330 | QFETCH(int, labelsAngle); |
|
326 | QFETCH(int, labelsAngle); | |
331 |
|
327 | |||
332 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
328 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
333 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
329 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
334 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
330 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
335 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
331 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
336 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
332 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
337 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
333 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
338 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
334 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
339 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
335 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
340 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
336 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
341 |
|
337 | |||
342 | m_axis->setLabelsAngle(labelsAngle); |
|
338 | m_axis->setLabelsAngle(labelsAngle); | |
343 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); |
|
339 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); | |
344 |
|
340 | |||
345 | QCOMPARE(spy0.count(), 0); |
|
341 | QCOMPARE(spy0.count(), 0); | |
346 | QCOMPARE(spy1.count(), 0); |
|
342 | QCOMPARE(spy1.count(), 0); | |
347 | QCOMPARE(spy2.count(), 0); |
|
343 | QCOMPARE(spy2.count(), 0); | |
348 | QCOMPARE(spy3.count(), 0); |
|
344 | QCOMPARE(spy3.count(), 0); | |
349 | QCOMPARE(spy4.count(), 0); |
|
345 | QCOMPARE(spy4.count(), 0); | |
350 | QCOMPARE(spy5.count(), 0); |
|
346 | QCOMPARE(spy5.count(), 0); | |
351 | QCOMPARE(spy6.count(), 0); |
|
347 | QCOMPARE(spy6.count(), 0); | |
352 | QCOMPARE(spy7.count(), 0); |
|
348 | QCOMPARE(spy7.count(), 0); | |
353 | QCOMPARE(spy8.count(), 0); |
|
349 | QCOMPARE(spy8.count(), 0); | |
354 |
|
350 | |||
355 | m_chart->setAxisX(m_axis, m_series); |
|
351 | m_chart->setAxisX(m_axis, m_series); | |
356 | m_view->show(); |
|
352 | m_view->show(); | |
357 | QTest::qWaitForWindowShown(m_view); |
|
353 | QTest::qWaitForWindowShown(m_view); | |
358 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); |
|
354 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); | |
359 | } |
|
355 | } | |
360 |
|
356 | |||
361 | void tst_QAbstractAxis::labelsBrush_data() |
|
357 | void tst_QAbstractAxis::labelsBrush_data() | |
362 | { |
|
358 | { | |
363 | QTest::addColumn<QBrush>("labelsBrush"); |
|
359 | QTest::addColumn<QBrush>("labelsBrush"); | |
364 | QTest::newRow("null") << QBrush(); |
|
360 | QTest::newRow("null") << QBrush(); | |
365 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
361 | QTest::newRow("blue") << QBrush(Qt::blue); | |
366 | QTest::newRow("black") << QBrush(Qt::black); |
|
362 | QTest::newRow("black") << QBrush(Qt::black); | |
367 |
|
363 | |||
368 | } |
|
364 | } | |
369 |
|
365 | |||
370 | void tst_QAbstractAxis::labelsBrush() |
|
366 | void tst_QAbstractAxis::labelsBrush() | |
371 | { |
|
367 | { | |
372 |
|
368 | |||
373 | QFETCH(QBrush, labelsBrush); |
|
369 | QFETCH(QBrush, labelsBrush); | |
374 |
|
370 | |||
375 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
371 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
376 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
372 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
377 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
373 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
378 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
374 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
379 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
375 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
380 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
376 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
381 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
377 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
382 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
378 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
383 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
379 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
384 |
|
380 | |||
385 | m_axis->setLabelsBrush(labelsBrush); |
|
381 | m_axis->setLabelsBrush(labelsBrush); | |
386 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); |
|
382 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); | |
387 |
|
383 | |||
388 | QCOMPARE(spy0.count(), 0); |
|
384 | QCOMPARE(spy0.count(), 0); | |
389 | QCOMPARE(spy1.count(), 0); |
|
385 | QCOMPARE(spy1.count(), 0); | |
390 | QCOMPARE(spy2.count(), 0); |
|
386 | QCOMPARE(spy2.count(), 0); | |
391 | QCOMPARE(spy3.count(), 0); |
|
387 | QCOMPARE(spy3.count(), 0); | |
392 | QCOMPARE(spy4.count(), 0); |
|
388 | QCOMPARE(spy4.count(), 0); | |
393 | QCOMPARE(spy5.count(), 0); |
|
389 | QCOMPARE(spy5.count(), 0); | |
394 | //TODO QCOMPARE(spy6.count(), 0); |
|
390 | //TODO QCOMPARE(spy6.count(), 0); | |
395 | QCOMPARE(spy7.count(), 0); |
|
391 | QCOMPARE(spy7.count(), 0); | |
396 | QCOMPARE(spy8.count(), 0); |
|
392 | QCOMPARE(spy8.count(), 0); | |
397 |
|
393 | |||
398 | m_view->show(); |
|
394 | m_view->show(); | |
399 | QTest::qWaitForWindowShown(m_view); |
|
395 | QTest::qWaitForWindowShown(m_view); | |
400 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); |
|
396 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); | |
401 |
|
397 | |||
402 | } |
|
398 | } | |
403 |
|
399 | |||
404 | void tst_QAbstractAxis::labelsColor_data() |
|
400 | void tst_QAbstractAxis::labelsColor_data() | |
405 | { |
|
401 | { | |
406 |
|
402 | |||
407 | } |
|
403 | } | |
408 |
|
404 | |||
409 | void tst_QAbstractAxis::labelsColor() |
|
405 | void tst_QAbstractAxis::labelsColor() | |
410 | { |
|
406 | { | |
411 | #ifdef QT5_QUICK_1 |
|
407 | QSKIP("Test is not implemented. This is deprecated function", SkipAll); | |
412 | QSKIP("Test is not implemented. This is depreciated function"); |
|
|||
413 | #else |
|
|||
414 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
|||
415 | #endif |
|
|||
416 | } |
|
408 | } | |
417 |
|
409 | |||
418 | void tst_QAbstractAxis::labelsFont_data() |
|
410 | void tst_QAbstractAxis::labelsFont_data() | |
419 | { |
|
411 | { | |
420 | QTest::addColumn<QFont>("labelsFont"); |
|
412 | QTest::addColumn<QFont>("labelsFont"); | |
421 | QTest::newRow("null") << QFont(); |
|
413 | QTest::newRow("null") << QFont(); | |
422 | QTest::newRow("serif") << QFont("SansSerif"); |
|
414 | QTest::newRow("serif") << QFont("SansSerif"); | |
423 | } |
|
415 | } | |
424 |
|
416 | |||
425 | void tst_QAbstractAxis::labelsFont() |
|
417 | void tst_QAbstractAxis::labelsFont() | |
426 | { |
|
418 | { | |
427 |
|
419 | |||
428 | QFETCH(QFont, labelsFont); |
|
420 | QFETCH(QFont, labelsFont); | |
429 |
|
421 | |||
430 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
422 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
431 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
423 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
432 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
424 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
433 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
425 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
434 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
426 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
435 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
427 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
436 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
428 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
437 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
429 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
438 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
430 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
439 |
|
431 | |||
440 | m_axis->setLabelsFont(labelsFont); |
|
432 | m_axis->setLabelsFont(labelsFont); | |
441 | QCOMPARE(m_axis->labelsFont(), labelsFont); |
|
433 | QCOMPARE(m_axis->labelsFont(), labelsFont); | |
442 |
|
434 | |||
443 | QCOMPARE(spy0.count(), 0); |
|
435 | QCOMPARE(spy0.count(), 0); | |
444 | QCOMPARE(spy1.count(), 0); |
|
436 | QCOMPARE(spy1.count(), 0); | |
445 | QCOMPARE(spy2.count(), 0); |
|
437 | QCOMPARE(spy2.count(), 0); | |
446 | QCOMPARE(spy3.count(), 0); |
|
438 | QCOMPARE(spy3.count(), 0); | |
447 | QCOMPARE(spy4.count(), 0); |
|
439 | QCOMPARE(spy4.count(), 0); | |
448 | QCOMPARE(spy5.count(), 0); |
|
440 | QCOMPARE(spy5.count(), 0); | |
449 | QCOMPARE(spy6.count(), 0); |
|
441 | QCOMPARE(spy6.count(), 0); | |
450 | QCOMPARE(spy7.count(), 0); |
|
442 | QCOMPARE(spy7.count(), 0); | |
451 | QCOMPARE(spy8.count(), 0); |
|
443 | QCOMPARE(spy8.count(), 0); | |
452 |
|
444 | |||
453 | m_view->show(); |
|
445 | m_view->show(); | |
454 | QTest::qWaitForWindowShown(m_view); |
|
446 | QTest::qWaitForWindowShown(m_view); | |
455 | QCOMPARE(m_axis->labelsFont(), labelsFont); |
|
447 | QCOMPARE(m_axis->labelsFont(), labelsFont); | |
456 |
|
448 | |||
457 | } |
|
449 | } | |
458 |
|
450 | |||
459 | void tst_QAbstractAxis::labelsPen_data() |
|
451 | void tst_QAbstractAxis::labelsPen_data() | |
460 | { |
|
452 | { | |
461 | QTest::addColumn<QPen>("labelsPen"); |
|
453 | QTest::addColumn<QPen>("labelsPen"); | |
462 | QTest::newRow("null") << QPen(); |
|
454 | QTest::newRow("null") << QPen(); | |
463 | QTest::newRow("blue") << QPen(Qt::blue); |
|
455 | QTest::newRow("blue") << QPen(Qt::blue); | |
464 | QTest::newRow("black") << QPen(Qt::black); |
|
456 | QTest::newRow("black") << QPen(Qt::black); | |
465 | QTest::newRow("red") << QPen(Qt::red); |
|
457 | QTest::newRow("red") << QPen(Qt::red); | |
466 | } |
|
458 | } | |
467 |
|
459 | |||
468 | void tst_QAbstractAxis::labelsPen() |
|
460 | void tst_QAbstractAxis::labelsPen() | |
469 | { |
|
461 | { | |
470 | QFETCH(QPen, labelsPen); |
|
462 | QFETCH(QPen, labelsPen); | |
471 |
|
463 | |||
472 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
464 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
473 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
465 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
474 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
466 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
475 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
467 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
476 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
468 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
477 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
469 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
478 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
470 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
479 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
471 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
480 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
472 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
481 |
|
473 | |||
482 | m_axis->setLabelsPen(labelsPen); |
|
474 | m_axis->setLabelsPen(labelsPen); | |
483 | QCOMPARE(m_axis->labelsPen(), labelsPen); |
|
475 | QCOMPARE(m_axis->labelsPen(), labelsPen); | |
484 |
|
476 | |||
485 | QCOMPARE(spy0.count(), 0); |
|
477 | QCOMPARE(spy0.count(), 0); | |
486 | QCOMPARE(spy1.count(), 0); |
|
478 | QCOMPARE(spy1.count(), 0); | |
487 | QCOMPARE(spy2.count(), 0); |
|
479 | QCOMPARE(spy2.count(), 0); | |
488 | QCOMPARE(spy3.count(), 0); |
|
480 | QCOMPARE(spy3.count(), 0); | |
489 | QCOMPARE(spy4.count(), 0); |
|
481 | QCOMPARE(spy4.count(), 0); | |
490 | QCOMPARE(spy5.count(), 0); |
|
482 | QCOMPARE(spy5.count(), 0); | |
491 | QCOMPARE(spy6.count(), 0); |
|
483 | QCOMPARE(spy6.count(), 0); | |
492 | QCOMPARE(spy7.count(), 0); |
|
484 | QCOMPARE(spy7.count(), 0); | |
493 | QCOMPARE(spy8.count(), 0); |
|
485 | QCOMPARE(spy8.count(), 0); | |
494 |
|
486 | |||
495 | m_chart->setAxisX(m_axis, m_series); |
|
487 | m_chart->setAxisX(m_axis, m_series); | |
496 | m_view->show(); |
|
488 | m_view->show(); | |
497 | QTest::qWaitForWindowShown(m_view); |
|
489 | QTest::qWaitForWindowShown(m_view); | |
498 | //TODO QCOMPARE(m_axis->labelsPen(), labelsPen); |
|
490 | //TODO QCOMPARE(m_axis->labelsPen(), labelsPen); | |
499 | } |
|
491 | } | |
500 |
|
492 | |||
501 | void tst_QAbstractAxis::labelsVisible_data() |
|
493 | void tst_QAbstractAxis::labelsVisible_data() | |
502 | { |
|
494 | { | |
503 | QTest::addColumn<bool>("labelsVisible"); |
|
495 | QTest::addColumn<bool>("labelsVisible"); | |
504 | QTest::newRow("true") << true; |
|
496 | QTest::newRow("true") << true; | |
505 | QTest::newRow("false") << false; |
|
497 | QTest::newRow("false") << false; | |
506 | } |
|
498 | } | |
507 |
|
499 | |||
508 | void tst_QAbstractAxis::labelsVisible() |
|
500 | void tst_QAbstractAxis::labelsVisible() | |
509 | { |
|
501 | { | |
510 | QFETCH(bool, labelsVisible); |
|
502 | QFETCH(bool, labelsVisible); | |
511 |
|
503 | |||
512 | m_axis->setLabelsVisible(!labelsVisible); |
|
504 | m_axis->setLabelsVisible(!labelsVisible); | |
513 |
|
505 | |||
514 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
506 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
515 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
507 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
516 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
508 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
517 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
509 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
518 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
510 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
519 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
511 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
520 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
512 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
521 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
513 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
522 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
514 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
523 |
|
515 | |||
524 | m_axis->setLabelsVisible(labelsVisible); |
|
516 | m_axis->setLabelsVisible(labelsVisible); | |
525 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); |
|
517 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); | |
526 |
|
518 | |||
527 | QCOMPARE(spy0.count(), 0); |
|
519 | QCOMPARE(spy0.count(), 0); | |
528 | QCOMPARE(spy1.count(), 0); |
|
520 | QCOMPARE(spy1.count(), 0); | |
529 | QCOMPARE(spy2.count(), 0); |
|
521 | QCOMPARE(spy2.count(), 0); | |
530 | QCOMPARE(spy3.count(), 0); |
|
522 | QCOMPARE(spy3.count(), 0); | |
531 | QCOMPARE(spy4.count(), 1); |
|
523 | QCOMPARE(spy4.count(), 1); | |
532 | QCOMPARE(spy5.count(), 0); |
|
524 | QCOMPARE(spy5.count(), 0); | |
533 | QCOMPARE(spy6.count(), 0); |
|
525 | QCOMPARE(spy6.count(), 0); | |
534 | QCOMPARE(spy7.count(), 0); |
|
526 | QCOMPARE(spy7.count(), 0); | |
535 | QCOMPARE(spy8.count(), 0); |
|
527 | QCOMPARE(spy8.count(), 0); | |
536 |
|
528 | |||
537 | m_chart->setAxisX(m_axis, m_series); |
|
529 | m_chart->setAxisX(m_axis, m_series); | |
538 | m_view->show(); |
|
530 | m_view->show(); | |
539 | QTest::qWaitForWindowShown(m_view); |
|
531 | QTest::qWaitForWindowShown(m_view); | |
540 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); |
|
532 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); | |
541 | } |
|
533 | } | |
542 |
|
534 | |||
543 | void tst_QAbstractAxis::orientation_data() |
|
535 | void tst_QAbstractAxis::orientation_data() | |
544 | { |
|
536 | { | |
545 | QTest::addColumn<Qt::Orientation>("orientation"); |
|
537 | QTest::addColumn<Qt::Orientation>("orientation"); | |
546 | QTest::newRow("Vertical") << Qt::Vertical; |
|
538 | QTest::newRow("Vertical") << Qt::Vertical; | |
547 | QTest::newRow("Horizontal") << Qt::Horizontal; |
|
539 | QTest::newRow("Horizontal") << Qt::Horizontal; | |
548 | } |
|
540 | } | |
549 |
|
541 | |||
550 | void tst_QAbstractAxis::orientation() |
|
542 | void tst_QAbstractAxis::orientation() | |
551 | { |
|
543 | { | |
552 | QFETCH(Qt::Orientation, orientation); |
|
544 | QFETCH(Qt::Orientation, orientation); | |
553 |
|
545 | |||
554 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
546 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
555 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
547 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
556 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
548 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
557 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
549 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
558 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
550 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
559 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
551 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
560 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
552 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
561 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
553 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
562 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
554 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
563 |
|
555 | |||
564 | if(orientation==Qt::Vertical){ |
|
556 | if(orientation==Qt::Vertical){ | |
565 | m_chart->setAxisY(m_axis,m_series); |
|
557 | m_chart->setAxisY(m_axis,m_series); | |
566 | }else{ |
|
558 | }else{ | |
567 | m_chart->setAxisX(m_axis,m_series); |
|
559 | m_chart->setAxisX(m_axis,m_series); | |
568 | } |
|
560 | } | |
569 | QCOMPARE(m_axis->orientation(), orientation); |
|
561 | QCOMPARE(m_axis->orientation(), orientation); | |
570 |
|
562 | |||
571 | QCOMPARE(spy0.count(), 0); |
|
563 | QCOMPARE(spy0.count(), 0); | |
572 | QCOMPARE(spy1.count(), 0); |
|
564 | QCOMPARE(spy1.count(), 0); | |
573 | QCOMPARE(spy2.count(), 0); |
|
565 | QCOMPARE(spy2.count(), 0); | |
574 | QCOMPARE(spy3.count(), 0); |
|
566 | QCOMPARE(spy3.count(), 0); | |
575 | QCOMPARE(spy4.count(), 0); |
|
567 | QCOMPARE(spy4.count(), 0); | |
576 | QCOMPARE(spy5.count(), 0); |
|
568 | QCOMPARE(spy5.count(), 0); | |
577 | QCOMPARE(spy6.count(), 0); |
|
569 | QCOMPARE(spy6.count(), 0); | |
578 | QCOMPARE(spy7.count(), 0); |
|
570 | QCOMPARE(spy7.count(), 0); | |
579 | QCOMPARE(spy8.count(), 1); |
|
571 | QCOMPARE(spy8.count(), 1); | |
580 |
|
572 | |||
581 | m_view->show(); |
|
573 | m_view->show(); | |
582 | QTest::qWaitForWindowShown(m_view); |
|
574 | QTest::qWaitForWindowShown(m_view); | |
583 | QCOMPARE(m_axis->orientation(), orientation); |
|
575 | QCOMPARE(m_axis->orientation(), orientation); | |
584 | } |
|
576 | } | |
585 |
|
577 | |||
586 | void tst_QAbstractAxis::setMax_data() |
|
578 | void tst_QAbstractAxis::setMax_data() | |
587 | { |
|
579 | { | |
588 | //just check if it does not crash |
|
580 | //just check if it does not crash | |
589 | QTest::addColumn<QVariant>("max"); |
|
581 | QTest::addColumn<QVariant>("max"); | |
590 | QTest::newRow("something") << QVariant("something"); |
|
582 | QTest::newRow("something") << QVariant("something"); | |
591 | QTest::newRow("1.0") << QVariant(1.0); |
|
583 | QTest::newRow("1.0") << QVariant(1.0); | |
592 | } |
|
584 | } | |
593 |
|
585 | |||
594 | void tst_QAbstractAxis::setMax() |
|
586 | void tst_QAbstractAxis::setMax() | |
595 | { |
|
587 | { | |
596 | QFETCH(QVariant, max); |
|
588 | QFETCH(QVariant, max); | |
597 | m_axis->setMax(max); |
|
589 | m_axis->setMax(max); | |
598 | } |
|
590 | } | |
599 |
|
591 | |||
600 | void tst_QAbstractAxis::setMin_data() |
|
592 | void tst_QAbstractAxis::setMin_data() | |
601 | { |
|
593 | { | |
602 | //just check if it does not crash |
|
594 | //just check if it does not crash | |
603 | QTest::addColumn<QVariant>("min"); |
|
595 | QTest::addColumn<QVariant>("min"); | |
604 | QTest::newRow("something") << QVariant("something"); |
|
596 | QTest::newRow("something") << QVariant("something"); | |
605 | QTest::newRow("1.0") << QVariant(1.0); |
|
597 | QTest::newRow("1.0") << QVariant(1.0); | |
606 | } |
|
598 | } | |
607 |
|
599 | |||
608 | // public void setMin(QVariant const& min) |
|
600 | // public void setMin(QVariant const& min) | |
609 | void tst_QAbstractAxis::setMin() |
|
601 | void tst_QAbstractAxis::setMin() | |
610 | { |
|
602 | { | |
611 | QFETCH(QVariant, min); |
|
603 | QFETCH(QVariant, min); | |
612 | m_axis->setMin(min); |
|
604 | m_axis->setMin(min); | |
613 | } |
|
605 | } | |
614 |
|
606 | |||
615 | void tst_QAbstractAxis::setRange_data() |
|
607 | void tst_QAbstractAxis::setRange_data() | |
616 | { |
|
608 | { | |
617 | //just check if it does not crash |
|
609 | //just check if it does not crash | |
618 | QTest::addColumn<QVariant>("min"); |
|
610 | QTest::addColumn<QVariant>("min"); | |
619 | QTest::addColumn<QVariant>("max"); |
|
611 | QTest::addColumn<QVariant>("max"); | |
620 | QTest::newRow("something") << QVariant("something0") << QVariant("something1"); |
|
612 | QTest::newRow("something") << QVariant("something0") << QVariant("something1"); | |
621 | QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0); |
|
613 | QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0); | |
622 | } |
|
614 | } | |
623 |
|
615 | |||
624 | // public void setRange(QVariant const& min, QVariant const& max) |
|
616 | // public void setRange(QVariant const& min, QVariant const& max) | |
625 | void tst_QAbstractAxis::setRange() |
|
617 | void tst_QAbstractAxis::setRange() | |
626 | { |
|
618 | { | |
627 |
|
619 | |||
628 | QFETCH(QVariant, min); |
|
620 | QFETCH(QVariant, min); | |
629 | QFETCH(QVariant, max); |
|
621 | QFETCH(QVariant, max); | |
630 | m_axis->setRange(min,max); |
|
622 | m_axis->setRange(min,max); | |
631 | } |
|
623 | } | |
632 |
|
624 | |||
633 | void tst_QAbstractAxis::shadesBorderColor_data() |
|
625 | void tst_QAbstractAxis::shadesBorderColor_data() | |
634 | { |
|
626 | { | |
635 |
|
627 | |||
636 | } |
|
628 | } | |
637 |
|
629 | |||
638 | void tst_QAbstractAxis::shadesBorderColor() |
|
630 | void tst_QAbstractAxis::shadesBorderColor() | |
639 | { |
|
631 | { | |
640 | #ifdef QT5_QUICK_1 |
|
632 | QSKIP("Test is not implemented. This is deprecated function", SkipAll); | |
641 | QSKIP("Test is not implemented. This is depreciated function"); |
|
|||
642 | #else |
|
|||
643 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
|||
644 | #endif |
|
|||
645 | } |
|
633 | } | |
646 |
|
634 | |||
647 | void tst_QAbstractAxis::shadesBrush_data() |
|
635 | void tst_QAbstractAxis::shadesBrush_data() | |
648 | { |
|
636 | { | |
649 | QTest::addColumn<QBrush>("shadesBrush"); |
|
637 | QTest::addColumn<QBrush>("shadesBrush"); | |
650 | QTest::newRow("null") << QBrush(); |
|
638 | QTest::newRow("null") << QBrush(); | |
651 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
639 | QTest::newRow("blue") << QBrush(Qt::blue); | |
652 | QTest::newRow("black") << QBrush(Qt::black); |
|
640 | QTest::newRow("black") << QBrush(Qt::black); | |
653 | } |
|
641 | } | |
654 |
|
642 | |||
655 | void tst_QAbstractAxis::shadesBrush() |
|
643 | void tst_QAbstractAxis::shadesBrush() | |
656 | { |
|
644 | { | |
657 | QFETCH(QBrush, shadesBrush); |
|
645 | QFETCH(QBrush, shadesBrush); | |
658 |
|
646 | |||
659 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
647 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
660 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
648 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
661 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
649 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
662 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
650 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
663 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
651 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
664 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
652 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
665 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
653 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
666 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
654 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
667 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
655 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
668 |
|
656 | |||
669 | m_axis->setShadesBrush(shadesBrush); |
|
657 | m_axis->setShadesBrush(shadesBrush); | |
670 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); |
|
658 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); | |
671 |
|
659 | |||
672 | QCOMPARE(spy0.count(), 0); |
|
660 | QCOMPARE(spy0.count(), 0); | |
673 | QCOMPARE(spy1.count(), 0); |
|
661 | QCOMPARE(spy1.count(), 0); | |
674 | QCOMPARE(spy2.count(), 0); |
|
662 | QCOMPARE(spy2.count(), 0); | |
675 | QCOMPARE(spy3.count(), 0); |
|
663 | QCOMPARE(spy3.count(), 0); | |
676 | QCOMPARE(spy4.count(), 0); |
|
664 | QCOMPARE(spy4.count(), 0); | |
677 | QCOMPARE(spy5.count(), 0); |
|
665 | QCOMPARE(spy5.count(), 0); | |
678 | //TODO QCOMPARE(spy6.count(), 0); |
|
666 | //TODO QCOMPARE(spy6.count(), 0); | |
679 | QCOMPARE(spy7.count(), 0); |
|
667 | QCOMPARE(spy7.count(), 0); | |
680 | QCOMPARE(spy8.count(), 0); |
|
668 | QCOMPARE(spy8.count(), 0); | |
681 |
|
669 | |||
682 | m_view->show(); |
|
670 | m_view->show(); | |
683 | QTest::qWaitForWindowShown(m_view); |
|
671 | QTest::qWaitForWindowShown(m_view); | |
684 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); |
|
672 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); | |
685 | } |
|
673 | } | |
686 |
|
674 | |||
687 | void tst_QAbstractAxis::shadesColor_data() |
|
675 | void tst_QAbstractAxis::shadesColor_data() | |
688 | { |
|
676 | { | |
689 | } |
|
677 | } | |
690 |
|
678 | |||
691 | // public QColor shadesColor() const |
|
679 | // public QColor shadesColor() const | |
692 | void tst_QAbstractAxis::shadesColor() |
|
680 | void tst_QAbstractAxis::shadesColor() | |
693 | { |
|
681 | { | |
694 | #ifdef QT5_QUICK_1 |
|
682 | QSKIP("Test is not implemented. This is deprecated function", SkipAll); | |
695 | QSKIP("Test is not implemented. This is depreciated function"); |
|
|||
696 | #else |
|
|||
697 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
|||
698 | #endif |
|
|||
699 | } |
|
683 | } | |
700 |
|
684 | |||
701 | void tst_QAbstractAxis::shadesPen_data() |
|
685 | void tst_QAbstractAxis::shadesPen_data() | |
702 | { |
|
686 | { | |
703 | QTest::addColumn<QPen>("shadesPen"); |
|
687 | QTest::addColumn<QPen>("shadesPen"); | |
704 | QTest::newRow("null") << QPen(); |
|
688 | QTest::newRow("null") << QPen(); | |
705 | QTest::newRow("blue") << QPen(Qt::blue); |
|
689 | QTest::newRow("blue") << QPen(Qt::blue); | |
706 | QTest::newRow("black") << QPen(Qt::black); |
|
690 | QTest::newRow("black") << QPen(Qt::black); | |
707 | QTest::newRow("red") << QPen(Qt::red); |
|
691 | QTest::newRow("red") << QPen(Qt::red); | |
708 | } |
|
692 | } | |
709 |
|
693 | |||
710 | void tst_QAbstractAxis::shadesPen() |
|
694 | void tst_QAbstractAxis::shadesPen() | |
711 | { |
|
695 | { | |
712 | QFETCH(QPen, shadesPen); |
|
696 | QFETCH(QPen, shadesPen); | |
713 |
|
697 | |||
714 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
698 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
715 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
699 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
716 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
700 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
717 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
701 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
718 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
702 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
719 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
703 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
720 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
704 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
721 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
705 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
722 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
706 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
723 |
|
707 | |||
724 | m_axis->setShadesPen(shadesPen); |
|
708 | m_axis->setShadesPen(shadesPen); | |
725 | QCOMPARE(m_axis->shadesPen(), shadesPen); |
|
709 | QCOMPARE(m_axis->shadesPen(), shadesPen); | |
726 |
|
710 | |||
727 | QCOMPARE(spy0.count(), 0); |
|
711 | QCOMPARE(spy0.count(), 0); | |
728 | QCOMPARE(spy1.count(), 0); |
|
712 | QCOMPARE(spy1.count(), 0); | |
729 | QCOMPARE(spy2.count(), 0); |
|
713 | QCOMPARE(spy2.count(), 0); | |
730 | QCOMPARE(spy3.count(), 0); |
|
714 | QCOMPARE(spy3.count(), 0); | |
731 | QCOMPARE(spy4.count(), 0); |
|
715 | QCOMPARE(spy4.count(), 0); | |
732 | QCOMPARE(spy5.count(), 0); |
|
716 | QCOMPARE(spy5.count(), 0); | |
733 | QCOMPARE(spy6.count(), 0); |
|
717 | QCOMPARE(spy6.count(), 0); | |
734 | QCOMPARE(spy7.count(), 0); |
|
718 | QCOMPARE(spy7.count(), 0); | |
735 | QCOMPARE(spy8.count(), 0); |
|
719 | QCOMPARE(spy8.count(), 0); | |
736 |
|
720 | |||
737 | m_chart->setAxisX(m_axis, m_series); |
|
721 | m_chart->setAxisX(m_axis, m_series); | |
738 | m_view->show(); |
|
722 | m_view->show(); | |
739 | QTest::qWaitForWindowShown(m_view); |
|
723 | QTest::qWaitForWindowShown(m_view); | |
740 | QCOMPARE(m_axis->shadesPen(), shadesPen); |
|
724 | QCOMPARE(m_axis->shadesPen(), shadesPen); | |
741 | } |
|
725 | } | |
742 |
|
726 | |||
743 | void tst_QAbstractAxis::shadesVisible_data() |
|
727 | void tst_QAbstractAxis::shadesVisible_data() | |
744 | { |
|
728 | { | |
745 | QTest::addColumn<bool>("shadesVisible"); |
|
729 | QTest::addColumn<bool>("shadesVisible"); | |
746 | QTest::newRow("true") << true; |
|
730 | QTest::newRow("true") << true; | |
747 | QTest::newRow("false") << false; |
|
731 | QTest::newRow("false") << false; | |
748 | } |
|
732 | } | |
749 |
|
733 | |||
750 | void tst_QAbstractAxis::shadesVisible() |
|
734 | void tst_QAbstractAxis::shadesVisible() | |
751 | { |
|
735 | { | |
752 | QFETCH(bool, shadesVisible); |
|
736 | QFETCH(bool, shadesVisible); | |
753 |
|
737 | |||
754 | m_axis->setShadesVisible(!shadesVisible); |
|
738 | m_axis->setShadesVisible(!shadesVisible); | |
755 |
|
739 | |||
756 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
740 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
757 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
741 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
758 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
742 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
759 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
743 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
760 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
744 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
761 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
745 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
762 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
746 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
763 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
747 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
764 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
748 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
765 |
|
749 | |||
766 | m_axis->setShadesVisible(shadesVisible); |
|
750 | m_axis->setShadesVisible(shadesVisible); | |
767 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); |
|
751 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); | |
768 |
|
752 | |||
769 | QCOMPARE(spy0.count(), 0); |
|
753 | QCOMPARE(spy0.count(), 0); | |
770 | QCOMPARE(spy1.count(), 0); |
|
754 | QCOMPARE(spy1.count(), 0); | |
771 | QCOMPARE(spy2.count(), 0); |
|
755 | QCOMPARE(spy2.count(), 0); | |
772 | QCOMPARE(spy3.count(), 0); |
|
756 | QCOMPARE(spy3.count(), 0); | |
773 | QCOMPARE(spy4.count(), 0); |
|
757 | QCOMPARE(spy4.count(), 0); | |
774 | QCOMPARE(spy5.count(), 0); |
|
758 | QCOMPARE(spy5.count(), 0); | |
775 | QCOMPARE(spy6.count(), 0); |
|
759 | QCOMPARE(spy6.count(), 0); | |
776 | QCOMPARE(spy7.count(), 1); |
|
760 | QCOMPARE(spy7.count(), 1); | |
777 | QCOMPARE(spy8.count(), 0); |
|
761 | QCOMPARE(spy8.count(), 0); | |
778 |
|
762 | |||
779 | m_chart->setAxisX(m_axis, m_series); |
|
763 | m_chart->setAxisX(m_axis, m_series); | |
780 | m_view->show(); |
|
764 | m_view->show(); | |
781 | QTest::qWaitForWindowShown(m_view); |
|
765 | QTest::qWaitForWindowShown(m_view); | |
782 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); |
|
766 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); | |
783 | } |
|
767 | } | |
784 |
|
768 | |||
785 | void tst_QAbstractAxis::show_data() |
|
769 | void tst_QAbstractAxis::show_data() | |
786 | { |
|
770 | { | |
787 |
|
771 | |||
788 | } |
|
772 | } | |
789 |
|
773 | |||
790 | void tst_QAbstractAxis::show() |
|
774 | void tst_QAbstractAxis::show() | |
791 | { |
|
775 | { | |
792 | m_axis->hide(); |
|
776 | m_axis->hide(); | |
793 | QCOMPARE(m_axis->isVisible(), false); |
|
777 | QCOMPARE(m_axis->isVisible(), false); | |
794 |
|
778 | |||
795 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
779 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
796 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
780 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
797 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
781 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
798 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
782 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
799 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
783 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
800 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
784 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
801 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
785 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
802 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
786 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
803 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
787 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
804 |
|
788 | |||
805 | m_axis->show(); |
|
789 | m_axis->show(); | |
806 |
|
790 | |||
807 | QCOMPARE(spy0.count(), 0); |
|
791 | QCOMPARE(spy0.count(), 0); | |
808 | QCOMPARE(spy1.count(), 0); |
|
792 | QCOMPARE(spy1.count(), 0); | |
809 | QCOMPARE(spy2.count(), 0); |
|
793 | QCOMPARE(spy2.count(), 0); | |
810 | QCOMPARE(spy3.count(), 0); |
|
794 | QCOMPARE(spy3.count(), 0); | |
811 | QCOMPARE(spy4.count(), 0); |
|
795 | QCOMPARE(spy4.count(), 0); | |
812 | QCOMPARE(spy5.count(), 0); |
|
796 | QCOMPARE(spy5.count(), 0); | |
813 | QCOMPARE(spy6.count(), 0); |
|
797 | QCOMPARE(spy6.count(), 0); | |
814 | QCOMPARE(spy7.count(), 0); |
|
798 | QCOMPARE(spy7.count(), 0); | |
815 | QCOMPARE(spy8.count(), 1); |
|
799 | QCOMPARE(spy8.count(), 1); | |
816 | QCOMPARE(m_axis->isVisible(), true); |
|
800 | QCOMPARE(m_axis->isVisible(), true); | |
817 | } |
|
801 | } | |
818 |
|
802 | |||
819 | void tst_QAbstractAxis::hide_data() |
|
803 | void tst_QAbstractAxis::hide_data() | |
820 | { |
|
804 | { | |
821 |
|
805 | |||
822 | } |
|
806 | } | |
823 |
|
807 | |||
824 | void tst_QAbstractAxis::hide() |
|
808 | void tst_QAbstractAxis::hide() | |
825 | { |
|
809 | { | |
826 | m_axis->show(); |
|
810 | m_axis->show(); | |
827 | QCOMPARE(m_axis->isVisible(),true); |
|
811 | QCOMPARE(m_axis->isVisible(),true); | |
828 |
|
812 | |||
829 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); |
|
813 | QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); | |
830 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
814 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
831 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
815 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
832 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
816 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
833 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
817 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
834 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
818 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
835 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
819 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
836 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
820 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
837 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
821 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
838 |
|
822 | |||
839 | m_axis->hide(); |
|
823 | m_axis->hide(); | |
840 |
|
824 | |||
841 | QCOMPARE(spy0.count(), 0); |
|
825 | QCOMPARE(spy0.count(), 0); | |
842 | QCOMPARE(spy1.count(), 0); |
|
826 | QCOMPARE(spy1.count(), 0); | |
843 | QCOMPARE(spy2.count(), 0); |
|
827 | QCOMPARE(spy2.count(), 0); | |
844 | QCOMPARE(spy3.count(), 0); |
|
828 | QCOMPARE(spy3.count(), 0); | |
845 | QCOMPARE(spy4.count(), 0); |
|
829 | QCOMPARE(spy4.count(), 0); | |
846 | QCOMPARE(spy5.count(), 0); |
|
830 | QCOMPARE(spy5.count(), 0); | |
847 | QCOMPARE(spy6.count(), 0); |
|
831 | QCOMPARE(spy6.count(), 0); | |
848 | QCOMPARE(spy7.count(), 0); |
|
832 | QCOMPARE(spy7.count(), 0); | |
849 | QCOMPARE(spy8.count(), 1); |
|
833 | QCOMPARE(spy8.count(), 1); | |
850 | QCOMPARE(m_axis->isVisible(),false); |
|
834 | QCOMPARE(m_axis->isVisible(),false); | |
851 | } |
|
835 | } | |
852 |
|
836 | |||
853 |
|
837 | |||
854 |
|
838 | |||
855 |
|
839 | |||
856 |
|
840 | |||
857 |
|
841 | |||
858 |
|
842 | |||
859 |
|
843 | |||
860 |
|
844 | |||
861 |
|
845 | |||
862 |
|
846 | |||
863 |
|
847 |
@@ -1,9 +1,5 | |||||
1 | !include( ../auto.pri ) { |
|
1 | !include( ../auto.pri ) { | |
2 | error( "Couldn't find the auto.pri file!" ) |
|
2 | error( "Couldn't find the auto.pri file!" ) | |
3 | } |
|
3 | } | |
4 | SOURCES += tst_qml.cpp |
|
4 | SOURCES += tst_qml.cpp | |
5 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
5 | QT += declarative | |
6 | QT += quick1 |
|
|||
7 | } else { |
|
|||
8 | QT += declarative |
|
|||
9 | } |
|
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
@@ -1,206 +1,200 | |||||
1 | // checksum 0x78c version 0x60010 |
|
1 | // checksum 0x78c version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QDir> |
|
13 | #include <QtCore/QDir> | |
14 | #include <QtCore/QFileInfo> |
|
14 | #include <QtCore/QFileInfo> | |
15 | #ifdef QT5_QUICK_1 |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
16 |
|
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
17 |
|
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
18 | #include <QtQuick1/QDeclarativeContext> |
|
|||
19 | #else |
|
|||
20 | #include <QtDeclarative/QDeclarativeComponent> |
|
|||
21 | #include <QtDeclarative/QDeclarativeEngine> |
|
|||
22 | #include <QtDeclarative/QDeclarativeContext> |
|
|||
23 | #endif |
|
|||
24 | #include <QApplication> |
|
18 | #include <QApplication> | |
25 |
|
19 | |||
26 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
27 |
|
21 | |||
28 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
29 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
30 | #endif |
|
24 | #endif | |
31 |
|
25 | |||
32 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
33 |
|
27 | |||
34 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
35 |
|
29 | |||
36 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
37 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
38 | #endif |
|
32 | #endif | |
39 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
40 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
41 | #endif |
|
35 | #endif | |
42 |
|
36 | |||
43 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
44 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
45 | { |
|
39 | { | |
46 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
47 | { |
|
41 | { | |
48 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
49 | } |
|
43 | } | |
50 | }; |
|
44 | }; | |
51 |
|
45 | |||
52 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
53 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
54 |
|
48 | |||
55 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
56 |
|
50 | |||
57 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
58 | { |
|
52 | { | |
59 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
60 |
|
54 | |||
61 | QString mainQmlFile; |
|
55 | QString mainQmlFile; | |
62 | QDeclarativeView *view; |
|
56 | QDeclarativeView *view; | |
63 | friend class QmlApplicationViewer; |
|
57 | friend class QmlApplicationViewer; | |
64 | QString adjustPath(const QString &path); |
|
58 | QString adjustPath(const QString &path); | |
65 | }; |
|
59 | }; | |
66 |
|
60 | |||
67 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
68 | { |
|
62 | { | |
69 | #ifdef Q_OS_UNIX |
|
63 | #ifdef Q_OS_UNIX | |
70 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
71 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
72 | return QCoreApplication::applicationDirPath() |
|
66 | return QCoreApplication::applicationDirPath() | |
73 | + QLatin1String("/../Resources/") + path; |
|
67 | + QLatin1String("/../Resources/") + path; | |
74 | #else |
|
68 | #else | |
75 | QString pathInInstallDir; |
|
69 | QString pathInInstallDir; | |
76 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
77 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
78 |
|
72 | |||
79 | if (QFileInfo(pathInInstallDir).exists()) |
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
80 | return pathInInstallDir; |
|
74 | return pathInInstallDir; | |
81 | #endif |
|
75 | #endif | |
82 | #endif |
|
76 | #endif | |
83 | return path; |
|
77 | return path; | |
84 | } |
|
78 | } | |
85 |
|
79 | |||
86 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
87 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
88 | , d(new QmlApplicationViewerPrivate(this)) |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
89 | { |
|
83 | { | |
90 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
91 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
92 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
93 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
94 | #if !defined(NO_JSDEBUGGER) |
|
88 | #if !defined(NO_JSDEBUGGER) | |
95 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
96 | #endif |
|
90 | #endif | |
97 | #if !defined(NO_QMLOBSERVER) |
|
91 | #if !defined(NO_QMLOBSERVER) | |
98 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
99 | #endif |
|
93 | #endif | |
100 | #endif |
|
94 | #endif | |
101 | } |
|
95 | } | |
102 |
|
96 | |||
103 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
104 | : QDeclarativeView(parent) |
|
98 | : QDeclarativeView(parent) | |
105 | , d(new QmlApplicationViewerPrivate(view)) |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
106 | { |
|
100 | { | |
107 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
108 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
109 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
110 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
111 | #if !defined(NO_JSDEBUGGER) |
|
105 | #if !defined(NO_JSDEBUGGER) | |
112 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
113 | #endif |
|
107 | #endif | |
114 | #if !defined(NO_QMLOBSERVER) |
|
108 | #if !defined(NO_QMLOBSERVER) | |
115 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
116 | #endif |
|
110 | #endif | |
117 | #endif |
|
111 | #endif | |
118 | } |
|
112 | } | |
119 |
|
113 | |||
120 | QmlApplicationViewer::~QmlApplicationViewer() |
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
121 | { |
|
115 | { | |
122 | delete d; |
|
116 | delete d; | |
123 | } |
|
117 | } | |
124 |
|
118 | |||
125 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
126 | { |
|
120 | { | |
127 | #ifdef HARMATTAN_BOOSTER |
|
121 | #ifdef HARMATTAN_BOOSTER | |
128 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
129 | #else |
|
123 | #else | |
130 | return new QmlApplicationViewer(); |
|
124 | return new QmlApplicationViewer(); | |
131 | #endif |
|
125 | #endif | |
132 | } |
|
126 | } | |
133 |
|
127 | |||
134 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
135 | { |
|
129 | { | |
136 | d->mainQmlFile = d->adjustPath(file); |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
137 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
138 | } |
|
132 | } | |
139 |
|
133 | |||
140 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
141 | { |
|
135 | { | |
142 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
143 | } |
|
137 | } | |
144 |
|
138 | |||
145 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
146 | //{ |
|
140 | //{ | |
147 | //#if defined(Q_OS_SYMBIAN) |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
148 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
149 | // if (orientation != ScreenOrientationAuto) { |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
150 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
151 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
152 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
153 | // return; |
|
147 | // return; | |
154 | // } |
|
148 | // } | |
155 | // } |
|
149 | // } | |
156 | //#endif // Q_OS_SYMBIAN |
|
150 | //#endif // Q_OS_SYMBIAN | |
157 |
|
151 | |||
158 | // Qt::WidgetAttribute attribute; |
|
152 | // Qt::WidgetAttribute attribute; | |
159 | // switch (orientation) { |
|
153 | // switch (orientation) { | |
160 | //#if QT_VERSION < 0x040702 |
|
154 | //#if QT_VERSION < 0x040702 | |
161 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
162 | // case ScreenOrientationLockPortrait: |
|
156 | // case ScreenOrientationLockPortrait: | |
163 | // attribute = static_cast<Qt::WidgetAttribute>(128); |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
164 | // break; |
|
158 | // break; | |
165 | // case ScreenOrientationLockLandscape: |
|
159 | // case ScreenOrientationLockLandscape: | |
166 | // attribute = static_cast<Qt::WidgetAttribute>(129); |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
167 | // break; |
|
161 | // break; | |
168 | // default: |
|
162 | // default: | |
169 | // case ScreenOrientationAuto: |
|
163 | // case ScreenOrientationAuto: | |
170 | // attribute = static_cast<Qt::WidgetAttribute>(130); |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
171 | // break; |
|
165 | // break; | |
172 | //#else // QT_VERSION < 0x040702 |
|
166 | //#else // QT_VERSION < 0x040702 | |
173 | // case ScreenOrientationLockPortrait: |
|
167 | // case ScreenOrientationLockPortrait: | |
174 | // attribute = Qt::WA_LockPortraitOrientation; |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
175 | // break; |
|
169 | // break; | |
176 | // case ScreenOrientationLockLandscape: |
|
170 | // case ScreenOrientationLockLandscape: | |
177 | // attribute = Qt::WA_LockLandscapeOrientation; |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
178 | // break; |
|
172 | // break; | |
179 | // default: |
|
173 | // default: | |
180 | // case ScreenOrientationAuto: |
|
174 | // case ScreenOrientationAuto: | |
181 | // attribute = Qt::WA_AutoOrientation; |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
182 | // break; |
|
176 | // break; | |
183 | //#endif // QT_VERSION < 0x040702 |
|
177 | //#endif // QT_VERSION < 0x040702 | |
184 | // }; |
|
178 | // }; | |
185 | // setAttribute(attribute, true); |
|
179 | // setAttribute(attribute, true); | |
186 | //} |
|
180 | //} | |
187 |
|
181 | |||
188 | void QmlApplicationViewer::showExpanded() |
|
182 | void QmlApplicationViewer::showExpanded() | |
189 | { |
|
183 | { | |
190 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
191 | d->view->showFullScreen(); |
|
185 | d->view->showFullScreen(); | |
192 | #elif defined(Q_WS_MAEMO_5) |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
193 | d->view->showMaximized(); |
|
187 | d->view->showMaximized(); | |
194 | #else |
|
188 | #else | |
195 | d->view->show(); |
|
189 | d->view->show(); | |
196 | #endif |
|
190 | #endif | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | QApplication *createApplication(int &argc, char **argv) |
|
193 | QApplication *createApplication(int &argc, char **argv) | |
200 | { |
|
194 | { | |
201 | #ifdef HARMATTAN_BOOSTER |
|
195 | #ifdef HARMATTAN_BOOSTER | |
202 | return MDeclarativeCache::qApplication(argc, argv); |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
203 | #else |
|
197 | #else | |
204 | return new QApplication(argc, argv); |
|
198 | return new QApplication(argc, argv); | |
205 | #endif |
|
199 | #endif | |
206 | } |
|
200 | } |
@@ -1,51 +1,47 | |||||
1 | // checksum 0x82ed version 0x60010 |
|
1 | // checksum 0x82ed version 0x60010 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
12 | #define QMLAPPLICATIONVIEWER_H |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
13 |
|
13 | |||
14 | #ifdef QT5_QUICK_1 |
|
14 | #include <QtDeclarative/QDeclarativeView> | |
15 | #include <QtQuick1/QDeclarativeView> |
|
|||
16 | #else |
|
|||
17 | #include <QtDeclarative/QDeclarativeView> |
|
|||
18 | #endif |
|
|||
19 |
|
15 | |||
20 | class QmlApplicationViewer : public QDeclarativeView |
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
21 | { |
|
17 | { | |
22 | Q_OBJECT |
|
18 | Q_OBJECT | |
23 |
|
19 | |||
24 | public: |
|
20 | public: | |
25 | enum ScreenOrientation { |
|
21 | enum ScreenOrientation { | |
26 | ScreenOrientationLockPortrait, |
|
22 | ScreenOrientationLockPortrait, | |
27 | ScreenOrientationLockLandscape, |
|
23 | ScreenOrientationLockLandscape, | |
28 | ScreenOrientationAuto |
|
24 | ScreenOrientationAuto | |
29 | }; |
|
25 | }; | |
30 |
|
26 | |||
31 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
32 | virtual ~QmlApplicationViewer(); |
|
28 | virtual ~QmlApplicationViewer(); | |
33 |
|
29 | |||
34 | static QmlApplicationViewer *create(); |
|
30 | static QmlApplicationViewer *create(); | |
35 |
|
31 | |||
36 | void setMainQmlFile(const QString &file); |
|
32 | void setMainQmlFile(const QString &file); | |
37 | void addImportPath(const QString &path); |
|
33 | void addImportPath(const QString &path); | |
38 |
|
34 | |||
39 | // Note that this will only have an effect on Symbian and Fremantle. |
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
40 | // void setOrientation(ScreenOrientation orientation); |
|
36 | // void setOrientation(ScreenOrientation orientation); | |
41 |
|
37 | |||
42 | void showExpanded(); |
|
38 | void showExpanded(); | |
43 |
|
39 | |||
44 | private: |
|
40 | private: | |
45 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
46 | class QmlApplicationViewerPrivate *d; |
|
42 | class QmlApplicationViewerPrivate *d; | |
47 | }; |
|
43 | }; | |
48 |
|
44 | |||
49 | QApplication *createApplication(int &argc, char **argv); |
|
45 | QApplication *createApplication(int &argc, char **argv); | |
50 |
|
46 | |||
51 | #endif // QMLAPPLICATIONVIEWER_H |
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,17 +1,13 | |||||
1 | greaterThan(QT_MAJOR_VERSION, 4) { |
|
1 | QT += declarative | |
2 | QT += quick1 |
|
|||
3 | } else { |
|
|||
4 | QT += declarative |
|
|||
5 | } |
|
|||
6 |
|
2 | |||
7 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
8 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
9 | INCLUDEPATH += $$PWD |
|
5 | INCLUDEPATH += $$PWD | |
10 |
|
6 | |||
11 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
12 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
13 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
14 | } else { |
|
10 | } else { | |
15 | DEFINES -= QMLJSDEBUGGER |
|
11 | DEFINES -= QMLJSDEBUGGER | |
16 | } |
|
12 | } | |
17 |
|
13 |
General Comments 0
You need to be logged in to leave comments.
Login now