Merge lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-extended into lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-staging
- stopwatch-feature-extended
- Merge into stopwatch-feature-staging
Status: | Merged |
---|---|
Approved by: | Nekhelesh Ramananthan |
Approved revision: | 382 |
Merged at revision: | 379 |
Proposed branch: | lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-extended |
Merge into: | lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-staging |
Diff against target: |
460 lines (+284/-16) 11 files modified
app/MainPage.qml (+15/-0) app/stopwatch/LapListView.qml (+1/-1) app/stopwatch/StopwatchPage.qml (+8/-14) backend/CMakeLists.txt (+25/-0) backend/modules/Stopwatch/LapHistory/backend.cpp (+34/-0) backend/modules/Stopwatch/LapHistory/backend.h (+35/-0) backend/modules/Stopwatch/LapHistory/history.cpp (+97/-0) backend/modules/Stopwatch/LapHistory/history.h (+64/-0) backend/modules/Stopwatch/LapHistory/qmldir (+2/-0) debian/changelog (+1/-0) debian/control (+2/-1) |
To merge this branch: | bzr merge lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-extended |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nekhelesh Ramananthan | Approve | ||
Bartosz Kosiorek | Approve | ||
Review via email: mp+268171@code.launchpad.net |
Commit message
Added stopwatch feature to keep working in the background even if clock app is closed / phone is switched off.
Description of the change
Added stopwatch feature to keep working in the background even if clock app is closed / phone is switched off.
Nekhelesh Ramananthan (nik90) wrote : | # |
Nekhelesh Ramananthan (nik90) wrote : | # |
I tested the swipe delete feature and it works correctly. I tested on phone and desktop, with multiple clock app restarts to check the stopwatch running background feature and no errors. everything works as expected.
Bartosz Kosiorek (gang65) wrote : | # |
It is working correctly for me
Nekhelesh Ramananthan (nik90) wrote : | # |
* Does the MP add/remove user visible strings? If Yes, has the pot file been
updated?
No strings changed.
* Does the MP change the UI? If Yes, has it been approved by design?
Minor UX change that was approved.
* Did you perform an exploratory manual test run of your code change and any
related functionality?
Extensive testing done on desktop and phone
* If the MP fixes a bug or implements a feature, are there accompanying unit
and autopilot tests?
Not required
* Is the clock app trunk buildable and runnable using Qtcreator?
Yes
* Was the debian changelog updated?
No!
* Was the copyright years updated if necessary?
Yes
Nekhelesh Ramananthan (nik90) wrote : | # |
Please update debian changelog since you are fixing a bug/feature request. thnx
- 382. By Bartosz Kosiorek
-
Keep running stopwatch even when the clock or phone is turned off (LP: #1484942)
Preview Diff
1 | === modified file 'app/MainPage.qml' | |||
2 | --- app/MainPage.qml 2015-08-20 15:32:48 +0000 | |||
3 | +++ app/MainPage.qml 2015-08-20 20:37:24 +0000 | |||
4 | @@ -19,6 +19,7 @@ | |||
5 | 19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
6 | 20 | import Ubuntu.Components 1.2 | 20 | import Ubuntu.Components 1.2 |
7 | 21 | import QtSystemInfo 5.0 | 21 | import QtSystemInfo 5.0 |
8 | 22 | import Qt.labs.settings 1.0 | ||
9 | 22 | import "upstreamcomponents" | 23 | import "upstreamcomponents" |
10 | 23 | import "alarm" | 24 | import "alarm" |
11 | 24 | import "clock" | 25 | import "clock" |
12 | @@ -59,6 +60,14 @@ | |||
13 | 59 | screenSaverEnabled: !stopwatchPage.running | 60 | screenSaverEnabled: !stopwatchPage.running |
14 | 60 | } | 61 | } |
15 | 61 | 62 | ||
16 | 63 | Settings { | ||
17 | 64 | id: stopwatchState | ||
18 | 65 | category: "Stopwatch" | ||
19 | 66 | property alias startTime: stopwatchPage.startTime | ||
20 | 67 | property alias running: stopwatchPage.running | ||
21 | 68 | property alias oldDiff: stopwatchPage.oldDiff | ||
22 | 69 | } | ||
23 | 70 | |||
24 | 62 | VisualItemModel { | 71 | VisualItemModel { |
25 | 63 | id: navigationModel | 72 | id: navigationModel |
26 | 64 | ClockPage { | 73 | ClockPage { |
27 | @@ -89,6 +98,12 @@ | |||
28 | 89 | ListView { | 98 | ListView { |
29 | 90 | id: listview | 99 | id: listview |
30 | 91 | 100 | ||
31 | 101 | // Show the stopwatch page on app startup if it is running | ||
32 | 102 | Component.onCompleted: { | ||
33 | 103 | if (stopwatchState.running) | ||
34 | 104 | positionViewAtIndex(1, ListView.SnapPosition) | ||
35 | 105 | } | ||
36 | 106 | |||
37 | 92 | anchors { | 107 | anchors { |
38 | 93 | top: headerRow.bottom | 108 | top: headerRow.bottom |
39 | 94 | left: parent.left | 109 | left: parent.left |
40 | 95 | 110 | ||
41 | === modified file 'app/stopwatch/LapListView.qml' | |||
42 | --- app/stopwatch/LapListView.qml 2015-08-20 15:52:32 +0000 | |||
43 | +++ app/stopwatch/LapListView.qml 2015-08-20 20:37:24 +0000 | |||
44 | @@ -81,7 +81,7 @@ | |||
45 | 81 | Action { | 81 | Action { |
46 | 82 | iconName: "delete" | 82 | iconName: "delete" |
47 | 83 | onTriggered: { | 83 | onTriggered: { |
49 | 84 | lapsModel.remove(index, 1) | 84 | lapHistory.removeLap(index) |
50 | 85 | } | 85 | } |
51 | 86 | } | 86 | } |
52 | 87 | ] | 87 | ] |
53 | 88 | 88 | ||
54 | === modified file 'app/stopwatch/StopwatchPage.qml' | |||
55 | --- app/stopwatch/StopwatchPage.qml 2015-08-17 12:14:10 +0000 | |||
56 | +++ app/stopwatch/StopwatchPage.qml 2015-08-20 20:37:24 +0000 | |||
57 | @@ -18,6 +18,7 @@ | |||
58 | 18 | 18 | ||
59 | 19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
60 | 20 | import Ubuntu.Components 1.2 | 20 | import Ubuntu.Components 1.2 |
61 | 21 | import Stopwatch.LapHistory 1.0 | ||
62 | 21 | 22 | ||
63 | 22 | Item { | 23 | Item { |
64 | 23 | id: _stopwatchPage | 24 | id: _stopwatchPage |
65 | @@ -57,18 +58,7 @@ | |||
66 | 57 | oldDiff = 0 | 58 | oldDiff = 0 |
67 | 58 | startTime = new Date() | 59 | startTime = new Date() |
68 | 59 | snapshot = startTime | 60 | snapshot = startTime |
81 | 60 | lapsModel.clear() | 61 | lapHistory.clear() |
70 | 61 | } | ||
71 | 62 | |||
72 | 63 | ListModel { | ||
73 | 64 | id: lapsModel | ||
74 | 65 | function addLap(totalTime) { | ||
75 | 66 | if (lapsModel.count === 0) { | ||
76 | 67 | append({"laptime": totalTime, "totaltime": totalTime}) | ||
77 | 68 | } else { | ||
78 | 69 | insert(0, {"laptime": totalTime - lapsModel.get(0).totaltime, "totaltime": totalTime}) | ||
79 | 70 | } | ||
80 | 71 | } | ||
82 | 72 | } | 62 | } |
83 | 73 | 63 | ||
84 | 74 | Timer { | 64 | Timer { |
85 | @@ -134,7 +124,7 @@ | |||
86 | 134 | onClicked: { | 124 | onClicked: { |
87 | 135 | if (_stopwatchPage.running) { | 125 | if (_stopwatchPage.running) { |
88 | 136 | _stopwatchPage.update() | 126 | _stopwatchPage.update() |
90 | 137 | lapsModel.addLap(_stopwatchPage.totalTimeDiff) | 127 | lapHistory.addLap(_stopwatchPage.totalTimeDiff) |
91 | 138 | } else { | 128 | } else { |
92 | 139 | _stopwatchPage.clear() | 129 | _stopwatchPage.clear() |
93 | 140 | } | 130 | } |
94 | @@ -165,11 +155,15 @@ | |||
95 | 165 | } | 155 | } |
96 | 166 | } | 156 | } |
97 | 167 | 157 | ||
98 | 158 | LapHistory { | ||
99 | 159 | id: lapHistory | ||
100 | 160 | } | ||
101 | 161 | |||
102 | 168 | Component { | 162 | Component { |
103 | 169 | id: lapListViewComponent | 163 | id: lapListViewComponent |
104 | 170 | LapListView { | 164 | LapListView { |
105 | 171 | id: lapListView | 165 | id: lapListView |
107 | 172 | model: lapsModel | 166 | model: lapHistory |
108 | 173 | } | 167 | } |
109 | 174 | } | 168 | } |
110 | 175 | } | 169 | } |
111 | 176 | 170 | ||
112 | === modified file 'backend/CMakeLists.txt' | |||
113 | --- backend/CMakeLists.txt 2015-07-16 21:02:18 +0000 | |||
114 | +++ backend/CMakeLists.txt 2015-08-20 20:37:24 +0000 | |||
115 | @@ -34,6 +34,12 @@ | |||
116 | 34 | modules/GeoLocation/geolocation.cpp | 34 | modules/GeoLocation/geolocation.cpp |
117 | 35 | ) | 35 | ) |
118 | 36 | 36 | ||
119 | 37 | set( | ||
120 | 38 | stopwatchlaphistory_SRCS | ||
121 | 39 | modules/Stopwatch/LapHistory/backend.cpp | ||
122 | 40 | modules/Stopwatch/LapHistory/history.cpp | ||
123 | 41 | ) | ||
124 | 42 | |||
125 | 37 | add_library(timezone MODULE | 43 | add_library(timezone MODULE |
126 | 38 | ${timezone_SRCS} | 44 | ${timezone_SRCS} |
127 | 39 | ) | 45 | ) |
128 | @@ -50,6 +56,11 @@ | |||
129 | 50 | ${geolocation_SRCS} | 56 | ${geolocation_SRCS} |
130 | 51 | ) | 57 | ) |
131 | 52 | 58 | ||
132 | 59 | add_library(stopwatchlaphistory MODULE | ||
133 | 60 | ${stopwatchlaphistory_SRCS} | ||
134 | 61 | ) | ||
135 | 62 | |||
136 | 63 | |||
137 | 53 | set_target_properties(timezone PROPERTIES | 64 | set_target_properties(timezone PROPERTIES |
138 | 54 | LIBRARY_OUTPUT_DIRECTORY Timezone | 65 | LIBRARY_OUTPUT_DIRECTORY Timezone |
139 | 55 | ) | 66 | ) |
140 | @@ -66,10 +77,15 @@ | |||
141 | 66 | LIBRARY_OUTPUT_DIRECTORY GeoLocation | 77 | LIBRARY_OUTPUT_DIRECTORY GeoLocation |
142 | 67 | ) | 78 | ) |
143 | 68 | 79 | ||
144 | 80 | set_target_properties(stopwatchlaphistory PROPERTIES | ||
145 | 81 | LIBRARY_OUTPUT_DIRECTORY Stopwatch/LapHistory | ||
146 | 82 | ) | ||
147 | 83 | |||
148 | 69 | qt5_use_modules(datetime Gui Qml Quick) | 84 | qt5_use_modules(datetime Gui Qml Quick) |
149 | 70 | qt5_use_modules(timezone Gui Qml Quick) | 85 | qt5_use_modules(timezone Gui Qml Quick) |
150 | 71 | qt5_use_modules(alarmsettings Gui Qml Quick DBus) | 86 | qt5_use_modules(alarmsettings Gui Qml Quick DBus) |
151 | 72 | qt5_use_modules(geolocation Gui Qml Quick) | 87 | qt5_use_modules(geolocation Gui Qml Quick) |
152 | 88 | qt5_use_modules(stopwatchlaphistory Qml) | ||
153 | 73 | 89 | ||
154 | 74 | # Copy qmldir file to build dir for running in QtCreator | 90 | # Copy qmldir file to build dir for running in QtCreator |
155 | 75 | add_custom_target(timezone-qmldir ALL | 91 | add_custom_target(timezone-qmldir ALL |
156 | @@ -92,6 +108,12 @@ | |||
157 | 92 | DEPENDS ${QMLFILES} | 108 | DEPENDS ${QMLFILES} |
158 | 93 | ) | 109 | ) |
159 | 94 | 110 | ||
160 | 111 | add_custom_target(stopwatchlaphistory-qmldir ALL | ||
161 | 112 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/modules/Stopwatch/LapHistory/qmldir ${CMAKE_CURRENT_BINARY_DIR}/Stopwatch/LapHistory | ||
162 | 113 | DEPENDS ${QMLFILES} | ||
163 | 114 | ) | ||
164 | 115 | |||
165 | 116 | |||
166 | 95 | # Install plugin file | 117 | # Install plugin file |
167 | 96 | install(TARGETS timezone DESTINATION ${MODULE_PATH}/Timezone/) | 118 | install(TARGETS timezone DESTINATION ${MODULE_PATH}/Timezone/) |
168 | 97 | install(FILES modules/Timezone/qmldir DESTINATION ${MODULE_PATH}/Timezone/) | 119 | install(FILES modules/Timezone/qmldir DESTINATION ${MODULE_PATH}/Timezone/) |
169 | @@ -104,3 +126,6 @@ | |||
170 | 104 | 126 | ||
171 | 105 | install(TARGETS geolocation DESTINATION ${MODULE_PATH}/GeoLocation/) | 127 | install(TARGETS geolocation DESTINATION ${MODULE_PATH}/GeoLocation/) |
172 | 106 | install(FILES modules/GeoLocation/qmldir DESTINATION ${MODULE_PATH}/GeoLocation/) | 128 | install(FILES modules/GeoLocation/qmldir DESTINATION ${MODULE_PATH}/GeoLocation/) |
173 | 129 | |||
174 | 130 | install(TARGETS stopwatchlaphistory DESTINATION ${MODULE_PATH}/Stopwatch/LapHistory/) | ||
175 | 131 | install(FILES modules/Stopwatch/LapHistory/qmldir DESTINATION ${MODULE_PATH}/Stopwatch/LapHistory/) | ||
176 | 107 | 132 | ||
177 | === added directory 'backend/modules/Stopwatch' | |||
178 | === added directory 'backend/modules/Stopwatch/LapHistory' | |||
179 | === added file 'backend/modules/Stopwatch/LapHistory/backend.cpp' | |||
180 | --- backend/modules/Stopwatch/LapHistory/backend.cpp 1970-01-01 00:00:00 +0000 | |||
181 | +++ backend/modules/Stopwatch/LapHistory/backend.cpp 2015-08-20 20:37:24 +0000 | |||
182 | @@ -0,0 +1,34 @@ | |||
183 | 1 | /* | ||
184 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
185 | 3 | * | ||
186 | 4 | * This file is part of Ubuntu Clock App | ||
187 | 5 | * | ||
188 | 6 | * Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
189 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
190 | 8 | * published by the Free Software Foundation. | ||
191 | 9 | * | ||
192 | 10 | * Ubuntu Clock App is distributed in the hope that it will be useful, | ||
193 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
194 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
195 | 13 | * GNU General Public License for more details. | ||
196 | 14 | * | ||
197 | 15 | * You should have received a copy of the GNU General Public License | ||
198 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
199 | 17 | */ | ||
200 | 18 | |||
201 | 19 | #include <QtQml> | ||
202 | 20 | #include <QtQml/QQmlContext> | ||
203 | 21 | #include "backend.h" | ||
204 | 22 | #include "history.h" | ||
205 | 23 | |||
206 | 24 | void BackendPlugin::registerTypes(const char *uri) | ||
207 | 25 | { | ||
208 | 26 | Q_ASSERT(uri == QLatin1String("Stopwatch.LapHistory")); | ||
209 | 27 | |||
210 | 28 | qmlRegisterType<LapHistory>(uri, 1, 0, "LapHistory"); | ||
211 | 29 | } | ||
212 | 30 | |||
213 | 31 | void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | ||
214 | 32 | { | ||
215 | 33 | QQmlExtensionPlugin::initializeEngine(engine, uri); | ||
216 | 34 | } | ||
217 | 0 | 35 | ||
218 | === added file 'backend/modules/Stopwatch/LapHistory/backend.h' | |||
219 | --- backend/modules/Stopwatch/LapHistory/backend.h 1970-01-01 00:00:00 +0000 | |||
220 | +++ backend/modules/Stopwatch/LapHistory/backend.h 2015-08-20 20:37:24 +0000 | |||
221 | @@ -0,0 +1,35 @@ | |||
222 | 1 | /* | ||
223 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
224 | 3 | * | ||
225 | 4 | * This file is part of Ubuntu Clock App | ||
226 | 5 | * | ||
227 | 6 | * Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
228 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
229 | 8 | * published by the Free Software Foundation. | ||
230 | 9 | * | ||
231 | 10 | * Ubuntu Clock App is distributed in the hope that it will be useful, | ||
232 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
233 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
234 | 13 | * GNU General Public License for more details. | ||
235 | 14 | * | ||
236 | 15 | * You should have received a copy of the GNU General Public License | ||
237 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
238 | 17 | */ | ||
239 | 18 | |||
240 | 19 | #ifndef BACKEND_PLUGIN_H | ||
241 | 20 | #define BACKEND_PLUGIN_H | ||
242 | 21 | |||
243 | 22 | #include <QtQml/QQmlEngine> | ||
244 | 23 | #include <QtQml/QQmlExtensionPlugin> | ||
245 | 24 | |||
246 | 25 | class BackendPlugin : public QQmlExtensionPlugin | ||
247 | 26 | { | ||
248 | 27 | Q_OBJECT | ||
249 | 28 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
250 | 29 | |||
251 | 30 | public: | ||
252 | 31 | void registerTypes(const char *uri); | ||
253 | 32 | void initializeEngine(QQmlEngine *engine, const char *uri); | ||
254 | 33 | }; | ||
255 | 34 | #endif // BACKEND_PLUGIN_H | ||
256 | 35 | |||
257 | 0 | 36 | ||
258 | === added file 'backend/modules/Stopwatch/LapHistory/history.cpp' | |||
259 | --- backend/modules/Stopwatch/LapHistory/history.cpp 1970-01-01 00:00:00 +0000 | |||
260 | +++ backend/modules/Stopwatch/LapHistory/history.cpp 2015-08-20 20:37:24 +0000 | |||
261 | @@ -0,0 +1,97 @@ | |||
262 | 1 | /* | ||
263 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
264 | 3 | * | ||
265 | 4 | * This file is part of Ubuntu Clock App | ||
266 | 5 | * | ||
267 | 6 | * Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
268 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
269 | 8 | * published by the Free Software Foundation. | ||
270 | 9 | * | ||
271 | 10 | * Ubuntu Clock App is distributed in the hope that it will be useful, | ||
272 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
273 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
274 | 13 | * GNU General Public License for more details. | ||
275 | 14 | * | ||
276 | 15 | * You should have received a copy of the GNU General Public License | ||
277 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
278 | 17 | */ | ||
279 | 18 | |||
280 | 19 | #include "history.h" | ||
281 | 20 | |||
282 | 21 | #include <QStandardPaths> | ||
283 | 22 | #include <QDebug> | ||
284 | 23 | |||
285 | 24 | LapHistory::LapHistory(QObject *parent) : | ||
286 | 25 | QAbstractListModel(parent), | ||
287 | 26 | /* | ||
288 | 27 | #FIXME: Change QStandardPaths::ConfigLocation to QStandardPaths::AppConfigLocation | ||
289 | 28 | when Ubuntu Touch moves over to Qt 5.5. AppConfigLocation will directly return | ||
290 | 29 | /home/phablet/.config/com.ubuntu.clock path. | ||
291 | 30 | */ | ||
292 | 31 | m_settings(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first() + "/com.ubuntu.clock/com.ubuntu.clock.conf", QSettings::IniFormat) | ||
293 | 32 | { | ||
294 | 33 | qDebug() << "[LOG] Loading laps from " << m_settings.fileName(); | ||
295 | 34 | } | ||
296 | 35 | |||
297 | 36 | int LapHistory::rowCount(const QModelIndex &parent) const | ||
298 | 37 | { | ||
299 | 38 | /* | ||
300 | 39 | QT's models also handle tables and tree views, so the index is not just a | ||
301 | 40 | integer but consists of a parent, row and a column. Since we using a simple | ||
302 | 41 | list model, let's ignore the parent. Q_UNUSED(parent) gets rid of the | ||
303 | 42 | compiler warning about the unused variable. | ||
304 | 43 | */ | ||
305 | 44 | Q_UNUSED(parent) | ||
306 | 45 | |||
307 | 46 | return m_settings.value("Stopwatch/laps").toList().count(); | ||
308 | 47 | } | ||
309 | 48 | |||
310 | 49 | QVariant LapHistory::data(const QModelIndex &index, int role) const | ||
311 | 50 | { | ||
312 | 51 | switch (role) { | ||
313 | 52 | case RoleTotalTime: | ||
314 | 53 | return m_settings.value("Stopwatch/laps").toList().at(index.row()); | ||
315 | 54 | case RoleDiffToPrevious: { | ||
316 | 55 | int previous = 0; | ||
317 | 56 | if(index.row() != m_settings.value("Stopwatch/laps").toList().count() - 1) | ||
318 | 57 | { | ||
319 | 58 | previous = data(this->index(index.row() + 1), RoleTotalTime).toInt(); | ||
320 | 59 | } | ||
321 | 60 | return m_settings.value("Stopwatch/laps").toList().at(index.row()).toInt() - previous; | ||
322 | 61 | } | ||
323 | 62 | } | ||
324 | 63 | return QVariant(); | ||
325 | 64 | } | ||
326 | 65 | |||
327 | 66 | QHash<int, QByteArray> LapHistory::roleNames() const | ||
328 | 67 | { | ||
329 | 68 | QHash< int, QByteArray> roles; | ||
330 | 69 | roles.insert(RoleTotalTime, "totaltime"); | ||
331 | 70 | roles.insert(RoleDiffToPrevious, "laptime"); | ||
332 | 71 | return roles; | ||
333 | 72 | } | ||
334 | 73 | |||
335 | 74 | void LapHistory::addLap(int timeDiff) | ||
336 | 75 | { | ||
337 | 76 | QVariantList laps = m_settings.value("Stopwatch/laps").toList(); | ||
338 | 77 | beginInsertRows(QModelIndex(), 0, 0); | ||
339 | 78 | laps.prepend(timeDiff); | ||
340 | 79 | m_settings.setValue("Stopwatch/laps", laps); | ||
341 | 80 | endInsertRows(); | ||
342 | 81 | } | ||
343 | 82 | |||
344 | 83 | void LapHistory::removeLap(int lapIndex) | ||
345 | 84 | { | ||
346 | 85 | QVariantList laps = m_settings.value("Stopwatch/laps").toList(); | ||
347 | 86 | beginRemoveRows(QModelIndex(), lapIndex, lapIndex); | ||
348 | 87 | laps.removeAt(lapIndex); | ||
349 | 88 | m_settings.setValue("Stopwatch/laps", laps); | ||
350 | 89 | endRemoveRows(); | ||
351 | 90 | } | ||
352 | 91 | |||
353 | 92 | void LapHistory::clear() | ||
354 | 93 | { | ||
355 | 94 | beginResetModel(); | ||
356 | 95 | m_settings.setValue("Stopwatch/laps", QVariantList()); | ||
357 | 96 | endResetModel(); | ||
358 | 97 | } | ||
359 | 0 | 98 | ||
360 | === added file 'backend/modules/Stopwatch/LapHistory/history.h' | |||
361 | --- backend/modules/Stopwatch/LapHistory/history.h 1970-01-01 00:00:00 +0000 | |||
362 | +++ backend/modules/Stopwatch/LapHistory/history.h 2015-08-20 20:37:24 +0000 | |||
363 | @@ -0,0 +1,64 @@ | |||
364 | 1 | /* | ||
365 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
366 | 3 | * | ||
367 | 4 | * This file is part of Ubuntu Clock App | ||
368 | 5 | * | ||
369 | 6 | * Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
370 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
371 | 8 | * published by the Free Software Foundation. | ||
372 | 9 | * | ||
373 | 10 | * Ubuntu Clock App is distributed in the hope that it will be useful, | ||
374 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
375 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
376 | 13 | * GNU General Public License for more details. | ||
377 | 14 | * | ||
378 | 15 | * You should have received a copy of the GNU General Public License | ||
379 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
380 | 17 | */ | ||
381 | 18 | |||
382 | 19 | #ifndef HISTORY_H | ||
383 | 20 | #define HISTORY_H | ||
384 | 21 | |||
385 | 22 | #include <QAbstractListModel> | ||
386 | 23 | #include <QSettings> | ||
387 | 24 | |||
388 | 25 | class LapHistory : public QAbstractListModel | ||
389 | 26 | { | ||
390 | 27 | Q_OBJECT | ||
391 | 28 | |||
392 | 29 | public: | ||
393 | 30 | enum Role { | ||
394 | 31 | RoleTotalTime, | ||
395 | 32 | RoleDiffToPrevious | ||
396 | 33 | }; | ||
397 | 34 | |||
398 | 35 | explicit LapHistory(QObject *parent = 0); | ||
399 | 36 | |||
400 | 37 | /* | ||
401 | 38 | Let's override the pure virtual functions (the ones marked as | ||
402 | 39 | "virtual" and have "= 0" in the end. | ||
403 | 40 | */ | ||
404 | 41 | int rowCount(const QModelIndex &parent) const; | ||
405 | 42 | QVariant data(const QModelIndex &index, int role) const; | ||
406 | 43 | |||
407 | 44 | /* | ||
408 | 45 | As QML can't really deal with the Roles enum above, we need a mapping | ||
409 | 46 | between the enum and strings | ||
410 | 47 | */ | ||
411 | 48 | QHash<int, QByteArray> roleNames() const override; | ||
412 | 49 | |||
413 | 50 | public slots: | ||
414 | 51 | // Function to add a stopwatch lap | ||
415 | 52 | void addLap(int timeDiff); | ||
416 | 53 | |||
417 | 54 | // Function to remove a stopwatch lap | ||
418 | 55 | void removeLap(int lapIndex); | ||
419 | 56 | |||
420 | 57 | // Function to clear all stopwatch laps | ||
421 | 58 | void clear(); | ||
422 | 59 | |||
423 | 60 | private: | ||
424 | 61 | QSettings m_settings; | ||
425 | 62 | }; | ||
426 | 63 | |||
427 | 64 | #endif // HISTORY_H | ||
428 | 0 | 65 | ||
429 | === added file 'backend/modules/Stopwatch/LapHistory/qmldir' | |||
430 | --- backend/modules/Stopwatch/LapHistory/qmldir 1970-01-01 00:00:00 +0000 | |||
431 | +++ backend/modules/Stopwatch/LapHistory/qmldir 2015-08-20 20:37:24 +0000 | |||
432 | @@ -0,0 +1,2 @@ | |||
433 | 1 | module Stopwatch.LapHistory | ||
434 | 2 | plugin stopwatchlaphistory | ||
435 | 0 | 3 | ||
436 | === modified file 'debian/changelog' | |||
437 | --- debian/changelog 2015-08-17 12:27:20 +0000 | |||
438 | +++ debian/changelog 2015-08-20 20:37:24 +0000 | |||
439 | @@ -7,6 +7,7 @@ | |||
440 | 7 | * Fix default alarm time issue (LP: #1484926) | 7 | * Fix default alarm time issue (LP: #1484926) |
441 | 8 | * Translate city and country names after language switch (LP: #1477492) | 8 | * Translate city and country names after language switch (LP: #1477492) |
442 | 9 | * Fix issue when unable to add city/country with apostrophes (LP: #1473074) | 9 | * Fix issue when unable to add city/country with apostrophes (LP: #1473074) |
443 | 10 | * Keep running stopwatch even when the clock or phone is turned off (LP: #1484942) | ||
444 | 10 | 11 | ||
445 | 11 | [Nekhelesh Ramananthan] | 12 | [Nekhelesh Ramananthan] |
446 | 12 | * Increase the height of times in the alarm screen (LP: #1365428) | 13 | * Increase the height of times in the alarm screen (LP: #1365428) |
447 | 13 | 14 | ||
448 | === modified file 'debian/control' | |||
449 | --- debian/control 2015-08-13 18:44:07 +0000 | |||
450 | +++ debian/control 2015-08-20 20:37:24 +0000 | |||
451 | @@ -10,7 +10,8 @@ | |||
452 | 10 | ubuntu-touch-sounds, | 10 | ubuntu-touch-sounds, |
453 | 11 | suru-icon-theme | ubuntu-mobile-icons, | 11 | suru-icon-theme | ubuntu-mobile-icons, |
454 | 12 | qml-module-qttest, | 12 | qml-module-qttest, |
456 | 13 | qml-module-qtsysteminfo, | 13 | qml-module-qtsysteminfo, |
457 | 14 | qml-module-qt-labs-settings, | ||
458 | 14 | qtdeclarative5-u1db1.0, | 15 | qtdeclarative5-u1db1.0, |
459 | 15 | qtdeclarative5-qtmultimedia-plugin, | 16 | qtdeclarative5-qtmultimedia-plugin, |
460 | 16 | qtdeclarative5-qtpositioning-plugin, | 17 | qtdeclarative5-qtpositioning-plugin, |
@bartosz I made the following changes to your MP,
1. Renamed plugin to Stopwatch. LapHistory. (Much before our discussion yesterday. We can get back to this in a MP during the weekend) For now let's leave it as such
2. Added comments, fixme to the plugin for better understandability.
3. Stopwatch laps are stored in com.ubuntu. clock.conf file itself in the [Stopwatch] category.
4. Removed the int count() function since we don't need it anymore in the QML side.
Personally I think this branch is ready and so I am approving. Feel free to go through it once more on your own, test it and then top-approve it. Then we merge it into the stopwatch-staging branch and the merge that branch to trunk tonight.