Merge lp:~kalikiana/dee-qt/deevarianttext into lp:dee-qt
- deevarianttext
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~kalikiana/dee-qt/deevarianttext |
Merge into: | lp:dee-qt |
Prerequisite: | lp:~saviq/dee-qt/rename-libs |
Diff against target: |
1021 lines (+608/-48) (has conflicts) 18 files modified
.bzrignore (+15/-2) CMakeLists.txt (+12/-1) deelistmodel.cpp (+70/-13) deelistmodel.h (+7/-2) deeprivate.h (+23/-0) deevarianttext.cpp (+72/-0) deevarianttext.h (+49/-0) modules/Dee/CMakeLists.txt (+7/-1) modules/Dee/plugin.cpp (+2/-0) tests/CMakeLists.txt (+29/-1) tests/conversiontest.cpp (+1/-0) tests/deelistmodeltest.cpp (+40/-2) tests/deevarianttexttest.cpp (+58/-0) tests/qtquick1plugintest.cpp (+48/-0) tests/test_qtquick1.qml (+36/-11) tests/test_qtquick2.qml (+0/-15) tests/tst_deelistmodel.qml (+79/-0) tests/tst_deevarianttext.qml (+60/-0) Text conflict in CMakeLists.txt Text conflict in deelistmodel.cpp Text conflict in modules/Dee/CMakeLists.txt |
To merge this branch: | bzr merge lp:~kalikiana/dee-qt/deevarianttext |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Needs Fixing | ||
Cris Dywan (community) | Abstain | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Michał Sawicz | Pending | ||
Review via email: mp+153458@code.launchpad.net |
This proposal supersedes a proposal from 2012-12-04.
This proposal has been superseded by a proposal from 2013-03-15.
Commit message
Drop delegate test, the approach is wrong
Description of the change
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:107
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) : | # |
Cris Dywan (kalikiana) : | # |
Albert Astals Cid (aacid) wrote : | # |
You still have the processEvents call, i think i commented already in a different merge request. Can you clarify why you need it? Having a processEvents call usually means you're doing something wrong.
Michał Sawicz (saviq) wrote : | # |
Remember this is superseded by lp:~unity-team/dee-qt/deevarianttext-and-tests
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 2012-11-30 12:56:33 +0000 | |||
3 | +++ .bzrignore 2013-03-14 20:47:26 +0000 | |||
4 | @@ -2,7 +2,20 @@ | |||
5 | 2 | CMakeFiles | 2 | CMakeFiles |
6 | 3 | Makefile | 3 | Makefile |
7 | 4 | cmake_install.cmake | 4 | cmake_install.cmake |
8 | 5 | install_manifest.txt | ||
9 | 5 | libdee-qt.so* | 6 | libdee-qt.so* |
10 | 6 | libdee-qt5.so* | 7 | libdee-qt5.so* |
13 | 7 | moc_*.cxx | 8 | libQtDee.so* |
14 | 8 | install_manifest.txt | 9 | moc_*.cpp |
15 | 10 | *.moc | ||
16 | 11 | *_automoc.cpp | ||
17 | 12 | *.pc | ||
18 | 13 | CTestTestfile.cmake | ||
19 | 14 | *Test.log | ||
20 | 15 | Testing | ||
21 | 16 | conversiontest | ||
22 | 17 | deelistmodeltest | ||
23 | 18 | deevarianttexttest | ||
24 | 19 | plugintest | ||
25 | 20 | test-helper | ||
26 | 21 | *-xunit.xml | ||
27 | 9 | 22 | ||
28 | === modified file 'CMakeLists.txt' | |||
29 | --- CMakeLists.txt 2013-01-31 17:47:23 +0000 | |||
30 | +++ CMakeLists.txt 2013-03-14 20:47:26 +0000 | |||
31 | @@ -22,7 +22,11 @@ | |||
32 | 22 | set(OUR_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}) | 22 | set(OUR_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}) |
33 | 23 | set(OUR_QT_CORE_LIB ${Qt5Core_LIBRARIES}) | 23 | set(OUR_QT_CORE_LIB ${Qt5Core_LIBRARIES}) |
34 | 24 | set(OUR_QT_DBUS_LIB ${Qt5DBus_LIBRARIES}) | 24 | set(OUR_QT_DBUS_LIB ${Qt5DBus_LIBRARIES}) |
35 | 25 | <<<<<<< TREE | ||
36 | 25 | set(QT_PKGCONFIG_DEPENDENCIES "Qt5Core") | 26 | set(QT_PKGCONFIG_DEPENDENCIES "Qt5Core") |
37 | 27 | ======= | ||
38 | 28 | set(QT_PKGCONFIG_DEPENDENCIES "QtCore QtQuick") | ||
39 | 29 | >>>>>>> MERGE-SOURCE | ||
40 | 26 | else () | 30 | else () |
41 | 27 | message("Building Qt4 version") | 31 | message("Building Qt4 version") |
42 | 28 | 32 | ||
43 | @@ -47,6 +51,12 @@ | |||
44 | 47 | # Sources | 51 | # Sources |
45 | 48 | set(DEE_QT_SRCS | 52 | set(DEE_QT_SRCS |
46 | 49 | deelistmodel.cpp | 53 | deelistmodel.cpp |
47 | 54 | deevarianttext.cpp | ||
48 | 55 | ) | ||
49 | 56 | |||
50 | 57 | ## QtDeeQml | ||
51 | 58 | set(QtDeeQml_SRCS | ||
52 | 59 | plugin.cpp | ||
53 | 50 | ) | 60 | ) |
54 | 51 | 61 | ||
55 | 52 | # Build | 62 | # Build |
56 | @@ -73,6 +83,7 @@ | |||
57 | 73 | # Unit-Test | 83 | # Unit-Test |
58 | 74 | enable_testing() | 84 | enable_testing() |
59 | 75 | 85 | ||
60 | 86 | add_custom_target(check COMMAND "env" "CTEST_OUTPUT_ON_FAILURE=1" "${CMAKE_CTEST_COMMAND}") | ||
61 | 76 | add_subdirectory(modules) | 87 | add_subdirectory(modules) |
62 | 77 | add_subdirectory(tests) | 88 | add_subdirectory(tests) |
63 | 78 | 89 | ||
64 | @@ -83,7 +94,7 @@ | |||
65 | 83 | LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}${LIB_SUFFIX} | 94 | LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}${LIB_SUFFIX} |
66 | 84 | ) | 95 | ) |
67 | 85 | 96 | ||
69 | 86 | install(FILES deelistmodel.h | 97 | install(FILES deelistmodel.h deevarianttext.h |
70 | 87 | DESTINATION ${INCLUDE_INSTALL_DIR} | 98 | DESTINATION ${INCLUDE_INSTALL_DIR} |
71 | 88 | ) | 99 | ) |
72 | 89 | 100 | ||
73 | 90 | 101 | ||
74 | === modified file 'deelistmodel.cpp' | |||
75 | --- deelistmodel.cpp 2013-01-18 13:21:04 +0000 | |||
76 | +++ deelistmodel.cpp 2013-03-14 20:47:26 +0000 | |||
77 | @@ -17,17 +17,20 @@ | |||
78 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
79 | 18 | */ | 18 | */ |
80 | 19 | 19 | ||
81 | 20 | #include <QCoreApplication> | ||
82 | 20 | #include <QtCore/QHash> | 21 | #include <QtCore/QHash> |
83 | 21 | #include <QtCore/QByteArray> | 22 | #include <QtCore/QByteArray> |
84 | 23 | #include <QDebug> | ||
85 | 22 | 24 | ||
86 | 23 | #include <dee.h> | 25 | #include <dee.h> |
87 | 24 | #include <glib-object.h> | ||
88 | 25 | 26 | ||
89 | 26 | #include "deelistmodel.h" | 27 | #include "deelistmodel.h" |
90 | 28 | #include "deeprivate.h" | ||
91 | 27 | 29 | ||
93 | 28 | static QVariant | 30 | QVariant |
94 | 29 | QVariantFromGVariant(GVariant *value) | 31 | QVariantFromGVariant(GVariant *value) |
95 | 30 | { | 32 | { |
96 | 33 | Q_ASSERT(value); | ||
97 | 31 | switch (g_variant_classify(value)) { | 34 | switch (g_variant_classify(value)) { |
98 | 32 | case G_VARIANT_CLASS_BOOLEAN: | 35 | case G_VARIANT_CLASS_BOOLEAN: |
99 | 33 | return QVariant((bool) g_variant_get_boolean(value)); | 36 | return QVariant((bool) g_variant_get_boolean(value)); |
100 | @@ -62,13 +65,14 @@ | |||
101 | 62 | } | 65 | } |
102 | 63 | return array; | 66 | return array; |
103 | 64 | } | 67 | } |
104 | 68 | case G_VARIANT_CLASS_VARIANT: | ||
105 | 69 | return QVariant(QVariantFromGVariant(g_variant_get_variant(value))); | ||
106 | 65 | default: | 70 | default: |
107 | 66 | /* Fallback on an empty QVariant. | 71 | /* Fallback on an empty QVariant. |
108 | 67 | FIXME: Missing conversion of following GVariant types: | 72 | FIXME: Missing conversion of following GVariant types: |
109 | 68 | - G_VARIANT_CLASS_HANDLE | 73 | - G_VARIANT_CLASS_HANDLE |
110 | 69 | - G_VARIANT_CLASS_OBJECT_PATH | 74 | - G_VARIANT_CLASS_OBJECT_PATH |
111 | 70 | - G_VARIANT_CLASS_SIGNATURE | 75 | - G_VARIANT_CLASS_SIGNATURE |
112 | 71 | - G_VARIANT_CLASS_VARIANT | ||
113 | 72 | - G_VARIANT_CLASS_MAYBE | 76 | - G_VARIANT_CLASS_MAYBE |
114 | 73 | - G_VARIANT_CLASS_DICT_ENTRY | 77 | - G_VARIANT_CLASS_DICT_ENTRY |
115 | 74 | */ | 78 | */ |
116 | @@ -84,7 +88,6 @@ | |||
117 | 84 | void connectToDeeModel(); | 88 | void connectToDeeModel(); |
118 | 85 | void connectToDeeModel(DeeModel *model); | 89 | void connectToDeeModel(DeeModel *model); |
119 | 86 | void disconnectFromDeeModel(); | 90 | void disconnectFromDeeModel(); |
120 | 87 | void createRoles(); | ||
121 | 88 | bool synchronized() const; | 91 | bool synchronized() const; |
122 | 89 | 92 | ||
123 | 90 | /* GObject signal handlers for m_deeModel */ | 93 | /* GObject signal handlers for m_deeModel */ |
124 | @@ -133,16 +136,27 @@ | |||
125 | 133 | if (!m_name.isEmpty()) | 136 | if (!m_name.isEmpty()) |
126 | 134 | { | 137 | { |
127 | 135 | m_deeModel = dee_shared_model_new(m_name.toUtf8().data()); | 138 | m_deeModel = dee_shared_model_new(m_name.toUtf8().data()); |
128 | 139 | // FIXME expose property to set schema in QML | ||
129 | 140 | bool ownSchema = m_name.contains(".test"); | ||
130 | 141 | if (ownSchema) | ||
131 | 142 | dee_model_set_schema(m_deeModel, "b", NULL); | ||
132 | 136 | g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent); | 143 | g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent); |
133 | 137 | g_signal_connect(m_deeModel, "row-added", G_CALLBACK(onRowAdded), m_parent); | 144 | g_signal_connect(m_deeModel, "row-added", G_CALLBACK(onRowAdded), m_parent); |
134 | 138 | g_signal_connect(m_deeModel, "row-removed", G_CALLBACK(onRowRemoved), m_parent); | 145 | g_signal_connect(m_deeModel, "row-removed", G_CALLBACK(onRowRemoved), m_parent); |
135 | 139 | g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent); | 146 | g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent); |
136 | 147 | if (ownSchema) | ||
137 | 148 | { | ||
138 | 149 | // Doc says we need to be synchronized before doing anything | ||
139 | 150 | while(!dee_shared_model_is_synchronized(DEE_SHARED_MODEL(m_deeModel))) | ||
140 | 151 | qApp->processEvents(); | ||
141 | 152 | } | ||
142 | 140 | } | 153 | } |
143 | 141 | } | 154 | } |
144 | 142 | 155 | ||
145 | 143 | void | 156 | void |
146 | 144 | DeeListModelPrivate::connectToDeeModel(DeeModel *model) | 157 | DeeListModelPrivate::connectToDeeModel(DeeModel *model) |
147 | 145 | { | 158 | { |
148 | 159 | m_parent->beginResetModel(); | ||
149 | 146 | disconnectFromDeeModel(); | 160 | disconnectFromDeeModel(); |
150 | 147 | 161 | ||
151 | 148 | m_deeModel = (DeeModel*)g_object_ref (model); | 162 | m_deeModel = (DeeModel*)g_object_ref (model); |
152 | @@ -151,16 +165,24 @@ | |||
153 | 151 | g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent); | 165 | g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent); |
154 | 152 | if (synchronized()) | 166 | if (synchronized()) |
155 | 153 | { | 167 | { |
156 | 168 | <<<<<<< TREE | ||
157 | 154 | createRoles(); | 169 | createRoles(); |
158 | 155 | m_parent->beginResetModel(); | 170 | m_parent->beginResetModel(); |
159 | 171 | ======= | ||
160 | 172 | >>>>>>> MERGE-SOURCE | ||
161 | 156 | m_count = dee_model_get_n_rows(m_deeModel); | 173 | m_count = dee_model_get_n_rows(m_deeModel); |
162 | 174 | <<<<<<< TREE | ||
163 | 157 | m_parent->endResetModel(); | 175 | m_parent->endResetModel(); |
164 | 176 | ======= | ||
165 | 177 | >>>>>>> MERGE-SOURCE | ||
166 | 158 | Q_EMIT m_parent->countChanged(); | 178 | Q_EMIT m_parent->countChanged(); |
167 | 179 | Q_EMIT m_parent->layoutChanged(); | ||
168 | 159 | } | 180 | } |
169 | 160 | else | 181 | else |
170 | 161 | { | 182 | { |
171 | 162 | g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent); | 183 | g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent); |
172 | 163 | } | 184 | } |
173 | 185 | m_parent->endResetModel(); | ||
174 | 164 | } | 186 | } |
175 | 165 | 187 | ||
176 | 166 | bool | 188 | bool |
177 | @@ -177,20 +199,23 @@ | |||
178 | 177 | } | 199 | } |
179 | 178 | } | 200 | } |
180 | 179 | 201 | ||
183 | 180 | void | 202 | QHash<int, QByteArray> |
184 | 181 | DeeListModelPrivate::createRoles() | 203 | DeeListModel::roleNames() |
185 | 182 | { | 204 | { |
186 | 183 | if (m_deeModel == NULL) { | ||
187 | 184 | return; | ||
188 | 185 | } | ||
189 | 186 | |||
190 | 187 | QHash<int, QByteArray> roles; | 205 | QHash<int, QByteArray> roles; |
191 | 206 | |||
192 | 207 | qDebug() << "m_deeModel" << d->m_deeModel; | ||
193 | 208 | if (d->m_deeModel == NULL) { | ||
194 | 209 | return roles; | ||
195 | 210 | } | ||
196 | 211 | |||
197 | 188 | QString column; | 212 | QString column; |
199 | 189 | guint n_columns = dee_model_get_n_columns(m_deeModel); | 213 | guint n_columns = dee_model_get_n_columns(d->m_deeModel); |
200 | 190 | 214 | ||
201 | 191 | for (unsigned int index=0; index<n_columns; index++) | 215 | for (unsigned int index=0; index<n_columns; index++) |
202 | 192 | { | 216 | { |
203 | 193 | column = QString("column_%1").arg(index); | 217 | column = QString("column_%1").arg(index); |
204 | 218 | <<<<<<< TREE | ||
205 | 194 | roles[index] = column.toLocal8Bit(); | 219 | roles[index] = column.toLocal8Bit(); |
206 | 195 | } | 220 | } |
207 | 196 | 221 | ||
208 | @@ -201,6 +226,29 @@ | |||
209 | 201 | #endif | 226 | #endif |
210 | 202 | m_roleNames = roles; | 227 | m_roleNames = roles; |
211 | 203 | Q_EMIT m_parent->roleNamesChanged(roles); | 228 | Q_EMIT m_parent->roleNamesChanged(roles); |
212 | 229 | ======= | ||
213 | 230 | roles[index] = column.toUtf8(); | ||
214 | 231 | } | ||
215 | 232 | return roles; | ||
216 | 233 | } | ||
217 | 234 | |||
218 | 235 | void DeeListModel::append(const QString & data) | ||
219 | 236 | { | ||
220 | 237 | GVariant* gvariant = g_variant_parse(NULL, "false", NULL, NULL, NULL); | ||
221 | 238 | if (!gvariant) | ||
222 | 239 | { | ||
223 | 240 | qDebug() << "Failed to append " << data << " (invalid) to model"; | ||
224 | 241 | return; | ||
225 | 242 | } | ||
226 | 243 | DeeModelIter* iter = dee_model_insert (d->m_deeModel, 0, &gvariant); | ||
227 | 244 | g_variant_unref(gvariant); | ||
228 | 245 | } | ||
229 | 246 | |||
230 | 247 | void DeeListModel::remove(int index) | ||
231 | 248 | { | ||
232 | 249 | DeeModelIter* iter = dee_model_get_iter_at_row (d->m_deeModel, index); | ||
233 | 250 | dee_model_remove(d->m_deeModel, iter); | ||
234 | 251 | >>>>>>> MERGE-SOURCE | ||
235 | 204 | } | 252 | } |
236 | 205 | 253 | ||
237 | 206 | void | 254 | void |
238 | @@ -208,12 +256,21 @@ | |||
239 | 208 | GParamSpec *pspec, | 256 | GParamSpec *pspec, |
240 | 209 | DeeListModel *model) | 257 | DeeListModel *model) |
241 | 210 | { | 258 | { |
242 | 259 | <<<<<<< TREE | ||
243 | 211 | model->d->createRoles(); | 260 | model->d->createRoles(); |
244 | 212 | model->beginResetModel(); | 261 | model->beginResetModel(); |
245 | 262 | ======= | ||
246 | 263 | model->beginResetModel(); | ||
247 | 264 | >>>>>>> MERGE-SOURCE | ||
248 | 213 | model->d->m_count = dee_model_get_n_rows(model->d->m_deeModel); | 265 | model->d->m_count = dee_model_get_n_rows(model->d->m_deeModel); |
249 | 214 | model->synchronizedChanged(model->synchronized()); | 266 | model->synchronizedChanged(model->synchronized()); |
250 | 267 | <<<<<<< TREE | ||
251 | 215 | model->endResetModel(); | 268 | model->endResetModel(); |
252 | 269 | ======= | ||
253 | 270 | >>>>>>> MERGE-SOURCE | ||
254 | 216 | Q_EMIT model->countChanged(); | 271 | Q_EMIT model->countChanged(); |
255 | 272 | Q_EMIT model->layoutChanged(); | ||
256 | 273 | model->endResetModel(); | ||
257 | 217 | } | 274 | } |
258 | 218 | 275 | ||
259 | 219 | void | 276 | void |
260 | @@ -236,6 +293,7 @@ | |||
261 | 236 | model->beginInsertRows(QModelIndex(), position, position); | 293 | model->beginInsertRows(QModelIndex(), position, position); |
262 | 237 | model->endInsertRows(); | 294 | model->endInsertRows(); |
263 | 238 | Q_EMIT model->countChanged(); | 295 | Q_EMIT model->countChanged(); |
264 | 296 | Q_EMIT model->layoutChanged(); | ||
265 | 239 | } | 297 | } |
266 | 240 | 298 | ||
267 | 241 | void | 299 | void |
268 | @@ -263,6 +321,7 @@ | |||
269 | 263 | model->beginRemoveRows(QModelIndex(), position, position); | 321 | model->beginRemoveRows(QModelIndex(), position, position); |
270 | 264 | model->endRemoveRows(); | 322 | model->endRemoveRows(); |
271 | 265 | Q_EMIT model->countChanged(); | 323 | Q_EMIT model->countChanged(); |
272 | 324 | Q_EMIT model->layoutChanged(); | ||
273 | 266 | } | 325 | } |
274 | 267 | 326 | ||
275 | 268 | void | 327 | void |
276 | @@ -279,8 +338,6 @@ | |||
277 | 279 | Q_EMIT model->dataChanged(index, index); | 338 | Q_EMIT model->dataChanged(index, index); |
278 | 280 | } | 339 | } |
279 | 281 | 340 | ||
280 | 282 | |||
281 | 283 | |||
282 | 284 | DeeListModel::DeeListModel(QObject *parent) : | 341 | DeeListModel::DeeListModel(QObject *parent) : |
283 | 285 | QAbstractListModel(parent), d(new DeeListModelPrivate(this)) | 342 | QAbstractListModel(parent), d(new DeeListModelPrivate(this)) |
284 | 286 | { | 343 | { |
285 | 287 | 344 | ||
286 | === modified file 'deelistmodel.h' | |||
287 | --- deelistmodel.h 2013-01-18 13:21:04 +0000 | |||
288 | +++ deelistmodel.h 2013-03-14 20:47:26 +0000 | |||
289 | @@ -20,11 +20,12 @@ | |||
290 | 20 | #ifndef DEELISTMODEL_H | 20 | #ifndef DEELISTMODEL_H |
291 | 21 | #define DEELISTMODEL_H | 21 | #define DEELISTMODEL_H |
292 | 22 | 22 | ||
293 | 23 | #include <QtCore/QObject> | ||
294 | 23 | #include <QtCore/QAbstractListModel> | 24 | #include <QtCore/QAbstractListModel> |
295 | 24 | 25 | ||
296 | 25 | class DeeListModelPrivate; | 26 | class DeeListModelPrivate; |
297 | 26 | typedef struct _DeeModel DeeModel; | 27 | typedef struct _DeeModel DeeModel; |
299 | 27 | class __attribute__ ((visibility ("default"))) DeeListModel : public QAbstractListModel | 28 | class Q_DECL_EXPORT DeeListModel : public QAbstractListModel |
300 | 28 | { | 29 | { |
301 | 29 | friend class DeeListModelPrivate; | 30 | friend class DeeListModelPrivate; |
302 | 30 | 31 | ||
303 | @@ -46,6 +47,10 @@ | |||
304 | 46 | int rowCount(const QModelIndex & parent = QModelIndex()) const; | 47 | int rowCount(const QModelIndex & parent = QModelIndex()) const; |
305 | 47 | QHash<int, QByteArray> roleNames() const; | 48 | QHash<int, QByteArray> roleNames() const; |
306 | 48 | 49 | ||
307 | 50 | /* Modification of the model */ | ||
308 | 51 | Q_INVOKABLE void append(const QString & data); | ||
309 | 52 | Q_INVOKABLE void remove(int index); | ||
310 | 53 | |||
311 | 49 | /* getters */ | 54 | /* getters */ |
312 | 50 | QString name() const; | 55 | QString name() const; |
313 | 51 | bool synchronized() const; | 56 | bool synchronized() const; |
314 | @@ -53,11 +58,11 @@ | |||
315 | 53 | /* setters */ | 58 | /* setters */ |
316 | 54 | void setName(const QString& name); | 59 | void setName(const QString& name); |
317 | 55 | void setModel(DeeModel* model); | 60 | void setModel(DeeModel* model); |
318 | 61 | QHash<int, QByteArray> roleNames(); | ||
319 | 56 | 62 | ||
320 | 57 | Q_SIGNALS: | 63 | Q_SIGNALS: |
321 | 58 | void nameChanged(const QString&); | 64 | void nameChanged(const QString&); |
322 | 59 | void synchronizedChanged(bool); | 65 | void synchronizedChanged(bool); |
323 | 60 | void roleNamesChanged(const QHash<int,QByteArray> &); | ||
324 | 61 | void countChanged(); | 66 | void countChanged(); |
325 | 62 | 67 | ||
326 | 63 | private: | 68 | private: |
327 | 64 | 69 | ||
328 | === added file 'deeprivate.h' | |||
329 | --- deeprivate.h 1970-01-01 00:00:00 +0000 | |||
330 | +++ deeprivate.h 2013-03-14 20:47:26 +0000 | |||
331 | @@ -0,0 +1,23 @@ | |||
332 | 1 | /* | ||
333 | 2 | * Copyright (C) 2012 Canonical, Ltd. | ||
334 | 3 | * | ||
335 | 4 | * Authors: | ||
336 | 5 | * Christian Dywan <christian.dywan@canonical.com> | ||
337 | 6 | * | ||
338 | 7 | * This program is free software; you can redistribute it and/or modify | ||
339 | 8 | * it under the terms of the GNU General Public License as published by | ||
340 | 9 | * the Free Software Foundation; version 3. | ||
341 | 10 | * | ||
342 | 11 | * This program is distributed in the hope that it will be useful, | ||
343 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
344 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
345 | 14 | * GNU General Public License for more details. | ||
346 | 15 | * | ||
347 | 16 | * You should have received a copy of the GNU General Public License | ||
348 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
349 | 18 | */ | ||
350 | 19 | |||
351 | 20 | #include <glib-object.h> | ||
352 | 21 | |||
353 | 22 | QVariant QVariantFromGVariant(GVariant *value); | ||
354 | 23 | |||
355 | 0 | 24 | ||
356 | === added file 'deevarianttext.cpp' | |||
357 | --- deevarianttext.cpp 1970-01-01 00:00:00 +0000 | |||
358 | +++ deevarianttext.cpp 2013-03-14 20:47:26 +0000 | |||
359 | @@ -0,0 +1,72 @@ | |||
360 | 1 | /* | ||
361 | 2 | * Copyright (C) 2012 Canonical, Ltd. | ||
362 | 3 | * | ||
363 | 4 | * Authors: | ||
364 | 5 | * Christian Dywan <christian.dywan@canonical.com> | ||
365 | 6 | * | ||
366 | 7 | * This program is free software; you can redistribute it and/or modify | ||
367 | 8 | * it under the terms of the GNU General Public License as published by | ||
368 | 9 | * the Free Software Foundation; version 3. | ||
369 | 10 | * | ||
370 | 11 | * This program is distributed in the hope that it will be useful, | ||
371 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
372 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
373 | 14 | * GNU General Public License for more details. | ||
374 | 15 | * | ||
375 | 16 | * You should have received a copy of the GNU General Public License | ||
376 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
377 | 18 | */ | ||
378 | 19 | |||
379 | 20 | #include <QDebug> | ||
380 | 21 | |||
381 | 22 | #include "deevarianttext.h" | ||
382 | 23 | #include "deeprivate.h" | ||
383 | 24 | |||
384 | 25 | DeeVariantText::DeeVariantText(QObject *parent) : | ||
385 | 26 | m_text(""), | ||
386 | 27 | m_value(QVariant()), | ||
387 | 28 | m_type("") | ||
388 | 29 | { | ||
389 | 30 | } | ||
390 | 31 | |||
391 | 32 | void | ||
392 | 33 | DeeVariantText::setText(const QString& text) | ||
393 | 34 | { | ||
394 | 35 | if (m_text == text) | ||
395 | 36 | return; | ||
396 | 37 | |||
397 | 38 | m_text = text; | ||
398 | 39 | GVariant *gvariant = g_variant_parse(NULL, text.toUtf8(), NULL, NULL, NULL); | ||
399 | 40 | if (!gvariant) | ||
400 | 41 | { | ||
401 | 42 | qDebug() << "Failed to parse " << text << " to QVariant"; | ||
402 | 43 | m_value = QVariant(); | ||
403 | 44 | m_type = ""; | ||
404 | 45 | } | ||
405 | 46 | else | ||
406 | 47 | { | ||
407 | 48 | m_value = QVariantFromGVariant(gvariant); | ||
408 | 49 | m_type = g_variant_get_type_string(gvariant); | ||
409 | 50 | } | ||
410 | 51 | Q_EMIT textChanged(text); | ||
411 | 52 | Q_EMIT valueChanged(m_value); | ||
412 | 53 | } | ||
413 | 54 | |||
414 | 55 | QString | ||
415 | 56 | DeeVariantText::getText() | ||
416 | 57 | { | ||
417 | 58 | return m_text; | ||
418 | 59 | } | ||
419 | 60 | |||
420 | 61 | QVariant | ||
421 | 62 | DeeVariantText::getValue() | ||
422 | 63 | { | ||
423 | 64 | return m_value; | ||
424 | 65 | } | ||
425 | 66 | |||
426 | 67 | QVariant | ||
427 | 68 | DeeVariantText::getType() | ||
428 | 69 | { | ||
429 | 70 | return m_type; | ||
430 | 71 | } | ||
431 | 72 | |||
432 | 0 | 73 | ||
433 | === added file 'deevarianttext.h' | |||
434 | --- deevarianttext.h 1970-01-01 00:00:00 +0000 | |||
435 | +++ deevarianttext.h 2013-03-14 20:47:26 +0000 | |||
436 | @@ -0,0 +1,49 @@ | |||
437 | 1 | /* | ||
438 | 2 | * Copyright (C) 2012 Canonical, Ltd. | ||
439 | 3 | * | ||
440 | 4 | * Authors: | ||
441 | 5 | * Christian Dywan <christian.dywan@canonical.com> | ||
442 | 6 | * | ||
443 | 7 | * This program is free software; you can redistribute it and/or modify | ||
444 | 8 | * it under the terms of the GNU General Public License as published by | ||
445 | 9 | * the Free Software Foundation; version 3. | ||
446 | 10 | * | ||
447 | 11 | * This program is distributed in the hope that it will be useful, | ||
448 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
449 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
450 | 14 | * GNU General Public License for more details. | ||
451 | 15 | * | ||
452 | 16 | * You should have received a copy of the GNU General Public License | ||
453 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
454 | 18 | */ | ||
455 | 19 | |||
456 | 20 | #ifndef DEEVARIANTTEXT_H | ||
457 | 21 | #define DEEVARIANTTEXT_H | ||
458 | 22 | |||
459 | 23 | #include <QtCore/QObject> | ||
460 | 24 | #include <QtCore/QVariant> | ||
461 | 25 | |||
462 | 26 | class Q_DECL_EXPORT DeeVariantText : public QObject { | ||
463 | 27 | Q_OBJECT | ||
464 | 28 | Q_PROPERTY(QString text READ getText WRITE setText NOTIFY textChanged) | ||
465 | 29 | Q_PROPERTY(QVariant value READ getValue NOTIFY valueChanged) | ||
466 | 30 | public: | ||
467 | 31 | DeeVariantText(QObject* parent = 0); | ||
468 | 32 | ~DeeVariantText() { } | ||
469 | 33 | |||
470 | 34 | QString getText(); | ||
471 | 35 | QVariant getValue(); | ||
472 | 36 | QVariant getType(); | ||
473 | 37 | void setText(const QString& text); | ||
474 | 38 | Q_SIGNALS: | ||
475 | 39 | void textChanged(const QString& text); | ||
476 | 40 | void valueChanged(const QVariant& value); | ||
477 | 41 | private: | ||
478 | 42 | Q_DISABLE_COPY(DeeVariantText) | ||
479 | 43 | QString m_text; | ||
480 | 44 | QVariant m_value; | ||
481 | 45 | QString m_type; | ||
482 | 46 | }; | ||
483 | 47 | |||
484 | 48 | #endif // DEEVARIANTTEXT_H | ||
485 | 49 | |||
486 | 0 | 50 | ||
487 | === modified file 'modules/Dee/CMakeLists.txt' | |||
488 | --- modules/Dee/CMakeLists.txt 2013-01-28 15:41:01 +0000 | |||
489 | +++ modules/Dee/CMakeLists.txt 2013-03-14 20:47:26 +0000 | |||
490 | @@ -4,7 +4,12 @@ | |||
491 | 4 | set(OUR_QT_QUICK_LIB ${Qt5Quick_LIBRARIES}) | 4 | set(OUR_QT_QUICK_LIB ${Qt5Quick_LIBRARIES}) |
492 | 5 | 5 | ||
493 | 6 | get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) | 6 | get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) |
495 | 7 | exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_QML" OUTPUT_VARIABLE QT_IMPORTS_DIR) | 7 | <<<<<<< TREE |
496 | 8 | exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_QML" OUTPUT_VARIABLE QT_IMPORTS_DIR) | ||
497 | 9 | ======= | ||
498 | 10 | # See http://doc-snapshot.qt-project.org/5.0/qtcore/qlibraryinfo.html#LibraryLocation-enum | ||
499 | 11 | exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_QML" OUTPUT_VARIABLE QT_IMPORTS_DIR) | ||
500 | 12 | >>>>>>> MERGE-SOURCE | ||
501 | 8 | file(TO_CMAKE_PATH "${QT_IMPORTS_DIR}" QT_IMPORTS_DIR) | 13 | file(TO_CMAKE_PATH "${QT_IMPORTS_DIR}" QT_IMPORTS_DIR) |
502 | 9 | 14 | ||
503 | 10 | set(OUR_QT_QUICK_INCLUDE ${Qt5Quick_INCLUDE_DIRS}) | 15 | set(OUR_QT_QUICK_INCLUDE ${Qt5Quick_INCLUDE_DIRS}) |
504 | @@ -20,6 +25,7 @@ | |||
505 | 20 | ) | 25 | ) |
506 | 21 | 26 | ||
507 | 22 | add_library(DeePlugin SHARED ${DeePlugin_SRCS}) | 27 | add_library(DeePlugin SHARED ${DeePlugin_SRCS}) |
508 | 28 | add_dependencies(check DeePlugin) | ||
509 | 23 | 29 | ||
510 | 24 | target_link_libraries(DeePlugin | 30 | target_link_libraries(DeePlugin |
511 | 25 | ${DEE_QT_LIBNAME} | 31 | ${DEE_QT_LIBNAME} |
512 | 26 | 32 | ||
513 | === modified file 'modules/Dee/plugin.cpp' | |||
514 | --- modules/Dee/plugin.cpp 2012-11-30 12:56:33 +0000 | |||
515 | +++ modules/Dee/plugin.cpp 2013-03-14 20:47:26 +0000 | |||
516 | @@ -18,6 +18,7 @@ | |||
517 | 18 | */ | 18 | */ |
518 | 19 | 19 | ||
519 | 20 | #include "deelistmodel.h" | 20 | #include "deelistmodel.h" |
520 | 21 | #include "deevarianttext.h" | ||
521 | 21 | #include "plugin.h" | 22 | #include "plugin.h" |
522 | 22 | #if WITHQT5 | 23 | #if WITHQT5 |
523 | 23 | #include <qqml.h> | 24 | #include <qqml.h> |
524 | @@ -28,6 +29,7 @@ | |||
525 | 28 | void DeePlugin::registerTypes(const char *uri) | 29 | void DeePlugin::registerTypes(const char *uri) |
526 | 29 | { | 30 | { |
527 | 30 | qmlRegisterType<DeeListModel>(uri, 3, 0, "DeeListModel"); | 31 | qmlRegisterType<DeeListModel>(uri, 3, 0, "DeeListModel"); |
528 | 32 | qmlRegisterType<DeeVariantText>(uri, 3, 0, "DeeVariantText"); | ||
529 | 31 | } | 33 | } |
530 | 32 | 34 | ||
531 | 33 | #if !WITHQT5 | 35 | #if !WITHQT5 |
532 | 34 | 36 | ||
533 | === modified file 'tests/CMakeLists.txt' | |||
534 | --- tests/CMakeLists.txt 2012-11-30 14:51:06 +0000 | |||
535 | +++ tests/CMakeLists.txt 2013-03-14 20:47:26 +0000 | |||
536 | @@ -5,25 +5,53 @@ | |||
537 | 5 | else () | 5 | else () |
538 | 6 | set(OUR_QT_TEST_LIB ${QT_QTTEST_LIBRARIES}) | 6 | set(OUR_QT_TEST_LIB ${QT_QTTEST_LIBRARIES}) |
539 | 7 | set(OUR_QT_TEST_INCLUDES ${QT_QTTEST_INCLUDE_DIR}) | 7 | set(OUR_QT_TEST_INCLUDES ${QT_QTTEST_INCLUDE_DIR}) |
540 | 8 | set(OUR_QT_QUICK_LIB ${QT_QTDECLARATIVE_LIBRARIES}) | ||
541 | 9 | set(OUR_QT_QUICK_INCLUDE ${QT_QTDECLARATIVE_INCLUDE_DIR}) | ||
542 | 10 | endif () | ||
543 | 11 | |||
544 | 12 | if (WITHQT5) | ||
545 | 13 | add_test(NAME plugintest COMMAND "qmltestrunner" "-import" "../modules" "-xunitxml" "-o" "plugintest-xunit.xml" "-input" "${CMAKE_CURRENT_SOURCE_DIR}") | ||
546 | 14 | else () | ||
547 | 15 | add_executable(plugintest qtquick1plugintest.cpp) | ||
548 | 16 | target_link_libraries(plugintest ${OUR_QT_TEST_LIB} ${OUR_QT_QUICK_LIB}) | ||
549 | 17 | set_target_properties(plugintest PROPERTIES COMPILE_FLAGS -fPIC) | ||
550 | 18 | 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") | ||
551 | 19 | set_property(TEST plugintest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") | ||
552 | 20 | set_property(TEST plugintest PROPERTY ENVIRONMENT "QT_GRAPHICSSYSTEM=raster") | ||
553 | 21 | set_property(TEST plugintest PROPERTY ENVIRONMENT "QML_IMPORT_PATH=${CMAKE_CURRENT_BINARY_DIR}/../modules") | ||
554 | 22 | add_dependencies(check plugintest) | ||
555 | 8 | endif () | 23 | endif () |
556 | 9 | 24 | ||
557 | 10 | include_directories( | 25 | include_directories( |
558 | 11 | ${CMAKE_CURRENT_BINARY_DIR} | 26 | ${CMAKE_CURRENT_BINARY_DIR} |
559 | 12 | ${OUR_QT_TEST_INCLUDES} | 27 | ${OUR_QT_TEST_INCLUDES} |
560 | 28 | ${OUR_QT_QUICK_INCLUDE} | ||
561 | 13 | ) | 29 | ) |
562 | 14 | 30 | ||
563 | 15 | add_executable(conversiontest conversiontest.cpp) | 31 | add_executable(conversiontest conversiontest.cpp) |
565 | 16 | target_link_libraries(conversiontest ${OUR_QT_TEST_LIB} ${DEE_QT_LIBNAME}) | 32 | target_link_libraries(conversiontest ${OUR_QT_WIDGETS_LIB} ${OUR_QT_TEST_LIB} ${OUR_QT_QUICK_LIB} ${DEE_QT_LIBNAME}) |
566 | 17 | set_target_properties(conversiontest PROPERTIES COMPILE_FLAGS -fPIC) | 33 | set_target_properties(conversiontest PROPERTIES COMPILE_FLAGS -fPIC) |
567 | 18 | add_test(NAME conversiontest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/conversiontest" "-p" "-xunitxml" "-p" "-o" "-p" "conversiontest-xunit.xml") | 34 | add_test(NAME conversiontest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/conversiontest" "-p" "-xunitxml" "-p" "-o" "-p" "conversiontest-xunit.xml") |
568 | 19 | set_property(TEST conversiontest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") | 35 | set_property(TEST conversiontest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
569 | 36 | set_property(TEST conversiontest PROPERTY ENVIRONMENT "QT_QPA_PLATFORM=minimal") | ||
570 | 37 | add_dependencies(check conversiontest) | ||
571 | 20 | 38 | ||
572 | 21 | add_executable(test-helper test-helper.cpp) | 39 | add_executable(test-helper test-helper.cpp) |
573 | 22 | target_link_libraries(test-helper ${OUR_QT_CORE_LIB} ${OUR_QT_DBUS_LIB} ${DEE_LDFLAGS}) | 40 | target_link_libraries(test-helper ${OUR_QT_CORE_LIB} ${OUR_QT_DBUS_LIB} ${DEE_LDFLAGS}) |
574 | 23 | set_target_properties(test-helper PROPERTIES COMPILE_FLAGS -fPIC) | 41 | set_target_properties(test-helper PROPERTIES COMPILE_FLAGS -fPIC) |
575 | 42 | add_dependencies(conversiontest ${DEE_QT_LIBNAME} test-helper) | ||
576 | 24 | 43 | ||
577 | 25 | add_executable(deelistmodeltest deelistmodeltest.cpp) | 44 | add_executable(deelistmodeltest deelistmodeltest.cpp) |
578 | 26 | target_link_libraries(deelistmodeltest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME}) | 45 | target_link_libraries(deelistmodeltest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME}) |
579 | 27 | set_target_properties(deelistmodeltest PROPERTIES COMPILE_FLAGS -fPIC) | 46 | set_target_properties(deelistmodeltest PROPERTIES COMPILE_FLAGS -fPIC) |
580 | 28 | 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") | 47 | 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") |
581 | 29 | set_property(TEST deelistmodeltest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") | 48 | set_property(TEST deelistmodeltest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") |
582 | 49 | add_dependencies(check deelistmodeltest) | ||
583 | 50 | |||
584 | 51 | add_executable(deevarianttexttest deevarianttexttest.cpp) | ||
585 | 52 | target_link_libraries(deevarianttexttest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME}) | ||
586 | 53 | set_target_properties(deevarianttexttest PROPERTIES COMPILE_FLAGS -fPIC) | ||
587 | 54 | add_test(NAME deevarianttexttest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/deevarianttexttest" "-p" "-xunitxml" "-p" "-o" "-p" "deevarianttexttest-xunit.xml") | ||
588 | 55 | set_property(TEST deevarianttexttest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.") | ||
589 | 56 | add_dependencies(check deevarianttexttest) | ||
590 | 57 | |||
591 | 30 | 58 | ||
592 | === modified file 'tests/conversiontest.cpp' | |||
593 | --- tests/conversiontest.cpp 2012-11-30 12:56:33 +0000 | |||
594 | +++ tests/conversiontest.cpp 2013-03-14 20:47:26 +0000 | |||
595 | @@ -18,6 +18,7 @@ | |||
596 | 18 | #include <QObject> | 18 | #include <QObject> |
597 | 19 | 19 | ||
598 | 20 | #include "deelistmodel.h" | 20 | #include "deelistmodel.h" |
599 | 21 | #include "deevarianttext.h" | ||
600 | 21 | 22 | ||
601 | 22 | #include <dee.h> | 23 | #include <dee.h> |
602 | 23 | 24 | ||
603 | 24 | 25 | ||
604 | === modified file 'tests/deelistmodeltest.cpp' | |||
605 | --- tests/deelistmodeltest.cpp 2012-11-30 12:56:33 +0000 | |||
606 | +++ tests/deelistmodeltest.cpp 2013-03-14 20:47:26 +0000 | |||
607 | @@ -80,9 +80,11 @@ | |||
608 | 80 | 80 | ||
609 | 81 | DeeListModel model_qt; | 81 | DeeListModel model_qt; |
610 | 82 | QCOMPARE(model_qt.count(), 0); | 82 | QCOMPARE(model_qt.count(), 0); |
611 | 83 | QSignalSpy modelReset(&model_qt, SIGNAL(modelReset())); | ||
612 | 83 | 84 | ||
613 | 84 | model_qt.setModel(model); | 85 | model_qt.setModel(model); |
614 | 85 | QCOMPARE(model_qt.synchronized(), (bool)dee_shared_model_is_synchronized(DEE_SHARED_MODEL(model))); | 86 | QCOMPARE(model_qt.synchronized(), (bool)dee_shared_model_is_synchronized(DEE_SHARED_MODEL(model))); |
615 | 87 | QCOMPARE(modelReset.count(), 1); | ||
616 | 86 | } | 88 | } |
617 | 87 | 89 | ||
618 | 88 | void setExistingModelTest() | 90 | void setExistingModelTest() |
619 | @@ -90,10 +92,12 @@ | |||
620 | 90 | DeeModel* model = dee_shared_model_new("com.deeqt.test.model"); | 92 | DeeModel* model = dee_shared_model_new("com.deeqt.test.model"); |
621 | 91 | 93 | ||
622 | 92 | DeeListModel model_qt; | 94 | DeeListModel model_qt; |
623 | 95 | QSignalSpy modelReset(&model_qt, SIGNAL(modelReset())); | ||
624 | 93 | QCOMPARE(model_qt.count(), 0); | 96 | QCOMPARE(model_qt.count(), 0); |
625 | 94 | 97 | ||
626 | 95 | model_qt.setModel(model); | 98 | model_qt.setModel(model); |
627 | 96 | QCOMPARE(model_qt.synchronized(), false); | 99 | QCOMPARE(model_qt.synchronized(), false); |
628 | 100 | QCOMPARE(modelReset.count(), 1); | ||
629 | 97 | 101 | ||
630 | 98 | while(!model_qt.synchronized()) | 102 | while(!model_qt.synchronized()) |
631 | 99 | qApp->processEvents(); | 103 | qApp->processEvents(); |
632 | @@ -102,12 +106,46 @@ | |||
633 | 102 | QCOMPARE(model_qt.roleNames().count(), 1); | 106 | QCOMPARE(model_qt.roleNames().count(), 1); |
634 | 103 | QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0")); | 107 | QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0")); |
635 | 104 | } | 108 | } |
637 | 105 | 109 | ||
638 | 110 | void insertRemoveTest() | ||
639 | 111 | { | ||
640 | 112 | /* TODO: "ReferenceError: column_0 is not defined" */ | ||
641 | 113 | DeeModel* model = dee_shared_model_new("com.deeqt.test.model"); | ||
642 | 114 | |||
643 | 115 | DeeListModel model_qt; | ||
644 | 116 | QSignalSpy modelReset(&model_qt, SIGNAL(modelReset())); | ||
645 | 117 | QSignalSpy layoutChanged(&model_qt, SIGNAL(layoutChanged())); | ||
646 | 118 | QSignalSpy rowsInserted(&model_qt, SIGNAL(rowsInserted(const QModelIndex&, int, int))); | ||
647 | 119 | QSignalSpy rowsRemoved(&model_qt, SIGNAL(rowsRemoved(const QModelIndex&, int, int))); | ||
648 | 120 | QCOMPARE(model_qt.count(), 0); | ||
649 | 121 | |||
650 | 122 | model_qt.setModel(model); | ||
651 | 123 | QCOMPARE(model_qt.synchronized(), false); | ||
652 | 124 | QCOMPARE(modelReset.count(), 1); | ||
653 | 125 | |||
654 | 126 | while(!model_qt.synchronized()) | ||
655 | 127 | qApp->processEvents(); | ||
656 | 128 | QCOMPARE(model_qt.synchronized(), true); | ||
657 | 129 | QCOMPARE(layoutChanged.count(), 1); | ||
658 | 130 | |||
659 | 131 | GVariant* b = g_variant_parse(NULL, "false", NULL, NULL, NULL); | ||
660 | 132 | Q_ASSERT(b); | ||
661 | 133 | DeeModelIter* iter = dee_model_insert (model, 0, &b); | ||
662 | 134 | g_variant_unref(b); | ||
663 | 135 | QCOMPARE(rowsInserted.count(), 1); | ||
664 | 136 | QCOMPARE(model_qt.rowCount(), 1); | ||
665 | 137 | QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0")); | ||
666 | 138 | |||
667 | 139 | dee_model_remove(model, iter); | ||
668 | 140 | QCOMPARE(rowsRemoved.count(), 1); | ||
669 | 141 | QCOMPARE(model_qt.rowCount(), 0); | ||
670 | 142 | QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0")); | ||
671 | 143 | } | ||
672 | 144 | |||
673 | 106 | void cleanupTestCase() | 145 | void cleanupTestCase() |
674 | 107 | { | 146 | { |
675 | 108 | tell_service_to_exit(); | 147 | tell_service_to_exit(); |
676 | 109 | } | 148 | } |
677 | 110 | |||
678 | 111 | }; | 149 | }; |
679 | 112 | 150 | ||
680 | 113 | QTEST_MAIN(DeeListModelTest) | 151 | QTEST_MAIN(DeeListModelTest) |
681 | 114 | 152 | ||
682 | === added file 'tests/deevarianttexttest.cpp' | |||
683 | --- tests/deevarianttexttest.cpp 1970-01-01 00:00:00 +0000 | |||
684 | +++ tests/deevarianttexttest.cpp 2013-03-14 20:47:26 +0000 | |||
685 | @@ -0,0 +1,58 @@ | |||
686 | 1 | /* | ||
687 | 2 | * Copyright (C) 2012 Canonical, Ltd. | ||
688 | 3 | * | ||
689 | 4 | * This program is free software; you can redistribute it and/or modify | ||
690 | 5 | * it under the terms of the GNU General Public License as published by | ||
691 | 6 | * the Free Software Foundation; version 3. | ||
692 | 7 | * | ||
693 | 8 | * This program is distributed in the hope that it will be useful, | ||
694 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
695 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
696 | 11 | * GNU General Public License for more details. | ||
697 | 12 | * | ||
698 | 13 | * You should have received a copy of the GNU General Public License | ||
699 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
700 | 15 | */ | ||
701 | 16 | |||
702 | 17 | #include <QtTest> | ||
703 | 18 | #include <QObject> | ||
704 | 19 | |||
705 | 20 | #include "deevarianttext.h" | ||
706 | 21 | |||
707 | 22 | #include <dee.h> | ||
708 | 23 | |||
709 | 24 | class DeeVariantTextTest : public QObject | ||
710 | 25 | { | ||
711 | 26 | Q_OBJECT | ||
712 | 27 | |||
713 | 28 | private Q_SLOTS: | ||
714 | 29 | void initTestCase() | ||
715 | 30 | { | ||
716 | 31 | g_type_init(); | ||
717 | 32 | } | ||
718 | 33 | |||
719 | 34 | void GVariantParseTest() | ||
720 | 35 | { | ||
721 | 36 | QHash<QString, QVariant> hash; | ||
722 | 37 | hash["[[1, 2, 3], [4, 5, 6]]"] = "aai"; | ||
723 | 38 | hash["[[1, 2, 3], [4, 5, 6.0]]"] = "aad"; | ||
724 | 39 | hash["[\"hello\", nothing]"] = "ams"; | ||
725 | 40 | hash["{1: \"one\", 2: \"two\", 3: \"three\"}"] = "a{is}"; | ||
726 | 41 | hash["[just 3, nothing]"] = "ami"; | ||
727 | 42 | // hash["{\"title\": <\"frobit\">, \"enabled\": <true>, width: <800>}"] = ""; | ||
728 | 43 | hash["@ms \"\""] = "ms"; | ||
729 | 44 | QHashIterator<QString, QVariant> i(hash); | ||
730 | 45 | while (i.hasNext()) { | ||
731 | 46 | i.next(); | ||
732 | 47 | QString input(i.key()); | ||
733 | 48 | DeeVariantText dvariant; | ||
734 | 49 | dvariant.setText(input); | ||
735 | 50 | QCOMPARE(dvariant.getText(), input); | ||
736 | 51 | QCOMPARE(dvariant.getType(), i.value()); | ||
737 | 52 | } | ||
738 | 53 | } | ||
739 | 54 | }; | ||
740 | 55 | |||
741 | 56 | QTEST_MAIN(DeeVariantTextTest) | ||
742 | 57 | |||
743 | 58 | #include "deevarianttexttest.moc" | ||
744 | 0 | 59 | ||
745 | === added file 'tests/qtquick1plugintest.cpp' | |||
746 | --- tests/qtquick1plugintest.cpp 1970-01-01 00:00:00 +0000 | |||
747 | +++ tests/qtquick1plugintest.cpp 2013-03-14 20:47:26 +0000 | |||
748 | @@ -0,0 +1,48 @@ | |||
749 | 1 | /* | ||
750 | 2 | * Copyright (C) 2012 Canonical, Ltd. | ||
751 | 3 | * | ||
752 | 4 | * This program is free software; you can redistribute it and/or modify | ||
753 | 5 | * it under the terms of the GNU General Public License as published by | ||
754 | 6 | * the Free Software Foundation; version 3. | ||
755 | 7 | * | ||
756 | 8 | * This program is distributed in the hope that it will be useful, | ||
757 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
758 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
759 | 11 | * GNU General Public License for more details. | ||
760 | 12 | * | ||
761 | 13 | * You should have received a copy of the GNU General Public License | ||
762 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
763 | 15 | */ | ||
764 | 16 | |||
765 | 17 | #include <QtTest> | ||
766 | 18 | #include <QObject> | ||
767 | 19 | #include <QtDeclarative> | ||
768 | 20 | |||
769 | 21 | class PluginTest : public QObject | ||
770 | 22 | { | ||
771 | 23 | Q_OBJECT | ||
772 | 24 | |||
773 | 25 | private Q_SLOTS: | ||
774 | 26 | void initTestCase() | ||
775 | 27 | { | ||
776 | 28 | } | ||
777 | 29 | |||
778 | 30 | void GVariantQMLTest() | ||
779 | 31 | { | ||
780 | 32 | // Dummy argc/v to avoid GCC confusing int with Display* on some systems | ||
781 | 33 | int argc = 0; | ||
782 | 34 | char *argv[0]; | ||
783 | 35 | QApplication app(argc, argv); | ||
784 | 36 | QDeclarativeView view; | ||
785 | 37 | view.setSource(QUrl::fromLocalFile("test_qtquick1.qml")); | ||
786 | 38 | Q_ASSERT(view.errors().empty()); | ||
787 | 39 | QObject *text2 = view.rootObject()->findChild<QObject*>("text2"); | ||
788 | 40 | Q_ASSERT(text2); | ||
789 | 41 | QVariant text2text(text2->metaObject()->property(text2->metaObject()->indexOfProperty("text")).read(text2)); | ||
790 | 42 | QCOMPARE(text2text.toString(), QString("4,1.1,0.1,0,0.3,3.6")); | ||
791 | 43 | } | ||
792 | 44 | }; | ||
793 | 45 | |||
794 | 46 | QTEST_MAIN(PluginTest) | ||
795 | 47 | |||
796 | 48 | #include "qtquick1plugintest.moc" | ||
797 | 0 | 49 | ||
798 | === modified file 'tests/test_qtquick1.qml' | |||
799 | --- tests/test_qtquick1.qml 2012-11-30 12:56:33 +0000 | |||
800 | +++ tests/test_qtquick1.qml 2013-03-14 20:47:26 +0000 | |||
801 | @@ -1,15 +1,40 @@ | |||
802 | 1 | import QtQuick 1.0 | 1 | import QtQuick 1.0 |
803 | 2 | import Dee 3.0 | 2 | import Dee 3.0 |
804 | 3 | 3 | ||
816 | 4 | ListView { | 4 | Item { |
817 | 5 | width: 200 | 5 | |
818 | 6 | height: 200 | 6 | ListView { |
819 | 7 | delegate: Text { | 7 | width: 200 |
820 | 8 | x: 66 | 8 | height: 200 |
821 | 9 | y: 93 | 9 | delegate: Text { |
822 | 10 | text: column_4 | 10 | x: 66 |
823 | 11 | } | 11 | y: 93 |
824 | 12 | model: DeeListModel { | 12 | text: column_4 |
825 | 13 | name: "com.canonical.Unity.Lens.applications.T1313498309.Results" | 13 | } |
826 | 14 | } | 14 | model: DeeListModel { |
827 | 15 | name: "com.canonical.Unity.Lens.applications.T1313498309.Results" | ||
828 | 16 | } | ||
829 | 17 | } | ||
830 | 18 | |||
831 | 19 | DeeVariantText { | ||
832 | 20 | id: arrayOfInt | ||
833 | 21 | text: "[[1, 2, 3], [4, 5, 6]]" | ||
834 | 22 | Component.onCompleted: { | ||
835 | 23 | arrayOfInt.text = "[[4, 1.1, .1], [0, 0.3, 3.6]]" | ||
836 | 24 | } | ||
837 | 25 | onTextChanged: { | ||
838 | 26 | text2.text = arrayOfInt.value.toString() | ||
839 | 27 | } | ||
840 | 28 | } | ||
841 | 29 | |||
842 | 30 | Text { | ||
843 | 31 | text: arrayOfInt.value.toString() | ||
844 | 32 | } | ||
845 | 33 | |||
846 | 34 | Text { | ||
847 | 35 | id: text2 | ||
848 | 36 | objectName: "text2" | ||
849 | 37 | } | ||
850 | 38 | |||
851 | 15 | } | 39 | } |
852 | 40 | |||
853 | 16 | 41 | ||
854 | === removed file 'tests/test_qtquick2.qml' | |||
855 | --- tests/test_qtquick2.qml 2012-11-30 12:56:33 +0000 | |||
856 | +++ tests/test_qtquick2.qml 1970-01-01 00:00:00 +0000 | |||
857 | @@ -1,15 +0,0 @@ | |||
858 | 1 | import QtQuick 2.0 | ||
859 | 2 | import Dee 3.0 | ||
860 | 3 | |||
861 | 4 | ListView { | ||
862 | 5 | width: 200 | ||
863 | 6 | height: 200 | ||
864 | 7 | delegate: Text { | ||
865 | 8 | x: 66 | ||
866 | 9 | y: 93 | ||
867 | 10 | text: column_4 | ||
868 | 11 | } | ||
869 | 12 | model: DeeListModel { | ||
870 | 13 | name: "com.canonical.Unity.Lens.applications.T1313498309.Results" | ||
871 | 14 | } | ||
872 | 15 | } | ||
873 | 16 | 0 | ||
874 | === added file 'tests/tst_deelistmodel.qml' | |||
875 | --- tests/tst_deelistmodel.qml 1970-01-01 00:00:00 +0000 | |||
876 | +++ tests/tst_deelistmodel.qml 2013-03-14 20:47:26 +0000 | |||
877 | @@ -0,0 +1,79 @@ | |||
878 | 1 | import QtQuick 2.0 | ||
879 | 2 | import QtTest 1.0 | ||
880 | 3 | import Dee 3.0 | ||
881 | 4 | |||
882 | 5 | TestCase { | ||
883 | 6 | name: "DeeListModel" | ||
884 | 7 | |||
885 | 8 | function test_1_initialModel () { | ||
886 | 9 | compare(myModel.count, 0) | ||
887 | 10 | compare(myView.count, 0) | ||
888 | 11 | } | ||
889 | 12 | |||
890 | 13 | function test_1_modelAssigned () { | ||
891 | 14 | myModel.name = "com.dee.qml.model.test1" | ||
892 | 15 | countChanged.wait() | ||
893 | 16 | compare(myModel.name, "com.dee.qml.model.test1") | ||
894 | 17 | compare(myModel.count, 0) | ||
895 | 18 | compare(myView.count, 0) | ||
896 | 19 | } | ||
897 | 20 | |||
898 | 21 | function test_2_modelAppend () { | ||
899 | 22 | myModel.name = "com.dee.qml.model.test2" | ||
900 | 23 | countChanged.wait() | ||
901 | 24 | compare(myModel.count, 0, "model empty") | ||
902 | 25 | myModel.append("[5.95,\"Pizza\"]") | ||
903 | 26 | countChanged.wait() | ||
904 | 27 | compare(myModel.count, 1, "model: one row more") | ||
905 | 28 | compare(myView.count, myModel.count, "model count matches listview") | ||
906 | 29 | } | ||
907 | 30 | |||
908 | 31 | function test_3_modelRemove () { | ||
909 | 32 | myModel.name = "com.dee.qml.model.test3" | ||
910 | 33 | countChanged.wait() | ||
911 | 34 | compare(myModel.count, 0, "model empty") | ||
912 | 35 | myModel.append("[0.99,\"Grean Tea, Sencha\"]") | ||
913 | 36 | myModel.append("[0.89,\"Black Tea, Oolong\"]") | ||
914 | 37 | countChanged.wait() | ||
915 | 38 | compare(myModel.count, 2, "two rows more") | ||
916 | 39 | compare(myView.count, myModel.count, "model count matches listview") | ||
917 | 40 | myModel.remove(0) | ||
918 | 41 | countChanged.wait() | ||
919 | 42 | compare(myModel.count, 1, "one row less") | ||
920 | 43 | } | ||
921 | 44 | |||
922 | 45 | function test_4_roleDefined () { | ||
923 | 46 | myModel.name = "com.dee.qml.model.test4" | ||
924 | 47 | countChanged.wait() | ||
925 | 48 | compare(myModel.count, 0, "model empty") | ||
926 | 49 | myModel.append("[5.95,\"Pizza\"]") | ||
927 | 50 | countChanged.wait() | ||
928 | 51 | compare(myModel.count, 1, "one row more") | ||
929 | 52 | } | ||
930 | 53 | |||
931 | 54 | SignalSpy { | ||
932 | 55 | id: countChanged | ||
933 | 56 | target: myModel | ||
934 | 57 | signalName: "countChanged" | ||
935 | 58 | } | ||
936 | 59 | |||
937 | 60 | ListView { | ||
938 | 61 | id: myView | ||
939 | 62 | |||
940 | 63 | width: 200 | ||
941 | 64 | height: 200 | ||
942 | 65 | delegate: Text { | ||
943 | 66 | id: myTextDelegate | ||
944 | 67 | x: 66 | ||
945 | 68 | y: 93 | ||
946 | 69 | text: "" // column_0 | ||
947 | 70 | } | ||
948 | 71 | |||
949 | 72 | model: DeeListModel { | ||
950 | 73 | id: myModel | ||
951 | 74 | name: "com.dee.qml.model.test0" | ||
952 | 75 | property string myColumnValue: "" | ||
953 | 76 | } | ||
954 | 77 | } | ||
955 | 78 | } | ||
956 | 79 | |||
957 | 0 | 80 | ||
958 | === added file 'tests/tst_deevarianttext.qml' | |||
959 | --- tests/tst_deevarianttext.qml 1970-01-01 00:00:00 +0000 | |||
960 | +++ tests/tst_deevarianttext.qml 2013-03-14 20:47:26 +0000 | |||
961 | @@ -0,0 +1,60 @@ | |||
962 | 1 | import QtQuick 2.0 | ||
963 | 2 | import QtTest 1.0 | ||
964 | 3 | import Dee 3.0 | ||
965 | 4 | |||
966 | 5 | TestCase { | ||
967 | 6 | name: "DeeVariantText" | ||
968 | 7 | |||
969 | 8 | function test_1_initialText () { | ||
970 | 9 | compare(arrayOfStr.value.toString(),"bar,foo") | ||
971 | 10 | } | ||
972 | 11 | |||
973 | 12 | function test_3_textAssigned () { | ||
974 | 13 | arrayOfInt.text = "[[4, 1.1, .1], [0, 0.3, 3.6]]" | ||
975 | 14 | compare(arrayOfInt.value.toString(),"4,1.1,0.1,0,0.3,3.6") | ||
976 | 15 | } | ||
977 | 16 | |||
978 | 17 | function test_4_textChanged () { | ||
979 | 18 | arrayOfInt.didChange = false | ||
980 | 19 | arrayOfInt.text = "@ams [nothing]" | ||
981 | 20 | compare(arrayOfInt.didChange,true) | ||
982 | 21 | } | ||
983 | 22 | |||
984 | 23 | function test_5_textNotChanged () { | ||
985 | 24 | arrayOfInt.text = "@ams [nothing]" | ||
986 | 25 | arrayOfInt.didChange = false | ||
987 | 26 | arrayOfInt.text = "@ams [nothing]" | ||
988 | 27 | compare(arrayOfInt.didChange,false) | ||
989 | 28 | } | ||
990 | 29 | |||
991 | 30 | function test_6_invalid () { | ||
992 | 31 | arrayOfInt.text = "[nothing]" | ||
993 | 32 | compare(arrayOfInt.value,undefined) | ||
994 | 33 | } | ||
995 | 34 | |||
996 | 35 | function test_7_unicode () { | ||
997 | 36 | arrayOfStr.text = "[\"١٢٣٤٥٦٧٨٩٠\", \"道具箱\", \"Котята\"]" | ||
998 | 37 | compare(arrayOfStr.value.toString(),"١٢٣٤٥٦٧٨٩٠,道具箱,Котята") | ||
999 | 38 | } | ||
1000 | 39 | |||
1001 | 40 | function test_8_gvariant () { | ||
1002 | 41 | arrayOfStr.text = "[<\"test\">, <\"test2\">]" | ||
1003 | 42 | compare(arrayOfStr.value.toString(), "test,test2") | ||
1004 | 43 | } | ||
1005 | 44 | |||
1006 | 45 | DeeVariantText { | ||
1007 | 46 | id: arrayOfStr | ||
1008 | 47 | text: "[\"bar\", \"foo\"]" | ||
1009 | 48 | } | ||
1010 | 49 | |||
1011 | 50 | DeeVariantText { | ||
1012 | 51 | id: arrayOfInt | ||
1013 | 52 | text: "[[1, 2, 3], [4, 5, 6]]" | ||
1014 | 53 | property bool didChange: false | ||
1015 | 54 | onTextChanged: { | ||
1016 | 55 | didChange = true | ||
1017 | 56 | } | ||
1018 | 57 | } | ||
1019 | 58 | |||
1020 | 59 | } | ||
1021 | 60 |
Your changes to DeeListModel broke it for our use (rolesChanged isn't fired anymore).