Merge lp:~kalikiana/dee-qt/deevarianttext into lp:dee-qt/0.2
- deevarianttext
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~kalikiana/dee-qt/deevarianttext |
Merge into: | lp:dee-qt/0.2 |
Prerequisite: | lp:~unity-team/dee-qt/qt4-and-qt5 |
Diff against target: |
1252 lines (+589/-260) 29 files modified
.bzrignore (+16/-3) CMakeLists.txt (+30/-90) debian/changelog (+13/-0) debian/control (+9/-7) debian/libdee-qt-3.install (+3/-3) debian/libdee-qt-dev.install (+3/-3) debian/libdee-qt5-3.install (+3/-3) debian/libdee-qt5-dev.install (+3/-3) deelistmodel.cpp (+19/-21) deelistmodel.h (+3/-2) deeprivate.h (+23/-0) deevarianttext.cpp (+72/-0) deevarianttext.h (+49/-0) libdee-qt.pc.in (+5/-5) modules/CMakeLists.txt (+1/-0) modules/Dee/CMakeLists.txt (+46/-0) modules/Dee/plugin.cpp (+5/-3) modules/Dee/plugin.h (+1/-1) modules/Dee/qmldir (+1/-1) test.cpp (+0/-35) test.h (+0/-52) test_qtquick2.qml (+0/-15) tests/CMakeLists.txt (+57/-0) tests/conversiontest.cpp (+1/-0) tests/deevarianttexttest.cpp (+58/-0) tests/qtquick1plugintest.cpp (+48/-0) tests/test_qtquick1.qml (+38/-13) tests/tst_deelistmodel.qml (+22/-0) tests/tst_deevarianttext.qml (+60/-0) |
To merge this branch: | bzr merge lp:~kalikiana/dee-qt/deevarianttext |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michał Sawicz | Pending | ||
Review via email: mp+137918@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-12-04.
Commit message
Description of the change
- 97. By Cris Dywan
- 98. By Cris Dywan
-
Fix running deevarianttexttest
- 99. By Cris Dywan
-
Add insertRemoveTest (needs improvement)
- 100. By Cris Dywan
-
Fixup insertRemoveTest
- 101. By Cris Dywan
-
Use QSignalSpy instead of manual callbacks to verify signals
- 102. By Cris Dywan
-
Expose append/ remove to QML to allow hosting new models
For now only in test models and no API to set the schema.
- 103. By Cris Dywan
-
Emit layoutChanged in addition to countChanged
- 104. By Cris Dywan
-
Use SignalSpy in QML - preliminary text delegate testing
- 105. By Cris Dywan
-
Use QT_INSTALL_QML (QtQuick2) instead of QT_INSTALL_IMPORTS (QtQuick1)
See http://
doc-snapshot. qt-project. org/5.0/ qtcore/ qlibraryinfo. html#LibraryLoc ation-enum - 106. By Cris Dywan
-
Drop delegate test, the approach is wrong
- 107. By Cris Dywan
-
Drop remaining pieces of delegate approach as well
Unmerged revisions
- 107. By Cris Dywan
-
Drop remaining pieces of delegate approach as well
- 106. By Cris Dywan
-
Drop delegate test, the approach is wrong
- 105. By Cris Dywan
-
Use QT_INSTALL_QML (QtQuick2) instead of QT_INSTALL_IMPORTS (QtQuick1)
See http://
doc-snapshot. qt-project. org/5.0/ qtcore/ qlibraryinfo. html#LibraryLoc ation-enum - 104. By Cris Dywan
-
Use SignalSpy in QML - preliminary text delegate testing
- 103. By Cris Dywan
-
Emit layoutChanged in addition to countChanged
- 102. By Cris Dywan
-
Expose append/ remove to QML to allow hosting new models
For now only in test models and no API to set the schema.
- 101. By Cris Dywan
-
Use QSignalSpy instead of manual callbacks to verify signals
- 100. By Cris Dywan
-
Fixup insertRemoveTest
- 99. By Cris Dywan
-
Add insertRemoveTest (needs improvement)
- 98. By Cris Dywan
-
Fix running deevarianttexttest
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2010-11-22 08:03:37 +0000 |
3 | +++ .bzrignore 2012-12-04 18:48:20 +0000 |
4 | @@ -2,7 +2,20 @@ |
5 | CMakeFiles |
6 | Makefile |
7 | cmake_install.cmake |
8 | +install_manifest.txt |
9 | +libdee-qt.so* |
10 | +libdee-qt5.so* |
11 | libQtDee.so* |
12 | -moc_*.cxx |
13 | -test |
14 | -install_manifest.txt |
15 | +moc_*.cpp |
16 | +*.moc |
17 | +*_automoc.cpp |
18 | +*.pc |
19 | +CTestTestfile.cmake |
20 | +*Test.log |
21 | +Testing |
22 | +conversiontest |
23 | +deelistmodeltest |
24 | +deevarianttexttest |
25 | +plugintest |
26 | +test-helper |
27 | +*-xunit.xml |
28 | |
29 | === modified file 'CMakeLists.txt' |
30 | --- CMakeLists.txt 2012-12-04 18:48:20 +0000 |
31 | +++ CMakeLists.txt 2012-12-04 18:48:20 +0000 |
32 | @@ -1,4 +1,4 @@ |
33 | -project(libqtdee) |
34 | +project(dee-qt) |
35 | cmake_minimum_required(VERSION 2.8.6) |
36 | |
37 | # Instruct CMake to run moc automatically when needed. |
38 | @@ -10,22 +10,15 @@ |
39 | message("Building Qt5 version") |
40 | |
41 | find_package(Qt5Core REQUIRED) |
42 | - find_package(Qt5Quick REQUIRED) |
43 | - find_package(Qt5Test REQUIRED) |
44 | find_package(Qt5DBus REQUIRED) |
45 | |
46 | add_definitions(-DWITHQT5=1) |
47 | |
48 | - set(QTDEE_LIBNAME QtDee-qt5) |
49 | - set(OUR_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5Quick_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}) |
50 | + set(DEE_QT_LIBNAME dee-qt5) |
51 | + set(OUR_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}) |
52 | set(OUR_QT_CORE_LIB ${Qt5Core_LIBRARIES}) |
53 | - set(OUR_QT_TEST_LIB ${Qt5Test_LIBRARIES}) |
54 | - set(OUR_QT_QUICK_LIB ${Qt5Quick_LIBRARIES}) |
55 | set(OUR_QT_DBUS_LIB ${Qt5DBus_LIBRARIES}) |
56 | - # FIXME: find a way to deterime that |
57 | - set(IMPORT_INSTALL_DIR /opt/qt5/imports/dee) |
58 | set(QT_PKGCONFIG_DEPENDENCIES "QtCore QtQuick") |
59 | - set(QT_DEE_PKGCONFIG_FILE libqtdee-qt5.pc) |
60 | else () |
61 | message("Building Qt4 version") |
62 | |
63 | @@ -33,94 +26,67 @@ |
64 | |
65 | add_definitions(-DWITHQT5=0) |
66 | |
67 | - set(QTDEE_LIBNAME QtDee) |
68 | - set(OUR_QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTDECLARATIVE_INCLUDE_DIR} ${QT_QTTEST_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}) |
69 | + set(DEE_QT_LIBNAME dee-qt) |
70 | + set(OUR_QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}) |
71 | set(OUR_QT_CORE_LIB ${QT_QTCORE_LIBRARIES}) |
72 | - set(OUR_QT_TEST_LIB ${QT_QTTEST_LIBRARIES}) |
73 | - set(OUR_QT_QUICK_LIB ${QT_QTDECLARATIVE_LIBRARIES}) |
74 | set(OUR_QT_DBUS_LIB ${QT_QTDBUS_LIBRARIES}) |
75 | - set(IMPORT_INSTALL_DIR lib/qt4/imports/dee) |
76 | - set(QT_PKGCONFIG_DEPENDENCIES "QtCore QtDBus QtDeclarative") |
77 | - set(QT_DEE_PKGCONFIG_FILE libqtdee.pc) |
78 | + set(QT_PKGCONFIG_DEPENDENCIES "QtCore QtDBus") |
79 | endif () |
80 | + |
81 | +set(QT_DEE_PKGCONFIG_FILE lib${DEE_QT_LIBNAME}.pc) |
82 | + |
83 | pkg_check_modules(DEE REQUIRED dee-1.0) |
84 | |
85 | # Build flags |
86 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wundef -std=c++0x") |
87 | |
88 | # Sources |
89 | -## QtDee |
90 | -set(QtDee_SRCS |
91 | +set(DEE_QT_SRCS |
92 | deelistmodel.cpp |
93 | - ) |
94 | - |
95 | -set(QtDee_MOC_HDRS |
96 | - deelistmodel.h |
97 | - ) |
98 | - |
99 | + deevarianttext.cpp |
100 | + ) |
101 | |
102 | ## QtDeeQml |
103 | set(QtDeeQml_SRCS |
104 | plugin.cpp |
105 | ) |
106 | |
107 | -set(QtDeeQml_MOC_HDRS |
108 | - plugin.h |
109 | - ) |
110 | - |
111 | # Build |
112 | add_definitions(-DQT_NO_KEYWORDS) |
113 | |
114 | include_directories( |
115 | + ${CMAKE_CURRENT_SOURCE_DIR} |
116 | ${CMAKE_CURRENT_BINARY_DIR} |
117 | ${OUR_QT_INCLUDES} |
118 | ${DEE_INCLUDE_DIRS} |
119 | ) |
120 | |
121 | -## QtDee |
122 | -add_library(${QTDEE_LIBNAME} SHARED ${QtDee_SRCS} ${QtDee_MOC_SRCS}) |
123 | -target_link_libraries(${QTDEE_LIBNAME} |
124 | +add_library(${DEE_QT_LIBNAME} SHARED ${DEE_QT_SRCS}) |
125 | +target_link_libraries(${DEE_QT_LIBNAME} |
126 | ${OUR_QT_CORE_LIB} |
127 | ${DEE_LDFLAGS} |
128 | ) |
129 | |
130 | -set_target_properties(${QTDEE_LIBNAME} PROPERTIES |
131 | - SOVERSION 2 |
132 | - VERSION 2.0.0 |
133 | - ) |
134 | - |
135 | -## QtDeeQml |
136 | -add_library(QtDeeQml SHARED ${QtDeeQml_SRCS} ${QtDeeQml_MOC_SRCS}) |
137 | - |
138 | -target_link_libraries(QtDeeQml |
139 | - ${QTDEE_LIBNAME} |
140 | - ${OUR_QT_QUICK_LIB} |
141 | - ) |
142 | - |
143 | -## test |
144 | -set(test_SRCS |
145 | - test.cpp |
146 | - ) |
147 | - |
148 | -set(test_MOC_HDRS |
149 | - test.h |
150 | - ) |
151 | - |
152 | -add_executable(test ${test_SRCS} ${test_MOC_SRCS}) |
153 | -set_target_properties(test PROPERTIES COMPILE_FLAGS -fPIC) |
154 | -target_link_libraries(test |
155 | - ${QTDEE_LIBNAME} |
156 | - ) |
157 | +set_target_properties(${DEE_QT_LIBNAME} PROPERTIES |
158 | + SOVERSION 3 |
159 | + VERSION 3.0.0 |
160 | + ) |
161 | + |
162 | +# Unit-Test |
163 | +enable_testing() |
164 | + |
165 | +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} CTEST_OUTPUT_ON_FAILURE=1) |
166 | +add_subdirectory(modules) |
167 | +add_subdirectory(tests) |
168 | |
169 | # Install |
170 | -set(INCLUDE_INSTALL_DIR include/QtDee) |
171 | +set(INCLUDE_INSTALL_DIR include/lib${DEE_QT_LIBNAME}) |
172 | |
173 | -## QtDee |
174 | -install(TARGETS ${QTDEE_LIBNAME} |
175 | +install(TARGETS ${DEE_QT_LIBNAME} |
176 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
177 | ) |
178 | |
179 | -install(FILES deelistmodel.h |
180 | +install(FILES deelistmodel.h deevarianttext.h |
181 | DESTINATION ${INCLUDE_INSTALL_DIR} |
182 | ) |
183 | |
184 | @@ -128,36 +94,10 @@ |
185 | set (PREFIX "${CMAKE_INSTALL_PREFIX}") |
186 | set (EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}") |
187 | |
188 | -configure_file (libqtdee.pc.in |
189 | +configure_file (libdee-qt.pc.in |
190 | ${CMAKE_CURRENT_BINARY_DIR}/${QT_DEE_PKGCONFIG_FILE} @ONLY) |
191 | |
192 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${QT_DEE_PKGCONFIG_FILE} |
193 | DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig |
194 | ) |
195 | |
196 | -## QtDeeQml |
197 | -install(TARGETS QtDeeQml |
198 | - LIBRARY DESTINATION ${IMPORT_INSTALL_DIR} |
199 | - ) |
200 | - |
201 | -install(FILES qmldir |
202 | - DESTINATION ${IMPORT_INSTALL_DIR} |
203 | - ) |
204 | - |
205 | -## Unit-Test |
206 | -enable_testing() |
207 | -add_executable(conversiontest conversiontest.cpp) |
208 | -target_link_libraries(conversiontest ${OUR_QT_TEST_LIB} ${QTDEE_LIBNAME}) |
209 | -set_target_properties(conversiontest PROPERTIES COMPILE_FLAGS -fPIC) |
210 | -add_test(NAME conversiontest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/conversiontest" "-p" "-xunitxml" "-p" "-o" "-p" "conversiontest-xunit.xml") |
211 | -set_property(TEST conversiontest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
212 | - |
213 | -add_executable(test-helper test-helper.cpp) |
214 | -target_link_libraries(test-helper ${OUR_QT_CORE_LIB} ${OUR_QT_DBUS_LIB} ${DEE_LDFLAGS}) |
215 | -set_target_properties(test-helper PROPERTIES COMPILE_FLAGS -fPIC) |
216 | - |
217 | -add_executable(deelistmodeltest deelistmodeltest.cpp) |
218 | -target_link_libraries(deelistmodeltest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${QTDEE_LIBNAME}) |
219 | -set_target_properties(deelistmodeltest PROPERTIES COMPILE_FLAGS -fPIC) |
220 | -add_test(NAME deelistmodeltest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/test-helper" "--task" "${CMAKE_CURRENT_BINARY_DIR}/deelistmodeltest" "-p" "-xunitxml" "-p" "-o" "-p" "deelistmodeltest-xunit.xml") |
221 | -set_property(TEST deelistmodeltest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
222 | |
223 | === modified file 'debian/changelog' |
224 | --- debian/changelog 2012-12-04 18:48:20 +0000 |
225 | +++ debian/changelog 2012-12-04 18:48:20 +0000 |
226 | @@ -1,3 +1,16 @@ |
227 | +dee-qt (3.0-0ubuntu1) quantal; urgency=low |
228 | + |
229 | + * new release |
230 | + * rename the source package to dee-qt |
231 | + * rename libqtdee to libdee-qt |
232 | + * rename libqtdee-qt5 to libdee-qt5 |
233 | + * separate plugin out into "modules" directory |
234 | + * separate tests out |
235 | + * drop obsolete test.cpp |
236 | + * rename dee 0.1 QML plugin to Dee 3.0 |
237 | + |
238 | + -- Michał Sawicz <michal.sawicz@canonical.com> Fri, 30 Nov 2012 12:32:41 +0100 |
239 | + |
240 | libqtdee (0.2.4-0ubuntu4) quantal; urgency=low |
241 | |
242 | * debian/rules |
243 | |
244 | === modified file 'debian/control' |
245 | --- debian/control 2012-12-04 18:48:20 +0000 |
246 | +++ debian/control 2012-12-04 18:48:20 +0000 |
247 | @@ -1,4 +1,4 @@ |
248 | -Source: libqtdee |
249 | +Source: dee-qt |
250 | Section: libs |
251 | Priority: optional |
252 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
253 | @@ -15,7 +15,7 @@ |
254 | # just go ahead. ~unity-team will notice and sync up the code again. |
255 | Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/dee-qt/trunk |
256 | |
257 | -Package: libqtdee2 |
258 | +Package: libdee-qt-3 |
259 | Architecture: any |
260 | Depends: ${shlibs:Depends}, |
261 | ${misc:Depends}, |
262 | @@ -24,31 +24,33 @@ |
263 | Description: Qt binding and QML plugin for Dee - shared library |
264 | Simple Qt binding and QML plugin for Dee (https://launchpad.net/dee). |
265 | |
266 | -Package: libqtdee-dev |
267 | +Package: libdee-qt-dev |
268 | Section: libdevel |
269 | Architecture: any |
270 | Depends: ${misc:Depends}, |
271 | - libqtdee2 (= ${binary:Version}), |
272 | + libdee-qt-3 (= ${binary:Version}), |
273 | libqt4-dev (>= 4.7), |
274 | + libdee-dev (>= 1.0.0), |
275 | Description: Qt binding and QML plugin for Dee - development files |
276 | Simple Qt binding and QML plugin for Dee (https://launchpad.net/dee). |
277 | . |
278 | This package contains the developer headers for the Qt binding for Dee |
279 | |
280 | -Package: libqtdee-qt5 |
281 | +Package: libdee-qt5-3 |
282 | Architecture: any |
283 | Depends: ${shlibs:Depends}, |
284 | ${misc:Depends}, |
285 | Description: Qt5 binding and QtQuick2 plugin for Dee - shared library |
286 | Simple Qt5 binding and QtQuick2 plugin for Dee (https://launchpad.net/dee). |
287 | |
288 | -Package: libqtdee-qt5-dev |
289 | +Package: libdee-qt5-dev |
290 | Section: libdevel |
291 | Architecture: any |
292 | Depends: ${misc:Depends}, |
293 | - libqtdee-qt5 (= ${binary:Version}), |
294 | + libdee-qt5-3 (= ${binary:Version}), |
295 | qtbase, |
296 | qtdeclarative, |
297 | + libdee-dev (>= 1.0.0), |
298 | Description: Qt5 binding and QtQuick2 plugin for Dee - development files |
299 | Simple Qt5 binding and QtQuick2 plugin for Dee (https://launchpad.net/dee). |
300 | . |
301 | |
302 | === renamed file 'debian/libqtdee2.install' => 'debian/libdee-qt-3.install' |
303 | --- debian/libqtdee2.install 2011-01-28 05:27:37 +0000 |
304 | +++ debian/libdee-qt-3.install 2012-12-04 18:48:20 +0000 |
305 | @@ -1,3 +1,3 @@ |
306 | -usr/lib/libQtDee.so.* |
307 | -usr/lib/qt4/imports/dee/libQtDeeQml.so |
308 | -usr/lib/qt4/imports/dee/qmldir |
309 | +usr/lib/libdee-qt.so.* |
310 | +usr/lib/*/qt4/imports/Dee/libDeePlugin.so |
311 | +usr/lib/*/qt4/imports/Dee/qmldir |
312 | |
313 | === renamed file 'debian/libqtdee-dev.install' => 'debian/libdee-qt-dev.install' |
314 | --- debian/libqtdee-dev.install 2012-01-05 20:27:31 +0000 |
315 | +++ debian/libdee-qt-dev.install 2012-12-04 18:48:20 +0000 |
316 | @@ -1,3 +1,3 @@ |
317 | -usr/lib/libQtDee.so |
318 | -usr/include/QtDee/*.h |
319 | -usr/lib/pkgconfig/libqtdee.pc |
320 | +usr/lib/libdee-qt.so |
321 | +usr/include/libdee-qt/*.h |
322 | +usr/lib/pkgconfig/libdee-qt.pc |
323 | |
324 | === renamed file 'debian/libqtdee-qt5.install' => 'debian/libdee-qt5-3.install' |
325 | --- debian/libqtdee-qt5.install 2012-12-04 18:48:20 +0000 |
326 | +++ debian/libdee-qt5-3.install 2012-12-04 18:48:20 +0000 |
327 | @@ -1,3 +1,3 @@ |
328 | -usr/lib/libQtDee-qt5.so.* |
329 | -opt/qt5/imports/dee/libQtDeeQml.so |
330 | -opt/qt5/imports/dee/qmldir |
331 | +usr/lib/libdee-qt5.so.* |
332 | +opt/qt5/imports/Dee/libDeePlugin.so |
333 | +opt/qt5/imports/Dee/qmldir |
334 | |
335 | === renamed file 'debian/libqtdee-qt5-dev.install' => 'debian/libdee-qt5-dev.install' |
336 | --- debian/libqtdee-qt5-dev.install 2012-12-04 18:48:20 +0000 |
337 | +++ debian/libdee-qt5-dev.install 2012-12-04 18:48:20 +0000 |
338 | @@ -1,3 +1,3 @@ |
339 | -usr/lib/libQtDee-qt5.so |
340 | -usr/include/QtDee/*.h |
341 | -usr/lib/pkgconfig/libqtdee-qt5.pc |
342 | +usr/lib/libdee-qt5.so |
343 | +usr/include/libdee-qt5/*.h |
344 | +usr/lib/pkgconfig/libdee-qt5.pc |
345 | |
346 | === modified file 'deelistmodel.cpp' |
347 | --- deelistmodel.cpp 2012-11-21 10:30:50 +0000 |
348 | +++ deelistmodel.cpp 2012-12-04 18:48:20 +0000 |
349 | @@ -21,13 +21,14 @@ |
350 | #include <QtCore/QByteArray> |
351 | |
352 | #include <dee.h> |
353 | -#include <glib-object.h> |
354 | |
355 | #include "deelistmodel.h" |
356 | +#include "deeprivate.h" |
357 | |
358 | -static QVariant |
359 | +QVariant |
360 | QVariantFromGVariant(GVariant *value) |
361 | { |
362 | + Q_ASSERT(value); |
363 | switch (g_variant_classify(value)) { |
364 | case G_VARIANT_CLASS_BOOLEAN: |
365 | return QVariant((bool) g_variant_get_boolean(value)); |
366 | @@ -62,13 +63,14 @@ |
367 | } |
368 | return array; |
369 | } |
370 | + case G_VARIANT_CLASS_VARIANT: |
371 | + return QVariant(QVariantFromGVariant(g_variant_get_variant(value))); |
372 | default: |
373 | /* Fallback on an empty QVariant. |
374 | FIXME: Missing conversion of following GVariant types: |
375 | - G_VARIANT_CLASS_HANDLE |
376 | - G_VARIANT_CLASS_OBJECT_PATH |
377 | - G_VARIANT_CLASS_SIGNATURE |
378 | - - G_VARIANT_CLASS_VARIANT |
379 | - G_VARIANT_CLASS_MAYBE |
380 | - G_VARIANT_CLASS_DICT_ENTRY |
381 | */ |
382 | @@ -84,7 +86,6 @@ |
383 | void connectToDeeModel(); |
384 | void connectToDeeModel(DeeModel *model); |
385 | void disconnectFromDeeModel(); |
386 | - void createRoles(); |
387 | bool synchronized() const; |
388 | |
389 | /* GObject signal handlers for m_deeModel */ |
390 | @@ -142,6 +143,7 @@ |
391 | void |
392 | DeeListModelPrivate::connectToDeeModel(DeeModel *model) |
393 | { |
394 | + m_parent->beginResetModel(); |
395 | disconnectFromDeeModel(); |
396 | |
397 | m_deeModel = (DeeModel*)g_object_ref (model); |
398 | @@ -150,15 +152,14 @@ |
399 | g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent); |
400 | if (synchronized()) |
401 | { |
402 | - createRoles(); |
403 | m_count = dee_model_get_n_rows(m_deeModel); |
404 | - m_parent->reset(); |
405 | Q_EMIT m_parent->countChanged(); |
406 | } |
407 | else |
408 | { |
409 | g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent); |
410 | } |
411 | + m_parent->endResetModel(); |
412 | } |
413 | |
414 | bool |
415 | @@ -175,25 +176,24 @@ |
416 | } |
417 | } |
418 | |
419 | -void |
420 | -DeeListModelPrivate::createRoles() |
421 | +QHash<int, QByteArray> |
422 | +DeeListModel::roleNames() |
423 | { |
424 | - if (m_deeModel == NULL) { |
425 | - return; |
426 | - } |
427 | - |
428 | QHash<int, QByteArray> roles; |
429 | + |
430 | + if (d->m_deeModel == NULL) { |
431 | + return roles; |
432 | + } |
433 | + |
434 | QString column; |
435 | - guint n_columns = dee_model_get_n_columns(m_deeModel); |
436 | + guint n_columns = dee_model_get_n_columns(d->m_deeModel); |
437 | |
438 | for (unsigned int index=0; index<n_columns; index++) |
439 | { |
440 | column = QString("column_%1").arg(index); |
441 | - roles[index] = column.toAscii(); |
442 | + roles[index] = column.toUtf8(); |
443 | } |
444 | - |
445 | - m_parent->setRoleNames(roles); |
446 | - Q_EMIT m_parent->roleNamesChanged(roles); |
447 | + return roles; |
448 | } |
449 | |
450 | void |
451 | @@ -201,11 +201,11 @@ |
452 | GParamSpec *pspec, |
453 | DeeListModel *model) |
454 | { |
455 | - model->d->createRoles(); |
456 | + model->beginResetModel(); |
457 | model->d->m_count = dee_model_get_n_rows(model->d->m_deeModel); |
458 | model->synchronizedChanged(model->synchronized()); |
459 | - model->reset(); |
460 | Q_EMIT model->countChanged(); |
461 | + model->endResetModel(); |
462 | } |
463 | |
464 | void |
465 | @@ -271,8 +271,6 @@ |
466 | Q_EMIT model->dataChanged(index, index); |
467 | } |
468 | |
469 | - |
470 | - |
471 | DeeListModel::DeeListModel(QObject *parent) : |
472 | QAbstractListModel(parent), d(new DeeListModelPrivate(this)) |
473 | { |
474 | |
475 | === modified file 'deelistmodel.h' |
476 | --- deelistmodel.h 2012-01-31 17:49:00 +0000 |
477 | +++ deelistmodel.h 2012-12-04 18:48:20 +0000 |
478 | @@ -20,11 +20,12 @@ |
479 | #ifndef DEELISTMODEL_H |
480 | #define DEELISTMODEL_H |
481 | |
482 | +#include <QtCore/QObject> |
483 | #include <QtCore/QAbstractListModel> |
484 | |
485 | class DeeListModelPrivate; |
486 | typedef struct _DeeModel DeeModel; |
487 | -class __attribute__ ((visibility ("default"))) DeeListModel : public QAbstractListModel |
488 | +class Q_DECL_EXPORT DeeListModel : public QAbstractListModel |
489 | { |
490 | friend class DeeListModelPrivate; |
491 | |
492 | @@ -52,11 +53,11 @@ |
493 | /* setters */ |
494 | void setName(const QString& name); |
495 | void setModel(DeeModel* model); |
496 | + QHash<int, QByteArray> roleNames(); |
497 | |
498 | Q_SIGNALS: |
499 | void nameChanged(const QString&); |
500 | void synchronizedChanged(bool); |
501 | - void roleNamesChanged(const QHash<int,QByteArray> &); |
502 | void countChanged(); |
503 | |
504 | private: |
505 | |
506 | === added file 'deeprivate.h' |
507 | --- deeprivate.h 1970-01-01 00:00:00 +0000 |
508 | +++ deeprivate.h 2012-12-04 18:48:20 +0000 |
509 | @@ -0,0 +1,23 @@ |
510 | +/* |
511 | + * Copyright (C) 2012 Canonical, Ltd. |
512 | + * |
513 | + * Authors: |
514 | + * Christian Dywan <christian.dywan@canonical.com> |
515 | + * |
516 | + * This program is free software; you can redistribute it and/or modify |
517 | + * it under the terms of the GNU General Public License as published by |
518 | + * the Free Software Foundation; version 3. |
519 | + * |
520 | + * This program is distributed in the hope that it will be useful, |
521 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
522 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
523 | + * GNU General Public License for more details. |
524 | + * |
525 | + * You should have received a copy of the GNU General Public License |
526 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
527 | + */ |
528 | + |
529 | +#include <glib-object.h> |
530 | + |
531 | +QVariant QVariantFromGVariant(GVariant *value); |
532 | + |
533 | |
534 | === added file 'deevarianttext.cpp' |
535 | --- deevarianttext.cpp 1970-01-01 00:00:00 +0000 |
536 | +++ deevarianttext.cpp 2012-12-04 18:48:20 +0000 |
537 | @@ -0,0 +1,72 @@ |
538 | +/* |
539 | + * Copyright (C) 2012 Canonical, Ltd. |
540 | + * |
541 | + * Authors: |
542 | + * Christian Dywan <christian.dywan@canonical.com> |
543 | + * |
544 | + * This program is free software; you can redistribute it and/or modify |
545 | + * it under the terms of the GNU General Public License as published by |
546 | + * the Free Software Foundation; version 3. |
547 | + * |
548 | + * This program is distributed in the hope that it will be useful, |
549 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
550 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
551 | + * GNU General Public License for more details. |
552 | + * |
553 | + * You should have received a copy of the GNU General Public License |
554 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
555 | + */ |
556 | + |
557 | +#include <QDebug> |
558 | + |
559 | +#include "deevarianttext.h" |
560 | +#include "deeprivate.h" |
561 | + |
562 | +DeeVariantText::DeeVariantText(QObject *parent) : |
563 | + m_text(""), |
564 | + m_value(QVariant()), |
565 | + m_type("") |
566 | +{ |
567 | +} |
568 | + |
569 | +void |
570 | +DeeVariantText::setText(const QString& text) |
571 | +{ |
572 | + if (m_text == text) |
573 | + return; |
574 | + |
575 | + m_text = text; |
576 | + GVariant *gvariant = g_variant_parse(NULL, text.toUtf8(), NULL, NULL, NULL); |
577 | + if (!gvariant) |
578 | + { |
579 | + qDebug() << "Failed to parse " << text << " to QVariant"; |
580 | + m_value = QVariant(); |
581 | + m_type = ""; |
582 | + } |
583 | + else |
584 | + { |
585 | + m_value = QVariantFromGVariant(gvariant); |
586 | + m_type = g_variant_get_type_string(gvariant); |
587 | + } |
588 | + Q_EMIT textChanged(text); |
589 | + Q_EMIT valueChanged(m_value); |
590 | +} |
591 | + |
592 | +QString |
593 | +DeeVariantText::getText() |
594 | +{ |
595 | + return m_text; |
596 | +} |
597 | + |
598 | +QVariant |
599 | +DeeVariantText::getValue() |
600 | +{ |
601 | + return m_value; |
602 | +} |
603 | + |
604 | +QVariant |
605 | +DeeVariantText::getType() |
606 | +{ |
607 | + return m_type; |
608 | +} |
609 | + |
610 | |
611 | === added file 'deevarianttext.h' |
612 | --- deevarianttext.h 1970-01-01 00:00:00 +0000 |
613 | +++ deevarianttext.h 2012-12-04 18:48:20 +0000 |
614 | @@ -0,0 +1,49 @@ |
615 | +/* |
616 | + * Copyright (C) 2012 Canonical, Ltd. |
617 | + * |
618 | + * Authors: |
619 | + * Christian Dywan <christian.dywan@canonical.com> |
620 | + * |
621 | + * This program is free software; you can redistribute it and/or modify |
622 | + * it under the terms of the GNU General Public License as published by |
623 | + * the Free Software Foundation; version 3. |
624 | + * |
625 | + * This program is distributed in the hope that it will be useful, |
626 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
627 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
628 | + * GNU General Public License for more details. |
629 | + * |
630 | + * You should have received a copy of the GNU General Public License |
631 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
632 | + */ |
633 | + |
634 | +#ifndef DEEVARIANTTEXT_H |
635 | +#define DEEVARIANTTEXT_H |
636 | + |
637 | +#include <QtCore/QObject> |
638 | +#include <QtCore/QVariant> |
639 | + |
640 | +class Q_DECL_EXPORT DeeVariantText : public QObject { |
641 | + Q_OBJECT |
642 | + Q_PROPERTY(QString text READ getText WRITE setText NOTIFY textChanged) |
643 | + Q_PROPERTY(QVariant value READ getValue NOTIFY valueChanged) |
644 | +public: |
645 | + DeeVariantText(QObject* parent = 0); |
646 | + ~DeeVariantText() { } |
647 | + |
648 | + QString getText(); |
649 | + QVariant getValue(); |
650 | + QVariant getType(); |
651 | + void setText(const QString& text); |
652 | +Q_SIGNALS: |
653 | + void textChanged(const QString& text); |
654 | + void valueChanged(const QVariant& value); |
655 | +private: |
656 | + Q_DISABLE_COPY(DeeVariantText) |
657 | + QString m_text; |
658 | + QVariant m_value; |
659 | + QString m_type; |
660 | +}; |
661 | + |
662 | +#endif // DEEVARIANTTEXT_H |
663 | + |
664 | |
665 | === renamed file 'libqtdee.pc.in' => 'libdee-qt.pc.in' |
666 | --- libqtdee.pc.in 2012-12-04 18:48:20 +0000 |
667 | +++ libdee-qt.pc.in 2012-12-04 18:48:20 +0000 |
668 | @@ -1,12 +1,12 @@ |
669 | prefix=@PREFIX@ |
670 | exec_prefix=@EXEC_PREFIX@ |
671 | libdir=${exec_prefix}/lib |
672 | -includedir=${prefix}/include |
673 | +includedir=${prefix}/@INCLUDE_INSTALL_DIR@ |
674 | |
675 | -Name: libqtdee |
676 | +Name: @DEE_QT_LIBNAME@ |
677 | Description: Qt binding and QML plugin for Dee. |
678 | -Version: 0.2 |
679 | +Version: 3.0 |
680 | |
681 | Requires: @QT_PKGCONFIG_DEPENDENCIES@ dee-1.0 |
682 | -Libs: -L${libdir} -l@QTDEE_LIBNAME@ |
683 | -Cflags: -I${includedir}/QtDee |
684 | +Libs: -L${libdir} -l@DEE_QT_LIBNAME@ |
685 | +Cflags: -I${includedir} |
686 | |
687 | === added directory 'modules' |
688 | === added file 'modules/CMakeLists.txt' |
689 | --- modules/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
690 | +++ modules/CMakeLists.txt 2012-12-04 18:48:20 +0000 |
691 | @@ -0,0 +1,1 @@ |
692 | +add_subdirectory(Dee) |
693 | |
694 | === added directory 'modules/Dee' |
695 | === added file 'modules/Dee/CMakeLists.txt' |
696 | --- modules/Dee/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
697 | +++ modules/Dee/CMakeLists.txt 2012-12-04 18:48:20 +0000 |
698 | @@ -0,0 +1,46 @@ |
699 | + |
700 | +if (WITHQT5) |
701 | + find_package(Qt5Quick REQUIRED) |
702 | + set(OUR_QT_QUICK_LIB ${Qt5Quick_LIBRARIES}) |
703 | + |
704 | + get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) |
705 | + exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_IMPORTS" OUTPUT_VARIABLE QT_IMPORTS_DIR) |
706 | + file(TO_CMAKE_PATH "${QT_IMPORTS_DIR}" QT_IMPORTS_DIR) |
707 | + |
708 | + set(OUR_QT_QUICK_INCLUDE ${Qt5Quick_INCLUDE_DIRS}) |
709 | + LIST(APPEND QT_PKGCONFIG_DEPENDENCIES "QtQuick") |
710 | +else () |
711 | + set(OUR_QT_QUICK_LIB ${QT_QTDECLARATIVE_LIBRARIES}) |
712 | + set(IMPORT_INSTALL_DIR lib/qt4/imports/Dee) |
713 | + set(OUR_QT_QUICK_INCLUDE ${QT_QTDECLARATIVE_INCLUDE_DIR}) |
714 | + LIST(APPEND QT_PKGCONFIG_DEPENDENCIES "QtDeclarative") |
715 | +endif () |
716 | + |
717 | +set(DeePlugin_SRCS |
718 | + plugin.cpp |
719 | + ) |
720 | + |
721 | +add_library(DeePlugin SHARED ${DeePlugin_SRCS}) |
722 | + |
723 | +target_link_libraries(DeePlugin |
724 | + ${DEE_QT_LIBNAME} |
725 | + ${OUR_QT_QUICK_LIB} |
726 | + ) |
727 | + |
728 | +include_directories( |
729 | + ${CMAKE_CURRENT_BINARY_DIR} |
730 | + ${OUR_QT_QUICK_INCLUDE} |
731 | + ) |
732 | + |
733 | +# copy qmldir file into build directory for shadow builds |
734 | +file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" |
735 | + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} |
736 | + ) |
737 | + |
738 | +install(TARGETS DeePlugin |
739 | + LIBRARY DESTINATION ${QT_IMPORTS_DIR}/Dee |
740 | + ) |
741 | + |
742 | +install(FILES qmldir |
743 | + DESTINATION ${QT_IMPORTS_DIR}/Dee |
744 | + ) |
745 | |
746 | === renamed file 'plugin.cpp' => 'modules/Dee/plugin.cpp' |
747 | --- plugin.cpp 2012-12-04 18:48:20 +0000 |
748 | +++ modules/Dee/plugin.cpp 2012-12-04 18:48:20 +0000 |
749 | @@ -18,6 +18,7 @@ |
750 | */ |
751 | |
752 | #include "deelistmodel.h" |
753 | +#include "deevarianttext.h" |
754 | #include "plugin.h" |
755 | #if WITHQT5 |
756 | #include <qqml.h> |
757 | @@ -25,11 +26,12 @@ |
758 | #include <QtDeclarative/qdeclarative.h> |
759 | #endif |
760 | |
761 | -void QtDeePlugin::registerTypes(const char *uri) |
762 | +void DeePlugin::registerTypes(const char *uri) |
763 | { |
764 | - qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel"); |
765 | + qmlRegisterType<DeeListModel>(uri, 3, 0, "DeeListModel"); |
766 | + qmlRegisterType<DeeVariantText>(uri, 3, 0, "DeeVariantText"); |
767 | } |
768 | |
769 | #if !WITHQT5 |
770 | - Q_EXPORT_PLUGIN2(QtDee, QtDeePlugin); |
771 | + Q_EXPORT_PLUGIN2(Dee, DeePlugin); |
772 | #endif |
773 | |
774 | === renamed file 'plugin.h' => 'modules/Dee/plugin.h' |
775 | --- plugin.h 2012-12-04 18:48:20 +0000 |
776 | +++ modules/Dee/plugin.h 2012-12-04 18:48:20 +0000 |
777 | @@ -26,7 +26,7 @@ |
778 | #include <QtDeclarative/QDeclarativeExtensionPlugin> |
779 | #endif |
780 | |
781 | -class QtDeePlugin : |
782 | +class DeePlugin : |
783 | #if WITHQT5 |
784 | public QQmlExtensionPlugin |
785 | #else |
786 | |
787 | === renamed file 'qmldir' => 'modules/Dee/qmldir' |
788 | --- qmldir 2011-01-13 16:05:58 +0000 |
789 | +++ modules/Dee/qmldir 2012-12-04 18:48:20 +0000 |
790 | @@ -1,1 +1,1 @@ |
791 | -plugin QtDeeQml |
792 | +plugin DeePlugin |
793 | |
794 | === removed file 'test.cpp' |
795 | --- test.cpp 2011-01-24 04:05:02 +0000 |
796 | +++ test.cpp 1970-01-01 00:00:00 +0000 |
797 | @@ -1,35 +0,0 @@ |
798 | -/* |
799 | - * Copyright (C) 2010 Canonical, Ltd. |
800 | - * |
801 | - * Authors: |
802 | - * Florian Boucault <florian.boucault@canonical.com> |
803 | - * |
804 | - * This program is free software; you can redistribute it and/or modify |
805 | - * it under the terms of the GNU General Public License as published by |
806 | - * the Free Software Foundation; version 3. |
807 | - * |
808 | - * This program is distributed in the hope that it will be useful, |
809 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
810 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
811 | - * GNU General Public License for more details. |
812 | - * |
813 | - * You should have received a copy of the GNU General Public License |
814 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
815 | - */ |
816 | - |
817 | -#include "test.h" |
818 | -#include "deelistmodel.h" |
819 | - |
820 | -int main(int argc, char *argv[]) |
821 | -{ |
822 | - TestApplication application(argc, argv); |
823 | - |
824 | - DeeListModel* model = new DeeListModel; |
825 | - |
826 | - QObject::connect(model, SIGNAL(synchronizedChanged(bool)), &application, SLOT(onSynchronizedChanged(bool))); |
827 | - QObject::connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)), &application, SLOT(onRowsInserted())); |
828 | - |
829 | - model->setName("com.canonical.Unity.ApplicationsPlace.ResultsModel"); |
830 | - |
831 | - return application.exec(); |
832 | -} |
833 | |
834 | === removed file 'test.h' |
835 | --- test.h 2012-01-04 23:52:05 +0000 |
836 | +++ test.h 1970-01-01 00:00:00 +0000 |
837 | @@ -1,52 +0,0 @@ |
838 | -/* |
839 | - * Copyright (C) 2011 Canonical, Ltd. |
840 | - * |
841 | - * Authors: |
842 | - * Florian Boucault <florian.boucault@canonical.com> |
843 | - * |
844 | - * This program is free software; you can redistribute it and/or modify |
845 | - * it under the terms of the GNU General Public License as published by |
846 | - * the Free Software Foundation; version 3. |
847 | - * |
848 | - * This program is distributed in the hope that it will be useful, |
849 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
850 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
851 | - * GNU General Public License for more details. |
852 | - * |
853 | - * You should have received a copy of the GNU General Public License |
854 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
855 | - */ |
856 | - |
857 | -#ifndef TEST_H |
858 | -#define TEST_H |
859 | - |
860 | -#include <QtCore/QCoreApplication> |
861 | -#include <QtCore/QDebug> |
862 | - |
863 | -#include "deelistmodel.h" |
864 | - |
865 | -class TestApplication : public QCoreApplication |
866 | -{ |
867 | - Q_OBJECT |
868 | - |
869 | -public: |
870 | - TestApplication(int& argc, char** argv) : QCoreApplication(argc, argv) {} |
871 | - |
872 | -public Q_SLOTS: |
873 | - void onSynchronizedChanged(bool synchronized) { |
874 | - DeeListModel* model = (DeeListModel*)sender(); |
875 | - qDebug() << "Number of columns:" << model->roleNames().size(); |
876 | - qDebug() << "Number of rows:" << model->rowCount(); |
877 | - |
878 | - for(int i = 0; i < model->rowCount(); ++i) { |
879 | - qDebug() << model->data(model->index(i)); |
880 | - } |
881 | - } |
882 | - |
883 | - void onRowsInserted() { |
884 | - DeeListModel* model = (DeeListModel*)sender(); |
885 | - qDebug() << "Rows added, current number:" << model->rowCount(); |
886 | - } |
887 | -}; |
888 | - |
889 | -#endif // TEST_H |
890 | |
891 | === removed file 'test_qtquick2.qml' |
892 | --- test_qtquick2.qml 2012-12-04 18:48:20 +0000 |
893 | +++ test_qtquick2.qml 1970-01-01 00:00:00 +0000 |
894 | @@ -1,15 +0,0 @@ |
895 | -import QtQuick 2.0 |
896 | -import dee 0.1 |
897 | - |
898 | -ListView { |
899 | - width: 200 |
900 | - height: 200 |
901 | - delegate: Text { |
902 | - x: 66 |
903 | - y: 93 |
904 | - text: column_4 |
905 | - } |
906 | - model: DeeListModel { |
907 | - name: "com.canonical.Unity.Lens.applications.T1313498309.Results" |
908 | - } |
909 | -} |
910 | |
911 | === added directory 'tests' |
912 | === added file 'tests/CMakeLists.txt' |
913 | --- tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
914 | +++ tests/CMakeLists.txt 2012-12-04 18:48:20 +0000 |
915 | @@ -0,0 +1,57 @@ |
916 | +if (WITHQT5) |
917 | + find_package(Qt5Test REQUIRED) |
918 | + set(OUR_QT_TEST_LIB ${Qt5Test_LIBRARIES}) |
919 | + set(OUR_QT_TEST_INCLUDES ${Qt5Test_INCLUDE_DIRS}) |
920 | +else () |
921 | + set(OUR_QT_TEST_LIB ${QT_QTTEST_LIBRARIES}) |
922 | + set(OUR_QT_TEST_INCLUDES ${QT_QTTEST_INCLUDE_DIR}) |
923 | + set(OUR_QT_QUICK_LIB ${QT_QTDECLARATIVE_LIBRARIES}) |
924 | + set(OUR_QT_QUICK_INCLUDE ${QT_QTDECLARATIVE_INCLUDE_DIR}) |
925 | +endif () |
926 | + |
927 | +if (WITHQT5) |
928 | + add_test(NAME plugintest COMMAND "qmltestrunner" "-import" "../modules" "-xunitxml" "-o" "plugintest-xunit.xml" "-input" "${CMAKE_CURRENT_SOURCE_DIR}") |
929 | +else () |
930 | + add_executable(plugintest qtquick1plugintest.cpp) |
931 | + target_link_libraries(plugintest ${OUR_QT_TEST_LIB} ${OUR_QT_QUICK_LIB}) |
932 | + set_target_properties(plugintest PROPERTIES COMPILE_FLAGS -fPIC) |
933 | + add_test(NAME plugintest WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/plugintest" "-p" "-xunitxml" "-p" "-o" "-p" "${CMAKE_CURRENT_BINARY_DIR}/plugintest-xunit.xml") |
934 | + set_property(TEST plugintest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
935 | + set_property(TEST plugintest PROPERTY ENVIRONMENT "QT_GRAPHICSSYSTEM=raster") |
936 | + set_property(TEST plugintest PROPERTY ENVIRONMENT "QML_IMPORT_PATH=${CMAKE_CURRENT_BINARY_DIR}/../modules") |
937 | + add_dependencies(check plugintest) |
938 | +endif () |
939 | + |
940 | +include_directories( |
941 | + ${CMAKE_CURRENT_BINARY_DIR} |
942 | + ${OUR_QT_TEST_INCLUDES} |
943 | + ${OUR_QT_QUICK_INCLUDE} |
944 | + ) |
945 | + |
946 | +add_executable(conversiontest conversiontest.cpp) |
947 | +target_link_libraries(conversiontest ${OUR_QT_WIDGETS_LIB} ${OUR_QT_TEST_LIB} ${OUR_QT_QUICK_LIB} ${DEE_QT_LIBNAME}) |
948 | +set_target_properties(conversiontest PROPERTIES COMPILE_FLAGS -fPIC) |
949 | +add_test(NAME conversiontest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/conversiontest" "-p" "-xunitxml" "-p" "-o" "-p" "conversiontest-xunit.xml") |
950 | +set_property(TEST conversiontest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
951 | +set_property(TEST conversiontest PROPERTY ENVIRONMENT "QT_QPA_PLATFORM=minimal") |
952 | +add_dependencies(check conversiontest) |
953 | + |
954 | +add_executable(test-helper test-helper.cpp) |
955 | +target_link_libraries(test-helper ${OUR_QT_CORE_LIB} ${OUR_QT_DBUS_LIB} ${DEE_LDFLAGS}) |
956 | +set_target_properties(test-helper PROPERTIES COMPILE_FLAGS -fPIC) |
957 | +add_dependencies(conversiontest ${DEE_QT_LIBNAME} test-helper) |
958 | + |
959 | +add_executable(deelistmodeltest deelistmodeltest.cpp) |
960 | +target_link_libraries(deelistmodeltest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME}) |
961 | +set_target_properties(deelistmodeltest PROPERTIES COMPILE_FLAGS -fPIC) |
962 | +add_test(NAME deelistmodeltest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/test-helper" "--task" "${CMAKE_CURRENT_BINARY_DIR}/deelistmodeltest" "-p" "-xunitxml" "-p" "-o" "-p" "deelistmodeltest-xunit.xml") |
963 | +set_property(TEST deelistmodeltest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
964 | +add_dependencies(check deelistmodeltest) |
965 | + |
966 | +add_executable(deevarianttexttest deevarianttexttest.cpp) |
967 | +target_link_libraries(deevarianttexttest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME}) |
968 | +set_target_properties(deevarianttexttest PROPERTIES COMPILE_FLAGS -fPIC) |
969 | +add_test(NAME deevarianttexttest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/test-helper" "--task" "${CMAKE_CURRENT_BINARY_DIR}/deelistmodeltest" "-p" "-xunitxml" "-p" "-o" "-p" "deelistmodeltest-xunit.xml") |
970 | +set_property(TEST deevarianttexttest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
971 | +add_dependencies(check deevarianttexttest) |
972 | + |
973 | |
974 | === renamed file 'conversiontest.cpp' => 'tests/conversiontest.cpp' |
975 | --- conversiontest.cpp 2012-11-21 12:09:44 +0000 |
976 | +++ tests/conversiontest.cpp 2012-12-04 18:48:20 +0000 |
977 | @@ -18,6 +18,7 @@ |
978 | #include <QObject> |
979 | |
980 | #include "deelistmodel.h" |
981 | +#include "deevarianttext.h" |
982 | |
983 | #include <dee.h> |
984 | |
985 | |
986 | === renamed file 'deelistmodeltest.cpp' => 'tests/deelistmodeltest.cpp' |
987 | === added file 'tests/deevarianttexttest.cpp' |
988 | --- tests/deevarianttexttest.cpp 1970-01-01 00:00:00 +0000 |
989 | +++ tests/deevarianttexttest.cpp 2012-12-04 18:48:20 +0000 |
990 | @@ -0,0 +1,58 @@ |
991 | +/* |
992 | + * Copyright (C) 2012 Canonical, Ltd. |
993 | + * |
994 | + * This program is free software; you can redistribute it and/or modify |
995 | + * it under the terms of the GNU General Public License as published by |
996 | + * the Free Software Foundation; version 3. |
997 | + * |
998 | + * This program is distributed in the hope that it will be useful, |
999 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1000 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1001 | + * GNU General Public License for more details. |
1002 | + * |
1003 | + * You should have received a copy of the GNU General Public License |
1004 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1005 | + */ |
1006 | + |
1007 | +#include <QtTest> |
1008 | +#include <QObject> |
1009 | + |
1010 | +#include "deevarianttext.h" |
1011 | + |
1012 | +#include <dee.h> |
1013 | + |
1014 | +class DeeVariantTextTest : public QObject |
1015 | +{ |
1016 | + Q_OBJECT |
1017 | + |
1018 | +private Q_SLOTS: |
1019 | + void initTestCase() |
1020 | + { |
1021 | + g_type_init(); |
1022 | + } |
1023 | + |
1024 | + void GVariantParseTest() |
1025 | + { |
1026 | + QHash<QString, QVariant> hash; |
1027 | + hash["[[1, 2, 3], [4, 5, 6]]"] = "aai"; |
1028 | + hash["[[1, 2, 3], [4, 5, 6.0]]"] = "aad"; |
1029 | + hash["[\"hello\", nothing]"] = "ams"; |
1030 | + hash["{1: \"one\", 2: \"two\", 3: \"three\"}"] = "a{is}"; |
1031 | + hash["[just 3, nothing]"] = "ami"; |
1032 | + // hash["{\"title\": <\"frobit\">, \"enabled\": <true>, width: <800>}"] = ""; |
1033 | + hash["@ms \"\""] = "ms"; |
1034 | + QHashIterator<QString, QVariant> i(hash); |
1035 | + while (i.hasNext()) { |
1036 | + i.next(); |
1037 | + QString input(i.key()); |
1038 | + DeeVariantText dvariant; |
1039 | + dvariant.setText(input); |
1040 | + QCOMPARE(dvariant.getText(), input); |
1041 | + QCOMPARE(dvariant.getType(), i.value()); |
1042 | + } |
1043 | + } |
1044 | +}; |
1045 | + |
1046 | +QTEST_MAIN(DeeVariantTextTest) |
1047 | + |
1048 | +#include "deevarianttexttest.moc" |
1049 | |
1050 | === added file 'tests/qtquick1plugintest.cpp' |
1051 | --- tests/qtquick1plugintest.cpp 1970-01-01 00:00:00 +0000 |
1052 | +++ tests/qtquick1plugintest.cpp 2012-12-04 18:48:20 +0000 |
1053 | @@ -0,0 +1,48 @@ |
1054 | +/* |
1055 | + * Copyright (C) 2012 Canonical, Ltd. |
1056 | + * |
1057 | + * This program is free software; you can redistribute it and/or modify |
1058 | + * it under the terms of the GNU General Public License as published by |
1059 | + * the Free Software Foundation; version 3. |
1060 | + * |
1061 | + * This program is distributed in the hope that it will be useful, |
1062 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1063 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1064 | + * GNU General Public License for more details. |
1065 | + * |
1066 | + * You should have received a copy of the GNU General Public License |
1067 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1068 | + */ |
1069 | + |
1070 | +#include <QtTest> |
1071 | +#include <QObject> |
1072 | +#include <QtDeclarative> |
1073 | + |
1074 | +class PluginTest : public QObject |
1075 | +{ |
1076 | + Q_OBJECT |
1077 | + |
1078 | +private Q_SLOTS: |
1079 | + void initTestCase() |
1080 | + { |
1081 | + } |
1082 | + |
1083 | + void GVariantQMLTest() |
1084 | + { |
1085 | + // Dummy argc/v to avoid GCC confusing int with Display* on some systems |
1086 | + int argc = 0; |
1087 | + char *argv[0]; |
1088 | + QApplication app(argc, argv); |
1089 | + QDeclarativeView view; |
1090 | + view.setSource(QUrl::fromLocalFile("test_qtquick1.qml")); |
1091 | + Q_ASSERT(view.errors().empty()); |
1092 | + QObject *text2 = view.rootObject()->findChild<QObject*>("text2"); |
1093 | + Q_ASSERT(text2); |
1094 | + QVariant text2text(text2->metaObject()->property(text2->metaObject()->indexOfProperty("text")).read(text2)); |
1095 | + QCOMPARE(text2text.toString(), QString("4,1.1,0.1,0,0.3,3.6")); |
1096 | + } |
1097 | +}; |
1098 | + |
1099 | +QTEST_MAIN(PluginTest) |
1100 | + |
1101 | +#include "qtquick1plugintest.moc" |
1102 | |
1103 | === renamed file 'test-helper.cpp' => 'tests/test-helper.cpp' |
1104 | === renamed file 'test_qtquick1.qml' => 'tests/test_qtquick1.qml' |
1105 | --- test_qtquick1.qml 2012-02-08 15:02:19 +0000 |
1106 | +++ tests/test_qtquick1.qml 2012-12-04 18:48:20 +0000 |
1107 | @@ -1,15 +1,40 @@ |
1108 | import QtQuick 1.0 |
1109 | -import dee 0.1 |
1110 | - |
1111 | -ListView { |
1112 | - width: 200 |
1113 | - height: 200 |
1114 | - delegate: Text { |
1115 | - x: 66 |
1116 | - y: 93 |
1117 | - text: column_4 |
1118 | - } |
1119 | - model: DeeListModel { |
1120 | - name: "com.canonical.Unity.Lens.applications.T1313498309.Results" |
1121 | - } |
1122 | +import Dee 3.0 |
1123 | + |
1124 | +Item { |
1125 | + |
1126 | + ListView { |
1127 | + width: 200 |
1128 | + height: 200 |
1129 | + delegate: Text { |
1130 | + x: 66 |
1131 | + y: 93 |
1132 | + text: column_4 |
1133 | + } |
1134 | + model: DeeListModel { |
1135 | + name: "com.canonical.Unity.Lens.applications.T1313498309.Results" |
1136 | + } |
1137 | + } |
1138 | + |
1139 | + DeeVariantText { |
1140 | + id: arrayOfInt |
1141 | + text: "[[1, 2, 3], [4, 5, 6]]" |
1142 | + Component.onCompleted: { |
1143 | + arrayOfInt.text = "[[4, 1.1, .1], [0, 0.3, 3.6]]" |
1144 | + } |
1145 | + onTextChanged: { |
1146 | + text2.text = arrayOfInt.value.toString() |
1147 | + } |
1148 | + } |
1149 | + |
1150 | + Text { |
1151 | + text: arrayOfInt.value.toString() |
1152 | + } |
1153 | + |
1154 | + Text { |
1155 | + id: text2 |
1156 | + objectName: "text2" |
1157 | + } |
1158 | + |
1159 | } |
1160 | + |
1161 | |
1162 | === added file 'tests/tst_deelistmodel.qml' |
1163 | --- tests/tst_deelistmodel.qml 1970-01-01 00:00:00 +0000 |
1164 | +++ tests/tst_deelistmodel.qml 2012-12-04 18:48:20 +0000 |
1165 | @@ -0,0 +1,22 @@ |
1166 | +import QtQuick 2.0 |
1167 | +import QtTest 1.0 |
1168 | +import Dee 3.0 |
1169 | + |
1170 | +TestCase { |
1171 | + name: "DeeListModel" |
1172 | + |
1173 | + ListView { |
1174 | + width: 200 |
1175 | + height: 200 |
1176 | + delegate: Text { |
1177 | + x: 66 |
1178 | + y: 93 |
1179 | + text: column_4 |
1180 | + } |
1181 | + model: DeeListModel { |
1182 | + name: "com.canonical.Unity.Lens.applications.T1313498309.Results" |
1183 | + } |
1184 | + } |
1185 | + |
1186 | +} |
1187 | + |
1188 | |
1189 | === added file 'tests/tst_deevarianttext.qml' |
1190 | --- tests/tst_deevarianttext.qml 1970-01-01 00:00:00 +0000 |
1191 | +++ tests/tst_deevarianttext.qml 2012-12-04 18:48:20 +0000 |
1192 | @@ -0,0 +1,60 @@ |
1193 | +import QtQuick 2.0 |
1194 | +import QtTest 1.0 |
1195 | +import Dee 3.0 |
1196 | + |
1197 | +TestCase { |
1198 | + name: "DeeVariantText" |
1199 | + |
1200 | + function test_1_initialText () { |
1201 | + compare(arrayOfStr.value.toString(),"bar,foo") |
1202 | + } |
1203 | + |
1204 | + function test_3_textAssigned () { |
1205 | + arrayOfInt.text = "[[4, 1.1, .1], [0, 0.3, 3.6]]" |
1206 | + compare(arrayOfInt.value.toString(),"4,1.1,0.1,0,0.3,3.6") |
1207 | + } |
1208 | + |
1209 | + function test_4_textChanged () { |
1210 | + arrayOfInt.didChange = false |
1211 | + arrayOfInt.text = "@ams [nothing]" |
1212 | + compare(arrayOfInt.didChange,true) |
1213 | + } |
1214 | + |
1215 | + function test_5_textNotChanged () { |
1216 | + arrayOfInt.text = "@ams [nothing]" |
1217 | + arrayOfInt.didChange = false |
1218 | + arrayOfInt.text = "@ams [nothing]" |
1219 | + compare(arrayOfInt.didChange,false) |
1220 | + } |
1221 | + |
1222 | + function test_6_invalid () { |
1223 | + arrayOfInt.text = "[nothing]" |
1224 | + compare(arrayOfInt.value,undefined) |
1225 | + } |
1226 | + |
1227 | + function test_7_unicode () { |
1228 | + arrayOfStr.text = "[\"١٢٣٤٥٦٧٨٩٠\", \"道具箱\", \"Котята\"]" |
1229 | + compare(arrayOfStr.value.toString(),"١٢٣٤٥٦٧٨٩٠,道具箱,Котята") |
1230 | + } |
1231 | + |
1232 | + function test_8_gvariant () { |
1233 | + arrayOfStr.text = "[<\"test\">, <\"test2\">]" |
1234 | + compare(arrayOfStr.value.toString(), "test,test2") |
1235 | + } |
1236 | + |
1237 | + DeeVariantText { |
1238 | + id: arrayOfStr |
1239 | + text: "[\"bar\", \"foo\"]" |
1240 | + } |
1241 | + |
1242 | + DeeVariantText { |
1243 | + id: arrayOfInt |
1244 | + text: "[[1, 2, 3], [4, 5, 6]]" |
1245 | + property bool didChange: false |
1246 | + onTextChanged: { |
1247 | + didChange = true |
1248 | + } |
1249 | + } |
1250 | + |
1251 | +} |
1252 | + |