Merge lp:~vthompson/ubuntu-weather-app/reboot-allow-adding-duplicate-current-location into lp:ubuntu-weather-app/obsolete.trunk
- reboot-allow-adding-duplicate-current-location
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~vthompson/ubuntu-weather-app/reboot-allow-adding-duplicate-current-location |
Merge into: | lp:ubuntu-weather-app/obsolete.trunk |
Diff against target: |
8157 lines (+7760/-0) (has conflicts) 70 files modified
.bzrignore (+19/-0) CMakeLists.txt (+101/-0) COPYING (+674/-0) README (+11/-0) README.translations (+37/-0) app/CMakeLists.txt (+18/-0) app/components/CMakeLists.txt (+7/-0) app/components/CurrentLocation.qml (+84/-0) app/components/DayDelegate.qml (+245/-0) app/components/ExpandableListItem.qml (+90/-0) app/components/FastScroll.js (+130/-0) app/components/FastScroll.qml (+321/-0) app/components/ForecastDetailsDelegate.qml (+48/-0) app/components/HeaderRow.qml (+62/-0) app/components/HomeGraphic.qml (+39/-0) app/components/HomeHourly.qml (+101/-0) app/components/HomeTempInfo.qml (+73/-0) app/components/ListItemActions/CMakeLists.txt (+5/-0) app/components/ListItemActions/CheckBox.qml (+25/-0) app/components/ListItemActions/Remove.qml (+27/-0) app/components/ListItemReorderComponent.qml (+106/-0) app/components/ListItemWithActions.qml (+496/-0) app/components/LoadingIndicator.qml (+87/-0) app/components/MultiSelectHeadState.qml (+72/-0) app/components/MultiSelectListView.qml (+52/-0) app/components/PageWithBottomEdge.qml (+411/-0) app/components/StandardListItem.qml (+48/-0) app/components/WeatherListItem.qml (+137/-0) app/components/WeatherListView.qml (+32/-0) app/data/CMakeLists.txt (+5/-0) app/data/CitiesList.js (+65/-0) app/data/Storage.qml (+214/-0) app/data/WeatherApi.js (+754/-0) app/data/key.js (+1/-0) app/graphics/CMakeLists.txt (+5/-0) app/graphics/extended-information_chance-of-rain.svg (+153/-0) app/graphics/extended-information_humidity.svg (+147/-0) app/graphics/extended-information_uv-level.svg (+270/-0) app/graphics/extended-information_wind.svg (+155/-0) app/ubuntu-weather-app.qml (+291/-0) app/ui/AddLocationPage.qml (+310/-0) app/ui/CMakeLists.txt (+7/-0) app/ui/HomePage.qml (+182/-0) app/ui/LocationPane.qml (+195/-0) app/ui/LocationsPage.qml (+279/-0) app/ui/SettingsPage.qml (+53/-0) app/ui/settings/CMakeLists.txt (+5/-0) app/ui/settings/DataProviderPage.qml (+54/-0) app/ui/settings/RefreshIntervalPage.qml (+55/-0) app/ui/settings/UnitsPage.qml (+147/-0) debian/changelog (+179/-0) debian/compat (+1/-0) debian/control (+41/-0) debian/copyright (+54/-0) debian/rules (+14/-0) debian/source/format (+1/-0) debian/ubuntu-weather-app-autopilot.install (+1/-0) debian/ubuntu-weather-app.install (+1/-0) manifest.json.in (+23/-0) po/CMakeLists.txt (+33/-0) po/com.ubuntu.weather.pot (+218/-0) tests/CMakeLists.txt (+1/-0) tests/autopilot/CMakeLists.txt (+10/-0) tests/autopilot/ubuntu_weather_app/CMakeLists.txt (+8/-0) tests/autopilot/ubuntu_weather_app/__init__.py (+59/-0) tests/autopilot/ubuntu_weather_app/tests/CMakeLists.txt (+6/-0) tests/autopilot/ubuntu_weather_app/tests/__init__.py (+150/-0) tests/autopilot/ubuntu_weather_app/tests/test_weather.py (+35/-0) ubuntu-weather-app.apparmor (+8/-0) ubuntu-weather-app.desktop.in.in (+12/-0) Conflict adding file .bzrignore. Moved existing file to .bzrignore.moved. Conflict adding file CMakeLists.txt. Moved existing file to CMakeLists.txt.moved. Conflict adding file COPYING. Moved existing file to COPYING.moved. Conflict adding file README. Moved existing file to README.moved. Conflict adding file README.translations. Moved existing file to README.translations.moved. Conflict adding file debian. Moved existing file to debian.moved. Conflict adding file po. Moved existing file to po.moved. Conflict adding file tests. Moved existing file to tests.moved. |
To merge this branch: | bzr merge lp:~vthompson/ubuntu-weather-app/reboot-allow-adding-duplicate-current-location |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Weather Developers | Pending | ||
Review via email: mp+263208@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-06-28.
Commit message
Allow adding the current location as a duplicate to the Locations List.
Description of the change
Allow adding the current location as a duplicate to the Locations List.
Unmerged revisions
- 58. By Victor Thompson
-
Allow adding the current location as a duplicate to the LocationsList.
- 57. By Victor Thompson
-
Properly migrate Locations.
Approved by Andrew Hayzen, Ubuntu Phone Apps Jenkins Bot.
- 56. By Nekhelesh Ramananthan
-
Migrates the following pages to the new SDK list items,
- SettingsPage.qml
- DayDelegate.qml
- Individual settings page like DataProviderPage.qml, RefreshInterval Page.qml and UnitsPage.qml.
- AddLocationsPage.qml. Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.
- 55. By Victor Thompson
-
Initial empty state.
Approved by Ubuntu Phone Apps Jenkins Bot, Nekhelesh Ramananthan.
- 54. By Victor Thompson
-
Show am/pm text depending upon locale.
Approved by Ubuntu Phone Apps Jenkins Bot, Nekhelesh Ramananthan.
- 53. By Victor Thompson
-
* Bump framework to 15.04 and apparmor policy version
* Bump QtQuick to 2.4 and UITK components to 1.2
* Remove useDeprecatedToolbar as it does not exist anymore. Approved by Nekhelesh Ramananthan, Ubuntu Phone Apps Jenkins Bot.
- 52. By Victor Thompson
-
* Make current location static in LocationsPage.
Approved by Andrew Hayzen, Ubuntu Phone Apps Jenkins Bot.
- 51. By Victor Thompson
-
* Do not lose currentIndex when pull to refresh.
Approved by Andrew Hayzen, Ubuntu Phone Apps Jenkins Bot.
- 50. By Victor Thompson
-
* Sync debian version with click version.
Approved by Andrew Hayzen, Ubuntu Phone Apps Jenkins Bot.
- 49. By Victor Thompson
-
Update LocationsPage layout to better match the design spec.
Approved by Andrew Hayzen, Ubuntu Phone Apps Jenkins Bot.
Preview Diff
1 | === added file '.bzrignore' | |||
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 | |||
3 | +++ .bzrignore 2015-06-28 23:49:12 +0000 | |||
4 | @@ -0,0 +1,19 @@ | |||
5 | 1 | *.user* | ||
6 | 2 | debian/files | ||
7 | 3 | debian/tmp | ||
8 | 4 | debian/ubuntu-weather-app* | ||
9 | 5 | debian/app-template/ | ||
10 | 6 | debian/*.debhelper.log | ||
11 | 7 | debian/*.substvars | ||
12 | 8 | .build | ||
13 | 9 | Makefile | ||
14 | 10 | CMakeCache.txt | ||
15 | 11 | CMakeFiles/ | ||
16 | 12 | *.cmake | ||
17 | 13 | *.gmo | ||
18 | 14 | *.mo | ||
19 | 15 | *.desktop | ||
20 | 16 | *.desktop.in | ||
21 | 17 | *.desktop.in.in.h | ||
22 | 18 | .excludes | ||
23 | 19 | ubuntu-weather-app.json | ||
24 | 0 | 20 | ||
25 | === renamed file '.bzrignore' => '.bzrignore.moved' | |||
26 | === added file 'CMakeLists.txt' | |||
27 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
28 | +++ CMakeLists.txt 2015-06-28 23:49:12 +0000 | |||
29 | @@ -0,0 +1,101 @@ | |||
30 | 1 | project(com.ubuntu.weather) | ||
31 | 2 | cmake_minimum_required(VERSION 2.8.9) | ||
32 | 3 | |||
33 | 4 | find_program(INTLTOOL_MERGE intltool-merge) | ||
34 | 5 | if(NOT INTLTOOL_MERGE) | ||
35 | 6 | message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package") | ||
36 | 7 | endif() | ||
37 | 8 | find_program(INTLTOOL_EXTRACT intltool-extract) | ||
38 | 9 | if(NOT INTLTOOL_EXTRACT) | ||
39 | 10 | message(FATAL_ERROR "Could not find intltool-extract, please install the intltool package") | ||
40 | 11 | endif() | ||
41 | 12 | |||
42 | 13 | set (UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Relative path to the manifest file") | ||
43 | 14 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra") | ||
44 | 15 | |||
45 | 16 | find_package(Qt5Core REQUIRED) | ||
46 | 17 | find_package(Qt5Qml REQUIRED) | ||
47 | 18 | find_package(Qt5Quick REQUIRED) | ||
48 | 19 | |||
49 | 20 | # Automatically create moc files | ||
50 | 21 | set(CMAKE_AUTOMOC ON) | ||
51 | 22 | |||
52 | 23 | option(INSTALL_TESTS "Install the tests on make install" on) | ||
53 | 24 | option(CLICK_MODE "Build as a click package" on) | ||
54 | 25 | |||
55 | 26 | # Tests | ||
56 | 27 | enable_testing() | ||
57 | 28 | |||
58 | 29 | # Standard install paths | ||
59 | 30 | include(GNUInstallDirs) | ||
60 | 31 | |||
61 | 32 | set(APP_NAME weather) | ||
62 | 33 | set(APP_HARDCODE ubuntu-weather-app) | ||
63 | 34 | set(MAIN_QML ${APP_HARDCODE}.qml) | ||
64 | 35 | set(DESKTOP_FILE "${APP_HARDCODE}.desktop") | ||
65 | 36 | set(ICON weather-app@30.png) | ||
66 | 37 | set(AUTOPILOT_DIR ubuntu_weather_app) | ||
67 | 38 | |||
68 | 39 | # Set install paths | ||
69 | 40 | if(CLICK_MODE) | ||
70 | 41 | set(CMAKE_INSTALL_PREFIX "/") | ||
71 | 42 | set(UBUNTU-WEATHER_APP_DIR "${CMAKE_INSTALL_DATADIR}/qml") | ||
72 | 43 | |||
73 | 44 | set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}") | ||
74 | 45 | set(EXEC "qmlscene $@ ${UBUNTU-WEATHER_APP_DIR}/${MAIN_QML}") | ||
75 | 46 | set(MODULE_PATH ${QT_IMPORTS_DIR}) | ||
76 | 47 | if(NOT BZR_REVNO) | ||
77 | 48 | execute_process( | ||
78 | 49 | COMMAND bzr revno | ||
79 | 50 | OUTPUT_VARIABLE BZR_REVNO | ||
80 | 51 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
81 | 52 | OUTPUT_STRIP_TRAILING_WHITESPACE | ||
82 | 53 | ) | ||
83 | 54 | endif(NOT BZR_REVNO) | ||
84 | 55 | if(NOT BZR_SOURCE) | ||
85 | 56 | set(BZR_SOURCE "lp:${APP_HARDCODE}/reboot") | ||
86 | 57 | message("-- Setting BZR_SOURCE to ${BZR_SOURCE}") | ||
87 | 58 | endif(NOT BZR_SOURCE) | ||
88 | 59 | else(CLICK_MODE) | ||
89 | 60 | set(UBUNTU-WEATHER_APP_DIR "${CMAKE_INSTALL_DATADIR}/ubuntu-weather-app") | ||
90 | 61 | execute_process( | ||
91 | 62 | COMMAND qmake -query QT_INSTALL_QML | ||
92 | 63 | OUTPUT_VARIABLE QT_IMPORTS_DIR | ||
93 | 64 | OUTPUT_STRIP_TRAILING_WHITESPACE | ||
94 | 65 | ) | ||
95 | 66 | set(MODULE_PATH ${QT_IMPORTS_DIR}/WeatherApp) | ||
96 | 67 | endif(CLICK_MODE) | ||
97 | 68 | |||
98 | 69 | if(${CLICK_MODE}) | ||
99 | 70 | message("-- Configuring manifest.json") | ||
100 | 71 | |||
101 | 72 | configure_file(${UBUNTU_MANIFEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/manifest.json) | ||
102 | 73 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
103 | 74 | install(FILES "${APP_HARDCODE}.apparmor" DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
104 | 75 | else(CLICK_MODE) | ||
105 | 76 | set(EXEC "qmlscene $@ -I ${MODULE_PATH} ${CMAKE_INSTALL_PREFIX}/${UBUNTU-WEATHER_APP_DIR}/${MAIN_QML}") | ||
106 | 77 | endif() | ||
107 | 78 | |||
108 | 79 | |||
109 | 80 | file(GLOB_RECURSE I18N_SRC_FILES | ||
110 | 81 | RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po | ||
111 | 82 | *.qml *.js) | ||
112 | 83 | list(APPEND I18N_SRC_FILES ${DESKTOP_FILE}.in.in.h) | ||
113 | 84 | list(SORT I18N_SRC_FILES) | ||
114 | 85 | |||
115 | 86 | configure_file(${DESKTOP_FILE}.in.in ${DESKTOP_FILE}.in) | ||
116 | 87 | |||
117 | 88 | add_custom_target(${DESKTOP_FILE} ALL | ||
118 | 89 | COMMENT "Merging translations into ${DESKTOP_FILE}..." | ||
119 | 90 | COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${DESKTOP_FILE}.in ${DESKTOP_FILE} | ||
120 | 91 | ) | ||
121 | 92 | |||
122 | 93 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE} | ||
123 | 94 | DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) | ||
124 | 95 | |||
125 | 96 | add_subdirectory(app) | ||
126 | 97 | add_subdirectory(po) | ||
127 | 98 | add_subdirectory(tests) | ||
128 | 99 | |||
129 | 100 | # TODO: Add custom target for autopilot and run. | ||
130 | 101 | |||
131 | 0 | 102 | ||
132 | === renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved' | |||
133 | === added file 'COPYING' | |||
134 | --- COPYING 1970-01-01 00:00:00 +0000 | |||
135 | +++ COPYING 2015-06-28 23:49:12 +0000 | |||
136 | @@ -0,0 +1,674 @@ | |||
137 | 1 | GNU GENERAL PUBLIC LICENSE | ||
138 | 2 | Version 3, 29 June 2007 | ||
139 | 3 | |||
140 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||
141 | 5 | Everyone is permitted to copy and distribute verbatim copies | ||
142 | 6 | of this license document, but changing it is not allowed. | ||
143 | 7 | |||
144 | 8 | Preamble | ||
145 | 9 | |||
146 | 10 | The GNU General Public License is a free, copyleft license for | ||
147 | 11 | software and other kinds of works. | ||
148 | 12 | |||
149 | 13 | The licenses for most software and other practical works are designed | ||
150 | 14 | to take away your freedom to share and change the works. By contrast, | ||
151 | 15 | the GNU General Public License is intended to guarantee your freedom to | ||
152 | 16 | share and change all versions of a program--to make sure it remains free | ||
153 | 17 | software for all its users. We, the Free Software Foundation, use the | ||
154 | 18 | GNU General Public License for most of our software; it applies also to | ||
155 | 19 | any other work released this way by its authors. You can apply it to | ||
156 | 20 | your programs, too. | ||
157 | 21 | |||
158 | 22 | When we speak of free software, we are referring to freedom, not | ||
159 | 23 | price. Our General Public Licenses are designed to make sure that you | ||
160 | 24 | have the freedom to distribute copies of free software (and charge for | ||
161 | 25 | them if you wish), that you receive source code or can get it if you | ||
162 | 26 | want it, that you can change the software or use pieces of it in new | ||
163 | 27 | free programs, and that you know you can do these things. | ||
164 | 28 | |||
165 | 29 | To protect your rights, we need to prevent others from denying you | ||
166 | 30 | these rights or asking you to surrender the rights. Therefore, you have | ||
167 | 31 | certain responsibilities if you distribute copies of the software, or if | ||
168 | 32 | you modify it: responsibilities to respect the freedom of others. | ||
169 | 33 | |||
170 | 34 | For example, if you distribute copies of such a program, whether | ||
171 | 35 | gratis or for a fee, you must pass on to the recipients the same | ||
172 | 36 | freedoms that you received. You must make sure that they, too, receive | ||
173 | 37 | or can get the source code. And you must show them these terms so they | ||
174 | 38 | know their rights. | ||
175 | 39 | |||
176 | 40 | Developers that use the GNU GPL protect your rights with two steps: | ||
177 | 41 | (1) assert copyright on the software, and (2) offer you this License | ||
178 | 42 | giving you legal permission to copy, distribute and/or modify it. | ||
179 | 43 | |||
180 | 44 | For the developers' and authors' protection, the GPL clearly explains | ||
181 | 45 | that there is no warranty for this free software. For both users' and | ||
182 | 46 | authors' sake, the GPL requires that modified versions be marked as | ||
183 | 47 | changed, so that their problems will not be attributed erroneously to | ||
184 | 48 | authors of previous versions. | ||
185 | 49 | |||
186 | 50 | Some devices are designed to deny users access to install or run | ||
187 | 51 | modified versions of the software inside them, although the manufacturer | ||
188 | 52 | can do so. This is fundamentally incompatible with the aim of | ||
189 | 53 | protecting users' freedom to change the software. The systematic | ||
190 | 54 | pattern of such abuse occurs in the area of products for individuals to | ||
191 | 55 | use, which is precisely where it is most unacceptable. Therefore, we | ||
192 | 56 | have designed this version of the GPL to prohibit the practice for those | ||
193 | 57 | products. If such problems arise substantially in other domains, we | ||
194 | 58 | stand ready to extend this provision to those domains in future versions | ||
195 | 59 | of the GPL, as needed to protect the freedom of users. | ||
196 | 60 | |||
197 | 61 | Finally, every program is threatened constantly by software patents. | ||
198 | 62 | States should not allow patents to restrict development and use of | ||
199 | 63 | software on general-purpose computers, but in those that do, we wish to | ||
200 | 64 | avoid the special danger that patents applied to a free program could | ||
201 | 65 | make it effectively proprietary. To prevent this, the GPL assures that | ||
202 | 66 | patents cannot be used to render the program non-free. | ||
203 | 67 | |||
204 | 68 | The precise terms and conditions for copying, distribution and | ||
205 | 69 | modification follow. | ||
206 | 70 | |||
207 | 71 | TERMS AND CONDITIONS | ||
208 | 72 | |||
209 | 73 | 0. Definitions. | ||
210 | 74 | |||
211 | 75 | "This License" refers to version 3 of the GNU General Public License. | ||
212 | 76 | |||
213 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of | ||
214 | 78 | works, such as semiconductor masks. | ||
215 | 79 | |||
216 | 80 | "The Program" refers to any copyrightable work licensed under this | ||
217 | 81 | License. Each licensee is addressed as "you". "Licensees" and | ||
218 | 82 | "recipients" may be individuals or organizations. | ||
219 | 83 | |||
220 | 84 | To "modify" a work means to copy from or adapt all or part of the work | ||
221 | 85 | in a fashion requiring copyright permission, other than the making of an | ||
222 | 86 | exact copy. The resulting work is called a "modified version" of the | ||
223 | 87 | earlier work or a work "based on" the earlier work. | ||
224 | 88 | |||
225 | 89 | A "covered work" means either the unmodified Program or a work based | ||
226 | 90 | on the Program. | ||
227 | 91 | |||
228 | 92 | To "propagate" a work means to do anything with it that, without | ||
229 | 93 | permission, would make you directly or secondarily liable for | ||
230 | 94 | infringement under applicable copyright law, except executing it on a | ||
231 | 95 | computer or modifying a private copy. Propagation includes copying, | ||
232 | 96 | distribution (with or without modification), making available to the | ||
233 | 97 | public, and in some countries other activities as well. | ||
234 | 98 | |||
235 | 99 | To "convey" a work means any kind of propagation that enables other | ||
236 | 100 | parties to make or receive copies. Mere interaction with a user through | ||
237 | 101 | a computer network, with no transfer of a copy, is not conveying. | ||
238 | 102 | |||
239 | 103 | An interactive user interface displays "Appropriate Legal Notices" | ||
240 | 104 | to the extent that it includes a convenient and prominently visible | ||
241 | 105 | feature that (1) displays an appropriate copyright notice, and (2) | ||
242 | 106 | tells the user that there is no warranty for the work (except to the | ||
243 | 107 | extent that warranties are provided), that licensees may convey the | ||
244 | 108 | work under this License, and how to view a copy of this License. If | ||
245 | 109 | the interface presents a list of user commands or options, such as a | ||
246 | 110 | menu, a prominent item in the list meets this criterion. | ||
247 | 111 | |||
248 | 112 | 1. Source Code. | ||
249 | 113 | |||
250 | 114 | The "source code" for a work means the preferred form of the work | ||
251 | 115 | for making modifications to it. "Object code" means any non-source | ||
252 | 116 | form of a work. | ||
253 | 117 | |||
254 | 118 | A "Standard Interface" means an interface that either is an official | ||
255 | 119 | standard defined by a recognized standards body, or, in the case of | ||
256 | 120 | interfaces specified for a particular programming language, one that | ||
257 | 121 | is widely used among developers working in that language. | ||
258 | 122 | |||
259 | 123 | The "System Libraries" of an executable work include anything, other | ||
260 | 124 | than the work as a whole, that (a) is included in the normal form of | ||
261 | 125 | packaging a Major Component, but which is not part of that Major | ||
262 | 126 | Component, and (b) serves only to enable use of the work with that | ||
263 | 127 | Major Component, or to implement a Standard Interface for which an | ||
264 | 128 | implementation is available to the public in source code form. A | ||
265 | 129 | "Major Component", in this context, means a major essential component | ||
266 | 130 | (kernel, window system, and so on) of the specific operating system | ||
267 | 131 | (if any) on which the executable work runs, or a compiler used to | ||
268 | 132 | produce the work, or an object code interpreter used to run it. | ||
269 | 133 | |||
270 | 134 | The "Corresponding Source" for a work in object code form means all | ||
271 | 135 | the source code needed to generate, install, and (for an executable | ||
272 | 136 | work) run the object code and to modify the work, including scripts to | ||
273 | 137 | control those activities. However, it does not include the work's | ||
274 | 138 | System Libraries, or general-purpose tools or generally available free | ||
275 | 139 | programs which are used unmodified in performing those activities but | ||
276 | 140 | which are not part of the work. For example, Corresponding Source | ||
277 | 141 | includes interface definition files associated with source files for | ||
278 | 142 | the work, and the source code for shared libraries and dynamically | ||
279 | 143 | linked subprograms that the work is specifically designed to require, | ||
280 | 144 | such as by intimate data communication or control flow between those | ||
281 | 145 | subprograms and other parts of the work. | ||
282 | 146 | |||
283 | 147 | The Corresponding Source need not include anything that users | ||
284 | 148 | can regenerate automatically from other parts of the Corresponding | ||
285 | 149 | Source. | ||
286 | 150 | |||
287 | 151 | The Corresponding Source for a work in source code form is that | ||
288 | 152 | same work. | ||
289 | 153 | |||
290 | 154 | 2. Basic Permissions. | ||
291 | 155 | |||
292 | 156 | All rights granted under this License are granted for the term of | ||
293 | 157 | copyright on the Program, and are irrevocable provided the stated | ||
294 | 158 | conditions are met. This License explicitly affirms your unlimited | ||
295 | 159 | permission to run the unmodified Program. The output from running a | ||
296 | 160 | covered work is covered by this License only if the output, given its | ||
297 | 161 | content, constitutes a covered work. This License acknowledges your | ||
298 | 162 | rights of fair use or other equivalent, as provided by copyright law. | ||
299 | 163 | |||
300 | 164 | You may make, run and propagate covered works that you do not | ||
301 | 165 | convey, without conditions so long as your license otherwise remains | ||
302 | 166 | in force. You may convey covered works to others for the sole purpose | ||
303 | 167 | of having them make modifications exclusively for you, or provide you | ||
304 | 168 | with facilities for running those works, provided that you comply with | ||
305 | 169 | the terms of this License in conveying all material for which you do | ||
306 | 170 | not control copyright. Those thus making or running the covered works | ||
307 | 171 | for you must do so exclusively on your behalf, under your direction | ||
308 | 172 | and control, on terms that prohibit them from making any copies of | ||
309 | 173 | your copyrighted material outside their relationship with you. | ||
310 | 174 | |||
311 | 175 | Conveying under any other circumstances is permitted solely under | ||
312 | 176 | the conditions stated below. Sublicensing is not allowed; section 10 | ||
313 | 177 | makes it unnecessary. | ||
314 | 178 | |||
315 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. | ||
316 | 180 | |||
317 | 181 | No covered work shall be deemed part of an effective technological | ||
318 | 182 | measure under any applicable law fulfilling obligations under article | ||
319 | 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or | ||
320 | 184 | similar laws prohibiting or restricting circumvention of such | ||
321 | 185 | measures. | ||
322 | 186 | |||
323 | 187 | When you convey a covered work, you waive any legal power to forbid | ||
324 | 188 | circumvention of technological measures to the extent such circumvention | ||
325 | 189 | is effected by exercising rights under this License with respect to | ||
326 | 190 | the covered work, and you disclaim any intention to limit operation or | ||
327 | 191 | modification of the work as a means of enforcing, against the work's | ||
328 | 192 | users, your or third parties' legal rights to forbid circumvention of | ||
329 | 193 | technological measures. | ||
330 | 194 | |||
331 | 195 | 4. Conveying Verbatim Copies. | ||
332 | 196 | |||
333 | 197 | You may convey verbatim copies of the Program's source code as you | ||
334 | 198 | receive it, in any medium, provided that you conspicuously and | ||
335 | 199 | appropriately publish on each copy an appropriate copyright notice; | ||
336 | 200 | keep intact all notices stating that this License and any | ||
337 | 201 | non-permissive terms added in accord with section 7 apply to the code; | ||
338 | 202 | keep intact all notices of the absence of any warranty; and give all | ||
339 | 203 | recipients a copy of this License along with the Program. | ||
340 | 204 | |||
341 | 205 | You may charge any price or no price for each copy that you convey, | ||
342 | 206 | and you may offer support or warranty protection for a fee. | ||
343 | 207 | |||
344 | 208 | 5. Conveying Modified Source Versions. | ||
345 | 209 | |||
346 | 210 | You may convey a work based on the Program, or the modifications to | ||
347 | 211 | produce it from the Program, in the form of source code under the | ||
348 | 212 | terms of section 4, provided that you also meet all of these conditions: | ||
349 | 213 | |||
350 | 214 | a) The work must carry prominent notices stating that you modified | ||
351 | 215 | it, and giving a relevant date. | ||
352 | 216 | |||
353 | 217 | b) The work must carry prominent notices stating that it is | ||
354 | 218 | released under this License and any conditions added under section | ||
355 | 219 | 7. This requirement modifies the requirement in section 4 to | ||
356 | 220 | "keep intact all notices". | ||
357 | 221 | |||
358 | 222 | c) You must license the entire work, as a whole, under this | ||
359 | 223 | License to anyone who comes into possession of a copy. This | ||
360 | 224 | License will therefore apply, along with any applicable section 7 | ||
361 | 225 | additional terms, to the whole of the work, and all its parts, | ||
362 | 226 | regardless of how they are packaged. This License gives no | ||
363 | 227 | permission to license the work in any other way, but it does not | ||
364 | 228 | invalidate such permission if you have separately received it. | ||
365 | 229 | |||
366 | 230 | d) If the work has interactive user interfaces, each must display | ||
367 | 231 | Appropriate Legal Notices; however, if the Program has interactive | ||
368 | 232 | interfaces that do not display Appropriate Legal Notices, your | ||
369 | 233 | work need not make them do so. | ||
370 | 234 | |||
371 | 235 | A compilation of a covered work with other separate and independent | ||
372 | 236 | works, which are not by their nature extensions of the covered work, | ||
373 | 237 | and which are not combined with it such as to form a larger program, | ||
374 | 238 | in or on a volume of a storage or distribution medium, is called an | ||
375 | 239 | "aggregate" if the compilation and its resulting copyright are not | ||
376 | 240 | used to limit the access or legal rights of the compilation's users | ||
377 | 241 | beyond what the individual works permit. Inclusion of a covered work | ||
378 | 242 | in an aggregate does not cause this License to apply to the other | ||
379 | 243 | parts of the aggregate. | ||
380 | 244 | |||
381 | 245 | 6. Conveying Non-Source Forms. | ||
382 | 246 | |||
383 | 247 | You may convey a covered work in object code form under the terms | ||
384 | 248 | of sections 4 and 5, provided that you also convey the | ||
385 | 249 | machine-readable Corresponding Source under the terms of this License, | ||
386 | 250 | in one of these ways: | ||
387 | 251 | |||
388 | 252 | a) Convey the object code in, or embodied in, a physical product | ||
389 | 253 | (including a physical distribution medium), accompanied by the | ||
390 | 254 | Corresponding Source fixed on a durable physical medium | ||
391 | 255 | customarily used for software interchange. | ||
392 | 256 | |||
393 | 257 | b) Convey the object code in, or embodied in, a physical product | ||
394 | 258 | (including a physical distribution medium), accompanied by a | ||
395 | 259 | written offer, valid for at least three years and valid for as | ||
396 | 260 | long as you offer spare parts or customer support for that product | ||
397 | 261 | model, to give anyone who possesses the object code either (1) a | ||
398 | 262 | copy of the Corresponding Source for all the software in the | ||
399 | 263 | product that is covered by this License, on a durable physical | ||
400 | 264 | medium customarily used for software interchange, for a price no | ||
401 | 265 | more than your reasonable cost of physically performing this | ||
402 | 266 | conveying of source, or (2) access to copy the | ||
403 | 267 | Corresponding Source from a network server at no charge. | ||
404 | 268 | |||
405 | 269 | c) Convey individual copies of the object code with a copy of the | ||
406 | 270 | written offer to provide the Corresponding Source. This | ||
407 | 271 | alternative is allowed only occasionally and noncommercially, and | ||
408 | 272 | only if you received the object code with such an offer, in accord | ||
409 | 273 | with subsection 6b. | ||
410 | 274 | |||
411 | 275 | d) Convey the object code by offering access from a designated | ||
412 | 276 | place (gratis or for a charge), and offer equivalent access to the | ||
413 | 277 | Corresponding Source in the same way through the same place at no | ||
414 | 278 | further charge. You need not require recipients to copy the | ||
415 | 279 | Corresponding Source along with the object code. If the place to | ||
416 | 280 | copy the object code is a network server, the Corresponding Source | ||
417 | 281 | may be on a different server (operated by you or a third party) | ||
418 | 282 | that supports equivalent copying facilities, provided you maintain | ||
419 | 283 | clear directions next to the object code saying where to find the | ||
420 | 284 | Corresponding Source. Regardless of what server hosts the | ||
421 | 285 | Corresponding Source, you remain obligated to ensure that it is | ||
422 | 286 | available for as long as needed to satisfy these requirements. | ||
423 | 287 | |||
424 | 288 | e) Convey the object code using peer-to-peer transmission, provided | ||
425 | 289 | you inform other peers where the object code and Corresponding | ||
426 | 290 | Source of the work are being offered to the general public at no | ||
427 | 291 | charge under subsection 6d. | ||
428 | 292 | |||
429 | 293 | A separable portion of the object code, whose source code is excluded | ||
430 | 294 | from the Corresponding Source as a System Library, need not be | ||
431 | 295 | included in conveying the object code work. | ||
432 | 296 | |||
433 | 297 | A "User Product" is either (1) a "consumer product", which means any | ||
434 | 298 | tangible personal property which is normally used for personal, family, | ||
435 | 299 | or household purposes, or (2) anything designed or sold for incorporation | ||
436 | 300 | into a dwelling. In determining whether a product is a consumer product, | ||
437 | 301 | doubtful cases shall be resolved in favor of coverage. For a particular | ||
438 | 302 | product received by a particular user, "normally used" refers to a | ||
439 | 303 | typical or common use of that class of product, regardless of the status | ||
440 | 304 | of the particular user or of the way in which the particular user | ||
441 | 305 | actually uses, or expects or is expected to use, the product. A product | ||
442 | 306 | is a consumer product regardless of whether the product has substantial | ||
443 | 307 | commercial, industrial or non-consumer uses, unless such uses represent | ||
444 | 308 | the only significant mode of use of the product. | ||
445 | 309 | |||
446 | 310 | "Installation Information" for a User Product means any methods, | ||
447 | 311 | procedures, authorization keys, or other information required to install | ||
448 | 312 | and execute modified versions of a covered work in that User Product from | ||
449 | 313 | a modified version of its Corresponding Source. The information must | ||
450 | 314 | suffice to ensure that the continued functioning of the modified object | ||
451 | 315 | code is in no case prevented or interfered with solely because | ||
452 | 316 | modification has been made. | ||
453 | 317 | |||
454 | 318 | If you convey an object code work under this section in, or with, or | ||
455 | 319 | specifically for use in, a User Product, and the conveying occurs as | ||
456 | 320 | part of a transaction in which the right of possession and use of the | ||
457 | 321 | User Product is transferred to the recipient in perpetuity or for a | ||
458 | 322 | fixed term (regardless of how the transaction is characterized), the | ||
459 | 323 | Corresponding Source conveyed under this section must be accompanied | ||
460 | 324 | by the Installation Information. But this requirement does not apply | ||
461 | 325 | if neither you nor any third party retains the ability to install | ||
462 | 326 | modified object code on the User Product (for example, the work has | ||
463 | 327 | been installed in ROM). | ||
464 | 328 | |||
465 | 329 | The requirement to provide Installation Information does not include a | ||
466 | 330 | requirement to continue to provide support service, warranty, or updates | ||
467 | 331 | for a work that has been modified or installed by the recipient, or for | ||
468 | 332 | the User Product in which it has been modified or installed. Access to a | ||
469 | 333 | network may be denied when the modification itself materially and | ||
470 | 334 | adversely affects the operation of the network or violates the rules and | ||
471 | 335 | protocols for communication across the network. | ||
472 | 336 | |||
473 | 337 | Corresponding Source conveyed, and Installation Information provided, | ||
474 | 338 | in accord with this section must be in a format that is publicly | ||
475 | 339 | documented (and with an implementation available to the public in | ||
476 | 340 | source code form), and must require no special password or key for | ||
477 | 341 | unpacking, reading or copying. | ||
478 | 342 | |||
479 | 343 | 7. Additional Terms. | ||
480 | 344 | |||
481 | 345 | "Additional permissions" are terms that supplement the terms of this | ||
482 | 346 | License by making exceptions from one or more of its conditions. | ||
483 | 347 | Additional permissions that are applicable to the entire Program shall | ||
484 | 348 | be treated as though they were included in this License, to the extent | ||
485 | 349 | that they are valid under applicable law. If additional permissions | ||
486 | 350 | apply only to part of the Program, that part may be used separately | ||
487 | 351 | under those permissions, but the entire Program remains governed by | ||
488 | 352 | this License without regard to the additional permissions. | ||
489 | 353 | |||
490 | 354 | When you convey a copy of a covered work, you may at your option | ||
491 | 355 | remove any additional permissions from that copy, or from any part of | ||
492 | 356 | it. (Additional permissions may be written to require their own | ||
493 | 357 | removal in certain cases when you modify the work.) You may place | ||
494 | 358 | additional permissions on material, added by you to a covered work, | ||
495 | 359 | for which you have or can give appropriate copyright permission. | ||
496 | 360 | |||
497 | 361 | Notwithstanding any other provision of this License, for material you | ||
498 | 362 | add to a covered work, you may (if authorized by the copyright holders of | ||
499 | 363 | that material) supplement the terms of this License with terms: | ||
500 | 364 | |||
501 | 365 | a) Disclaiming warranty or limiting liability differently from the | ||
502 | 366 | terms of sections 15 and 16 of this License; or | ||
503 | 367 | |||
504 | 368 | b) Requiring preservation of specified reasonable legal notices or | ||
505 | 369 | author attributions in that material or in the Appropriate Legal | ||
506 | 370 | Notices displayed by works containing it; or | ||
507 | 371 | |||
508 | 372 | c) Prohibiting misrepresentation of the origin of that material, or | ||
509 | 373 | requiring that modified versions of such material be marked in | ||
510 | 374 | reasonable ways as different from the original version; or | ||
511 | 375 | |||
512 | 376 | d) Limiting the use for publicity purposes of names of licensors or | ||
513 | 377 | authors of the material; or | ||
514 | 378 | |||
515 | 379 | e) Declining to grant rights under trademark law for use of some | ||
516 | 380 | trade names, trademarks, or service marks; or | ||
517 | 381 | |||
518 | 382 | f) Requiring indemnification of licensors and authors of that | ||
519 | 383 | material by anyone who conveys the material (or modified versions of | ||
520 | 384 | it) with contractual assumptions of liability to the recipient, for | ||
521 | 385 | any liability that these contractual assumptions directly impose on | ||
522 | 386 | those licensors and authors. | ||
523 | 387 | |||
524 | 388 | All other non-permissive additional terms are considered "further | ||
525 | 389 | restrictions" within the meaning of section 10. If the Program as you | ||
526 | 390 | received it, or any part of it, contains a notice stating that it is | ||
527 | 391 | governed by this License along with a term that is a further | ||
528 | 392 | restriction, you may remove that term. If a license document contains | ||
529 | 393 | a further restriction but permits relicensing or conveying under this | ||
530 | 394 | License, you may add to a covered work material governed by the terms | ||
531 | 395 | of that license document, provided that the further restriction does | ||
532 | 396 | not survive such relicensing or conveying. | ||
533 | 397 | |||
534 | 398 | If you add terms to a covered work in accord with this section, you | ||
535 | 399 | must place, in the relevant source files, a statement of the | ||
536 | 400 | additional terms that apply to those files, or a notice indicating | ||
537 | 401 | where to find the applicable terms. | ||
538 | 402 | |||
539 | 403 | Additional terms, permissive or non-permissive, may be stated in the | ||
540 | 404 | form of a separately written license, or stated as exceptions; | ||
541 | 405 | the above requirements apply either way. | ||
542 | 406 | |||
543 | 407 | 8. Termination. | ||
544 | 408 | |||
545 | 409 | You may not propagate or modify a covered work except as expressly | ||
546 | 410 | provided under this License. Any attempt otherwise to propagate or | ||
547 | 411 | modify it is void, and will automatically terminate your rights under | ||
548 | 412 | this License (including any patent licenses granted under the third | ||
549 | 413 | paragraph of section 11). | ||
550 | 414 | |||
551 | 415 | However, if you cease all violation of this License, then your | ||
552 | 416 | license from a particular copyright holder is reinstated (a) | ||
553 | 417 | provisionally, unless and until the copyright holder explicitly and | ||
554 | 418 | finally terminates your license, and (b) permanently, if the copyright | ||
555 | 419 | holder fails to notify you of the violation by some reasonable means | ||
556 | 420 | prior to 60 days after the cessation. | ||
557 | 421 | |||
558 | 422 | Moreover, your license from a particular copyright holder is | ||
559 | 423 | reinstated permanently if the copyright holder notifies you of the | ||
560 | 424 | violation by some reasonable means, this is the first time you have | ||
561 | 425 | received notice of violation of this License (for any work) from that | ||
562 | 426 | copyright holder, and you cure the violation prior to 30 days after | ||
563 | 427 | your receipt of the notice. | ||
564 | 428 | |||
565 | 429 | Termination of your rights under this section does not terminate the | ||
566 | 430 | licenses of parties who have received copies or rights from you under | ||
567 | 431 | this License. If your rights have been terminated and not permanently | ||
568 | 432 | reinstated, you do not qualify to receive new licenses for the same | ||
569 | 433 | material under section 10. | ||
570 | 434 | |||
571 | 435 | 9. Acceptance Not Required for Having Copies. | ||
572 | 436 | |||
573 | 437 | You are not required to accept this License in order to receive or | ||
574 | 438 | run a copy of the Program. Ancillary propagation of a covered work | ||
575 | 439 | occurring solely as a consequence of using peer-to-peer transmission | ||
576 | 440 | to receive a copy likewise does not require acceptance. However, | ||
577 | 441 | nothing other than this License grants you permission to propagate or | ||
578 | 442 | modify any covered work. These actions infringe copyright if you do | ||
579 | 443 | not accept this License. Therefore, by modifying or propagating a | ||
580 | 444 | covered work, you indicate your acceptance of this License to do so. | ||
581 | 445 | |||
582 | 446 | 10. Automatic Licensing of Downstream Recipients. | ||
583 | 447 | |||
584 | 448 | Each time you convey a covered work, the recipient automatically | ||
585 | 449 | receives a license from the original licensors, to run, modify and | ||
586 | 450 | propagate that work, subject to this License. You are not responsible | ||
587 | 451 | for enforcing compliance by third parties with this License. | ||
588 | 452 | |||
589 | 453 | An "entity transaction" is a transaction transferring control of an | ||
590 | 454 | organization, or substantially all assets of one, or subdividing an | ||
591 | 455 | organization, or merging organizations. If propagation of a covered | ||
592 | 456 | work results from an entity transaction, each party to that | ||
593 | 457 | transaction who receives a copy of the work also receives whatever | ||
594 | 458 | licenses to the work the party's predecessor in interest had or could | ||
595 | 459 | give under the previous paragraph, plus a right to possession of the | ||
596 | 460 | Corresponding Source of the work from the predecessor in interest, if | ||
597 | 461 | the predecessor has it or can get it with reasonable efforts. | ||
598 | 462 | |||
599 | 463 | You may not impose any further restrictions on the exercise of the | ||
600 | 464 | rights granted or affirmed under this License. For example, you may | ||
601 | 465 | not impose a license fee, royalty, or other charge for exercise of | ||
602 | 466 | rights granted under this License, and you may not initiate litigation | ||
603 | 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that | ||
604 | 468 | any patent claim is infringed by making, using, selling, offering for | ||
605 | 469 | sale, or importing the Program or any portion of it. | ||
606 | 470 | |||
607 | 471 | 11. Patents. | ||
608 | 472 | |||
609 | 473 | A "contributor" is a copyright holder who authorizes use under this | ||
610 | 474 | License of the Program or a work on which the Program is based. The | ||
611 | 475 | work thus licensed is called the contributor's "contributor version". | ||
612 | 476 | |||
613 | 477 | A contributor's "essential patent claims" are all patent claims | ||
614 | 478 | owned or controlled by the contributor, whether already acquired or | ||
615 | 479 | hereafter acquired, that would be infringed by some manner, permitted | ||
616 | 480 | by this License, of making, using, or selling its contributor version, | ||
617 | 481 | but do not include claims that would be infringed only as a | ||
618 | 482 | consequence of further modification of the contributor version. For | ||
619 | 483 | purposes of this definition, "control" includes the right to grant | ||
620 | 484 | patent sublicenses in a manner consistent with the requirements of | ||
621 | 485 | this License. | ||
622 | 486 | |||
623 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free | ||
624 | 488 | patent license under the contributor's essential patent claims, to | ||
625 | 489 | make, use, sell, offer for sale, import and otherwise run, modify and | ||
626 | 490 | propagate the contents of its contributor version. | ||
627 | 491 | |||
628 | 492 | In the following three paragraphs, a "patent license" is any express | ||
629 | 493 | agreement or commitment, however denominated, not to enforce a patent | ||
630 | 494 | (such as an express permission to practice a patent or covenant not to | ||
631 | 495 | sue for patent infringement). To "grant" such a patent license to a | ||
632 | 496 | party means to make such an agreement or commitment not to enforce a | ||
633 | 497 | patent against the party. | ||
634 | 498 | |||
635 | 499 | If you convey a covered work, knowingly relying on a patent license, | ||
636 | 500 | and the Corresponding Source of the work is not available for anyone | ||
637 | 501 | to copy, free of charge and under the terms of this License, through a | ||
638 | 502 | publicly available network server or other readily accessible means, | ||
639 | 503 | then you must either (1) cause the Corresponding Source to be so | ||
640 | 504 | available, or (2) arrange to deprive yourself of the benefit of the | ||
641 | 505 | patent license for this particular work, or (3) arrange, in a manner | ||
642 | 506 | consistent with the requirements of this License, to extend the patent | ||
643 | 507 | license to downstream recipients. "Knowingly relying" means you have | ||
644 | 508 | actual knowledge that, but for the patent license, your conveying the | ||
645 | 509 | covered work in a country, or your recipient's use of the covered work | ||
646 | 510 | in a country, would infringe one or more identifiable patents in that | ||
647 | 511 | country that you have reason to believe are valid. | ||
648 | 512 | |||
649 | 513 | If, pursuant to or in connection with a single transaction or | ||
650 | 514 | arrangement, you convey, or propagate by procuring conveyance of, a | ||
651 | 515 | covered work, and grant a patent license to some of the parties | ||
652 | 516 | receiving the covered work authorizing them to use, propagate, modify | ||
653 | 517 | or convey a specific copy of the covered work, then the patent license | ||
654 | 518 | you grant is automatically extended to all recipients of the covered | ||
655 | 519 | work and works based on it. | ||
656 | 520 | |||
657 | 521 | A patent license is "discriminatory" if it does not include within | ||
658 | 522 | the scope of its coverage, prohibits the exercise of, or is | ||
659 | 523 | conditioned on the non-exercise of one or more of the rights that are | ||
660 | 524 | specifically granted under this License. You may not convey a covered | ||
661 | 525 | work if you are a party to an arrangement with a third party that is | ||
662 | 526 | in the business of distributing software, under which you make payment | ||
663 | 527 | to the third party based on the extent of your activity of conveying | ||
664 | 528 | the work, and under which the third party grants, to any of the | ||
665 | 529 | parties who would receive the covered work from you, a discriminatory | ||
666 | 530 | patent license (a) in connection with copies of the covered work | ||
667 | 531 | conveyed by you (or copies made from those copies), or (b) primarily | ||
668 | 532 | for and in connection with specific products or compilations that | ||
669 | 533 | contain the covered work, unless you entered into that arrangement, | ||
670 | 534 | or that patent license was granted, prior to 28 March 2007. | ||
671 | 535 | |||
672 | 536 | Nothing in this License shall be construed as excluding or limiting | ||
673 | 537 | any implied license or other defenses to infringement that may | ||
674 | 538 | otherwise be available to you under applicable patent law. | ||
675 | 539 | |||
676 | 540 | 12. No Surrender of Others' Freedom. | ||
677 | 541 | |||
678 | 542 | If conditions are imposed on you (whether by court order, agreement or | ||
679 | 543 | otherwise) that contradict the conditions of this License, they do not | ||
680 | 544 | excuse you from the conditions of this License. If you cannot convey a | ||
681 | 545 | covered work so as to satisfy simultaneously your obligations under this | ||
682 | 546 | License and any other pertinent obligations, then as a consequence you may | ||
683 | 547 | not convey it at all. For example, if you agree to terms that obligate you | ||
684 | 548 | to collect a royalty for further conveying from those to whom you convey | ||
685 | 549 | the Program, the only way you could satisfy both those terms and this | ||
686 | 550 | License would be to refrain entirely from conveying the Program. | ||
687 | 551 | |||
688 | 552 | 13. Use with the GNU Affero General Public License. | ||
689 | 553 | |||
690 | 554 | Notwithstanding any other provision of this License, you have | ||
691 | 555 | permission to link or combine any covered work with a work licensed | ||
692 | 556 | under version 3 of the GNU Affero General Public License into a single | ||
693 | 557 | combined work, and to convey the resulting work. The terms of this | ||
694 | 558 | License will continue to apply to the part which is the covered work, | ||
695 | 559 | but the special requirements of the GNU Affero General Public License, | ||
696 | 560 | section 13, concerning interaction through a network will apply to the | ||
697 | 561 | combination as such. | ||
698 | 562 | |||
699 | 563 | 14. Revised Versions of this License. | ||
700 | 564 | |||
701 | 565 | The Free Software Foundation may publish revised and/or new versions of | ||
702 | 566 | the GNU General Public License from time to time. Such new versions will | ||
703 | 567 | be similar in spirit to the present version, but may differ in detail to | ||
704 | 568 | address new problems or concerns. | ||
705 | 569 | |||
706 | 570 | Each version is given a distinguishing version number. If the | ||
707 | 571 | Program specifies that a certain numbered version of the GNU General | ||
708 | 572 | Public License "or any later version" applies to it, you have the | ||
709 | 573 | option of following the terms and conditions either of that numbered | ||
710 | 574 | version or of any later version published by the Free Software | ||
711 | 575 | Foundation. If the Program does not specify a version number of the | ||
712 | 576 | GNU General Public License, you may choose any version ever published | ||
713 | 577 | by the Free Software Foundation. | ||
714 | 578 | |||
715 | 579 | If the Program specifies that a proxy can decide which future | ||
716 | 580 | versions of the GNU General Public License can be used, that proxy's | ||
717 | 581 | public statement of acceptance of a version permanently authorizes you | ||
718 | 582 | to choose that version for the Program. | ||
719 | 583 | |||
720 | 584 | Later license versions may give you additional or different | ||
721 | 585 | permissions. However, no additional obligations are imposed on any | ||
722 | 586 | author or copyright holder as a result of your choosing to follow a | ||
723 | 587 | later version. | ||
724 | 588 | |||
725 | 589 | 15. Disclaimer of Warranty. | ||
726 | 590 | |||
727 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY | ||
728 | 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT | ||
729 | 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY | ||
730 | 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, | ||
731 | 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
732 | 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM | ||
733 | 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF | ||
734 | 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | ||
735 | 599 | |||
736 | 600 | 16. Limitation of Liability. | ||
737 | 601 | |||
738 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
739 | 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS | ||
740 | 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY | ||
741 | 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE | ||
742 | 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF | ||
743 | 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD | ||
744 | 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), | ||
745 | 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
746 | 610 | SUCH DAMAGES. | ||
747 | 611 | |||
748 | 612 | 17. Interpretation of Sections 15 and 16. | ||
749 | 613 | |||
750 | 614 | If the disclaimer of warranty and limitation of liability provided | ||
751 | 615 | above cannot be given local legal effect according to their terms, | ||
752 | 616 | reviewing courts shall apply local law that most closely approximates | ||
753 | 617 | an absolute waiver of all civil liability in connection with the | ||
754 | 618 | Program, unless a warranty or assumption of liability accompanies a | ||
755 | 619 | copy of the Program in return for a fee. | ||
756 | 620 | |||
757 | 621 | END OF TERMS AND CONDITIONS | ||
758 | 622 | |||
759 | 623 | How to Apply These Terms to Your New Programs | ||
760 | 624 | |||
761 | 625 | If you develop a new program, and you want it to be of the greatest | ||
762 | 626 | possible use to the public, the best way to achieve this is to make it | ||
763 | 627 | free software which everyone can redistribute and change under these terms. | ||
764 | 628 | |||
765 | 629 | To do so, attach the following notices to the program. It is safest | ||
766 | 630 | to attach them to the start of each source file to most effectively | ||
767 | 631 | state the exclusion of warranty; and each file should have at least | ||
768 | 632 | the "copyright" line and a pointer to where the full notice is found. | ||
769 | 633 | |||
770 | 634 | <one line to give the program's name and a brief idea of what it does.> | ||
771 | 635 | Copyright (C) <year> <name of author> | ||
772 | 636 | |||
773 | 637 | This program is free software: you can redistribute it and/or modify | ||
774 | 638 | it under the terms of the GNU General Public License as published by | ||
775 | 639 | the Free Software Foundation, either version 3 of the License, or | ||
776 | 640 | (at your option) any later version. | ||
777 | 641 | |||
778 | 642 | This program is distributed in the hope that it will be useful, | ||
779 | 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
780 | 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
781 | 645 | GNU General Public License for more details. | ||
782 | 646 | |||
783 | 647 | You should have received a copy of the GNU General Public License | ||
784 | 648 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
785 | 649 | |||
786 | 650 | Also add information on how to contact you by electronic and paper mail. | ||
787 | 651 | |||
788 | 652 | If the program does terminal interaction, make it output a short | ||
789 | 653 | notice like this when it starts in an interactive mode: | ||
790 | 654 | |||
791 | 655 | <program> Copyright (C) <year> <name of author> | ||
792 | 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
793 | 657 | This is free software, and you are welcome to redistribute it | ||
794 | 658 | under certain conditions; type `show c' for details. | ||
795 | 659 | |||
796 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
797 | 661 | parts of the General Public License. Of course, your program's commands | ||
798 | 662 | might be different; for a GUI interface, you would use an "about box". | ||
799 | 663 | |||
800 | 664 | You should also get your employer (if you work as a programmer) or school, | ||
801 | 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. | ||
802 | 666 | For more information on this, and how to apply and follow the GNU GPL, see | ||
803 | 667 | <http://www.gnu.org/licenses/>. | ||
804 | 668 | |||
805 | 669 | The GNU General Public License does not permit incorporating your program | ||
806 | 670 | into proprietary programs. If your program is a subroutine library, you | ||
807 | 671 | may consider it more useful to permit linking proprietary applications with | ||
808 | 672 | the library. If this is what you want to do, use the GNU Lesser General | ||
809 | 673 | Public License instead of this License. But first, please read | ||
810 | 674 | <http://www.gnu.org/philosophy/why-not-lgpl.html>. | ||
811 | 0 | 675 | ||
812 | === renamed file 'COPYING' => 'COPYING.moved' | |||
813 | === added file 'README' | |||
814 | --- README 1970-01-01 00:00:00 +0000 | |||
815 | +++ README 2015-06-28 23:49:12 +0000 | |||
816 | @@ -0,0 +1,11 @@ | |||
817 | 1 | Weather app for Ubuntu devices | ||
818 | 2 | |||
819 | 3 | To contribute: | ||
820 | 4 | https://wiki.ubuntu.com/Touch/CoreApps/Weather | ||
821 | 5 | https://wiki.ubuntu.com/Touch/CoreApps/DevelopmentGuide | ||
822 | 6 | |||
823 | 7 | The following essential packages are required to develop this app: | ||
824 | 8 | - ubuntu-sdk (see http://developer.ubuntu.com/start) | ||
825 | 9 | - intltool - run the `sudo apt-get install intltool` command for installation | ||
826 | 10 | |||
827 | 11 | See the debian/control file for an up-to-date list of dependencies | ||
828 | 0 | 12 | ||
829 | === renamed file 'README' => 'README.moved' | |||
830 | === added file 'README.translations' | |||
831 | --- README.translations 1970-01-01 00:00:00 +0000 | |||
832 | +++ README.translations 2015-06-28 23:49:12 +0000 | |||
833 | @@ -0,0 +1,37 @@ | |||
834 | 1 | # Updating translations | ||
835 | 2 | |||
836 | 3 | Translations for the Weather app happen in [Launchpad Translations][] and | ||
837 | 4 | are automatically committed daily on the trunk branch in the po/ folder. | ||
838 | 5 | |||
839 | 6 | They are then built and installed as part of the package build, so that | ||
840 | 7 | developers don't really need to worry about them. | ||
841 | 8 | |||
842 | 9 | However, there is one task that needs to be taken care of: exposing new | ||
843 | 10 | translatable messages to translators. So whenever you add new translatable | ||
844 | 11 | messages in the code, make sure to follow these steps: | ||
845 | 12 | |||
846 | 13 | 1. Run click-buddy to build the project and generate a new .pot file: | ||
847 | 14 | `click-buddy --dir .` | ||
848 | 15 | 2. Commit the generated .pot file: | ||
849 | 16 | `bzr commit -m"Updated translation template"` | ||
850 | 17 | 3. Push the branch and send a merge proposal as usual | ||
851 | 18 | |||
852 | 19 | And that's it, once the branch lands Launchpad should take care of all the rest! | ||
853 | 20 | |||
854 | 21 | # Behind the scenes | ||
855 | 22 | |||
856 | 23 | Behind the scenes, whenever the po/*.pot file (also known as translations template) | ||
857 | 24 | is committed to trunk Launchpad reads it and updates the translatable strings | ||
858 | 25 | exposed in the web UI. This will enable translators to work on the new strings. | ||
859 | 26 | The translations template contains all translatable strings that have been | ||
860 | 27 | extracted from the source code files. | ||
861 | 28 | |||
862 | 29 | Launchpad will then store translations in its database and will commit them daily | ||
863 | 30 | in the form of textual po/*.po files to trunk. The PO files are also usually | ||
864 | 31 | referred to as the translations files. You'll find a translation file for each | ||
865 | 32 | language the app has got at least a translated message available for. | ||
866 | 33 | |||
867 | 34 | Translations for core apps follow the standard [gettext format]. | ||
868 | 35 | |||
869 | 36 | [Launchpad Translations]: https://translations.launchpad.net/ubuntu-weather-app | ||
870 | 37 | [gettext format]: https://www.gnu.org/software/gettext/ | ||
871 | 0 | 38 | ||
872 | === renamed file 'README.translations' => 'README.translations.moved' | |||
873 | === added directory 'app' | |||
874 | === added file 'app/CMakeLists.txt' | |||
875 | --- app/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
876 | +++ app/CMakeLists.txt 2015-06-28 23:49:12 +0000 | |||
877 | @@ -0,0 +1,18 @@ | |||
878 | 1 | if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") | ||
879 | 2 | file(GLOB QML_JS_FILES *.qml *.js) | ||
880 | 3 | add_custom_target(ubuntu-weather-app_QMlFiles ALL SOURCES ${QML_JS_FILES}) | ||
881 | 4 | endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") | ||
882 | 5 | |||
883 | 6 | |||
884 | 7 | if(CLICK_MODE) | ||
885 | 8 | set(ICON ${ICON}) | ||
886 | 9 | install(FILES ${ICON} DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
887 | 10 | endif(CLICK_MODE) | ||
888 | 11 | |||
889 | 12 | install(FILES ${MAIN_QML} DESTINATION ${UBUNTU-WEATHER_APP_DIR}) | ||
890 | 13 | |||
891 | 14 | add_subdirectory(components) | ||
892 | 15 | add_subdirectory(data) | ||
893 | 16 | add_subdirectory(graphics) | ||
894 | 17 | add_subdirectory(ui) | ||
895 | 18 | |||
896 | 0 | 19 | ||
897 | === added directory 'app/components' | |||
898 | === added file 'app/components/CMakeLists.txt' | |||
899 | --- app/components/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
900 | +++ app/components/CMakeLists.txt 2015-06-28 23:49:12 +0000 | |||
901 | @@ -0,0 +1,7 @@ | |||
902 | 1 | add_subdirectory(ListItemActions) | ||
903 | 2 | |||
904 | 3 | file(GLOB COMPONENTS_QML_JS_FILES *.qml *.js) | ||
905 | 4 | |||
906 | 5 | add_custom_target(ubuntu-weather-app_components_QMlFiles ALL SOURCES ${COMPONENTS_QML_JS_FILES}) | ||
907 | 6 | |||
908 | 7 | install(FILES ${COMPONENTS_QML_JS_FILES} DESTINATION ${UBUNTU-WEATHER_APP_DIR}/components) | ||
909 | 0 | 8 | ||
910 | === added file 'app/components/CurrentLocation.qml' | |||
911 | --- app/components/CurrentLocation.qml 1970-01-01 00:00:00 +0000 | |||
912 | +++ app/components/CurrentLocation.qml 2015-06-28 23:49:12 +0000 | |||
913 | @@ -0,0 +1,84 @@ | |||
914 | 1 | /* | ||
915 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
916 | 3 | * | ||
917 | 4 | * This file is part of Ubuntu Weather App | ||
918 | 5 | * | ||
919 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
920 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
921 | 8 | * published by the Free Software Foundation. | ||
922 | 9 | * | ||
923 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
924 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
925 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
926 | 13 | * GNU General Public License for more details. | ||
927 | 14 | * | ||
928 | 15 | * You should have received a copy of the GNU General Public License | ||
929 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
930 | 17 | */ | ||
931 | 18 | |||
932 | 19 | import QtLocation 5.3 | ||
933 | 20 | import QtPositioning 5.2 | ||
934 | 21 | import QtQuick 2.4 | ||
935 | 22 | import Ubuntu.Components 1.2 | ||
936 | 23 | import "../data/WeatherApi.js" as WeatherApi | ||
937 | 24 | |||
938 | 25 | |||
939 | 26 | Item { | ||
940 | 27 | id: currentLocation | ||
941 | 28 | |||
942 | 29 | property string string: "Undefined" | ||
943 | 30 | |||
944 | 31 | function searchForLocation(lat, lon) { | ||
945 | 32 | WeatherApi.sendRequest({ | ||
946 | 33 | action: "searchByPoint", | ||
947 | 34 | params: { | ||
948 | 35 | coords: { | ||
949 | 36 | lat: lat, | ||
950 | 37 | lon: lon | ||
951 | 38 | } | ||
952 | 39 | } | ||
953 | 40 | }, searchResponseHandler) | ||
954 | 41 | } | ||
955 | 42 | |||
956 | 43 | function searchResponseHandler(msgObject) { | ||
957 | 44 | if (!msgObject.error) { | ||
958 | 45 | console.log("Loc to add:", JSON.stringify(msgObject.result.locations[0])) | ||
959 | 46 | storage.updateCurrentLocation(msgObject.result.locations[0]) | ||
960 | 47 | } | ||
961 | 48 | } | ||
962 | 49 | |||
963 | 50 | |||
964 | 51 | PositionSource { | ||
965 | 52 | id: currentPosition | ||
966 | 53 | updateInterval: 1000 | ||
967 | 54 | active: true | ||
968 | 55 | |||
969 | 56 | onPositionChanged: { | ||
970 | 57 | var coord = currentPosition.position.coordinate | ||
971 | 58 | if (coord.isValid) { | ||
972 | 59 | geocodeModel.query = coord | ||
973 | 60 | geocodeModel.update() | ||
974 | 61 | } | ||
975 | 62 | } | ||
976 | 63 | } | ||
977 | 64 | |||
978 | 65 | Plugin { | ||
979 | 66 | id: osmPlugin | ||
980 | 67 | name: "osm" | ||
981 | 68 | } | ||
982 | 69 | |||
983 | 70 | GeocodeModel { | ||
984 | 71 | id: geocodeModel | ||
985 | 72 | autoUpdate: false | ||
986 | 73 | plugin: osmPlugin | ||
987 | 74 | |||
988 | 75 | onCountChanged: { | ||
989 | 76 | // Update the currentLocation if one is found and it does not match the stored location | ||
990 | 77 | if (count > 0 && currentLocation.string !== geocodeModel.get(0).address.city) { | ||
991 | 78 | var loc = geocodeModel.get(0) | ||
992 | 79 | currentLocation.string = loc.address.city | ||
993 | 80 | searchForLocation(loc.coordinate.latitude, loc.coordinate.longitude) | ||
994 | 81 | } | ||
995 | 82 | } | ||
996 | 83 | } | ||
997 | 84 | } | ||
998 | 0 | 85 | ||
999 | === added file 'app/components/DayDelegate.qml' | |||
1000 | --- app/components/DayDelegate.qml 1970-01-01 00:00:00 +0000 | |||
1001 | +++ app/components/DayDelegate.qml 2015-06-28 23:49:12 +0000 | |||
1002 | @@ -0,0 +1,245 @@ | |||
1003 | 1 | /* | ||
1004 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
1005 | 3 | * | ||
1006 | 4 | * This file is part of Ubuntu Weather App | ||
1007 | 5 | * | ||
1008 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
1009 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1010 | 8 | * published by the Free Software Foundation. | ||
1011 | 9 | * | ||
1012 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
1013 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1014 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1015 | 13 | * GNU General Public License for more details. | ||
1016 | 14 | * | ||
1017 | 15 | * You should have received a copy of the GNU General Public License | ||
1018 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1019 | 17 | */ | ||
1020 | 18 | |||
1021 | 19 | import QtQuick 2.4 | ||
1022 | 20 | import Ubuntu.Components 1.2 | ||
1023 | 21 | |||
1024 | 22 | ListItem { | ||
1025 | 23 | id: dayDelegate | ||
1026 | 24 | height: collapsedHeight | ||
1027 | 25 | |||
1028 | 26 | property int collapsedHeight: units.gu(8) | ||
1029 | 27 | property int expandedHeight: collapsedHeight + units.gu(4) + extraInfoColumn.height | ||
1030 | 28 | |||
1031 | 29 | property alias day: dayLabel.text | ||
1032 | 30 | property alias image: weatherImage.name | ||
1033 | 31 | property alias high: highLabel.text | ||
1034 | 32 | property alias low: lowLabel.text | ||
1035 | 33 | |||
1036 | 34 | property alias chanceOfRain: chanceOfRainForecast.chance | ||
1037 | 35 | property alias humidity: humidityForecast.value | ||
1038 | 36 | property alias pollen: pollenForecast.value | ||
1039 | 37 | property alias sunrise: sunriseForecast.value | ||
1040 | 38 | property alias sunset: sunsetForecast.value | ||
1041 | 39 | property alias wind: windForecast.value | ||
1042 | 40 | property alias uvIndex: uvIndexForecast.value | ||
1043 | 41 | |||
1044 | 42 | state: "normal" | ||
1045 | 43 | states: [ | ||
1046 | 44 | State { | ||
1047 | 45 | name: "normal" | ||
1048 | 46 | PropertyChanges { | ||
1049 | 47 | target: dayDelegate | ||
1050 | 48 | height: collapsedHeight | ||
1051 | 49 | } | ||
1052 | 50 | }, | ||
1053 | 51 | State { | ||
1054 | 52 | name: "expanded" | ||
1055 | 53 | PropertyChanges { | ||
1056 | 54 | target: dayDelegate | ||
1057 | 55 | height: expandedHeight | ||
1058 | 56 | } | ||
1059 | 57 | PropertyChanges { | ||
1060 | 58 | target: expandedInfo | ||
1061 | 59 | opacity: 1 | ||
1062 | 60 | } | ||
1063 | 61 | } | ||
1064 | 62 | ] | ||
1065 | 63 | |||
1066 | 64 | transitions: [ | ||
1067 | 65 | Transition { | ||
1068 | 66 | from: "normal" | ||
1069 | 67 | to: "expanded" | ||
1070 | 68 | SequentialAnimation { | ||
1071 | 69 | NumberAnimation { | ||
1072 | 70 | easing.type: Easing.InOutQuad | ||
1073 | 71 | properties: "height" | ||
1074 | 72 | } | ||
1075 | 73 | NumberAnimation { | ||
1076 | 74 | easing.type: Easing.InOutQuad | ||
1077 | 75 | properties: "opacity" | ||
1078 | 76 | } | ||
1079 | 77 | } | ||
1080 | 78 | }, | ||
1081 | 79 | Transition { | ||
1082 | 80 | from: "expanded" | ||
1083 | 81 | to: "normal" | ||
1084 | 82 | SequentialAnimation { | ||
1085 | 83 | NumberAnimation { | ||
1086 | 84 | easing.type: Easing.InOutQuad | ||
1087 | 85 | properties: "opacity" | ||
1088 | 86 | } | ||
1089 | 87 | NumberAnimation { | ||
1090 | 88 | easing.type: Easing.InOutQuad | ||
1091 | 89 | properties: "height" | ||
1092 | 90 | } | ||
1093 | 91 | } | ||
1094 | 92 | } | ||
1095 | 93 | ] | ||
1096 | 94 | |||
1097 | 95 | onClicked: { | ||
1098 | 96 | state = state === "normal" ? "expanded" : "normal" | ||
1099 | 97 | locationPages.collapseOtherDelegates(index) | ||
1100 | 98 | } | ||
1101 | 99 | |||
1102 | 100 | Item { | ||
1103 | 101 | id: mainInfo | ||
1104 | 102 | |||
1105 | 103 | height: collapsedHeight | ||
1106 | 104 | anchors { | ||
1107 | 105 | left: parent.left | ||
1108 | 106 | right: parent.right | ||
1109 | 107 | margins: units.gu(2) | ||
1110 | 108 | } | ||
1111 | 109 | |||
1112 | 110 | Label { | ||
1113 | 111 | id: dayLabel | ||
1114 | 112 | anchors { | ||
1115 | 113 | left: parent.left | ||
1116 | 114 | right: weatherImage.left | ||
1117 | 115 | rightMargin: units.gu(1) | ||
1118 | 116 | top: parent.top | ||
1119 | 117 | topMargin: (collapsedHeight - dayLabel.height) / 2 | ||
1120 | 118 | } | ||
1121 | 119 | elide: Text.ElideRight | ||
1122 | 120 | font.weight: Font.Light | ||
1123 | 121 | fontSize: "medium" | ||
1124 | 122 | } | ||
1125 | 123 | |||
1126 | 124 | Icon { | ||
1127 | 125 | id: weatherImage | ||
1128 | 126 | anchors { | ||
1129 | 127 | horizontalCenter: parent.horizontalCenter | ||
1130 | 128 | verticalCenter: dayLabel.verticalCenter | ||
1131 | 129 | } | ||
1132 | 130 | height: units.gu(3) | ||
1133 | 131 | width: units.gu(3) | ||
1134 | 132 | } | ||
1135 | 133 | |||
1136 | 134 | Label { | ||
1137 | 135 | id: lowLabel | ||
1138 | 136 | anchors { | ||
1139 | 137 | left: weatherImage.right | ||
1140 | 138 | right: highLabel.left | ||
1141 | 139 | rightMargin: units.gu(1) | ||
1142 | 140 | verticalCenter: dayLabel.verticalCenter | ||
1143 | 141 | } | ||
1144 | 142 | elide: Text.ElideRight | ||
1145 | 143 | font.pixelSize: units.gu(2) | ||
1146 | 144 | font.weight: Font.Light | ||
1147 | 145 | fontSize: "medium" | ||
1148 | 146 | height: units.gu(2) | ||
1149 | 147 | horizontalAlignment: Text.AlignRight | ||
1150 | 148 | verticalAlignment: Text.AlignTop // AlignTop appears to align bottom? | ||
1151 | 149 | } | ||
1152 | 150 | |||
1153 | 151 | Label { | ||
1154 | 152 | id: highLabel | ||
1155 | 153 | anchors { | ||
1156 | 154 | bottom: lowLabel.bottom | ||
1157 | 155 | right: parent.right | ||
1158 | 156 | } | ||
1159 | 157 | color: UbuntuColors.orange | ||
1160 | 158 | elide: Text.ElideRight | ||
1161 | 159 | font.pixelSize: units.gu(3) | ||
1162 | 160 | font.weight: Font.Normal | ||
1163 | 161 | height: units.gu(3) | ||
1164 | 162 | verticalAlignment: Text.AlignTop // AlignTop appears to align bottom? | ||
1165 | 163 | } | ||
1166 | 164 | } | ||
1167 | 165 | |||
1168 | 166 | Item { | ||
1169 | 167 | id: expandedInfo | ||
1170 | 168 | anchors { | ||
1171 | 169 | bottom: parent.bottom | ||
1172 | 170 | left: parent.left | ||
1173 | 171 | right: parent.right | ||
1174 | 172 | top: mainInfo.bottom | ||
1175 | 173 | bottomMargin: units.gu(2) | ||
1176 | 174 | } | ||
1177 | 175 | opacity: 0 | ||
1178 | 176 | visible: opacity !== 0 | ||
1179 | 177 | |||
1180 | 178 | Column { | ||
1181 | 179 | id: extraInfoColumn | ||
1182 | 180 | anchors { | ||
1183 | 181 | centerIn: parent | ||
1184 | 182 | } | ||
1185 | 183 | spacing: units.gu(2) | ||
1186 | 184 | |||
1187 | 185 | // FIXME: extended-infomation_* aren't actually on device | ||
1188 | 186 | |||
1189 | 187 | // Overview text | ||
1190 | 188 | Label { | ||
1191 | 189 | id: chanceOfRainForecast | ||
1192 | 190 | color: UbuntuColors.coolGrey | ||
1193 | 191 | fontSize: "x-large" | ||
1194 | 192 | horizontalAlignment: Text.AlignHCenter | ||
1195 | 193 | text: i18n.tr("Chance of rain") | ||
1196 | 194 | width: parent.width | ||
1197 | 195 | visible: false // FIXME: add overview text eg "Chance of flurries" | ||
1198 | 196 | |||
1199 | 197 | property int chance: 0 | ||
1200 | 198 | } | ||
1201 | 199 | |||
1202 | 200 | ForecastDetailsDelegate { | ||
1203 | 201 | id: windForecast | ||
1204 | 202 | forecast: i18n.tr("Winds") | ||
1205 | 203 | imageSource: "../graphics/extended-information_wind.svg" | ||
1206 | 204 | } | ||
1207 | 205 | |||
1208 | 206 | ForecastDetailsDelegate { | ||
1209 | 207 | id: uvIndexForecast | ||
1210 | 208 | imageSource: "../graphics/extended-information_uv-level.svg" | ||
1211 | 209 | forecast: i18n.tr("UV Index") | ||
1212 | 210 | } | ||
1213 | 211 | |||
1214 | 212 | ForecastDetailsDelegate { | ||
1215 | 213 | id: pollenForecast | ||
1216 | 214 | forecast: i18n.tr("Pollen") | ||
1217 | 215 | // FIXME: need icon | ||
1218 | 216 | } | ||
1219 | 217 | |||
1220 | 218 | ForecastDetailsDelegate { | ||
1221 | 219 | id: humidityForecast | ||
1222 | 220 | forecast: i18n.tr("Humidity") | ||
1223 | 221 | imageSource: "../graphics/extended-information_humidity.svg" | ||
1224 | 222 | } | ||
1225 | 223 | |||
1226 | 224 | ForecastDetailsDelegate { | ||
1227 | 225 | id: sunriseForecast | ||
1228 | 226 | forecast: i18n.tr("Sunrise") | ||
1229 | 227 | // FIXME: need icon | ||
1230 | 228 | } | ||
1231 | 229 | |||
1232 | 230 | ForecastDetailsDelegate { | ||
1233 | 231 | id: sunsetForecast | ||
1234 | 232 | forecast: i18n.tr("Sunset") | ||
1235 | 233 | // FIXME: need icon | ||
1236 | 234 | } | ||
1237 | 235 | } | ||
1238 | 236 | } | ||
1239 | 237 | |||
1240 | 238 | Component.onCompleted: { | ||
1241 | 239 | locationPages.collapseOtherDelegates.connect(function(otherIndex) { | ||
1242 | 240 | if (dayDelegate && typeof index !== "undefined" && otherIndex !== index) { | ||
1243 | 241 | state = "normal" | ||
1244 | 242 | } | ||
1245 | 243 | }); | ||
1246 | 244 | } | ||
1247 | 245 | } | ||
1248 | 0 | 246 | ||
1249 | === added file 'app/components/ExpandableListItem.qml' | |||
1250 | --- app/components/ExpandableListItem.qml 1970-01-01 00:00:00 +0000 | |||
1251 | +++ app/components/ExpandableListItem.qml 2015-06-28 23:49:12 +0000 | |||
1252 | @@ -0,0 +1,90 @@ | |||
1253 | 1 | /* | ||
1254 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
1255 | 3 | * | ||
1256 | 4 | * This file is part of Ubuntu Weather App | ||
1257 | 5 | * | ||
1258 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
1259 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1260 | 8 | * published by the Free Software Foundation. | ||
1261 | 9 | * | ||
1262 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
1263 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1264 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1265 | 13 | * GNU General Public License for more details. | ||
1266 | 14 | * | ||
1267 | 15 | * You should have received a copy of the GNU General Public License | ||
1268 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1269 | 17 | */ | ||
1270 | 18 | |||
1271 | 19 | import QtQuick 2.4 | ||
1272 | 20 | import Ubuntu.Components 1.2 | ||
1273 | 21 | import Ubuntu.Components.ListItems 1.0 as ListItem | ||
1274 | 22 | |||
1275 | 23 | /* | ||
1276 | 24 | Component which extends the SDK Expandable list item and provides a easy | ||
1277 | 25 | to use component where the title, subtitle and listview can be displayed. It | ||
1278 | 26 | matches the design specification provided for clock. | ||
1279 | 27 | */ | ||
1280 | 28 | |||
1281 | 29 | ListItem.Expandable { | ||
1282 | 30 | id: expandableListItem | ||
1283 | 31 | |||
1284 | 32 | property ListModel model | ||
1285 | 33 | property Component delegate | ||
1286 | 34 | property alias text: expandableHeader.text | ||
1287 | 35 | property alias subText: expandableHeader.subText | ||
1288 | 36 | property alias listViewHeight: expandableList.height | ||
1289 | 37 | |||
1290 | 38 | anchors { | ||
1291 | 39 | left: parent.left | ||
1292 | 40 | right: parent.right | ||
1293 | 41 | margins: units.gu(-2) | ||
1294 | 42 | } | ||
1295 | 43 | |||
1296 | 44 | collapseOnClick: true | ||
1297 | 45 | expandedHeight: contentColumn.height + units.gu(1) | ||
1298 | 46 | |||
1299 | 47 | Column { | ||
1300 | 48 | id: contentColumn | ||
1301 | 49 | |||
1302 | 50 | anchors { | ||
1303 | 51 | left: parent.left | ||
1304 | 52 | right: parent.right | ||
1305 | 53 | } | ||
1306 | 54 | |||
1307 | 55 | Item { | ||
1308 | 56 | width: parent.width | ||
1309 | 57 | height: expandableListItem.collapsedHeight | ||
1310 | 58 | |||
1311 | 59 | ListItem.Subtitled { | ||
1312 | 60 | id: expandableHeader | ||
1313 | 61 | onClicked: expandableListItem.expanded = true | ||
1314 | 62 | |||
1315 | 63 | Icon { | ||
1316 | 64 | id: arrow | ||
1317 | 65 | |||
1318 | 66 | width: units.gu(2) | ||
1319 | 67 | height: width | ||
1320 | 68 | anchors.right: parent.right | ||
1321 | 69 | anchors.verticalCenter: parent.verticalCenter | ||
1322 | 70 | |||
1323 | 71 | name: "go-down" | ||
1324 | 72 | color: "Grey" | ||
1325 | 73 | rotation: expandableListItem.expanded ? 180 : 0 | ||
1326 | 74 | |||
1327 | 75 | Behavior on rotation { | ||
1328 | 76 | UbuntuNumberAnimation {} | ||
1329 | 77 | } | ||
1330 | 78 | } | ||
1331 | 79 | } | ||
1332 | 80 | } | ||
1333 | 81 | |||
1334 | 82 | ListView { | ||
1335 | 83 | id: expandableList | ||
1336 | 84 | width: parent.width | ||
1337 | 85 | interactive: false | ||
1338 | 86 | model: expandableListItem.model | ||
1339 | 87 | delegate: expandableListItem.delegate | ||
1340 | 88 | } | ||
1341 | 89 | } | ||
1342 | 90 | } | ||
1343 | 0 | 91 | ||
1344 | === added file 'app/components/FastScroll.js' | |||
1345 | --- app/components/FastScroll.js 1970-01-01 00:00:00 +0000 | |||
1346 | +++ app/components/FastScroll.js 2015-06-28 23:49:12 +0000 | |||
1347 | @@ -0,0 +1,130 @@ | |||
1348 | 1 | /**************************************************************************** | ||
1349 | 2 | ** | ||
1350 | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). | ||
1351 | 4 | ** Copyright (C) 2014 Canonical Ltda | ||
1352 | 5 | ** All rights reserved. | ||
1353 | 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) | ||
1354 | 7 | ** | ||
1355 | 8 | ** This file is part of the Qt Components project. | ||
1356 | 9 | ** | ||
1357 | 10 | ** $QT_BEGIN_LICENSE:BSD$ | ||
1358 | 11 | ** You may use this file under the terms of the BSD license as follows: | ||
1359 | 12 | ** | ||
1360 | 13 | ** "Redistribution and use in source and binary forms, with or without | ||
1361 | 14 | ** modification, are permitted provided that the following conditions are | ||
1362 | 15 | ** met: | ||
1363 | 16 | ** * Redistributions of source code must retain the above copyright | ||
1364 | 17 | ** notice, this list of conditions and the following disclaimer. | ||
1365 | 18 | ** * Redistributions in binary form must reproduce the above copyright | ||
1366 | 19 | ** notice, this list of conditions and the following disclaimer in | ||
1367 | 20 | ** the documentation and/or other materials provided with the | ||
1368 | 21 | ** distribution. | ||
1369 | 22 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor | ||
1370 | 23 | ** the names of its contributors may be used to endorse or promote | ||
1371 | 24 | ** products derived from this software without specific prior written | ||
1372 | 25 | ** permission. | ||
1373 | 26 | ** | ||
1374 | 27 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
1375 | 28 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
1376 | 29 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
1377 | 30 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
1378 | 31 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
1379 | 32 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
1380 | 33 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1381 | 34 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1382 | 35 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1383 | 36 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
1384 | 37 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | ||
1385 | 38 | ** $QT_END_LICENSE$ | ||
1386 | 39 | ** | ||
1387 | 40 | ****************************************************************************/ | ||
1388 | 41 | |||
1389 | 42 | // FastScroll.js - this is just SectionScroller.js with a fix for | ||
1390 | 43 | // section.criteria == ViewSection.FirstCharacter | ||
1391 | 44 | var sectionData = []; | ||
1392 | 45 | var _sections = []; | ||
1393 | 46 | |||
1394 | 47 | function initialize(list) { | ||
1395 | 48 | initSectionData(list); | ||
1396 | 49 | } | ||
1397 | 50 | |||
1398 | 51 | function contains(name) { | ||
1399 | 52 | return (_sections.indexOf(name) > -1) | ||
1400 | 53 | } | ||
1401 | 54 | |||
1402 | 55 | function initSectionData(list) { | ||
1403 | 56 | if (!list || !list.model) return; | ||
1404 | 57 | sectionData = []; | ||
1405 | 58 | _sections = []; | ||
1406 | 59 | var current = "", | ||
1407 | 60 | prop = list.section.property, | ||
1408 | 61 | sectionText; | ||
1409 | 62 | |||
1410 | 63 | if (list.section.criteria === ViewSection.FullString) { | ||
1411 | 64 | for (var i = 0, count = list.model.count; i < count; i++) { | ||
1412 | 65 | sectionText = list.getSectionText(i) | ||
1413 | 66 | if (sectionText !== current) { | ||
1414 | 67 | current = sectionText; | ||
1415 | 68 | _sections.push(current); | ||
1416 | 69 | sectionData.push({ index: i, header: current }); | ||
1417 | 70 | } | ||
1418 | 71 | } | ||
1419 | 72 | } else if (list.section.criteria === ViewSection.FirstCharacter) { | ||
1420 | 73 | for (var i = 0, count = list.model.count; i < count; i++) { | ||
1421 | 74 | sectionText = list.getSectionText(i).substring(0, 1) | ||
1422 | 75 | if (sectionText !== current) { | ||
1423 | 76 | current = sectionText | ||
1424 | 77 | _sections.push(sectionText); | ||
1425 | 78 | sectionData.push({ index: i, header: current }); | ||
1426 | 79 | } | ||
1427 | 80 | } | ||
1428 | 81 | } | ||
1429 | 82 | } | ||
1430 | 83 | |||
1431 | 84 | function getSectionPositionString(name) { | ||
1432 | 85 | var val = _sections.indexOf(name); | ||
1433 | 86 | return val === 0 ? "first" : | ||
1434 | 87 | val === _sections.length - 1 ? "last" : false; | ||
1435 | 88 | } | ||
1436 | 89 | |||
1437 | 90 | function getAt(pos) { | ||
1438 | 91 | return _sections[pos] ? _sections[pos] : ""; | ||
1439 | 92 | } | ||
1440 | 93 | |||
1441 | 94 | function getRelativeSections(current) { | ||
1442 | 95 | var val = _sections.indexOf(current), | ||
1443 | 96 | sect = [], | ||
1444 | 97 | sl = _sections.length; | ||
1445 | 98 | |||
1446 | 99 | val = val < 1 ? 1 : val >= sl-1 ? sl-2 : val; | ||
1447 | 100 | sect = [getAt(val - 1), getAt(val), getAt(val + 1)]; | ||
1448 | 101 | |||
1449 | 102 | return sect; | ||
1450 | 103 | } | ||
1451 | 104 | |||
1452 | 105 | function getClosestSection(pos, down) { | ||
1453 | 106 | var tmp = (_sections.length) * pos; | ||
1454 | 107 | var val = Math.ceil(tmp) // TODO: better algorithm | ||
1455 | 108 | val = val < 2 ? 1 : val; | ||
1456 | 109 | return _sections[val-1]; | ||
1457 | 110 | } | ||
1458 | 111 | |||
1459 | 112 | function getNextSection(current) { | ||
1460 | 113 | var val = _sections.indexOf(current); | ||
1461 | 114 | return (val > -1 ? _sections[(val < _sections.length - 1 ? val + 1 : val)] : _sections[0]) || ""; | ||
1462 | 115 | } | ||
1463 | 116 | |||
1464 | 117 | function getPreviousSection(current) { | ||
1465 | 118 | var val = _sections.indexOf(current); | ||
1466 | 119 | return (val > -1 ? _sections[(val > 0 ? val - 1 : val)] : _sections[0]) || ""; | ||
1467 | 120 | } | ||
1468 | 121 | |||
1469 | 122 | function getIndexFor(sectionName) { | ||
1470 | 123 | var data = sectionData[_sections.indexOf(sectionName)] | ||
1471 | 124 | if (data) { | ||
1472 | 125 | var val = data.index; | ||
1473 | 126 | return val === 0 || val > 0 ? val : -1; | ||
1474 | 127 | } else { | ||
1475 | 128 | return -1 | ||
1476 | 129 | } | ||
1477 | 130 | } | ||
1478 | 0 | 131 | ||
1479 | === added file 'app/components/FastScroll.qml' | |||
1480 | --- app/components/FastScroll.qml 1970-01-01 00:00:00 +0000 | |||
1481 | +++ app/components/FastScroll.qml 2015-06-28 23:49:12 +0000 | |||
1482 | @@ -0,0 +1,321 @@ | |||
1483 | 1 | /**************************************************************************** | ||
1484 | 2 | ** | ||
1485 | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). | ||
1486 | 4 | ** Copyright (C) 2014, 2015 Canonical Ltda | ||
1487 | 5 | ** All rights reserved. | ||
1488 | 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) | ||
1489 | 7 | ** | ||
1490 | 8 | ** This file is part of the Qt Components project. | ||
1491 | 9 | ** | ||
1492 | 10 | ** $QT_BEGIN_LICENSE:BSD$ | ||
1493 | 11 | ** You may use this file under the terms of the BSD license as follows: | ||
1494 | 12 | ** | ||
1495 | 13 | ** "Redistribution and use in source and binary forms, with or without | ||
1496 | 14 | ** modification, are permitted provided that the following conditions are | ||
1497 | 15 | ** met: | ||
1498 | 16 | ** * Redistributions of source code must retain the above copyright | ||
1499 | 17 | ** notice, this list of conditions and the following disclaimer. | ||
1500 | 18 | ** * Redistributions in binary form must reproduce the above copyright | ||
1501 | 19 | ** notice, this list of conditions and the following disclaimer in | ||
1502 | 20 | ** the documentation and/or other materials provided with the | ||
1503 | 21 | ** distribution. | ||
1504 | 22 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor | ||
1505 | 23 | ** the names of its contributors may be used to endorse or promote | ||
1506 | 24 | ** products derived from this software without specific prior written | ||
1507 | 25 | ** permission. | ||
1508 | 26 | ** | ||
1509 | 27 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
1510 | 28 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
1511 | 29 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
1512 | 30 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
1513 | 31 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
1514 | 32 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
1515 | 33 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1516 | 34 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1517 | 35 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1518 | 36 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
1519 | 37 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | ||
1520 | 38 | ** $QT_END_LICENSE$ | ||
1521 | 39 | ** | ||
1522 | 40 | ****************************************************************************/ | ||
1523 | 41 | |||
1524 | 42 | // FastScroll.qml | ||
1525 | 43 | import QtQuick 2.4 | ||
1526 | 44 | import Ubuntu.Components 1.2 | ||
1527 | 45 | import "FastScroll.js" as Sections | ||
1528 | 46 | |||
1529 | 47 | Item { | ||
1530 | 48 | id: root | ||
1531 | 49 | |||
1532 | 50 | property ListView listView | ||
1533 | 51 | property int pinSize: units.gu(2) | ||
1534 | 52 | |||
1535 | 53 | readonly property var letters: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] | ||
1536 | 54 | readonly property alias fastScrolling: internal.fastScrolling | ||
1537 | 55 | readonly property bool showing: (rail.opacity !== 0.0) | ||
1538 | 56 | readonly property double minimumHeight: rail.height | ||
1539 | 57 | |||
1540 | 58 | width: units.gu(7) | ||
1541 | 59 | height: rail.height | ||
1542 | 60 | |||
1543 | 61 | onListViewChanged: { | ||
1544 | 62 | if (listView && listView.model) { | ||
1545 | 63 | internal.initDirtyObserver(); | ||
1546 | 64 | } else if (listView) { | ||
1547 | 65 | listView.modelChanged.connect(function() { | ||
1548 | 66 | if (listView.model) { | ||
1549 | 67 | internal.initDirtyObserver(); | ||
1550 | 68 | } | ||
1551 | 69 | }); | ||
1552 | 70 | } | ||
1553 | 71 | } | ||
1554 | 72 | |||
1555 | 73 | Connections { | ||
1556 | 74 | target: listView | ||
1557 | 75 | onCurrentIndexChanged: { | ||
1558 | 76 | if (currentIndex != -1) { | ||
1559 | 77 | rail.opacity = 0.0 | ||
1560 | 78 | } | ||
1561 | 79 | } | ||
1562 | 80 | } | ||
1563 | 81 | |||
1564 | 82 | Rectangle { | ||
1565 | 83 | id: magnified | ||
1566 | 84 | |||
1567 | 85 | color: Theme.palette.normal.overlay | ||
1568 | 86 | radius: height * 0.3 | ||
1569 | 87 | height: pinSize * 2 | ||
1570 | 88 | width: height | ||
1571 | 89 | opacity: internal.fastScrolling && root.enabled ? 1.0 : 0.0 | ||
1572 | 90 | x: -cursor.width - units.gu(3) | ||
1573 | 91 | y: { | ||
1574 | 92 | if (internal.currentItem) { | ||
1575 | 93 | var itemCenterY = rail.y + internal.currentItem.y + (internal.currentItem.height / 2) | ||
1576 | 94 | return (itemCenterY - (magnified.height / 2)) | ||
1577 | 95 | } else { | ||
1578 | 96 | return 0 | ||
1579 | 97 | } | ||
1580 | 98 | } | ||
1581 | 99 | |||
1582 | 100 | Label { | ||
1583 | 101 | anchors.fill: parent | ||
1584 | 102 | horizontalAlignment: Text.AlignHCenter | ||
1585 | 103 | verticalAlignment: Text.AlignVCenter | ||
1586 | 104 | text: internal.desireSection | ||
1587 | 105 | fontSize: "small" | ||
1588 | 106 | } | ||
1589 | 107 | |||
1590 | 108 | Behavior on opacity { | ||
1591 | 109 | UbuntuNumberAnimation {} | ||
1592 | 110 | } | ||
1593 | 111 | } | ||
1594 | 112 | |||
1595 | 113 | Rectangle { | ||
1596 | 114 | id: cursor | ||
1597 | 115 | |||
1598 | 116 | property bool showLabel: false | ||
1599 | 117 | property string currentSectionName: "" | ||
1600 | 118 | |||
1601 | 119 | radius: pinSize * 0.3 | ||
1602 | 120 | height: pinSize | ||
1603 | 121 | width: height | ||
1604 | 122 | color: Theme.palette.normal.foreground | ||
1605 | 123 | opacity: rail.opacity | ||
1606 | 124 | x: rail.x | ||
1607 | 125 | y: { | ||
1608 | 126 | if (internal.currentItem) { | ||
1609 | 127 | var itemCenterY = rail.y + internal.currentItem.y + (internal.currentItem.height / 2) | ||
1610 | 128 | return (itemCenterY - (cursor.height / 2)) | ||
1611 | 129 | } else { | ||
1612 | 130 | return 0 | ||
1613 | 131 | } | ||
1614 | 132 | } | ||
1615 | 133 | Behavior on y { | ||
1616 | 134 | enabled: !internal.fastScrolling | ||
1617 | 135 | UbuntuNumberAnimation { } | ||
1618 | 136 | } | ||
1619 | 137 | } | ||
1620 | 138 | |||
1621 | 139 | Column { | ||
1622 | 140 | id: rail | ||
1623 | 141 | |||
1624 | 142 | property bool isVisible: root.enabled && | ||
1625 | 143 | (listView.flicking || dragArea.pressed) && | ||
1626 | 144 | (listView.currentIndex == -1) | ||
1627 | 145 | anchors { | ||
1628 | 146 | right: parent.right | ||
1629 | 147 | rightMargin: units.gu(2) | ||
1630 | 148 | left: parent.left | ||
1631 | 149 | leftMargin: units.gu(2) | ||
1632 | 150 | top: parent.top | ||
1633 | 151 | } | ||
1634 | 152 | height: childrenRect.height | ||
1635 | 153 | opacity: 0.0 | ||
1636 | 154 | onIsVisibleChanged: { | ||
1637 | 155 | if (isVisible) { | ||
1638 | 156 | rail.opacity = 1.0 | ||
1639 | 157 | hideTimer.stop() | ||
1640 | 158 | } else if (!root.enabled) { | ||
1641 | 159 | rail.opacity = 0.0 | ||
1642 | 160 | } else { | ||
1643 | 161 | hideTimer.restart() | ||
1644 | 162 | } | ||
1645 | 163 | } | ||
1646 | 164 | |||
1647 | 165 | Behavior on opacity { | ||
1648 | 166 | UbuntuNumberAnimation { } | ||
1649 | 167 | } | ||
1650 | 168 | |||
1651 | 169 | Repeater { | ||
1652 | 170 | id: sectionsRepeater | ||
1653 | 171 | |||
1654 | 172 | model: root.letters | ||
1655 | 173 | Label { | ||
1656 | 174 | id: lbl | ||
1657 | 175 | |||
1658 | 176 | anchors.left: parent.left | ||
1659 | 177 | height: pinSize | ||
1660 | 178 | width: pinSize | ||
1661 | 179 | verticalAlignment: Text.AlignVCenter | ||
1662 | 180 | horizontalAlignment: Text.AlignHCenter | ||
1663 | 181 | text: modelData | ||
1664 | 182 | fontSize: "x-small" | ||
1665 | 183 | color: cursor.y === y ? "white" : Theme.palette.selected.backgroundText | ||
1666 | 184 | opacity: !internal.modelDirty && Sections.contains(text) ? 1.0 : 0.5 | ||
1667 | 185 | } | ||
1668 | 186 | } | ||
1669 | 187 | |||
1670 | 188 | Timer { | ||
1671 | 189 | id: hideTimer | ||
1672 | 190 | |||
1673 | 191 | running: false | ||
1674 | 192 | interval: 2000 | ||
1675 | 193 | onTriggered: rail.opacity = 0.0 | ||
1676 | 194 | } | ||
1677 | 195 | } | ||
1678 | 196 | |||
1679 | 197 | MouseArea { | ||
1680 | 198 | id: dragArea | ||
1681 | 199 | |||
1682 | 200 | anchors { | ||
1683 | 201 | left: parent.left | ||
1684 | 202 | right: parent.right | ||
1685 | 203 | } | ||
1686 | 204 | y: rail.y | ||
1687 | 205 | height: rail.height | ||
1688 | 206 | visible: rail.opacity == 1.0 | ||
1689 | 207 | |||
1690 | 208 | preventStealing: true | ||
1691 | 209 | onPressed: { | ||
1692 | 210 | internal.adjustContentPosition(mouseY) | ||
1693 | 211 | dragginTimer.start() | ||
1694 | 212 | } | ||
1695 | 213 | |||
1696 | 214 | onReleased: { | ||
1697 | 215 | dragginTimer.stop() | ||
1698 | 216 | internal.desireSection = "" | ||
1699 | 217 | internal.fastScrolling = false | ||
1700 | 218 | } | ||
1701 | 219 | |||
1702 | 220 | onPositionChanged: internal.adjustContentPosition(mouseY) | ||
1703 | 221 | |||
1704 | 222 | Timer { | ||
1705 | 223 | id: dragginTimer | ||
1706 | 224 | |||
1707 | 225 | running: false | ||
1708 | 226 | interval: 150 | ||
1709 | 227 | onTriggered: { | ||
1710 | 228 | internal.fastScrolling = true | ||
1711 | 229 | } | ||
1712 | 230 | } | ||
1713 | 231 | } | ||
1714 | 232 | |||
1715 | 233 | Timer { | ||
1716 | 234 | id: dirtyTimer | ||
1717 | 235 | interval: 500 | ||
1718 | 236 | running: false | ||
1719 | 237 | onTriggered: { | ||
1720 | 238 | Sections.initSectionData(listView); | ||
1721 | 239 | internal.modelDirty = false; | ||
1722 | 240 | } | ||
1723 | 241 | } | ||
1724 | 242 | |||
1725 | 243 | Timer { | ||
1726 | 244 | id: timerScroll | ||
1727 | 245 | |||
1728 | 246 | running: false | ||
1729 | 247 | interval: 10 | ||
1730 | 248 | onTriggered: { | ||
1731 | 249 | if (internal.desireSection != internal.currentSection) { | ||
1732 | 250 | var idx = Sections.getIndexFor(internal.desireSection) | ||
1733 | 251 | if (idx !== -1) { | ||
1734 | 252 | listView.cancelFlick() | ||
1735 | 253 | listView.positionViewAtIndex(idx, ListView.Beginning) | ||
1736 | 254 | } | ||
1737 | 255 | } | ||
1738 | 256 | } | ||
1739 | 257 | } | ||
1740 | 258 | |||
1741 | 259 | QtObject { | ||
1742 | 260 | id: internal | ||
1743 | 261 | |||
1744 | 262 | property string currentSection: listView.currentSection | ||
1745 | 263 | property string desireSection: "" | ||
1746 | 264 | property string targetSection: fastScrolling ? desireSection : currentSection | ||
1747 | 265 | property int oldY: 0 | ||
1748 | 266 | property bool modelDirty: false | ||
1749 | 267 | property bool down: true | ||
1750 | 268 | property bool fastScrolling: false | ||
1751 | 269 | property var currentItem: null | ||
1752 | 270 | |||
1753 | 271 | onTargetSectionChanged: moveIndicator(targetSection) | ||
1754 | 272 | |||
1755 | 273 | function initDirtyObserver() { | ||
1756 | 274 | Sections.initialize(listView); | ||
1757 | 275 | function dirtyObserver() { | ||
1758 | 276 | if (!internal.modelDirty) { | ||
1759 | 277 | internal.modelDirty = true; | ||
1760 | 278 | dirtyTimer.running = true; | ||
1761 | 279 | } | ||
1762 | 280 | } | ||
1763 | 281 | |||
1764 | 282 | if (listView.model.countChanged) | ||
1765 | 283 | listView.model.countChanged.connect(dirtyObserver); | ||
1766 | 284 | |||
1767 | 285 | if (listView.model.itemsChanged) | ||
1768 | 286 | listView.model.itemsChanged.connect(dirtyObserver); | ||
1769 | 287 | |||
1770 | 288 | if (listView.model.itemsInserted) | ||
1771 | 289 | listView.model.itemsInserted.connect(dirtyObserver); | ||
1772 | 290 | |||
1773 | 291 | if (listView.model.itemsMoved) | ||
1774 | 292 | listView.model.itemsMoved.connect(dirtyObserver); | ||
1775 | 293 | |||
1776 | 294 | if (listView.model.itemsRemoved) | ||
1777 | 295 | listView.model.itemsRemoved.connect(dirtyObserver); | ||
1778 | 296 | } | ||
1779 | 297 | |||
1780 | 298 | function adjustContentPosition(mouseY) { | ||
1781 | 299 | var child = rail.childAt(rail.width / 2, mouseY) | ||
1782 | 300 | if (!child || child.text === "") { | ||
1783 | 301 | return | ||
1784 | 302 | } | ||
1785 | 303 | var section = child.text | ||
1786 | 304 | if (internal.desireSection !== section) { | ||
1787 | 305 | internal.desireSection = section | ||
1788 | 306 | moveIndicator(section) | ||
1789 | 307 | if (dragArea.pressed) { | ||
1790 | 308 | timerScroll.restart() | ||
1791 | 309 | } | ||
1792 | 310 | } | ||
1793 | 311 | } | ||
1794 | 312 | |||
1795 | 313 | function moveIndicator(section) | ||
1796 | 314 | { | ||
1797 | 315 | var index = root.letters.indexOf(section) | ||
1798 | 316 | if (index != -1) { | ||
1799 | 317 | currentItem = sectionsRepeater.itemAt(index) | ||
1800 | 318 | } | ||
1801 | 319 | } | ||
1802 | 320 | } | ||
1803 | 321 | } | ||
1804 | 0 | 322 | ||
1805 | === added file 'app/components/ForecastDetailsDelegate.qml' | |||
1806 | --- app/components/ForecastDetailsDelegate.qml 1970-01-01 00:00:00 +0000 | |||
1807 | +++ app/components/ForecastDetailsDelegate.qml 2015-06-28 23:49:12 +0000 | |||
1808 | @@ -0,0 +1,48 @@ | |||
1809 | 1 | /* | ||
1810 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
1811 | 3 | * | ||
1812 | 4 | * This file is part of Ubuntu Weather App | ||
1813 | 5 | * | ||
1814 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
1815 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1816 | 8 | * published by the Free Software Foundation. | ||
1817 | 9 | * | ||
1818 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
1819 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1820 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1821 | 13 | * GNU General Public License for more details. | ||
1822 | 14 | * | ||
1823 | 15 | * You should have received a copy of the GNU General Public License | ||
1824 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1825 | 17 | */ | ||
1826 | 18 | |||
1827 | 19 | import QtQuick 2.4 | ||
1828 | 20 | import Ubuntu.Components 1.2 | ||
1829 | 21 | |||
1830 | 22 | Row { | ||
1831 | 23 | height: icon.height | ||
1832 | 24 | spacing: units.gu(2) | ||
1833 | 25 | visible: value !== "" | ||
1834 | 26 | |||
1835 | 27 | property alias imageSource: icon.source | ||
1836 | 28 | property alias forecast: forecastLabel.text | ||
1837 | 29 | property alias value: forecastValue.text | ||
1838 | 30 | |||
1839 | 31 | Icon { | ||
1840 | 32 | id: icon | ||
1841 | 33 | color: "#000" | ||
1842 | 34 | height: units.gu(2) | ||
1843 | 35 | width: height | ||
1844 | 36 | } | ||
1845 | 37 | |||
1846 | 38 | Label { | ||
1847 | 39 | id: forecastLabel | ||
1848 | 40 | elide: Text.ElideRight | ||
1849 | 41 | width: units.gu(8) | ||
1850 | 42 | } | ||
1851 | 43 | |||
1852 | 44 | Label { | ||
1853 | 45 | id: forecastValue | ||
1854 | 46 | width: units.gu(10) | ||
1855 | 47 | } | ||
1856 | 48 | } | ||
1857 | 0 | 49 | ||
1858 | === added file 'app/components/HeaderRow.qml' | |||
1859 | --- app/components/HeaderRow.qml 1970-01-01 00:00:00 +0000 | |||
1860 | +++ app/components/HeaderRow.qml 2015-06-28 23:49:12 +0000 | |||
1861 | @@ -0,0 +1,62 @@ | |||
1862 | 1 | /* | ||
1863 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
1864 | 3 | * | ||
1865 | 4 | * This file is part of Ubuntu Weather App | ||
1866 | 5 | * | ||
1867 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
1868 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1869 | 8 | * published by the Free Software Foundation. | ||
1870 | 9 | * | ||
1871 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
1872 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1873 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1874 | 13 | * GNU General Public License for more details. | ||
1875 | 14 | * | ||
1876 | 15 | * You should have received a copy of the GNU General Public License | ||
1877 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1878 | 17 | */ | ||
1879 | 18 | |||
1880 | 19 | import QtQuick 2.4 | ||
1881 | 20 | import QtQuick.Layouts 1.1 | ||
1882 | 21 | import Ubuntu.Components 1.2 | ||
1883 | 22 | |||
1884 | 23 | RowLayout { | ||
1885 | 24 | id: headerRow | ||
1886 | 25 | |||
1887 | 26 | property alias locationName: locationNameLabel.text | ||
1888 | 27 | |||
1889 | 28 | width: parent.width | ||
1890 | 29 | |||
1891 | 30 | Label { | ||
1892 | 31 | id: locationNameLabel | ||
1893 | 32 | color: UbuntuColors.darkGrey | ||
1894 | 33 | elide: Text.ElideRight | ||
1895 | 34 | font.weight: Font.Normal | ||
1896 | 35 | fontSize: "large" | ||
1897 | 36 | height: settingsButton.height | ||
1898 | 37 | Layout.fillWidth: true | ||
1899 | 38 | verticalAlignment: Text.AlignVCenter | ||
1900 | 39 | } | ||
1901 | 40 | |||
1902 | 41 | AbstractButton { | ||
1903 | 42 | id: settingsButton | ||
1904 | 43 | height: width | ||
1905 | 44 | width: units.gu(4) | ||
1906 | 45 | |||
1907 | 46 | onClicked: mainPageStack.push(Qt.resolvedUrl("../ui/SettingsPage.qml")) | ||
1908 | 47 | |||
1909 | 48 | Rectangle { | ||
1910 | 49 | anchors.fill: parent | ||
1911 | 50 | color: Theme.palette.selected.background | ||
1912 | 51 | visible: parent.pressed | ||
1913 | 52 | } | ||
1914 | 53 | |||
1915 | 54 | Icon { | ||
1916 | 55 | anchors.centerIn: parent | ||
1917 | 56 | color: UbuntuColors.darkGrey | ||
1918 | 57 | height: width | ||
1919 | 58 | name: "settings" | ||
1920 | 59 | width: units.gu(2.5) | ||
1921 | 60 | } | ||
1922 | 61 | } | ||
1923 | 62 | } | ||
1924 | 0 | 63 | ||
1925 | === added file 'app/components/HomeGraphic.qml' | |||
1926 | --- app/components/HomeGraphic.qml 1970-01-01 00:00:00 +0000 | |||
1927 | +++ app/components/HomeGraphic.qml 2015-06-28 23:49:12 +0000 | |||
1928 | @@ -0,0 +1,39 @@ | |||
1929 | 1 | /* | ||
1930 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
1931 | 3 | * | ||
1932 | 4 | * This file is part of Ubuntu Weather App | ||
1933 | 5 | * | ||
1934 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
1935 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1936 | 8 | * published by the Free Software Foundation. | ||
1937 | 9 | * | ||
1938 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
1939 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1940 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1941 | 13 | * GNU General Public License for more details. | ||
1942 | 14 | * | ||
1943 | 15 | * You should have received a copy of the GNU General Public License | ||
1944 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1945 | 17 | */ | ||
1946 | 18 | |||
1947 | 19 | import QtQuick 2.4 | ||
1948 | 20 | import Ubuntu.Components 1.2 | ||
1949 | 21 | |||
1950 | 22 | Item { | ||
1951 | 23 | height: units.gu(32) | ||
1952 | 24 | width: parent.width | ||
1953 | 25 | |||
1954 | 26 | property alias icon: iconImage.source | ||
1955 | 27 | |||
1956 | 28 | // TODO: will be on 'rails' (horizontal listview?) to reveal hourly forecast | ||
1957 | 29 | Image { | ||
1958 | 30 | id: iconImage | ||
1959 | 31 | anchors { | ||
1960 | 32 | centerIn: parent | ||
1961 | 33 | } | ||
1962 | 34 | fillMode: Image.PreserveAspectFit | ||
1963 | 35 | height: parent.height | ||
1964 | 36 | width: parent.width | ||
1965 | 37 | } | ||
1966 | 38 | } | ||
1967 | 39 | |||
1968 | 0 | 40 | ||
1969 | === added file 'app/components/HomeHourly.qml' | |||
1970 | --- app/components/HomeHourly.qml 1970-01-01 00:00:00 +0000 | |||
1971 | +++ app/components/HomeHourly.qml 2015-06-28 23:49:12 +0000 | |||
1972 | @@ -0,0 +1,101 @@ | |||
1973 | 1 | /* | ||
1974 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
1975 | 3 | * | ||
1976 | 4 | * This file is part of Ubuntu Weather App | ||
1977 | 5 | * | ||
1978 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
1979 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1980 | 8 | * published by the Free Software Foundation. | ||
1981 | 9 | * | ||
1982 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
1983 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1984 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1985 | 13 | * GNU General Public License for more details. | ||
1986 | 14 | * | ||
1987 | 15 | * You should have received a copy of the GNU General Public License | ||
1988 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1989 | 17 | */ | ||
1990 | 18 | |||
1991 | 19 | import QtQuick 2.4 | ||
1992 | 20 | import Ubuntu.Components 1.2 | ||
1993 | 21 | |||
1994 | 22 | ListView { | ||
1995 | 23 | id: homeHourly | ||
1996 | 24 | |||
1997 | 25 | clip:true | ||
1998 | 26 | height: parent ? parent.height : undefined | ||
1999 | 27 | width: parent ? parent.width : undefined | ||
2000 | 28 | model: forecasts.length | ||
2001 | 29 | orientation: ListView.Horizontal | ||
2002 | 30 | |||
2003 | 31 | property string currentDate: Qt.formatTime(new Date()) | ||
2004 | 32 | |||
2005 | 33 | onVisibleChanged: { | ||
2006 | 34 | if(visible) { | ||
2007 | 35 | ListView.model = forecasts.length | ||
2008 | 36 | } | ||
2009 | 37 | } | ||
2010 | 38 | |||
2011 | 39 | MouseArea { | ||
2012 | 40 | anchors.fill: parent | ||
2013 | 41 | onClicked: { | ||
2014 | 42 | homeGraphic.visible = true | ||
2015 | 43 | } | ||
2016 | 44 | } | ||
2017 | 45 | |||
2018 | 46 | delegate: Item { | ||
2019 | 47 | id: delegate | ||
2020 | 48 | |||
2021 | 49 | property var hourData: forecasts[index] | ||
2022 | 50 | |||
2023 | 51 | height: parent.height | ||
2024 | 52 | width: childrenRect.width | ||
2025 | 53 | |||
2026 | 54 | Column { | ||
2027 | 55 | id: hourColumn | ||
2028 | 56 | |||
2029 | 57 | anchors.verticalCenter: parent.verticalCenter | ||
2030 | 58 | height: childrenRect.height | ||
2031 | 59 | width: units.gu(10) | ||
2032 | 60 | |||
2033 | 61 | Label { | ||
2034 | 62 | anchors.horizontalCenter: parent.horizontalCenter | ||
2035 | 63 | fontSize: "small" | ||
2036 | 64 | font.weight: Font.Light | ||
2037 | 65 | text: currentDate.search(Qt.locale().amText) !== -1 || currentDate.search(Qt.locale().pmText) !== -1 ? "%1 %2".arg(formatTimestamp(hourData.date, 'ddd')).arg(formatTime(hourData.date, 'hap')) : "%1 %2".arg(formatTimestamp(hourData.date, 'ddd')).arg(formatTime(hourData.date, 'h:mm')) | ||
2038 | 66 | } | ||
2039 | 67 | |||
2040 | 68 | Item { | ||
2041 | 69 | anchors.horizontalCenter: parent.horizontalCenter | ||
2042 | 70 | height: units.gu(7) | ||
2043 | 71 | width: units.gu(7) | ||
2044 | 72 | |||
2045 | 73 | Icon { | ||
2046 | 74 | anchors { | ||
2047 | 75 | fill: parent | ||
2048 | 76 | margins: units.gu(0.5) | ||
2049 | 77 | } | ||
2050 | 78 | color: UbuntuColors.orange | ||
2051 | 79 | name: (hourData.icon !== undefined && iconMap[hourData.icon] !== undefined) ? iconMap[hourData.icon] : "" | ||
2052 | 80 | } | ||
2053 | 81 | } | ||
2054 | 82 | |||
2055 | 83 | Label { | ||
2056 | 84 | anchors.horizontalCenter: parent.horizontalCenter | ||
2057 | 85 | font.pixelSize: units.gu(3) | ||
2058 | 86 | font.weight: Font.Light | ||
2059 | 87 | text: Math.round(hourData[tempUnits].temp).toString()+settings.tempScale | ||
2060 | 88 | } | ||
2061 | 89 | } | ||
2062 | 90 | |||
2063 | 91 | Rectangle { | ||
2064 | 92 | anchors.verticalCenter: parent.verticalCenter | ||
2065 | 93 | color: UbuntuColors.darkGrey | ||
2066 | 94 | height: hourColumn.height | ||
2067 | 95 | opacity: 0.2 | ||
2068 | 96 | visible: index > 0 | ||
2069 | 97 | width: units.gu(0.1) | ||
2070 | 98 | } | ||
2071 | 99 | } | ||
2072 | 100 | } | ||
2073 | 101 | |||
2074 | 0 | 102 | ||
2075 | === added file 'app/components/HomeTempInfo.qml' | |||
2076 | --- app/components/HomeTempInfo.qml 1970-01-01 00:00:00 +0000 | |||
2077 | +++ app/components/HomeTempInfo.qml 2015-06-28 23:49:12 +0000 | |||
2078 | @@ -0,0 +1,73 @@ | |||
2079 | 1 | /* | ||
2080 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
2081 | 3 | * | ||
2082 | 4 | * This file is part of Ubuntu Weather App | ||
2083 | 5 | * | ||
2084 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
2085 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2086 | 8 | * published by the Free Software Foundation. | ||
2087 | 9 | * | ||
2088 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
2089 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2090 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2091 | 13 | * GNU General Public License for more details. | ||
2092 | 14 | * | ||
2093 | 15 | * You should have received a copy of the GNU General Public License | ||
2094 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2095 | 17 | */ | ||
2096 | 18 | |||
2097 | 19 | import QtQuick 2.4 | ||
2098 | 20 | import Ubuntu.Components 1.2 | ||
2099 | 21 | |||
2100 | 22 | |||
2101 | 23 | Column { | ||
2102 | 24 | anchors { | ||
2103 | 25 | left: parent.left | ||
2104 | 26 | right: parent.right | ||
2105 | 27 | } | ||
2106 | 28 | spacing: units.gu(1) | ||
2107 | 29 | |||
2108 | 30 | property alias description: descriptionLabel.text | ||
2109 | 31 | property alias high: highLabel.text | ||
2110 | 32 | property alias low: lowLabel.text | ||
2111 | 33 | property alias now: nowLabel.text | ||
2112 | 34 | |||
2113 | 35 | Label { | ||
2114 | 36 | font.weight: Font.Light | ||
2115 | 37 | fontSize: "small" | ||
2116 | 38 | text: i18n.tr("Today") | ||
2117 | 39 | } | ||
2118 | 40 | |||
2119 | 41 | Label { | ||
2120 | 42 | id: descriptionLabel | ||
2121 | 43 | font.weight: Font.Normal | ||
2122 | 44 | fontSize: "large" | ||
2123 | 45 | } | ||
2124 | 46 | |||
2125 | 47 | Row { | ||
2126 | 48 | spacing: units.gu(2) | ||
2127 | 49 | |||
2128 | 50 | Label { | ||
2129 | 51 | id: nowLabel | ||
2130 | 52 | color: UbuntuColors.orange | ||
2131 | 53 | font.pixelSize: units.gu(8) | ||
2132 | 54 | font.weight: Font.Light | ||
2133 | 55 | height: units.gu(8) | ||
2134 | 56 | verticalAlignment: Text.AlignBottom // AlignBottom seems to put it at the top? | ||
2135 | 57 | } | ||
2136 | 58 | |||
2137 | 59 | Column { | ||
2138 | 60 | Label { | ||
2139 | 61 | id: lowLabel | ||
2140 | 62 | font.weight: Font.Light | ||
2141 | 63 | fontSize: "medium" | ||
2142 | 64 | } | ||
2143 | 65 | |||
2144 | 66 | Label { | ||
2145 | 67 | id: highLabel | ||
2146 | 68 | font.weight: Font.Light | ||
2147 | 69 | fontSize: "medium" | ||
2148 | 70 | } | ||
2149 | 71 | } | ||
2150 | 72 | } | ||
2151 | 73 | } | ||
2152 | 0 | 74 | ||
2153 | === added directory 'app/components/ListItemActions' | |||
2154 | === added file 'app/components/ListItemActions/CMakeLists.txt' | |||
2155 | --- app/components/ListItemActions/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2156 | +++ app/components/ListItemActions/CMakeLists.txt 2015-06-28 23:49:12 +0000 | |||
2157 | @@ -0,0 +1,5 @@ | |||
2158 | 1 | file(GLOB LISTITEMACTIONS_QML_JS_FILES *.qml *.js) | ||
2159 | 2 | |||
2160 | 3 | add_custom_target(ubuntu-weather-app_listitemactions_QMlFiles ALL SOURCES ${LISTITEMACTIONS_QML_JS_FILES}) | ||
2161 | 4 | |||
2162 | 5 | install(FILES ${LISTITEMACTIONS_QML_JS_FILES} DESTINATION ${UBUNTU-WEATHER_APP_DIR}/components/ListItemActions) | ||
2163 | 0 | 6 | ||
2164 | === added file 'app/components/ListItemActions/CheckBox.qml' | |||
2165 | --- app/components/ListItemActions/CheckBox.qml 1970-01-01 00:00:00 +0000 | |||
2166 | +++ app/components/ListItemActions/CheckBox.qml 2015-06-28 23:49:12 +0000 | |||
2167 | @@ -0,0 +1,25 @@ | |||
2168 | 1 | /* | ||
2169 | 2 | * Copyright (C) 2012-2014, 2015 Canonical, Ltd. | ||
2170 | 3 | * | ||
2171 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2172 | 5 | * it under the terms of the GNU General Public License as published by | ||
2173 | 6 | * the Free Software Foundation; version 3. | ||
2174 | 7 | * | ||
2175 | 8 | * This program is distributed in the hope that it will be useful, | ||
2176 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2177 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2178 | 11 | * GNU General Public License for more details. | ||
2179 | 12 | * | ||
2180 | 13 | * You should have received a copy of the GNU General Public License | ||
2181 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2182 | 15 | */ | ||
2183 | 16 | |||
2184 | 17 | import QtQuick 2.4 | ||
2185 | 18 | import Ubuntu.Components 1.2 | ||
2186 | 19 | |||
2187 | 20 | CheckBox { | ||
2188 | 21 | checked: root.selected | ||
2189 | 22 | width: implicitWidth | ||
2190 | 23 | // disable item mouse area to avoid conflicts with parent mouse area | ||
2191 | 24 | __mouseArea.enabled: false | ||
2192 | 25 | } | ||
2193 | 0 | 26 | ||
2194 | === added file 'app/components/ListItemActions/Remove.qml' | |||
2195 | --- app/components/ListItemActions/Remove.qml 1970-01-01 00:00:00 +0000 | |||
2196 | +++ app/components/ListItemActions/Remove.qml 2015-06-28 23:49:12 +0000 | |||
2197 | @@ -0,0 +1,27 @@ | |||
2198 | 1 | /* | ||
2199 | 2 | * Copyright (C) 2014, 2015 Andrew Hayzen <ahayzen@gmail.com> | ||
2200 | 3 | * Daniel Holm <d.holmen@gmail.com> | ||
2201 | 4 | * Victor Thompson <victor.thompson@gmail.com> | ||
2202 | 5 | * | ||
2203 | 6 | * This program is free software; you can redistribute it and/or modify | ||
2204 | 7 | * it under the terms of the GNU General Public License as published by | ||
2205 | 8 | * the Free Software Foundation; version 3. | ||
2206 | 9 | * | ||
2207 | 10 | * This program is distributed in the hope that it will be useful, | ||
2208 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2209 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2210 | 13 | * GNU General Public License for more details. | ||
2211 | 14 | * | ||
2212 | 15 | * You should have received a copy of the GNU General Public License | ||
2213 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2214 | 17 | */ | ||
2215 | 18 | |||
2216 | 19 | import QtQuick 2.4 | ||
2217 | 20 | import Ubuntu.Components 1.2 | ||
2218 | 21 | |||
2219 | 22 | Action { | ||
2220 | 23 | id: removeAction | ||
2221 | 24 | iconName: "delete" | ||
2222 | 25 | objectName: "swipeDeleteAction" | ||
2223 | 26 | text: i18n.tr("Remove") | ||
2224 | 27 | } | ||
2225 | 0 | 28 | ||
2226 | === added file 'app/components/ListItemReorderComponent.qml' | |||
2227 | --- app/components/ListItemReorderComponent.qml 1970-01-01 00:00:00 +0000 | |||
2228 | +++ app/components/ListItemReorderComponent.qml 2015-06-28 23:49:12 +0000 | |||
2229 | @@ -0,0 +1,106 @@ | |||
2230 | 1 | /* | ||
2231 | 2 | * Copyright (C) 2013, 2014, 2015 | ||
2232 | 3 | * Andrew Hayzen <ahayzen@gmail.com> | ||
2233 | 4 | * Nekhelesh Ramananthan <krnekhelesh@gmail.com> | ||
2234 | 5 | * Victor Thompson <victor.thompson@gmail.com> | ||
2235 | 6 | * | ||
2236 | 7 | * This program is free software; you can redistribute it and/or modify | ||
2237 | 8 | * it under the terms of the GNU General Public License as published by | ||
2238 | 9 | * the Free Software Foundation; version 3. | ||
2239 | 10 | * | ||
2240 | 11 | * This program is distributed in the hope that it will be useful, | ||
2241 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2242 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2243 | 14 | * GNU General Public License for more details. | ||
2244 | 15 | * | ||
2245 | 16 | * You should have received a copy of the GNU General Public License | ||
2246 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2247 | 18 | */ | ||
2248 | 19 | |||
2249 | 20 | import QtQuick 2.4 | ||
2250 | 21 | import Ubuntu.Components 1.2 | ||
2251 | 22 | |||
2252 | 23 | |||
2253 | 24 | Item { | ||
2254 | 25 | id: actionReorder | ||
2255 | 26 | width: units.gu(4) | ||
2256 | 27 | |||
2257 | 28 | Icon { | ||
2258 | 29 | anchors { | ||
2259 | 30 | horizontalCenter: parent.horizontalCenter | ||
2260 | 31 | verticalCenter: parent.verticalCenter | ||
2261 | 32 | } | ||
2262 | 33 | name: "navigation-menu" // TODO: use proper image | ||
2263 | 34 | height: width | ||
2264 | 35 | width: units.gu(3) | ||
2265 | 36 | } | ||
2266 | 37 | |||
2267 | 38 | MouseArea { | ||
2268 | 39 | id: actionReorderMouseArea | ||
2269 | 40 | anchors { | ||
2270 | 41 | fill: parent | ||
2271 | 42 | } | ||
2272 | 43 | property int startY: 0 | ||
2273 | 44 | property int startContentY: 0 | ||
2274 | 45 | |||
2275 | 46 | onPressed: { | ||
2276 | 47 | root.parent.parent.interactive = false; // stop scrolling of listview | ||
2277 | 48 | startY = root.y; | ||
2278 | 49 | startContentY = root.parent.parent.contentY; | ||
2279 | 50 | root.z += 10; // force ontop of other elements | ||
2280 | 51 | |||
2281 | 52 | console.debug("Reorder listitem pressed", root.y) | ||
2282 | 53 | } | ||
2283 | 54 | onMouseYChanged: root.y += mouse.y - (root.height / 2); | ||
2284 | 55 | onReleased: { | ||
2285 | 56 | console.debug("Reorder diff by position", getDiff()); | ||
2286 | 57 | |||
2287 | 58 | var diff = getDiff(); | ||
2288 | 59 | |||
2289 | 60 | // Remove the height of the actual item if moved down | ||
2290 | 61 | if (diff > 0) { | ||
2291 | 62 | diff -= 1; | ||
2292 | 63 | } | ||
2293 | 64 | |||
2294 | 65 | root.parent.parent.interactive = true; // reenable scrolling | ||
2295 | 66 | |||
2296 | 67 | if (diff === 0) { | ||
2297 | 68 | // Nothing has changed so reset the item | ||
2298 | 69 | // z index is restored after animation | ||
2299 | 70 | resetListItemYAnimation.start(); | ||
2300 | 71 | } | ||
2301 | 72 | else { | ||
2302 | 73 | var newIndex = index + diff; | ||
2303 | 74 | |||
2304 | 75 | if (newIndex < 0) { | ||
2305 | 76 | newIndex = 0; | ||
2306 | 77 | } | ||
2307 | 78 | else if (newIndex > root.parent.parent.count - 1) { | ||
2308 | 79 | newIndex = root.parent.parent.count - 1; | ||
2309 | 80 | } | ||
2310 | 81 | |||
2311 | 82 | root.z -= 10; // restore z index | ||
2312 | 83 | reorder(index, newIndex) | ||
2313 | 84 | } | ||
2314 | 85 | } | ||
2315 | 86 | |||
2316 | 87 | function getDiff() { | ||
2317 | 88 | // Get the amount of items that have been passed over (by centre) | ||
2318 | 89 | return Math.round((((root.y - startY) + (root.parent.parent.contentY - startContentY)) / root.height) + 0.5); | ||
2319 | 90 | } | ||
2320 | 91 | } | ||
2321 | 92 | |||
2322 | 93 | SequentialAnimation { | ||
2323 | 94 | id: resetListItemYAnimation | ||
2324 | 95 | UbuntuNumberAnimation { | ||
2325 | 96 | target: root; | ||
2326 | 97 | property: "y"; | ||
2327 | 98 | to: actionReorderMouseArea.startY | ||
2328 | 99 | } | ||
2329 | 100 | ScriptAction { | ||
2330 | 101 | script: { | ||
2331 | 102 | root.z -= 10; // restore z index | ||
2332 | 103 | } | ||
2333 | 104 | } | ||
2334 | 105 | } | ||
2335 | 106 | } | ||
2336 | 0 | 107 | ||
2337 | === added file 'app/components/ListItemWithActions.qml' | |||
2338 | --- app/components/ListItemWithActions.qml 1970-01-01 00:00:00 +0000 | |||
2339 | +++ app/components/ListItemWithActions.qml 2015-06-28 23:49:12 +0000 | |||
2340 | @@ -0,0 +1,496 @@ | |||
2341 | 1 | /* | ||
2342 | 2 | * Copyright (C) 2012-2015 Canonical, Ltd. | ||
2343 | 3 | * | ||
2344 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2345 | 5 | * it under the terms of the GNU General Public License as published by | ||
2346 | 6 | * the Free Software Foundation; version 3. | ||
2347 | 7 | * | ||
2348 | 8 | * This program is distributed in the hope that it will be useful, | ||
2349 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2350 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2351 | 11 | * GNU General Public License for more details. | ||
2352 | 12 | * | ||
2353 | 13 | * You should have received a copy of the GNU General Public License | ||
2354 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2355 | 15 | */ | ||
2356 | 16 | |||
2357 | 17 | import QtQuick 2.4 | ||
2358 | 18 | import Ubuntu.Components 1.2 | ||
2359 | 19 | import Ubuntu.Components.ListItems 1.0 as ListItem | ||
2360 | 20 | |||
2361 | 21 | |||
2362 | 22 | Item { | ||
2363 | 23 | id: root | ||
2364 | 24 | width: parent.width | ||
2365 | 25 | |||
2366 | 26 | property Action leftSideAction: null | ||
2367 | 27 | property list<Action> rightSideActions | ||
2368 | 28 | property double defaultHeight: units.gu(8) | ||
2369 | 29 | property bool locked: false | ||
2370 | 30 | property Action activeAction: null | ||
2371 | 31 | property var activeItem: null | ||
2372 | 32 | property bool triggerActionOnMouseRelease: false | ||
2373 | 33 | property color color: Theme.palette.normal.background | ||
2374 | 34 | property color selectedColor: "#E6E6E6" | ||
2375 | 35 | property bool selected: false | ||
2376 | 36 | property bool selectionMode: false | ||
2377 | 37 | property alias internalAnchors: mainContents.anchors | ||
2378 | 38 | default property alias contents: mainContents.children | ||
2379 | 39 | |||
2380 | 40 | readonly property double actionWidth: units.gu(4) | ||
2381 | 41 | readonly property double leftActionWidth: units.gu(10) | ||
2382 | 42 | readonly property double actionThreshold: actionWidth * 0.4 | ||
2383 | 43 | readonly property double threshold: 0.4 | ||
2384 | 44 | readonly property string swipeState: main.x == 0 ? "Normal" : main.x > 0 ? "LeftToRight" : "RightToLeft" | ||
2385 | 45 | readonly property alias swipping: mainItemMoving.running | ||
2386 | 46 | readonly property bool _showActions: mouseArea.pressed || swipeState != "Normal" || swipping | ||
2387 | 47 | |||
2388 | 48 | property alias _main: main // CUSTOM | ||
2389 | 49 | property alias pressed: mouseArea.pressed // CUSTOM | ||
2390 | 50 | |||
2391 | 51 | /* internal */ | ||
2392 | 52 | property var _visibleRightSideActions: filterVisibleActions(rightSideActions) | ||
2393 | 53 | |||
2394 | 54 | signal itemClicked(var mouse) | ||
2395 | 55 | signal itemPressAndHold(var mouse) | ||
2396 | 56 | |||
2397 | 57 | function returnToBoundsRTL(direction) | ||
2398 | 58 | { | ||
2399 | 59 | var actionFullWidth = actionWidth + units.gu(2) | ||
2400 | 60 | |||
2401 | 61 | // go back to normal state if swipping reverse | ||
2402 | 62 | if (direction === "LTR") { | ||
2403 | 63 | updatePosition(0) | ||
2404 | 64 | return | ||
2405 | 65 | } else if (!triggerActionOnMouseRelease) { | ||
2406 | 66 | updatePosition(-rightActionsView.width + units.gu(2)) | ||
2407 | 67 | return | ||
2408 | 68 | } | ||
2409 | 69 | |||
2410 | 70 | var xOffset = Math.abs(main.x) | ||
2411 | 71 | var index = Math.min(Math.floor(xOffset / actionFullWidth), _visibleRightSideActions.length) | ||
2412 | 72 | var newX = 0 | ||
2413 | 73 | |||
2414 | 74 | if (index === _visibleRightSideActions.length) { | ||
2415 | 75 | newX = -(rightActionsView.width - units.gu(2)) | ||
2416 | 76 | } else if (index >= 1) { | ||
2417 | 77 | newX = -(actionFullWidth * index) | ||
2418 | 78 | } | ||
2419 | 79 | |||
2420 | 80 | updatePosition(newX) | ||
2421 | 81 | } | ||
2422 | 82 | |||
2423 | 83 | function returnToBoundsLTR(direction) | ||
2424 | 84 | { | ||
2425 | 85 | var finalX = leftActionWidth | ||
2426 | 86 | if ((direction === "RTL") || (main.x <= (finalX * root.threshold))) | ||
2427 | 87 | finalX = 0 | ||
2428 | 88 | updatePosition(finalX) | ||
2429 | 89 | } | ||
2430 | 90 | |||
2431 | 91 | function returnToBounds(direction) | ||
2432 | 92 | { | ||
2433 | 93 | if (main.x < 0) { | ||
2434 | 94 | returnToBoundsRTL(direction) | ||
2435 | 95 | } else if (main.x > 0) { | ||
2436 | 96 | returnToBoundsLTR(direction) | ||
2437 | 97 | } else { | ||
2438 | 98 | updatePosition(0) | ||
2439 | 99 | } | ||
2440 | 100 | } | ||
2441 | 101 | |||
2442 | 102 | function contains(item, point, marginX) | ||
2443 | 103 | { | ||
2444 | 104 | var itemStartX = item.x - marginX | ||
2445 | 105 | var itemEndX = item.x + item.width + marginX | ||
2446 | 106 | return (point.x >= itemStartX) && (point.x <= itemEndX) && | ||
2447 | 107 | (point.y >= item.y) && (point.y <= (item.y + item.height)); | ||
2448 | 108 | } | ||
2449 | 109 | |||
2450 | 110 | function getActionAt(point) | ||
2451 | 111 | { | ||
2452 | 112 | if (leftSideAction && contains(leftActionViewLoader.item, point, 0)) { | ||
2453 | 113 | return leftSideAction | ||
2454 | 114 | } else if (contains(rightActionsView, point, 0)) { | ||
2455 | 115 | var newPoint = root.mapToItem(rightActionsView, point.x, point.y) | ||
2456 | 116 | for (var i = 0; i < rightActionsRepeater.count; i++) { | ||
2457 | 117 | var child = rightActionsRepeater.itemAt(i) | ||
2458 | 118 | if (contains(child, newPoint, units.gu(1))) { | ||
2459 | 119 | return i | ||
2460 | 120 | } | ||
2461 | 121 | } | ||
2462 | 122 | } | ||
2463 | 123 | return -1 | ||
2464 | 124 | } | ||
2465 | 125 | |||
2466 | 126 | function updateActiveAction() | ||
2467 | 127 | { | ||
2468 | 128 | if (triggerActionOnMouseRelease && | ||
2469 | 129 | (main.x <= -(root.actionWidth + units.gu(2))) && | ||
2470 | 130 | (main.x > -(rightActionsView.width - units.gu(2)))) { | ||
2471 | 131 | var actionFullWidth = actionWidth + units.gu(2) | ||
2472 | 132 | var xOffset = Math.abs(main.x) | ||
2473 | 133 | var index = Math.min(Math.floor(xOffset / actionFullWidth), _visibleRightSideActions.length) | ||
2474 | 134 | index = index - 1 | ||
2475 | 135 | if (index > -1) { | ||
2476 | 136 | root.activeItem = rightActionsRepeater.itemAt(index) | ||
2477 | 137 | root.activeAction = root._visibleRightSideActions[index] | ||
2478 | 138 | } | ||
2479 | 139 | } else { | ||
2480 | 140 | root.activeAction = null | ||
2481 | 141 | } | ||
2482 | 142 | } | ||
2483 | 143 | |||
2484 | 144 | function resetSwipe() | ||
2485 | 145 | { | ||
2486 | 146 | updatePosition(0) | ||
2487 | 147 | } | ||
2488 | 148 | |||
2489 | 149 | function filterVisibleActions(actions) | ||
2490 | 150 | { | ||
2491 | 151 | var visibleActions = [] | ||
2492 | 152 | for(var i = 0; i < actions.length; i++) { | ||
2493 | 153 | var action = actions[i] | ||
2494 | 154 | if (action.visible) { | ||
2495 | 155 | visibleActions.push(action) | ||
2496 | 156 | } | ||
2497 | 157 | } | ||
2498 | 158 | return visibleActions | ||
2499 | 159 | } | ||
2500 | 160 | |||
2501 | 161 | function updatePosition(pos) | ||
2502 | 162 | { | ||
2503 | 163 | if (!root.triggerActionOnMouseRelease && (pos !== 0)) { | ||
2504 | 164 | mouseArea.state = pos > 0 ? "RightToLeft" : "LeftToRight" | ||
2505 | 165 | } else { | ||
2506 | 166 | mouseArea.state = "" | ||
2507 | 167 | } | ||
2508 | 168 | main.x = pos | ||
2509 | 169 | } | ||
2510 | 170 | |||
2511 | 171 | // CUSTOM remove animation | ||
2512 | 172 | SequentialAnimation { | ||
2513 | 173 | id: removeAnimation | ||
2514 | 174 | |||
2515 | 175 | property var action | ||
2516 | 176 | |||
2517 | 177 | UbuntuNumberAnimation { | ||
2518 | 178 | target: root | ||
2519 | 179 | duration: UbuntuAnimation.BriskDuration | ||
2520 | 180 | property: "height"; | ||
2521 | 181 | to: 0 | ||
2522 | 182 | } | ||
2523 | 183 | ScriptAction { | ||
2524 | 184 | script: removeAnimation.action.trigger() | ||
2525 | 185 | } | ||
2526 | 186 | } | ||
2527 | 187 | |||
2528 | 188 | states: [ | ||
2529 | 189 | State { | ||
2530 | 190 | name: "select" | ||
2531 | 191 | when: selectionMode || selected | ||
2532 | 192 | PropertyChanges { | ||
2533 | 193 | target: selectionIcon | ||
2534 | 194 | source: Qt.resolvedUrl("ListItemActions/CheckBox.qml") | ||
2535 | 195 | anchors.leftMargin: units.gu(2) | ||
2536 | 196 | } | ||
2537 | 197 | PropertyChanges { | ||
2538 | 198 | target: root | ||
2539 | 199 | locked: true | ||
2540 | 200 | } | ||
2541 | 201 | PropertyChanges { | ||
2542 | 202 | target: main | ||
2543 | 203 | x: 0 | ||
2544 | 204 | } | ||
2545 | 205 | } | ||
2546 | 206 | ] | ||
2547 | 207 | |||
2548 | 208 | height: defaultHeight | ||
2549 | 209 | //clip: height !== defaultHeight // CUSTOM | ||
2550 | 210 | |||
2551 | 211 | Loader { // CUSTOM | ||
2552 | 212 | id: leftActionViewLoader | ||
2553 | 213 | anchors { | ||
2554 | 214 | top: parent.top | ||
2555 | 215 | bottom: parent.bottom | ||
2556 | 216 | right: main.left | ||
2557 | 217 | } | ||
2558 | 218 | asynchronous: true | ||
2559 | 219 | sourceComponent: leftSideAction ? leftActionViewComponent : undefined | ||
2560 | 220 | } | ||
2561 | 221 | |||
2562 | 222 | Component { // CUSTOM | ||
2563 | 223 | id: leftActionViewComponent | ||
2564 | 224 | |||
2565 | 225 | Rectangle { | ||
2566 | 226 | id: leftActionView | ||
2567 | 227 | width: root.leftActionWidth + actionThreshold | ||
2568 | 228 | color: UbuntuColors.red | ||
2569 | 229 | |||
2570 | 230 | Icon { | ||
2571 | 231 | id: leftActionIcon | ||
2572 | 232 | anchors { | ||
2573 | 233 | centerIn: parent | ||
2574 | 234 | horizontalCenterOffset: actionThreshold / 2 | ||
2575 | 235 | } | ||
2576 | 236 | objectName: "swipeDeleteAction" // CUSTOM | ||
2577 | 237 | name: leftSideAction && _showActions ? leftSideAction.iconName : "" | ||
2578 | 238 | color: Theme.palette.selected.field | ||
2579 | 239 | height: units.gu(3) | ||
2580 | 240 | width: units.gu(3) | ||
2581 | 241 | } | ||
2582 | 242 | } | ||
2583 | 243 | } | ||
2584 | 244 | |||
2585 | 245 | //Rectangle { | ||
2586 | 246 | Item { // CUSTOM | ||
2587 | 247 | id: rightActionsView | ||
2588 | 248 | |||
2589 | 249 | anchors { | ||
2590 | 250 | top: main.top | ||
2591 | 251 | left: main.right | ||
2592 | 252 | bottom: main.bottom | ||
2593 | 253 | } | ||
2594 | 254 | visible: _visibleRightSideActions.length > 0 | ||
2595 | 255 | width: rightActionsRepeater.count > 0 ? rightActionsRepeater.count * (root.actionWidth + units.gu(2)) + root.actionThreshold + units.gu(2) : 0 | ||
2596 | 256 | // color: "white" // CUSTOM | ||
2597 | 257 | |||
2598 | 258 | Row { | ||
2599 | 259 | anchors{ | ||
2600 | 260 | top: parent.top | ||
2601 | 261 | left: parent.left | ||
2602 | 262 | leftMargin: units.gu(2) | ||
2603 | 263 | right: parent.right | ||
2604 | 264 | rightMargin: units.gu(2) | ||
2605 | 265 | bottom: parent.bottom | ||
2606 | 266 | } | ||
2607 | 267 | spacing: units.gu(2) | ||
2608 | 268 | Repeater { | ||
2609 | 269 | id: rightActionsRepeater | ||
2610 | 270 | |||
2611 | 271 | model: _showActions ? _visibleRightSideActions : [] | ||
2612 | 272 | Item { | ||
2613 | 273 | property alias image: img | ||
2614 | 274 | |||
2615 | 275 | height: rightActionsView.height | ||
2616 | 276 | width: root.actionWidth | ||
2617 | 277 | |||
2618 | 278 | Icon { | ||
2619 | 279 | id: img | ||
2620 | 280 | |||
2621 | 281 | anchors.centerIn: parent | ||
2622 | 282 | objectName: rightSideActions[index].objectName // CUSTOM | ||
2623 | 283 | width: units.gu(3) | ||
2624 | 284 | height: units.gu(3) | ||
2625 | 285 | name: modelData.iconName | ||
2626 | 286 | color: root.activeAction === modelData ? UbuntuColors.orange : UbuntuColors.coolGrey // CUSTOM | ||
2627 | 287 | } | ||
2628 | 288 | } | ||
2629 | 289 | } | ||
2630 | 290 | } | ||
2631 | 291 | } | ||
2632 | 292 | |||
2633 | 293 | Rectangle { | ||
2634 | 294 | id: main | ||
2635 | 295 | objectName: "mainItem" | ||
2636 | 296 | |||
2637 | 297 | anchors { | ||
2638 | 298 | top: parent.top | ||
2639 | 299 | bottom: parent.bottom | ||
2640 | 300 | } | ||
2641 | 301 | |||
2642 | 302 | width: parent.width | ||
2643 | 303 | color: root.selected ? root.selectedColor : root.color | ||
2644 | 304 | |||
2645 | 305 | Loader { | ||
2646 | 306 | id: selectionIcon | ||
2647 | 307 | |||
2648 | 308 | anchors { | ||
2649 | 309 | left: main.left | ||
2650 | 310 | verticalCenter: main.verticalCenter | ||
2651 | 311 | } | ||
2652 | 312 | asynchronous: true // CUSTOM | ||
2653 | 313 | width: (status === Loader.Ready) ? item.implicitWidth : 0 | ||
2654 | 314 | visible: (status === Loader.Ready) && (item.width === item.implicitWidth) | ||
2655 | 315 | |||
2656 | 316 | Behavior on width { | ||
2657 | 317 | NumberAnimation { | ||
2658 | 318 | duration: UbuntuAnimation.SnapDuration | ||
2659 | 319 | } | ||
2660 | 320 | } | ||
2661 | 321 | } | ||
2662 | 322 | |||
2663 | 323 | Item { | ||
2664 | 324 | id: mainContents | ||
2665 | 325 | |||
2666 | 326 | anchors { | ||
2667 | 327 | left: selectionIcon.right | ||
2668 | 328 | //leftMargin: units.gu(2) // CUSTOM | ||
2669 | 329 | top: parent.top | ||
2670 | 330 | //topMargin: units.gu(1) // CUSTOM | ||
2671 | 331 | right: parent.right | ||
2672 | 332 | //rightMargin: units.gu(2) // CUSTOM | ||
2673 | 333 | bottom: parent.bottom | ||
2674 | 334 | //bottomMargin: units.gu(1) // CUSTOM | ||
2675 | 335 | } | ||
2676 | 336 | } | ||
2677 | 337 | |||
2678 | 338 | Behavior on x { | ||
2679 | 339 | UbuntuNumberAnimation { | ||
2680 | 340 | id: mainItemMoving | ||
2681 | 341 | |||
2682 | 342 | easing.type: Easing.OutElastic | ||
2683 | 343 | duration: UbuntuAnimation.SlowDuration | ||
2684 | 344 | } | ||
2685 | 345 | } | ||
2686 | 346 | } | ||
2687 | 347 | |||
2688 | 348 | SequentialAnimation { | ||
2689 | 349 | id: triggerAction | ||
2690 | 350 | |||
2691 | 351 | property var currentItem: root.activeItem ? root.activeItem.image : null | ||
2692 | 352 | |||
2693 | 353 | running: false | ||
2694 | 354 | ParallelAnimation { | ||
2695 | 355 | UbuntuNumberAnimation { | ||
2696 | 356 | target: triggerAction.currentItem | ||
2697 | 357 | property: "opacity" | ||
2698 | 358 | from: 1.0 | ||
2699 | 359 | to: 0.0 | ||
2700 | 360 | duration: UbuntuAnimation.SlowDuration | ||
2701 | 361 | easing {type: Easing.InOutBack; } | ||
2702 | 362 | } | ||
2703 | 363 | UbuntuNumberAnimation { | ||
2704 | 364 | target: triggerAction.currentItem | ||
2705 | 365 | properties: "width, height" | ||
2706 | 366 | from: units.gu(3) | ||
2707 | 367 | to: root.actionWidth | ||
2708 | 368 | duration: UbuntuAnimation.SlowDuration | ||
2709 | 369 | easing {type: Easing.InOutBack; } | ||
2710 | 370 | } | ||
2711 | 371 | } | ||
2712 | 372 | PropertyAction { | ||
2713 | 373 | target: triggerAction.currentItem | ||
2714 | 374 | properties: "width, height" | ||
2715 | 375 | value: units.gu(3) | ||
2716 | 376 | } | ||
2717 | 377 | PropertyAction { | ||
2718 | 378 | target: triggerAction.currentItem | ||
2719 | 379 | properties: "opacity" | ||
2720 | 380 | value: 1.0 | ||
2721 | 381 | } | ||
2722 | 382 | ScriptAction { | ||
2723 | 383 | script: { | ||
2724 | 384 | root.activeAction.triggered(root) | ||
2725 | 385 | mouseArea.state = "" | ||
2726 | 386 | } | ||
2727 | 387 | } | ||
2728 | 388 | PauseAnimation { | ||
2729 | 389 | duration: 500 | ||
2730 | 390 | } | ||
2731 | 391 | UbuntuNumberAnimation { | ||
2732 | 392 | target: main | ||
2733 | 393 | property: "x" | ||
2734 | 394 | to: 0 | ||
2735 | 395 | } | ||
2736 | 396 | } | ||
2737 | 397 | |||
2738 | 398 | MouseArea { | ||
2739 | 399 | id: mouseArea | ||
2740 | 400 | |||
2741 | 401 | property bool locked: root.locked || ((root.leftSideAction === null) && (root._visibleRightSideActions.count === 0)) // CUSTOM | ||
2742 | 402 | property bool manual: false | ||
2743 | 403 | property string direction: "None" | ||
2744 | 404 | property real lastX: -1 | ||
2745 | 405 | |||
2746 | 406 | anchors.fill: parent | ||
2747 | 407 | drag { | ||
2748 | 408 | target: locked ? null : main | ||
2749 | 409 | axis: Drag.XAxis | ||
2750 | 410 | minimumX: rightActionsView.visible ? -(rightActionsView.width) : 0 | ||
2751 | 411 | maximumX: leftSideAction ? leftActionViewLoader.item.width : 0 | ||
2752 | 412 | threshold: root.actionThreshold | ||
2753 | 413 | } | ||
2754 | 414 | |||
2755 | 415 | states: [ | ||
2756 | 416 | State { | ||
2757 | 417 | name: "LeftToRight" | ||
2758 | 418 | PropertyChanges { | ||
2759 | 419 | target: mouseArea | ||
2760 | 420 | drag.maximumX: 0 | ||
2761 | 421 | } | ||
2762 | 422 | }, | ||
2763 | 423 | State { | ||
2764 | 424 | name: "RightToLeft" | ||
2765 | 425 | PropertyChanges { | ||
2766 | 426 | target: mouseArea | ||
2767 | 427 | drag.minimumX: 0 | ||
2768 | 428 | } | ||
2769 | 429 | } | ||
2770 | 430 | ] | ||
2771 | 431 | |||
2772 | 432 | onMouseXChanged: { | ||
2773 | 433 | var offset = (lastX - mouseX) | ||
2774 | 434 | if (Math.abs(offset) <= root.actionThreshold) { | ||
2775 | 435 | return | ||
2776 | 436 | } | ||
2777 | 437 | lastX = mouseX | ||
2778 | 438 | direction = offset > 0 ? "RTL" : "LTR"; | ||
2779 | 439 | } | ||
2780 | 440 | |||
2781 | 441 | onPressed: { | ||
2782 | 442 | lastX = mouse.x | ||
2783 | 443 | } | ||
2784 | 444 | |||
2785 | 445 | onReleased: { | ||
2786 | 446 | if (root.triggerActionOnMouseRelease && root.activeAction) { | ||
2787 | 447 | triggerAction.start() | ||
2788 | 448 | } else { | ||
2789 | 449 | root.returnToBounds() | ||
2790 | 450 | root.activeAction = null | ||
2791 | 451 | } | ||
2792 | 452 | lastX = -1 | ||
2793 | 453 | direction = "None" | ||
2794 | 454 | } | ||
2795 | 455 | onClicked: { | ||
2796 | 456 | if (selectionMode) { // CUSTOM - selecting a listitem should toggle selection if in selectionMode | ||
2797 | 457 | selected = !selected | ||
2798 | 458 | return | ||
2799 | 459 | } else if (main.x === 0) { | ||
2800 | 460 | root.itemClicked(mouse) | ||
2801 | 461 | } else if (main.x > 0) { | ||
2802 | 462 | var action = getActionAt(Qt.point(mouse.x, mouse.y)) | ||
2803 | 463 | if (action && action !== -1) { | ||
2804 | 464 | //action.triggered(root) | ||
2805 | 465 | removeAnimation.action = action // CUSTOM - use our animation instead | ||
2806 | 466 | removeAnimation.start() // CUSTOM | ||
2807 | 467 | } | ||
2808 | 468 | } else { | ||
2809 | 469 | var actionIndex = getActionAt(Qt.point(mouse.x, mouse.y)) | ||
2810 | 470 | |||
2811 | 471 | if (actionIndex !== -1 && actionIndex !== leftSideAction) { // CUSTOM - can be leftAction | ||
2812 | 472 | root.activeItem = rightActionsRepeater.itemAt(actionIndex) | ||
2813 | 473 | root.activeAction = root.rightSideActions[actionIndex] | ||
2814 | 474 | triggerAction.start() | ||
2815 | 475 | return | ||
2816 | 476 | } | ||
2817 | 477 | } | ||
2818 | 478 | root.resetSwipe() | ||
2819 | 479 | } | ||
2820 | 480 | |||
2821 | 481 | onPositionChanged: { | ||
2822 | 482 | if (mouseArea.pressed) { | ||
2823 | 483 | updateActiveAction() | ||
2824 | 484 | |||
2825 | 485 | listItemSwiping(index) // CUSTOM - tells other listitems to dismiss any swipe | ||
2826 | 486 | } | ||
2827 | 487 | } | ||
2828 | 488 | onPressAndHold: { | ||
2829 | 489 | if (main.x === 0) { | ||
2830 | 490 | root.itemPressAndHold(mouse) | ||
2831 | 491 | } | ||
2832 | 492 | } | ||
2833 | 493 | |||
2834 | 494 | z: -1 | ||
2835 | 495 | } | ||
2836 | 496 | } | ||
2837 | 0 | 497 | ||
2838 | === added file 'app/components/LoadingIndicator.qml' | |||
2839 | --- app/components/LoadingIndicator.qml 1970-01-01 00:00:00 +0000 | |||
2840 | +++ app/components/LoadingIndicator.qml 2015-06-28 23:49:12 +0000 | |||
2841 | @@ -0,0 +1,87 @@ | |||
2842 | 1 | /* | ||
2843 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
2844 | 3 | * | ||
2845 | 4 | * This file is part of Ubuntu Weather App | ||
2846 | 5 | * | ||
2847 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
2848 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2849 | 8 | * published by the Free Software Foundation. | ||
2850 | 9 | * | ||
2851 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
2852 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2853 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2854 | 13 | * GNU General Public License for more details. | ||
2855 | 14 | * | ||
2856 | 15 | * You should have received a copy of the GNU General Public License | ||
2857 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2858 | 17 | */ | ||
2859 | 18 | |||
2860 | 19 | import QtQuick 2.4 | ||
2861 | 20 | import Ubuntu.Components 1.2 | ||
2862 | 21 | |||
2863 | 22 | Rectangle { | ||
2864 | 23 | id: indicator | ||
2865 | 24 | objectName: "processingIndicator" | ||
2866 | 25 | anchors { | ||
2867 | 26 | left: parent.left | ||
2868 | 27 | right: parent.right | ||
2869 | 28 | bottom: parent.bottom | ||
2870 | 29 | bottomMargin: Qt.inputMethod.keyboardRectangle.height | ||
2871 | 30 | } | ||
2872 | 31 | height: units.dp(3) | ||
2873 | 32 | color: "white" | ||
2874 | 33 | opacity: 0 | ||
2875 | 34 | visible: opacity > 0 | ||
2876 | 35 | |||
2877 | 36 | readonly property bool processing: loading | ||
2878 | 37 | |||
2879 | 38 | Behavior on opacity { | ||
2880 | 39 | UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration } | ||
2881 | 40 | } | ||
2882 | 41 | |||
2883 | 42 | onProcessingChanged: { | ||
2884 | 43 | if (processing) delay.start(); | ||
2885 | 44 | else if (!persist.running) indicator.opacity = 0; | ||
2886 | 45 | } | ||
2887 | 46 | |||
2888 | 47 | Timer { | ||
2889 | 48 | id: delay | ||
2890 | 49 | interval: 200 | ||
2891 | 50 | onTriggered: if (indicator.processing) { | ||
2892 | 51 | persist.restart(); | ||
2893 | 52 | indicator.opacity = 1; | ||
2894 | 53 | } | ||
2895 | 54 | } | ||
2896 | 55 | |||
2897 | 56 | Timer { | ||
2898 | 57 | id: persist | ||
2899 | 58 | interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration | ||
2900 | 59 | onTriggered: if (!indicator.processing) indicator.opacity = 0 | ||
2901 | 60 | } | ||
2902 | 61 | |||
2903 | 62 | Rectangle { | ||
2904 | 63 | id: orange | ||
2905 | 64 | anchors { top: parent.top; bottom: parent.bottom } | ||
2906 | 65 | width: parent.width / 4 | ||
2907 | 66 | color: UbuntuColors.orange | ||
2908 | 67 | |||
2909 | 68 | SequentialAnimation { | ||
2910 | 69 | running: indicator.visible | ||
2911 | 70 | loops: Animation.Infinite | ||
2912 | 71 | XAnimator { | ||
2913 | 72 | from: -orange.width / 2 | ||
2914 | 73 | to: indicator.width - orange.width / 2 | ||
2915 | 74 | duration: UbuntuAnimation.SleepyDuration | ||
2916 | 75 | easing.type: Easing.InOutSine | ||
2917 | 76 | target: orange | ||
2918 | 77 | } | ||
2919 | 78 | XAnimator { | ||
2920 | 79 | from: indicator.width - orange.width / 2 | ||
2921 | 80 | to: -orange.width / 2 | ||
2922 | 81 | duration: UbuntuAnimation.SleepyDuration | ||
2923 | 82 | easing.type: Easing.InOutSine | ||
2924 | 83 | target: orange | ||
2925 | 84 | } | ||
2926 | 85 | } | ||
2927 | 86 | } | ||
2928 | 87 | } | ||
2929 | 0 | 88 | ||
2930 | === added file 'app/components/MultiSelectHeadState.qml' | |||
2931 | --- app/components/MultiSelectHeadState.qml 1970-01-01 00:00:00 +0000 | |||
2932 | +++ app/components/MultiSelectHeadState.qml 2015-06-28 23:49:12 +0000 | |||
2933 | @@ -0,0 +1,72 @@ | |||
2934 | 1 | /* | ||
2935 | 2 | * Copyright (C) 2015 | ||
2936 | 3 | * Andrew Hayzen <ahayzen@gmail.com> | ||
2937 | 4 | * Victor Thompson <victor.thompson@gmail.com> | ||
2938 | 5 | * | ||
2939 | 6 | * This program is free software; you can redistribute it and/or modify | ||
2940 | 7 | * it under the terms of the GNU General Public License as published by | ||
2941 | 8 | * the Free Software Foundation; version 3. | ||
2942 | 9 | * | ||
2943 | 10 | * This program is distributed in the hope that it will be useful, | ||
2944 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2945 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2946 | 13 | * GNU General Public License for more details. | ||
2947 | 14 | * | ||
2948 | 15 | * You should have received a copy of the GNU General Public License | ||
2949 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2950 | 17 | */ | ||
2951 | 18 | |||
2952 | 19 | import QtQuick 2.4 | ||
2953 | 20 | import Ubuntu.Components 1.2 | ||
2954 | 21 | |||
2955 | 22 | PageHeadState { | ||
2956 | 23 | id: selectionState | ||
2957 | 24 | actions: [ | ||
2958 | 25 | Action { | ||
2959 | 26 | iconName: "select" | ||
2960 | 27 | text: i18n.tr("Select All") | ||
2961 | 28 | onTriggered: { | ||
2962 | 29 | if (listview.selectedItems.length === listview.model.count) { | ||
2963 | 30 | listview.clearSelection() | ||
2964 | 31 | } else { | ||
2965 | 32 | listview.selectAll() | ||
2966 | 33 | } | ||
2967 | 34 | } | ||
2968 | 35 | }, | ||
2969 | 36 | Action { | ||
2970 | 37 | enabled: listview.selectedItems.length > 0 | ||
2971 | 38 | iconName: "delete" | ||
2972 | 39 | text: i18n.tr("Delete") | ||
2973 | 40 | visible: removable | ||
2974 | 41 | |||
2975 | 42 | onTriggered: { | ||
2976 | 43 | removed(listview.selectedItems) | ||
2977 | 44 | |||
2978 | 45 | listview.closeSelection() | ||
2979 | 46 | } | ||
2980 | 47 | } | ||
2981 | 48 | |||
2982 | 49 | ] | ||
2983 | 50 | backAction: Action { | ||
2984 | 51 | text: i18n.tr("Cancel selection") | ||
2985 | 52 | iconName: "back" | ||
2986 | 53 | onTriggered: { | ||
2987 | 54 | listview.clearSelection() | ||
2988 | 55 | listview.state = "normal" | ||
2989 | 56 | } | ||
2990 | 57 | } | ||
2991 | 58 | head: thisPage.head | ||
2992 | 59 | name: "selection" | ||
2993 | 60 | |||
2994 | 61 | PropertyChanges { | ||
2995 | 62 | target: thisPage.head | ||
2996 | 63 | backAction: selectionState.backAction | ||
2997 | 64 | actions: selectionState.actions | ||
2998 | 65 | } | ||
2999 | 66 | |||
3000 | 67 | property ListView listview | ||
3001 | 68 | property bool removable: false | ||
3002 | 69 | property Page thisPage | ||
3003 | 70 | |||
3004 | 71 | signal removed(var selectedItems) | ||
3005 | 72 | } | ||
3006 | 0 | 73 | ||
3007 | === added file 'app/components/MultiSelectListView.qml' | |||
3008 | --- app/components/MultiSelectListView.qml 1970-01-01 00:00:00 +0000 | |||
3009 | +++ app/components/MultiSelectListView.qml 2015-06-28 23:49:12 +0000 | |||
3010 | @@ -0,0 +1,52 @@ | |||
3011 | 1 | /* | ||
3012 | 2 | * Copyright (C) 2013, 2014, 2015 | ||
3013 | 3 | * Andrew Hayzen <ahayzen@gmail.com> | ||
3014 | 4 | * Daniel Holm <d.holmen@gmail.com> | ||
3015 | 5 | * Victor Thompson <victor.thompson@gmail.com> | ||
3016 | 6 | * | ||
3017 | 7 | * This program is free software; you can redistribute it and/or modify | ||
3018 | 8 | * it under the terms of the GNU General Public License as published by | ||
3019 | 9 | * the Free Software Foundation; version 3. | ||
3020 | 10 | * | ||
3021 | 11 | * This program is distributed in the hope that it will be useful, | ||
3022 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3023 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3024 | 14 | * GNU General Public License for more details. | ||
3025 | 15 | * | ||
3026 | 16 | * You should have received a copy of the GNU General Public License | ||
3027 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3028 | 18 | */ | ||
3029 | 19 | |||
3030 | 20 | import QtQuick 2.4 | ||
3031 | 21 | import Ubuntu.Components 1.2 | ||
3032 | 22 | |||
3033 | 23 | |||
3034 | 24 | WeatherListView { | ||
3035 | 25 | property var selectedItems: [] | ||
3036 | 26 | |||
3037 | 27 | signal clearSelection() | ||
3038 | 28 | signal closeSelection() | ||
3039 | 29 | signal selectAll() | ||
3040 | 30 | |||
3041 | 31 | onClearSelection: selectedItems = [] | ||
3042 | 32 | onCloseSelection: { | ||
3043 | 33 | clearSelection() | ||
3044 | 34 | state = "normal" | ||
3045 | 35 | } | ||
3046 | 36 | onSelectAll: { | ||
3047 | 37 | var tmp = selectedItems | ||
3048 | 38 | |||
3049 | 39 | for (var i=0; i < model.count; i++) { | ||
3050 | 40 | if (tmp.indexOf(i) === -1) { | ||
3051 | 41 | tmp.push(i) | ||
3052 | 42 | } | ||
3053 | 43 | } | ||
3054 | 44 | |||
3055 | 45 | selectedItems = tmp | ||
3056 | 46 | } | ||
3057 | 47 | onVisibleChanged: { | ||
3058 | 48 | if (!visible) { | ||
3059 | 49 | closeSelection() | ||
3060 | 50 | } | ||
3061 | 51 | } | ||
3062 | 52 | } | ||
3063 | 0 | 53 | ||
3064 | === added file 'app/components/PageWithBottomEdge.qml' | |||
3065 | --- app/components/PageWithBottomEdge.qml 1970-01-01 00:00:00 +0000 | |||
3066 | +++ app/components/PageWithBottomEdge.qml 2015-06-28 23:49:12 +0000 | |||
3067 | @@ -0,0 +1,411 @@ | |||
3068 | 1 | /* | ||
3069 | 2 | * Copyright (C) 2014, 2015 Canonical, Ltd. | ||
3070 | 3 | * | ||
3071 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3072 | 5 | * it under the terms of the GNU General Public License as published by | ||
3073 | 6 | * the Free Software Foundation; version 3. | ||
3074 | 7 | * | ||
3075 | 8 | * This program is distributed in the hope that it will be useful, | ||
3076 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3077 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3078 | 11 | * GNU General Public License for more details. | ||
3079 | 12 | * | ||
3080 | 13 | * You should have received a copy of the GNU General Public License | ||
3081 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3082 | 15 | */ | ||
3083 | 16 | |||
3084 | 17 | /* | ||
3085 | 18 | Example: | ||
3086 | 19 | |||
3087 | 20 | MainView { | ||
3088 | 21 | objectName: "mainView" | ||
3089 | 22 | |||
3090 | 23 | applicationName: "com.ubuntu.developer.boiko.bottomedge" | ||
3091 | 24 | |||
3092 | 25 | width: units.gu(100) | ||
3093 | 26 | height: units.gu(75) | ||
3094 | 27 | |||
3095 | 28 | Component { | ||
3096 | 29 | id: pageComponent | ||
3097 | 30 | |||
3098 | 31 | PageWithBottomEdge { | ||
3099 | 32 | id: mainPage | ||
3100 | 33 | title: i18n.tr("Main Page") | ||
3101 | 34 | |||
3102 | 35 | Rectangle { | ||
3103 | 36 | anchors.fill: parent | ||
3104 | 37 | color: "white" | ||
3105 | 38 | } | ||
3106 | 39 | |||
3107 | 40 | bottomEdgePageComponent: Page { | ||
3108 | 41 | title: "Contents" | ||
3109 | 42 | anchors.fill: parent | ||
3110 | 43 | //anchors.topMargin: contentsPage.flickable.contentY | ||
3111 | 44 | |||
3112 | 45 | ListView { | ||
3113 | 46 | anchors.fill: parent | ||
3114 | 47 | model: 50 | ||
3115 | 48 | delegate: ListItems.Standard { | ||
3116 | 49 | text: "One Content Item: " + index | ||
3117 | 50 | } | ||
3118 | 51 | } | ||
3119 | 52 | } | ||
3120 | 53 | bottomEdgeTitle: i18n.tr("Bottom edge action") | ||
3121 | 54 | } | ||
3122 | 55 | } | ||
3123 | 56 | |||
3124 | 57 | PageStack { | ||
3125 | 58 | id: stack | ||
3126 | 59 | Component.onCompleted: stack.push(pageComponent) | ||
3127 | 60 | } | ||
3128 | 61 | } | ||
3129 | 62 | |||
3130 | 63 | */ | ||
3131 | 64 | |||
3132 | 65 | import QtQuick 2.4 | ||
3133 | 66 | import Ubuntu.Components 1.2 | ||
3134 | 67 | |||
3135 | 68 | Page { | ||
3136 | 69 | id: page | ||
3137 | 70 | |||
3138 | 71 | property alias bottomEdgePageComponent: edgeLoader.sourceComponent | ||
3139 | 72 | property alias bottomEdgePageSource: edgeLoader.source | ||
3140 | 73 | property alias bottomEdgeTitle: tipLabel.text | ||
3141 | 74 | property bool bottomEdgeEnabled: true | ||
3142 | 75 | property int bottomEdgeExpandThreshold: page.height * 0.2 | ||
3143 | 76 | property int bottomEdgeExposedArea: bottomEdge.state !== "expanded" ? (page.height - bottomEdge.y - bottomEdge.tipHeight) : _areaWhenExpanded | ||
3144 | 77 | property bool reloadBottomEdgePage: true | ||
3145 | 78 | |||
3146 | 79 | readonly property alias bottomEdgePage: edgeLoader.item | ||
3147 | 80 | readonly property bool isReady: ((bottomEdge.y === 0) && bottomEdgePageLoaded && edgeLoader.item.active) | ||
3148 | 81 | readonly property bool isCollapsed: (bottomEdge.y === page.height) | ||
3149 | 82 | readonly property bool bottomEdgePageLoaded: (edgeLoader.status == Loader.Ready) | ||
3150 | 83 | |||
3151 | 84 | property bool _showEdgePageWhenReady: false | ||
3152 | 85 | property int _areaWhenExpanded: 0 | ||
3153 | 86 | |||
3154 | 87 | // CUSTOM properties to allow changing of color | ||
3155 | 88 | property alias tipColor: tip.color | ||
3156 | 89 | property alias tipLabelColor: tipLabel.color | ||
3157 | 90 | |||
3158 | 91 | signal bottomEdgeReleased() | ||
3159 | 92 | signal bottomEdgeDismissed() | ||
3160 | 93 | |||
3161 | 94 | |||
3162 | 95 | function showBottomEdgePage(source, properties) | ||
3163 | 96 | { | ||
3164 | 97 | edgeLoader.setSource(source, properties) | ||
3165 | 98 | _showEdgePageWhenReady = true | ||
3166 | 99 | } | ||
3167 | 100 | |||
3168 | 101 | function setBottomEdgePage(source, properties) | ||
3169 | 102 | { | ||
3170 | 103 | edgeLoader.setSource(source, properties) | ||
3171 | 104 | } | ||
3172 | 105 | |||
3173 | 106 | function _pushPage() | ||
3174 | 107 | { | ||
3175 | 108 | if (edgeLoader.status === Loader.Ready) { | ||
3176 | 109 | edgeLoader.item.active = true | ||
3177 | 110 | page.pageStack.push(edgeLoader.item) | ||
3178 | 111 | if (edgeLoader.item.flickable) { | ||
3179 | 112 | edgeLoader.item.flickable.contentY = -page.header.height | ||
3180 | 113 | edgeLoader.item.flickable.returnToBounds() | ||
3181 | 114 | } | ||
3182 | 115 | if (edgeLoader.item.ready) | ||
3183 | 116 | edgeLoader.item.ready() | ||
3184 | 117 | } | ||
3185 | 118 | } | ||
3186 | 119 | |||
3187 | 120 | |||
3188 | 121 | Component.onCompleted: { | ||
3189 | 122 | // avoid a binding on the expanded height value | ||
3190 | 123 | var expandedHeight = height; | ||
3191 | 124 | _areaWhenExpanded = expandedHeight; | ||
3192 | 125 | } | ||
3193 | 126 | |||
3194 | 127 | onActiveChanged: { | ||
3195 | 128 | if (active) { | ||
3196 | 129 | bottomEdge.state = "collapsed" | ||
3197 | 130 | } | ||
3198 | 131 | } | ||
3199 | 132 | |||
3200 | 133 | onBottomEdgePageLoadedChanged: { | ||
3201 | 134 | if (_showEdgePageWhenReady && bottomEdgePageLoaded) { | ||
3202 | 135 | bottomEdge.state = "expanded" | ||
3203 | 136 | _showEdgePageWhenReady = false | ||
3204 | 137 | } | ||
3205 | 138 | } | ||
3206 | 139 | |||
3207 | 140 | Rectangle { | ||
3208 | 141 | id: bgVisual | ||
3209 | 142 | |||
3210 | 143 | color: "black" | ||
3211 | 144 | anchors.fill: page | ||
3212 | 145 | opacity: 0.7 * ((page.height - bottomEdge.y) / page.height) | ||
3213 | 146 | z: 1 | ||
3214 | 147 | } | ||
3215 | 148 | |||
3216 | 149 | UbuntuShape { | ||
3217 | 150 | id: tip | ||
3218 | 151 | objectName: "bottomEdgeTip" | ||
3219 | 152 | |||
3220 | 153 | property bool hidden: (activeFocus === false) || ((bottomEdge.y - units.gu(1)) < tip.y) | ||
3221 | 154 | |||
3222 | 155 | enabled: mouseArea.enabled | ||
3223 | 156 | visible: page.bottomEdgeEnabled | ||
3224 | 157 | anchors { | ||
3225 | 158 | bottom: parent.bottom | ||
3226 | 159 | horizontalCenter: bottomEdge.horizontalCenter | ||
3227 | 160 | bottomMargin: hidden ? - height + units.gu(1) : -units.gu(1) | ||
3228 | 161 | Behavior on bottomMargin { | ||
3229 | 162 | SequentialAnimation { | ||
3230 | 163 | // wait some msecs in case of the focus change again, to avoid flickering | ||
3231 | 164 | PauseAnimation { | ||
3232 | 165 | duration: 300 | ||
3233 | 166 | } | ||
3234 | 167 | UbuntuNumberAnimation { | ||
3235 | 168 | duration: UbuntuAnimation.SnapDuration | ||
3236 | 169 | } | ||
3237 | 170 | } | ||
3238 | 171 | } | ||
3239 | 172 | } | ||
3240 | 173 | |||
3241 | 174 | z: 1 | ||
3242 | 175 | width: tipLabel.paintedWidth + units.gu(6) | ||
3243 | 176 | height: bottomEdge.tipHeight + units.gu(1) | ||
3244 | 177 | color: Theme.palette.normal.overlay | ||
3245 | 178 | Label { | ||
3246 | 179 | id: tipLabel | ||
3247 | 180 | |||
3248 | 181 | anchors { | ||
3249 | 182 | top: parent.top | ||
3250 | 183 | left: parent.left | ||
3251 | 184 | right: parent.right | ||
3252 | 185 | } | ||
3253 | 186 | height: bottomEdge.tipHeight | ||
3254 | 187 | verticalAlignment: Text.AlignVCenter | ||
3255 | 188 | horizontalAlignment: Text.AlignHCenter | ||
3256 | 189 | opacity: tip.hidden ? 0.0 : 1.0 | ||
3257 | 190 | Behavior on opacity { | ||
3258 | 191 | UbuntuNumberAnimation { | ||
3259 | 192 | duration: UbuntuAnimation.SnapDuration | ||
3260 | 193 | } | ||
3261 | 194 | } | ||
3262 | 195 | } | ||
3263 | 196 | } | ||
3264 | 197 | |||
3265 | 198 | Rectangle { | ||
3266 | 199 | id: shadow | ||
3267 | 200 | |||
3268 | 201 | anchors { | ||
3269 | 202 | left: parent.left | ||
3270 | 203 | right: parent.right | ||
3271 | 204 | bottom: parent.bottom | ||
3272 | 205 | } | ||
3273 | 206 | height: units.gu(1) | ||
3274 | 207 | z: 1 | ||
3275 | 208 | opacity: 0.0 | ||
3276 | 209 | gradient: Gradient { | ||
3277 | 210 | GradientStop { position: 0.0; color: "transparent" } | ||
3278 | 211 | GradientStop { position: 1.0; color: Qt.rgba(0, 0, 0, 0.2) } | ||
3279 | 212 | } | ||
3280 | 213 | } | ||
3281 | 214 | |||
3282 | 215 | MouseArea { | ||
3283 | 216 | id: mouseArea | ||
3284 | 217 | |||
3285 | 218 | property real previousY: -1 | ||
3286 | 219 | property string dragDirection: "None" | ||
3287 | 220 | |||
3288 | 221 | preventStealing: true | ||
3289 | 222 | drag { | ||
3290 | 223 | axis: Drag.YAxis | ||
3291 | 224 | target: bottomEdge | ||
3292 | 225 | minimumY: bottomEdge.pageStartY | ||
3293 | 226 | maximumY: page.height | ||
3294 | 227 | } | ||
3295 | 228 | enabled: edgeLoader.status == Loader.Ready | ||
3296 | 229 | visible: page.bottomEdgeEnabled | ||
3297 | 230 | |||
3298 | 231 | anchors { | ||
3299 | 232 | left: parent.left | ||
3300 | 233 | right: parent.right | ||
3301 | 234 | bottom: parent.bottom | ||
3302 | 235 | |||
3303 | 236 | } | ||
3304 | 237 | height: bottomEdge.tipHeight | ||
3305 | 238 | z: 1 | ||
3306 | 239 | |||
3307 | 240 | onReleased: { | ||
3308 | 241 | page.bottomEdgeReleased() | ||
3309 | 242 | if ((dragDirection === "BottomToTop") && | ||
3310 | 243 | bottomEdge.y < (page.height - bottomEdgeExpandThreshold - bottomEdge.tipHeight)) { | ||
3311 | 244 | bottomEdge.state = "expanded" | ||
3312 | 245 | } else { | ||
3313 | 246 | bottomEdge.state = "collapsed" | ||
3314 | 247 | } | ||
3315 | 248 | previousY = -1 | ||
3316 | 249 | dragDirection = "None" | ||
3317 | 250 | } | ||
3318 | 251 | |||
3319 | 252 | onPressed: { | ||
3320 | 253 | previousY = mouse.y | ||
3321 | 254 | tip.forceActiveFocus() | ||
3322 | 255 | } | ||
3323 | 256 | |||
3324 | 257 | onMouseYChanged: { | ||
3325 | 258 | var yOffset = previousY - mouseY | ||
3326 | 259 | // skip if was a small move | ||
3327 | 260 | if (Math.abs(yOffset) <= units.gu(2)) { | ||
3328 | 261 | return | ||
3329 | 262 | } | ||
3330 | 263 | previousY = mouseY | ||
3331 | 264 | dragDirection = yOffset > 0 ? "BottomToTop" : "TopToBottom" | ||
3332 | 265 | } | ||
3333 | 266 | } | ||
3334 | 267 | |||
3335 | 268 | Rectangle { | ||
3336 | 269 | id: bottomEdge | ||
3337 | 270 | objectName: "bottomEdge" | ||
3338 | 271 | |||
3339 | 272 | readonly property int tipHeight: units.gu(3) | ||
3340 | 273 | readonly property int pageStartY: 0 | ||
3341 | 274 | |||
3342 | 275 | z: 1 | ||
3343 | 276 | color: Theme.palette.normal.background | ||
3344 | 277 | clip: true | ||
3345 | 278 | anchors { | ||
3346 | 279 | left: parent.left | ||
3347 | 280 | right: parent.right | ||
3348 | 281 | } | ||
3349 | 282 | height: page.height | ||
3350 | 283 | y: height | ||
3351 | 284 | visible: !page.isCollapsed | ||
3352 | 285 | state: "collapsed" | ||
3353 | 286 | states: [ | ||
3354 | 287 | State { | ||
3355 | 288 | name: "collapsed" | ||
3356 | 289 | PropertyChanges { | ||
3357 | 290 | target: bottomEdge | ||
3358 | 291 | y: bottomEdge.height | ||
3359 | 292 | } | ||
3360 | 293 | }, | ||
3361 | 294 | State { | ||
3362 | 295 | name: "expanded" | ||
3363 | 296 | PropertyChanges { | ||
3364 | 297 | target: bottomEdge | ||
3365 | 298 | y: bottomEdge.pageStartY | ||
3366 | 299 | } | ||
3367 | 300 | }, | ||
3368 | 301 | State { | ||
3369 | 302 | name: "floating" | ||
3370 | 303 | when: mouseArea.drag.active | ||
3371 | 304 | PropertyChanges { | ||
3372 | 305 | target: shadow | ||
3373 | 306 | opacity: 1.0 | ||
3374 | 307 | } | ||
3375 | 308 | } | ||
3376 | 309 | ] | ||
3377 | 310 | |||
3378 | 311 | transitions: [ | ||
3379 | 312 | Transition { | ||
3380 | 313 | to: "expanded" | ||
3381 | 314 | SequentialAnimation { | ||
3382 | 315 | alwaysRunToEnd: true | ||
3383 | 316 | |||
3384 | 317 | SmoothedAnimation { | ||
3385 | 318 | target: bottomEdge | ||
3386 | 319 | property: "y" | ||
3387 | 320 | duration: UbuntuAnimation.FastDuration | ||
3388 | 321 | easing.type: Easing.Linear | ||
3389 | 322 | } | ||
3390 | 323 | SmoothedAnimation { | ||
3391 | 324 | target: edgeLoader | ||
3392 | 325 | property: "anchors.topMargin" | ||
3393 | 326 | to: - units.gu(4) | ||
3394 | 327 | duration: UbuntuAnimation.FastDuration | ||
3395 | 328 | easing.type: Easing.Linear | ||
3396 | 329 | } | ||
3397 | 330 | SmoothedAnimation { | ||
3398 | 331 | target: edgeLoader | ||
3399 | 332 | property: "anchors.topMargin" | ||
3400 | 333 | to: 0 | ||
3401 | 334 | duration: UbuntuAnimation.FastDuration | ||
3402 | 335 | easing: UbuntuAnimation.StandardEasing | ||
3403 | 336 | } | ||
3404 | 337 | ScriptAction { | ||
3405 | 338 | script: page._pushPage() | ||
3406 | 339 | } | ||
3407 | 340 | } | ||
3408 | 341 | }, | ||
3409 | 342 | Transition { | ||
3410 | 343 | from: "expanded" | ||
3411 | 344 | to: "collapsed" | ||
3412 | 345 | SequentialAnimation { | ||
3413 | 346 | alwaysRunToEnd: true | ||
3414 | 347 | |||
3415 | 348 | ScriptAction { | ||
3416 | 349 | script: { | ||
3417 | 350 | Qt.inputMethod.hide() | ||
3418 | 351 | edgeLoader.item.parent = edgeLoader | ||
3419 | 352 | edgeLoader.item.anchors.fill = edgeLoader | ||
3420 | 353 | edgeLoader.item.active = false | ||
3421 | 354 | } | ||
3422 | 355 | } | ||
3423 | 356 | SmoothedAnimation { | ||
3424 | 357 | target: bottomEdge | ||
3425 | 358 | property: "y" | ||
3426 | 359 | duration: UbuntuAnimation.SlowDuration | ||
3427 | 360 | } | ||
3428 | 361 | ScriptAction { | ||
3429 | 362 | script: { | ||
3430 | 363 | // destroy current bottom page | ||
3431 | 364 | if (page.reloadBottomEdgePage) { | ||
3432 | 365 | edgeLoader.active = false | ||
3433 | 366 | // tip will receive focus on page active true | ||
3434 | 367 | } else { | ||
3435 | 368 | tip.forceActiveFocus() | ||
3436 | 369 | } | ||
3437 | 370 | |||
3438 | 371 | // notify | ||
3439 | 372 | page.bottomEdgeDismissed() | ||
3440 | 373 | |||
3441 | 374 | edgeLoader.active = true | ||
3442 | 375 | } | ||
3443 | 376 | } | ||
3444 | 377 | } | ||
3445 | 378 | }, | ||
3446 | 379 | Transition { | ||
3447 | 380 | from: "floating" | ||
3448 | 381 | to: "collapsed" | ||
3449 | 382 | SmoothedAnimation { | ||
3450 | 383 | target: bottomEdge | ||
3451 | 384 | property: "y" | ||
3452 | 385 | duration: UbuntuAnimation.FastDuration | ||
3453 | 386 | } | ||
3454 | 387 | } | ||
3455 | 388 | ] | ||
3456 | 389 | |||
3457 | 390 | Loader { | ||
3458 | 391 | id: edgeLoader | ||
3459 | 392 | |||
3460 | 393 | asynchronous: true | ||
3461 | 394 | anchors.fill: parent | ||
3462 | 395 | //WORKAROUND: The SDK move the page contents down to allocate space for the header we need to avoid that during the page dragging | ||
3463 | 396 | Binding { | ||
3464 | 397 | target: edgeLoader.status === Loader.Ready ? edgeLoader : null | ||
3465 | 398 | property: "anchors.topMargin" | ||
3466 | 399 | value: edgeLoader.item && edgeLoader.item.flickable ? edgeLoader.item.flickable.contentY : 0 | ||
3467 | 400 | when: !page.isReady | ||
3468 | 401 | } | ||
3469 | 402 | |||
3470 | 403 | onLoaded: { | ||
3471 | 404 | tip.forceActiveFocus() | ||
3472 | 405 | if (page.isReady && edgeLoader.item.active !== true) { | ||
3473 | 406 | page._pushPage() | ||
3474 | 407 | } | ||
3475 | 408 | } | ||
3476 | 409 | } | ||
3477 | 410 | } | ||
3478 | 411 | } | ||
3479 | 0 | 412 | ||
3480 | === added file 'app/components/StandardListItem.qml' | |||
3481 | --- app/components/StandardListItem.qml 1970-01-01 00:00:00 +0000 | |||
3482 | +++ app/components/StandardListItem.qml 2015-06-28 23:49:12 +0000 | |||
3483 | @@ -0,0 +1,48 @@ | |||
3484 | 1 | /* | ||
3485 | 2 | * Copyright (C) 2015 Canonical Ltd | ||
3486 | 3 | * | ||
3487 | 4 | * This file is part of Ubuntu Weather App | ||
3488 | 5 | * | ||
3489 | 6 | * Ubuntu Weather App is free software: you can redistribute it and/or modify | ||
3490 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
3491 | 8 | * published by the Free Software Foundation. | ||
3492 | 9 | * | ||
3493 | 10 | * Ubuntu Weather App is distributed in the hope that it will be useful, | ||
3494 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3495 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3496 | 13 | * GNU General Public License for more details. | ||
3497 | 14 | * | ||
3498 | 15 | * You should have received a copy of the GNU General Public License | ||
3499 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3500 | 17 | */ | ||
3501 | 18 | |||
3502 | 19 | import QtQuick 2.4 | ||
3503 | 20 | import QtQuick.Layouts 1.1 | ||
3504 | 21 | import Ubuntu.Components 1.2 | ||
3505 | 22 | |||
3506 | 23 | ListItem { | ||
3507 | 24 | id: listItem | ||
3508 | 25 | |||
3509 | 26 | property alias title: _title.text | ||
3510 | 27 | property alias icon: _icon.name | ||
3511 | 28 | property alias showIcon: _icon.visible | ||
3512 | 29 | |||
3513 | 30 | RowLayout { | ||
3514 | 31 | anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: units.gu(2) } | ||
3515 | 32 | height: _icon.height | ||
3516 | 33 | spacing: units.gu(2) | ||
3517 | 34 | |||
3518 | 35 | Label { | ||
3519 | 36 | id: _title | ||
3520 | 37 | anchors.verticalCenter: _icon.verticalCenter | ||
3521 | 38 | elide: Text.ElideRight | ||
3522 | 39 | Layout.fillWidth: true | ||
3523 | 40 | } | ||
3524 | 41 | |||
3525 | 42 | Icon { | ||
3526 | 43 | id: _icon | ||
3527 | 44 | height: units.gu(2); width: height | ||
3528 | 45 | name: "go-next" | ||
3529 | 46 | } | ||
3530 | 47 | } | ||
3531 | 48 | } | ||
3532 | 0 | 49 | ||
3533 | === added file 'app/components/WeatherListItem.qml' | |||
3534 | --- app/components/WeatherListItem.qml 1970-01-01 00:00:00 +0000 | |||
3535 | +++ app/components/WeatherListItem.qml 2015-06-28 23:49:12 +0000 | |||
3536 | @@ -0,0 +1,137 @@ | |||
3537 | 1 | /* | ||
3538 | 2 | * Copyright (C) 2013, 2014, 2015 | ||
3539 | 3 | * Andrew Hayzen <ahayzen@gmail.com> | ||
3540 | 4 | * Nekhelesh Ramananthan <krnekhelesh@gmail.com> | ||
3541 | 5 | * Victor Thompson <victor.thompson@gmail.com> | ||
3542 | 6 | * | ||
3543 | 7 | * This program is free software; you can redistribute it and/or modify | ||
3544 | 8 | * it under the terms of the GNU General Public License as published by | ||
3545 | 9 | * the Free Software Foundation; version 3. | ||
3546 | 10 | * | ||
3547 | 11 | * This program is distributed in the hope that it will be useful, | ||
3548 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3549 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3550 | 14 | * GNU General Public License for more details. | ||
3551 | 15 | * | ||
3552 | 16 | * You should have received a copy of the GNU General Public License | ||
3553 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3554 | 18 | */ | ||
3555 | 19 | |||
3556 | 20 | import QtQuick 2.4 | ||
3557 | 21 | import Ubuntu.Components 1.2 | ||
3558 | 22 | |||
3559 | 23 | ListItemWithActions { | ||
3560 | 24 | id: root | ||
3561 | 25 | |||
3562 | 26 | property int listItemIndex: index | ||
3563 | 27 | property bool multiselectable: false | ||
3564 | 28 | property int previousListItemIndex: -1 | ||
3565 | 29 | property bool reorderable: false | ||
3566 | 30 | |||
3567 | 31 | signal reorder(int from, int to) | ||
3568 | 32 | |||
3569 | 33 | onItemPressAndHold: { | ||
3570 | 34 | if (multiselectable) { | ||
3571 | 35 | selectionMode = true | ||
3572 | 36 | } | ||
3573 | 37 | } | ||
3574 | 38 | |||
3575 | 39 | onListItemIndexChanged: { | ||
3576 | 40 | var i = parent.parent.selectedItems.lastIndexOf(previousListItemIndex) | ||
3577 | 41 | |||
3578 | 42 | if (i !== -1) { | ||
3579 | 43 | parent.parent.selectedItems[i] = listItemIndex | ||
3580 | 44 | } | ||
3581 | 45 | |||
3582 | 46 | previousListItemIndex = listItemIndex | ||
3583 | 47 | } | ||
3584 | 48 | |||
3585 | 49 | onSelectedChanged: { | ||
3586 | 50 | if (selectionMode) { | ||
3587 | 51 | var tmp = parent.parent.selectedItems | ||
3588 | 52 | |||
3589 | 53 | if (selected) { | ||
3590 | 54 | if (parent.parent.selectedItems.indexOf(listItemIndex) === -1) { | ||
3591 | 55 | tmp.push(listItemIndex) | ||
3592 | 56 | parent.parent.selectedItems = tmp | ||
3593 | 57 | } | ||
3594 | 58 | } else { | ||
3595 | 59 | tmp.splice(parent.parent.selectedItems.indexOf(listItemIndex), 1) | ||
3596 | 60 | parent.parent.selectedItems = tmp | ||
3597 | 61 | } | ||
3598 | 62 | } | ||
3599 | 63 | } | ||
3600 | 64 | |||
3601 | 65 | onSelectionModeChanged: { | ||
3602 | 66 | if (reorderable && selectionMode) { | ||
3603 | 67 | resetSwipe() | ||
3604 | 68 | } | ||
3605 | 69 | |||
3606 | 70 | for (var j=0; j < _main.children.length; j++) { | ||
3607 | 71 | if (_main.children[j] !== actionReorderLoader) { | ||
3608 | 72 | _main.children[j].anchors.rightMargin = reorderable && selectionMode ? actionReorderLoader.width + units.gu(2) : 0 | ||
3609 | 73 | } | ||
3610 | 74 | } | ||
3611 | 75 | |||
3612 | 76 | parent.parent.state = selectionMode ? "multiselectable" : "normal" | ||
3613 | 77 | |||
3614 | 78 | if (!selectionMode) { | ||
3615 | 79 | selected = false | ||
3616 | 80 | } | ||
3617 | 81 | } | ||
3618 | 82 | |||
3619 | 83 | /* Highlight the listitem on press */ | ||
3620 | 84 | Rectangle { | ||
3621 | 85 | id: listItemBrighten | ||
3622 | 86 | color: root.pressed ? UbuntuColors.coolGrey : "transparent" | ||
3623 | 87 | opacity: 0.1 | ||
3624 | 88 | height: root.height | ||
3625 | 89 | x: root.x - parent.x // -parent.x due to selectionIcon in ListItemWithActions | ||
3626 | 90 | width: root.width | ||
3627 | 91 | } | ||
3628 | 92 | |||
3629 | 93 | /* Reorder Component */ | ||
3630 | 94 | Loader { | ||
3631 | 95 | id: actionReorderLoader | ||
3632 | 96 | active: reorderable && selectionMode && root.parent.parent.selectedItems.length === 0 | ||
3633 | 97 | anchors { | ||
3634 | 98 | bottom: parent.bottom | ||
3635 | 99 | right: parent.right | ||
3636 | 100 | rightMargin: units.gu(1) | ||
3637 | 101 | top: parent.top | ||
3638 | 102 | } | ||
3639 | 103 | asynchronous: true | ||
3640 | 104 | source: "ListItemReorderComponent.qml" | ||
3641 | 105 | } | ||
3642 | 106 | |||
3643 | 107 | Item { | ||
3644 | 108 | Connections { // Only allow one ListItem to be swiping at any time | ||
3645 | 109 | target: weatherApp | ||
3646 | 110 | onListItemSwiping: { | ||
3647 | 111 | if (i !== index) { | ||
3648 | 112 | root.resetSwipe(); | ||
3649 | 113 | } | ||
3650 | 114 | } | ||
3651 | 115 | } | ||
3652 | 116 | |||
3653 | 117 | Connections { // Connections from signals in the ListView | ||
3654 | 118 | target: root.parent.parent | ||
3655 | 119 | onClearSelection: selected = false | ||
3656 | 120 | onFlickingChanged: { | ||
3657 | 121 | if (root.parent.parent.flicking) { | ||
3658 | 122 | root.resetSwipe() | ||
3659 | 123 | } | ||
3660 | 124 | } | ||
3661 | 125 | onSelectAll: selected = true | ||
3662 | 126 | onStateChanged: selectionMode = root.parent.parent.state === "multiselectable" | ||
3663 | 127 | } | ||
3664 | 128 | } | ||
3665 | 129 | |||
3666 | 130 | Component.onCompleted: { // reload settings as delegates are destroyed | ||
3667 | 131 | if (parent.parent.selectedItems.indexOf(index) !== -1) { | ||
3668 | 132 | selected = true | ||
3669 | 133 | } | ||
3670 | 134 | |||
3671 | 135 | selectionMode = root.parent.parent.state === "multiselectable" | ||
3672 | 136 | } | ||
3673 | 137 | } | ||
3674 | 0 | 138 | ||
3675 | === added file 'app/components/WeatherListView.qml' | |||
3676 | --- app/components/WeatherListView.qml 1970-01-01 00:00:00 +0000 | |||
3677 | +++ app/components/WeatherListView.qml 2015-06-28 23:49:12 +0000 | |||
3678 | @@ -0,0 +1,32 @@ | |||
3679 | 1 | /* | ||
3680 | 2 | * Copyright (C) 2013, 2014, 2015 | ||
3681 | 3 | * Andrew Hayzen <ahayzen@gmail.com> | ||
3682 | 4 | * Daniel Holm <d.holmen@gmail.com> | ||
3683 | 5 | * Victor Thompson <victor.thompson@gmail.com> | ||
3684 | 6 | * | ||
3685 | 7 | * This program is free software; you can redistribute it and/or modify | ||
3686 | 8 | * it under the terms of the GNU General Public License as published by | ||
3687 | 9 | * the Free Software Foundation; version 3. | ||
3688 | 10 | * | ||
3689 | 11 | * This program is distributed in the hope that it will be useful, | ||
3690 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3691 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3692 | 14 | * GNU General Public License for more details. | ||
3693 | 15 | * | ||
3694 | 16 | * You should have received a copy of the GNU General Public License | ||
3695 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3696 | 18 | */ | ||
3697 | 19 | |||
3698 | 20 | import QtQuick 2.4 | ||
3699 | 21 | import Ubuntu.Components 1.2 | ||
3700 | 22 | |||
3701 | 23 | |||
3702 | 24 | ListView { | ||
3703 | 25 | Component.onCompleted: { | ||
3704 | 26 | // FIXME: workaround for qtubuntu not returning values depending on the grid unit definition | ||
3705 | 27 | // for Flickable.maximumFlickVelocity and Flickable.flickDeceleration | ||
3706 | 28 | var scaleFactor = units.gridUnit / 8; | ||
3707 | 29 | maximumFlickVelocity = maximumFlickVelocity * scaleFactor; | ||
3708 | 30 | flickDeceleration = flickDeceleration * scaleFactor; | ||
3709 | 31 | } | ||
3710 | 32 | } | ||
3711 | 0 | 33 | ||
3712 | === added directory 'app/data' | |||
3713 | === added file 'app/data/CMakeLists.txt' | |||
3714 | --- app/data/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3715 | +++ app/data/CMakeLists.txt 2015-06-28 23:49:12 +0000 | |||
3716 | @@ -0,0 +1,5 @@ | |||
3717 | 1 | file(GLOB DATA_QML_JS_FILES *.qml *.js) | ||
3718 | 2 | |||
3719 | 3 | add_custom_target(ubuntu-weather-app_data_QMlFiles ALL SOURCES ${DATA_QML_JS_FILES}) | ||
3720 | 4 | |||
3721 | 5 | install(FILES ${DATA_QML_JS_FILES} DESTINATION ${UBUNTU-WEATHER_APP_DIR}/data) | ||
3722 | 0 | 6 | ||
3723 | === added file 'app/data/CitiesList.js' | |||
3724 | --- app/data/CitiesList.js 1970-01-01 00:00:00 +0000 | |||
3725 | +++ app/data/CitiesList.js 2015-06-28 23:49:12 +0000 | |||
3726 | @@ -0,0 +1,65 @@ | |||
3727 | 1 | .pragma library | ||
3728 | 2 | /* | ||
3729 | 3 | * Copyright (C) 2013 Canonical Ltd | ||
3730 | 4 | * | ||
3731 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3732 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
3733 | 7 | * published by the Free Software Foundation. | ||
3734 | 8 | * | ||
3735 | 9 | * This program is distributed in the hope that it will be useful, | ||
3736 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3737 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3738 | 12 | * GNU General Public License for more details. | ||
3739 | 13 | * | ||
3740 | 14 | * You should have received a copy of the GNU General Public License | ||
3741 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3742 | 16 | * | ||
3743 | 17 | * Authored by: Martin Borho <martin@borho.net> | ||
3744 | 18 | */ | ||
3745 | 19 | |||
3746 | 20 | var preList = [ | ||
3747 | 21 | {"coord":{"lon":"4.88969","lat":"52.37403"},"timezone":{"gmtOffset":1,"dstOffset":2,"timeZoneId":"Europe/Amsterdam"},"population":741636,"adminName2":"Gemeente Amsterdam","name":"Amsterdam","country":"NL","countryName":"Netherlands","adminName1":"North Holland","adminName3":"","services":{"geonames":2759794},"areaLabel":"North Holland, Netherlands"}, | ||
3748 | 22 | {"coord":{"lon":"116.39723","lat":"39.9075"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Shanghai"},"population":7480601,"adminName2":"","name":"Beijing","country":"CN","countryName":"China","adminName1":"Beijing","adminName3":"","services":{"geonames":1816670},"areaLabel":"Beijing, China"}, | ||
3749 | 23 | {"coord":{"lon":"-74.08175","lat":"4.60971"},"timezone":{"gmtOffset":-5,"dstOffset":-5,"timeZoneId":"America/Bogota"},"population":7674366,"adminName2":"","name":"Bogotá","country":"CO","countryName":"Colombia","adminName1":"Bogota D.C.","adminName3":"","services":{"geonames":3688689},"areaLabel":"Bogota D.C., Colombia"}, | ||
3750 | 24 | {"coord":{"lon":"-58.37723","lat":"-34.61315"},"timezone":{"gmtOffset":-3,"dstOffset":-3,"timeZoneId":"America/Argentina/Buenos_Aires"},"population":13076300,"adminName2":"","name":"Buenos Aires","country":"AR","countryName":"Argentina","adminName1":"Buenos Aires F.D.","adminName3":"","services":{"geonames":3435910},"areaLabel":"Buenos Aires F.D., Argentina"}, | ||
3751 | 25 | {"coord":{"lon":"31.24967","lat":"30.06263"},"timezone":{"gmtOffset":2,"dstOffset":2,"timeZoneId":"Africa/Cairo"},"population":7734614,"adminName2":"","name":"Cairo","country":"EG","countryName":"Egypt","adminName1":"Al Qāhirah","adminName3":"","services":{"geonames":360630},"areaLabel":"Al Qāhirah, Egypt"}, | ||
3752 | 26 | {"coord":{"lon":"-66.87919","lat":"10.48801"},"timezone":{"gmtOffset":-4.5,"dstOffset":-4.5,"timeZoneId":"America/Caracas"},"population":3000000,"adminName2":"Municipio Libertador","name":"Caracas","country":"VE","countryName":"Venezuela","adminName1":"Distrito Federal","adminName3":"","services":{"geonames":3646738},"areaLabel":"Distrito Federal, Venezuela, Bolivarian Republic of"}, | ||
3753 | 27 | {"coord":{"lon":"-87.65005","lat":"41.85003"},"timezone":{"gmtOffset":-6,"dstOffset":-5,"timeZoneId":"America/Chicago"},"population":2695598,"adminName2":"Cook County","name":"Chicago","country":"US","countryName":"United States","adminName1":"Illinois","adminName3":"","services":{"geonames":4887398},"areaLabel":"Illinois, United States"}, | ||
3754 | 28 | {"coord":{"lon":"77.22897","lat":"28.65381"},"timezone":{"gmtOffset":5.5,"dstOffset":5.5,"timeZoneId":"Asia/Kolkata"},"population":10927986,"adminName2":"","name":"Dehli","country":"IN","countryName":"India","adminName1":"NCT","adminName3":"","services":{"geonames":1273294},"areaLabel":"NCT, India"}, | ||
3755 | 29 | {"coord":{"lon":"55.30472","lat":"25.25817"},"timezone":{"gmtOffset":4,"dstOffset":4,"timeZoneId":"Asia/Dubai"},"population":1137347,"adminName2":"","name":"Dubai","country":"AE","countryName":"United Arab Emirates","adminName1":"Dubai","adminName3":"","services":{"geonames":292223},"areaLabel":"Dubai, United Arab Emirates"}, | ||
3756 | 30 | {"coord":{"lon":"113.25","lat":"23.11667"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Shanghai"},"population":3152825,"adminName2":"","name":"Guangzhou","country":"CN","countryName":"China","adminName1":"Guangdong Province","adminName3":"","services":{"geonames":1809858},"areaLabel":"Guangdong Province, China"}, | ||
3757 | 31 | {"coord":{"lon":"10.01534","lat":"53.57532"},"timezone":{"gmtOffset":1,"dstOffset":2,"timeZoneId":"Europe/Berlin"},"population":1739117,"adminName2":"","name":"Hamburg","country":"DE","countryName":"Germany","adminName1":"Hamburg","adminName3":"","services":{"geonames":2911298},"areaLabel":"Hamburg, Germany"}, | ||
3758 | 32 | {"coord":{"lon":"-95.36327","lat":"29.76328"},"timezone":{"gmtOffset":-6,"dstOffset":-5,"timeZoneId":"America/Chicago"},"population":2099451,"adminName2":"Harris County","name":"Houston","country":"US","countryName":"United States","adminName1":"Texas","adminName3":"","services":{"geonames":4699066},"areaLabel":"Texas, United States"}, | ||
3759 | 33 | {"coord":{"lon":"28.94966","lat":"41.01384"},"timezone":{"gmtOffset":2,"dstOffset":3,"timeZoneId":"Europe/Istanbul"},"population":11174257,"adminName2":"","name":"Istanbul","country":"TR","countryName":"Turkey","adminName1":"Istanbul","adminName3":"","services":{"geonames":745044},"areaLabel":"Istanbul, Turkey"}, | ||
3760 | 34 | {"coord":{"lon":"106.84513","lat":"-6.21462"},"timezone":{"gmtOffset":7,"dstOffset":7,"timeZoneId":"Asia/Jakarta"},"population":8540121,"adminName2":"","name":"Jakarta","country":"ID","countryName":"Indonesia","adminName1":"Jakarta Raya","adminName3":"","services":{"geonames":1642911},"areaLabel":"Jakarta Raya, Indonesia"}, | ||
3761 | 35 | {"coord":{"lon":"28.04363","lat":"-26.20227"},"timezone":{"gmtOffset":2,"dstOffset":2,"timeZoneId":"Africa/Johannesburg"},"population":2026469,"adminName2":"City of Johannesburg Metropolitan Municipality","name":"Johannesburg","country":"ZA","countryName":"South Africa","adminName1":"Gauteng","adminName3":"City of Johannesburg","services":{"geonames":993800},"areaLabel":"Gauteng, South Africa"}, | ||
3762 | 36 | {"coord":{"lon":"67.0822","lat":"24.9056"},"timezone":{"gmtOffset":5,"dstOffset":5,"timeZoneId":"Asia/Karachi"},"population":11624219,"adminName2":"Karāchi District","name":"Karachi","country":"PK","countryName":"Pakistan","adminName1":"Sindh","adminName3":"","services":{"geonames":1174872},"areaLabel":"Sindh, Pakistan"}, | ||
3763 | 37 | {"coord":{"lon":"15.30807","lat":"-4.32142"},"timezone":{"gmtOffset":1,"dstOffset":1,"timeZoneId":"Africa/Kinshasa"},"population":7785965,"adminName2":"","name":"Kinshasa","country":"CD","countryName":"Democratic Republic of the Congo","adminName1":"Kinshasa","adminName3":"","services":{"geonames":2314302},"areaLabel":"Kinshasa, Congo, the Democratic Republic of the"}, | ||
3764 | 38 | {"coord":{"lon":"88.36304","lat":"22.56263"},"timezone":{"gmtOffset":5.5,"dstOffset":5.5,"timeZoneId":"Asia/Kolkata"},"population":4631392,"adminName2":"","name":"Kolkata","country":"IN","countryName":"India","adminName1":"Bengal","adminName3":"","services":{"geonames":1275004},"areaLabel":"Bengal, India"}, | ||
3765 | 39 | {"coord":{"lon":"3.39583","lat":"6.45306"},"timezone":{"gmtOffset":1,"dstOffset":1,"timeZoneId":"Africa/Lagos"},"population":9000000,"adminName2":"","name":"Lagos","country":"NG","countryName":"Nigeria","adminName1":"Lagos","adminName3":"","services":{"geonames":2332459},"areaLabel":"Lagos, Nigeria"}, | ||
3766 | 40 | {"coord":{"lon":"-77.02824","lat":"-12.04318"},"timezone":{"gmtOffset":-5,"dstOffset":-5,"timeZoneId":"America/Lima"},"population":7737002,"adminName2":"","name":"Lima","country":"PE","countryName":"Peru","adminName1":"Provincia de Lima","adminName3":"","services":{"geonames":3936456},"areaLabel":"Provincia de Lima, Peru"}, | ||
3767 | 41 | {"coord":{"lon":"-0.12574","lat":"51.50853"},"timezone":{"gmtOffset":0,"dstOffset":1,"timeZoneId":"Europe/London"},"population":7556900,"adminName2":"Greater London","name":"London","country":"GB","countryName":"United Kingdom","adminName1":"England","adminName3":"","services":{"geonames":2643743},"areaLabel":"England, Greater London, United Kingdom"}, | ||
3768 | 42 | {"coord":{"lon":"-118.24368","lat":"34.05223"},"timezone":{"gmtOffset":-8,"dstOffset":-7,"timeZoneId":"America/Los_Angeles"},"population":3792621,"adminName2":"Los Angeles County","name":"Los Angeles","country":"US","countryName":"United States","adminName1":"California","adminName3":"","services":{"geonames":5368361},"areaLabel":"California, United States"}, | ||
3769 | 43 | {"coord":{"lon":"-3.70256","lat":"40.4165"},"timezone":{"gmtOffset":1,"dstOffset":2,"timeZoneId":"Europe/Madrid"},"population":3255944,"adminName2":"Madrid","name":"Madrid","country":"ES","countryName":"Spain","adminName1":"Madrid","adminName3":"Madrid","services":{"geonames":3117735},"areaLabel":"Madrid, Spain"}, | ||
3770 | 44 | {"coord":{"lon":"120.9822","lat":"14.6042"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Manila"},"population":10444527,"adminName2":"PH.NCR.D9","name":"Manila","country":"PH","countryName":"Philippines","adminName1":"National Capital Region","adminName3":"","services":{"geonames":1701668},"areaLabel":"National Capital, Philippines"}, | ||
3771 | 45 | {"coord":{"lon":"-73.58781","lat":"45.50884"},"timezone":{"gmtOffset":-5,"dstOffset":-4,"timeZoneId":"America/Montreal"},"population":3268513,"adminName2":"Montréal","name":"Montreal","country":"CA","countryName":"Canada","adminName1":"Quebec","adminName3":"","services":{"geonames":6077243},"areaLabel":"Quebec, Canada"}, | ||
3772 | 46 | {"coord":{"lon":"-99.12766","lat":"19.42847"},"timezone":{"gmtOffset":-6,"dstOffset":-5,"timeZoneId":"America/Mexico_City"},"population":12294193,"adminName2":"","name":"Mexico City","country":"MX","countryName":"Mexico","adminName1":"The Federal District","adminName3":"","services":{"geonames":3530597},"areaLabel":"The Federal District, Mexico"}, | ||
3773 | 47 | {"coord":{"lon":"37.61556","lat":"55.75222"},"timezone":{"gmtOffset":4,"dstOffset":4,"timeZoneId":"Europe/Moscow"},"population":10381222,"adminName2":"","name":"Moscow","country":"RU","countryName":"Russia","adminName1":"Moscow","adminName3":"","services":{"geonames":524901},"areaLabel":"Moscow, Russian Federation"}, | ||
3774 | 48 | {"coord":{"lon":"72.88261","lat":"19.07283"},"timezone":{"gmtOffset":5.5,"dstOffset":5.5,"timeZoneId":"Asia/Kolkata"},"population":12691836,"adminName2":"Konkan Division","name":"Mumbai","country":"IN","countryName":"India","adminName1":"Mahārāshtra","adminName3":"","services":{"geonames":1275339},"areaLabel":"Mahārāshtra, India"}, | ||
3775 | 49 | {"coord":{"lon":"36.81667","lat":"-1.28333"},"timezone":{"gmtOffset":3,"dstOffset":3,"timeZoneId":"Africa/Nairobi"},"population":2750547,"adminName2":"","name":"Nairobi","country":"KE","countryName":"Kenya","adminName1":"Nairobi Area","adminName3":"","services":{"geonames":184745},"areaLabel":"Nairobi Area, Kenya"}, | ||
3776 | 50 | {"coord":{"lon":"-74.00597","lat":"40.71427"},"timezone":{"gmtOffset":-5,"dstOffset":-4,"timeZoneId":"America/New_York"},"population":8175133,"adminName2":"","name":"New York City","country":"US","countryName":"United States","adminName1":"New York","adminName3":"","services":{"geonames":5128581},"areaLabel":"New York, United States"}, | ||
3777 | 51 | {"coord":{"lon":"135.50218","lat":"34.69374"},"timezone":{"gmtOffset":9,"dstOffset":9,"timeZoneId":"Asia/Tokyo"},"population":2592413,"adminName2":"","name":"Osaka","country":"JP","countryName":"Japan","adminName1":"Ōsaka","adminName3":"","services":{"geonames":1853909},"areaLabel":"Ōsaka, Japan"}, | ||
3778 | 52 | {"coord":{"lon":"-43.2075","lat":"-22.90278"},"timezone":{"gmtOffset":-2,"dstOffset":-3,"timeZoneId":"America/Sao_Paulo"},"population":6023699,"adminName2":"Rio de Janeiro","name":"Rio de Janeiro","country":"BR","countryName":"Brazil","adminName1":"Rio de Janeiro","adminName3":"","services":{"geonames":3451190},"areaLabel":"Rio de Janeiro, Brazil"}, | ||
3779 | 53 | {"coord":{"lon":"12.4839","lat":"41.89474"},"timezone":{"gmtOffset":1,"dstOffset":2,"timeZoneId":"Europe/Rome"},"population":2563241,"adminName2":"Rome","name":"Rome","country":"IT","countryName":"Italy","adminName1":"Latium","adminName3":"Rome","services":{"geonames":3169070},"areaLabel":"Latium, Italy"}, | ||
3780 | 54 | {"coord":{"lon":"126.97783","lat":"37.56826"},"timezone":{"gmtOffset":9,"dstOffset":9,"timeZoneId":"Asia/Seoul"},"population":10349312,"adminName2":"","name":"Seoul","country":"KR","countryName":"South Korea","adminName1":"Seoul","adminName3":"","services":{"geonames":1835848},"areaLabel":"Seoul, Korea, Republic of"}, | ||
3781 | 55 | {"coord":{"lon":"-122.41942","lat":"37.77493"},"timezone":{"gmtOffset":-8,"dstOffset":-7,"timeZoneId":"America/Los_Angeles"},"population":805235,"adminName2":"San Francisco County","name":"San Francisco","country":"US","countryName":"United States","adminName1":"California","adminName3":"","services":{"geonames":5391959},"areaLabel":"California, United States"}, | ||
3782 | 56 | {"coord":{"lon":"-46.63611","lat":"-23.5475"},"timezone":{"gmtOffset":-2,"dstOffset":-3,"timeZoneId":"America/Sao_Paulo"},"population":10021295,"adminName2":"São Paulo","name":"São Paulo","country":"BR","countryName":"Brazil","adminName1":"São Paulo","adminName3":"","services":{"geonames":3448439},"areaLabel":"São Paulo, Brazil"}, | ||
3783 | 57 | {"coord":{"lon":"121.45806","lat":"31.22222"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Shanghai"},"population":14608512,"adminName2":"","name":"Shanghai","country":"CN","countryName":"China","adminName1":"Shanghai Shi","adminName3":"","services":{"geonames":1796236},"areaLabel":"Shanghai Shi, China"}, | ||
3784 | 58 | {"coord":{"lon":"114.0683","lat":"22.54554"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Shanghai"},"population":3000000,"adminName2":"Shenzhen","name":"Shenzhen","country":"CN","countryName":"China","adminName1":"Guangdong Province","adminName3":"","services":{"geonames":1795565},"areaLabel":"Guangdong Province, Shenzhen, China"}, | ||
3785 | 59 | {"coord":{"lon":"103.85007","lat":"1.28967"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Singapore"},"population":3547809,"adminName2":"","name":"Singapore","country":"SG","countryName":"Singapore","adminName1":"","adminName3":"","services":{"geonames":1880252},"areaLabel":"Singapore"}, | ||
3786 | 60 | {"coord":{"lon":"151.20732","lat":"-33.86785"},"timezone":{"gmtOffset":11,"dstOffset":10,"timeZoneId":"Australia/Sydney"},"population":4627345,"adminName2":"City of Sydney","name":"Sydney","country":"AU","countryName":"Australia","adminName1":"New South Wales","adminName3":"","services":{"geonames":2147714},"areaLabel":"New South Wales, Australia"}, | ||
3787 | 61 | {"coord":{"lon":"51.42151","lat":"35.69439"},"timezone":{"gmtOffset":3.5,"dstOffset":4.5,"timeZoneId":"Asia/Tehran"},"population":7153309,"adminName2":"","name":"Tehran","country":"IR","countryName":"Iran","adminName1":"Tehrān","adminName3":"","services":{"geonames":112931},"areaLabel":"Tehrān, Iran, Islamic Republic of"}, | ||
3788 | 62 | {"coord":{"lon":"117.17667","lat":"39.14222"},"timezone":{"gmtOffset":8,"dstOffset":8,"timeZoneId":"Asia/Shanghai"},"population":3766207,"adminName2":"","name":"Tianjin","country":"CN","countryName":"China","adminName1":"Tianjin Shi","adminName3":"","services":{"geonames":1792947},"areaLabel":"Tianjin Shi, China"}, | ||
3789 | 63 | {"coord":{"lon":"139.69171","lat":"35.6895"},"timezone":{"gmtOffset":9,"dstOffset":9,"timeZoneId":"Asia/Tokyo"},"population":8336599,"adminName2":"","name":"Tokyo","country":"JP","countryName":"Japan","adminName1":"Tōkyō","adminName3":"","services":{"geonames":1850147},"areaLabel":"Tōkyō, Japan"}, | ||
3790 | 64 | {"coord":{"lon":"-79.4163","lat":"43.70011"},"timezone":{"gmtOffset":-5,"dstOffset":-4,"timeZoneId":"America/Toronto"},"population":4612191,"adminName2":"","name":"Toronto","country":"CA","countryName":"Canada","adminName1":"Ontario","adminName3":"","services":{"geonames":6167865},"areaLabel":"Ontario, Canada"} | ||
3791 | 65 | ] | ||
3792 | 0 | 66 | ||
3793 | === added file 'app/data/Storage.qml' | |||
3794 | --- app/data/Storage.qml 1970-01-01 00:00:00 +0000 | |||
3795 | +++ app/data/Storage.qml 2015-06-28 23:49:12 +0000 | |||
3796 | @@ -0,0 +1,214 @@ | |||
3797 | 1 | /* | ||
3798 | 2 | * Copyright (C) 2013, 2014, 2015 Canonical Ltd | ||
3799 | 3 | * | ||
3800 | 4 | * This program is free software: you can redistribute it and/or modify | ||
3801 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
3802 | 6 | * published by the Free Software Foundation. | ||
3803 | 7 | * | ||
3804 | 8 | * This program is distributed in the hope that it will be useful, | ||
3805 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3806 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3807 | 11 | * GNU General Public License for more details. | ||
3808 | 12 | * | ||
3809 | 13 | * You should have received a copy of the GNU General Public License | ||
3810 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3811 | 15 | * | ||
3812 | 16 | * Authored by: Martin Borho <martin@borho.net> | ||
3813 | 17 | */ | ||
3814 | 18 | import QtQuick.LocalStorage 2.0 | ||
3815 | 19 | import QtQuick 2.4 | ||
3816 | 20 | |||
3817 | 21 | Item { | ||
3818 | 22 | property var db: null | ||
3819 | 23 | |||
3820 | 24 | function openDB() { | ||
3821 | 25 | if(db !== null) return; | ||
3822 | 26 | |||
3823 | 27 | db = LocalStorage.openDatabaseSync("com.ubuntu.weather", "", "Default Ubuntu weather app", 100000); | ||
3824 | 28 | |||
3825 | 29 | if (db.version === "") { | ||
3826 | 30 | db.changeVersion("", "0.1", | ||
3827 | 31 | function(tx) { | ||
3828 | 32 | tx.executeSql('CREATE TABLE IF NOT EXISTS Locations(id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT, date TEXT)'); | ||
3829 | 33 | console.log('Database created'); | ||
3830 | 34 | }); | ||
3831 | 35 | // reopen database with new version number | ||
3832 | 36 | db = LocalStorage.openDatabaseSync("com.ubuntu.weather", "", "Default Ubuntu weather app", 100000); | ||
3833 | 37 | } | ||
3834 | 38 | |||
3835 | 39 | if(db.version === "0.1") { | ||
3836 | 40 | db.changeVersion("0.1", "0.2", | ||
3837 | 41 | function(tx) { | ||
3838 | 42 | tx.executeSql('CREATE TABLE IF NOT EXISTS settings(key TEXT UNIQUE, value TEXT)'); | ||
3839 | 43 | console.log('Settings table added, Database upgraded to v0.2'); | ||
3840 | 44 | }); | ||
3841 | 45 | // reopen database with new version number | ||
3842 | 46 | db = LocalStorage.openDatabaseSync("com.ubuntu.weather", "", "Default Ubuntu weather app", 100000); | ||
3843 | 47 | } | ||
3844 | 48 | |||
3845 | 49 | if(db.version === "0.2") { | ||
3846 | 50 | db.changeVersion("0.2", "0.3", | ||
3847 | 51 | function(tx) { | ||
3848 | 52 | tx.executeSql('DELETE FROM Locations WHERE 1'); | ||
3849 | 53 | console.log('Removed old locations, Database upgraded to v0.3'); | ||
3850 | 54 | }); | ||
3851 | 55 | } | ||
3852 | 56 | |||
3853 | 57 | if (!settings.migrated) { | ||
3854 | 58 | try { // attempt to read the old settings | ||
3855 | 59 | var oldSettings = {}; | ||
3856 | 60 | |||
3857 | 61 | // Load old settings | ||
3858 | 62 | db.readTransaction( function(tx) { | ||
3859 | 63 | var rs = tx.executeSql("SELECT * FROM settings") | ||
3860 | 64 | |||
3861 | 65 | for(var i = 0; i < rs.rows.length; i++) { | ||
3862 | 66 | var row = rs.rows.item(i); | ||
3863 | 67 | oldSettings[row.key] = row.value; | ||
3864 | 68 | } | ||
3865 | 69 | }); | ||
3866 | 70 | |||
3867 | 71 | console.debug("Migrating old data:", JSON.stringify(oldSettings)) | ||
3868 | 72 | |||
3869 | 73 | var metric = Qt.locale().measurementSystem === Locale.MetricSystem | ||
3870 | 74 | |||
3871 | 75 | // Move to new Settings API | ||
3872 | 76 | settings.migrated = true | ||
3873 | 77 | settings.service = oldSettings["service"] === undefined ? "weatherchannel" : oldSettings["service"] | ||
3874 | 78 | |||
3875 | 79 | if (oldSettings["precip_units"] !== undefined) { | ||
3876 | 80 | settings.precipUnits = oldSettings["precip_units"] | ||
3877 | 81 | } else { | ||
3878 | 82 | settings.precipUnits = metric ? "mm" : "in" | ||
3879 | 83 | } | ||
3880 | 84 | |||
3881 | 85 | if (oldSettings["units"] !== undefined) { | ||
3882 | 86 | settings.tempScale = oldSettings["units"] === "metric" ? "°C" : "°F" | ||
3883 | 87 | settings.units = oldSettings["units"] | ||
3884 | 88 | } else { | ||
3885 | 89 | settings.tempScale = metric ? "°C" : "°F" | ||
3886 | 90 | settings.units = metric ? "metric" : "imperial" | ||
3887 | 91 | } | ||
3888 | 92 | |||
3889 | 93 | if (oldSettings["units"] !== undefined) { | ||
3890 | 94 | // If old wind speed was in "kmh" use "kph" instead | ||
3891 | 95 | settings.windUnits = oldSettings["wind_units"] === "kmh" ? "kph" : oldSettings["wind_units"] | ||
3892 | 96 | } else { | ||
3893 | 97 | settings.windUnits = metric ? "kph" : "mph" | ||
3894 | 98 | } | ||
3895 | 99 | |||
3896 | 100 | /* | ||
3897 | 101 | TODO: uncomment when reboot is ready to replace existing app | ||
3898 | 102 | db.transaction( function(tx) { | ||
3899 | 103 | tx.executeSql("DROP TABLE IF EXISTS settings") | ||
3900 | 104 | }); | ||
3901 | 105 | */ | ||
3902 | 106 | } catch (e) { // likely table did not exist | ||
3903 | 107 | console.debug("No old data to migrate.") | ||
3904 | 108 | settings.migrated = true | ||
3905 | 109 | } | ||
3906 | 110 | } | ||
3907 | 111 | } | ||
3908 | 112 | |||
3909 | 113 | function insertLocation(data) { | ||
3910 | 114 | openDB(); | ||
3911 | 115 | var res; | ||
3912 | 116 | |||
3913 | 117 | db.transaction( function(tx){ | ||
3914 | 118 | var r = tx.executeSql('INSERT INTO Locations(data, date) VALUES(?, ?)', [JSON.stringify(data), new Date().getTime()]); | ||
3915 | 119 | res = r.insertId; | ||
3916 | 120 | }); | ||
3917 | 121 | return res; | ||
3918 | 122 | } | ||
3919 | 123 | |||
3920 | 124 | function insertLocationAtStart(data) { | ||
3921 | 125 | var res = insertLocation(data); | ||
3922 | 126 | reorder(res, 0); | ||
3923 | 127 | return 0; | ||
3924 | 128 | } | ||
3925 | 129 | |||
3926 | 130 | function updateLocation(dbId, data) { | ||
3927 | 131 | openDB(); | ||
3928 | 132 | db.transaction( function(tx){ | ||
3929 | 133 | var r = tx.executeSql('UPDATE Locations SET data = ?, date=? WHERE id = ?', [JSON.stringify(data), new Date().getTime(), dbId]) | ||
3930 | 134 | }); | ||
3931 | 135 | } | ||
3932 | 136 | |||
3933 | 137 | function getLocations(callback) { | ||
3934 | 138 | openDB(); | ||
3935 | 139 | db.readTransaction( | ||
3936 | 140 | function(tx){ | ||
3937 | 141 | var locations = []; | ||
3938 | 142 | var rs = tx.executeSql('SELECT * FROM Locations'); | ||
3939 | 143 | for(var i = 0; i < rs.rows.length; i++) { | ||
3940 | 144 | var row = rs.rows.item(i), | ||
3941 | 145 | locData = JSON.parse(row.data); | ||
3942 | 146 | locData["updated"] = parseInt(row.date, 10); | ||
3943 | 147 | locData["db"] = {id: row.id, updated: new Date(parseInt(row.date, 10))}; | ||
3944 | 148 | locations.push(locData); | ||
3945 | 149 | } | ||
3946 | 150 | callback(locations); | ||
3947 | 151 | } | ||
3948 | 152 | ); | ||
3949 | 153 | } | ||
3950 | 154 | |||
3951 | 155 | function clearLocation(location_id) { | ||
3952 | 156 | openDB(); | ||
3953 | 157 | db.transaction(function(tx){ | ||
3954 | 158 | tx.executeSql('DELETE FROM Locations WHERE id = ?', [location_id]); | ||
3955 | 159 | }); | ||
3956 | 160 | } | ||
3957 | 161 | |||
3958 | 162 | function clearMultiLocation(locations) { | ||
3959 | 163 | openDB(); | ||
3960 | 164 | |||
3961 | 165 | db.transaction(function (tx) { | ||
3962 | 166 | // Remove all the deleted indexes | ||
3963 | 167 | for (var i=0; i < locations.length; i++) { | ||
3964 | 168 | tx.executeSql('DELETE FROM Locations WHERE id=?;', [locations[i]]) | ||
3965 | 169 | } | ||
3966 | 170 | |||
3967 | 171 | // Rebuild locations in order | ||
3968 | 172 | var rs = tx.executeSql('SELECT id FROM Locations ORDER BY id ASC') | ||
3969 | 173 | |||
3970 | 174 | for (i=0; i < rs.rows.length; i++) { | ||
3971 | 175 | tx.executeSql('UPDATE Locations SET id=? WHERE id=?;', | ||
3972 | 176 | [i, rs.rows.item(i).id]) | ||
3973 | 177 | } | ||
3974 | 178 | }) | ||
3975 | 179 | } | ||
3976 | 180 | |||
3977 | 181 | function clearDB() { // for dev purposes | ||
3978 | 182 | openDB(); | ||
3979 | 183 | db.transaction(function(tx){ | ||
3980 | 184 | tx.executeSql('DELETE FROM Locations WHERE 1'); | ||
3981 | 185 | }); | ||
3982 | 186 | } | ||
3983 | 187 | |||
3984 | 188 | function reorder(from, to) { | ||
3985 | 189 | openDB(); | ||
3986 | 190 | |||
3987 | 191 | db.transaction(function(tx) { | ||
3988 | 192 | // Track to move put as -1 for now | ||
3989 | 193 | tx.executeSql('UPDATE Locations SET id=? WHERE id=?;', | ||
3990 | 194 | [-1, from]) | ||
3991 | 195 | |||
3992 | 196 | // Shuffle locations inbetween from->to | ||
3993 | 197 | if (from > to) { | ||
3994 | 198 | for (var i = from-1; i >= to; i--) { | ||
3995 | 199 | tx.executeSql('UPDATE Locations SET id=? WHERE id=?;', | ||
3996 | 200 | [i+1, i]) | ||
3997 | 201 | } | ||
3998 | 202 | } else { | ||
3999 | 203 | for (var j = from+1; j <= to; j++) { | ||
4000 | 204 | tx.executeSql('UPDATE Locations SET id=? WHERE id=?;', | ||
4001 | 205 | [j-1, j]) | ||
4002 | 206 | } | ||
4003 | 207 | } | ||
4004 | 208 | |||
4005 | 209 | // Switch moving location to its new position | ||
4006 | 210 | tx.executeSql('UPDATE Locations SET id=? WHERE id=?;', | ||
4007 | 211 | [to, -1]) | ||
4008 | 212 | }) | ||
4009 | 213 | } | ||
4010 | 214 | } | ||
4011 | 0 | 215 | ||
4012 | === added file 'app/data/WeatherApi.js' | |||
4013 | --- app/data/WeatherApi.js 1970-01-01 00:00:00 +0000 | |||
4014 | +++ app/data/WeatherApi.js 2015-06-28 23:49:12 +0000 | |||
4015 | @@ -0,0 +1,754 @@ | |||
4016 | 1 | .pragma library | ||
4017 | 2 | /* | ||
4018 | 3 | * Copyright (C) 2013 Canonical Ltd | ||
4019 | 4 | * | ||
4020 | 5 | * This program is free software: you can redistribute it and/or modify | ||
4021 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
4022 | 7 | * published by the Free Software Foundation. | ||
4023 | 8 | * | ||
4024 | 9 | * This program is distributed in the hope that it will be useful, | ||
4025 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4026 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4027 | 12 | * GNU General Public License for more details. | ||
4028 | 13 | * | ||
4029 | 14 | * You should have received a copy of the GNU General Public License | ||
4030 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4031 | 16 | * | ||
4032 | 17 | * Authored by: Raúl Yeguas <neokore@gmail.com> | ||
4033 | 18 | * Martin Borho <martin@borho.net> | ||
4034 | 19 | * Andrew Starr-Bochicchio <a.starr.b@gmail.com> | ||
4035 | 20 | */ | ||
4036 | 21 | |||
4037 | 22 | /** | ||
4038 | 23 | * Version of the response data format. | ||
4039 | 24 | * Increase this number to force a refresh. | ||
4040 | 25 | */ | ||
4041 | 26 | var RESPONSE_DATA_VERSION = 20150404; | ||
4042 | 27 | |||
4043 | 28 | /** | ||
4044 | 29 | * Helper functions | ||
4045 | 30 | */ | ||
4046 | 31 | function debug(obj) { | ||
4047 | 32 | print(JSON.stringify(obj)) | ||
4048 | 33 | } | ||
4049 | 34 | // | ||
4050 | 35 | function calcFahrenheit(celsius) { | ||
4051 | 36 | return celsius * 1.8 + 32; | ||
4052 | 37 | } | ||
4053 | 38 | // | ||
4054 | 39 | function calcMph(ms) { | ||
4055 | 40 | return ms*2.24; | ||
4056 | 41 | } | ||
4057 | 42 | // | ||
4058 | 43 | function calcInch(mm) { | ||
4059 | 44 | return mm/25.4; | ||
4060 | 45 | } | ||
4061 | 46 | // | ||
4062 | 47 | function calcKph(ms) { | ||
4063 | 48 | return ms*3.6; | ||
4064 | 49 | } | ||
4065 | 50 | // | ||
4066 | 51 | function convertKphToMph(kph) { | ||
4067 | 52 | return kph*0.621; | ||
4068 | 53 | } | ||
4069 | 54 | // | ||
4070 | 55 | function calcWindDir(degrees) { | ||
4071 | 56 | var direction = "?"; | ||
4072 | 57 | if(degrees >=0 && degrees <= 30){ | ||
4073 | 58 | direction = "N"; | ||
4074 | 59 | } else if(degrees >30 && degrees <= 60){ | ||
4075 | 60 | direction = "NE"; | ||
4076 | 61 | } else if(degrees >60 && degrees <= 120){ | ||
4077 | 62 | direction = "E"; | ||
4078 | 63 | } else if(degrees >120 && degrees <= 150){ | ||
4079 | 64 | direction = "SE"; | ||
4080 | 65 | } else if(degrees >150 && degrees <= 210){ | ||
4081 | 66 | direction = "S"; | ||
4082 | 67 | } else if(degrees >210 && degrees <= 240){ | ||
4083 | 68 | direction = "SW"; | ||
4084 | 69 | } else if(degrees >240 && degrees <= 300){ | ||
4085 | 70 | direction = "W"; | ||
4086 | 71 | } else if(degrees >300 && degrees <= 330){ | ||
4087 | 72 | direction = "NW"; | ||
4088 | 73 | } else if(degrees >330 && degrees <= 360){ | ||
4089 | 74 | direction = "N"; | ||
4090 | 75 | } | ||
4091 | 76 | return direction; | ||
4092 | 77 | } | ||
4093 | 78 | |||
4094 | 79 | // | ||
4095 | 80 | function getLocationTime(tstamp) { | ||
4096 | 81 | var locTime = new Date(tstamp); | ||
4097 | 82 | return { | ||
4098 | 83 | year: locTime.getUTCFullYear(), | ||
4099 | 84 | month: locTime.getUTCMonth(), | ||
4100 | 85 | date: locTime.getUTCDate(), | ||
4101 | 86 | hours: locTime.getUTCHours(), | ||
4102 | 87 | minutes: locTime.getUTCMinutes() | ||
4103 | 88 | } | ||
4104 | 89 | } | ||
4105 | 90 | // Serialize a JavaScript object to URL parameters | ||
4106 | 91 | // E.g. {param1: value1, param2: value2} to "param1=value¶m2=value" | ||
4107 | 92 | // TODO: it'd be nice to make it work with either passing a single object | ||
4108 | 93 | // or several at once | ||
4109 | 94 | function parameterize(obj) { | ||
4110 | 95 | var str = []; | ||
4111 | 96 | for(var param in obj) { | ||
4112 | 97 | str.push(encodeURIComponent(param) + "=" + encodeURIComponent(obj[param])); | ||
4113 | 98 | } | ||
4114 | 99 | return str.join("&"); | ||
4115 | 100 | } | ||
4116 | 101 | |||
4117 | 102 | var GeoipApi = (function() { | ||
4118 | 103 | var _baseUrl = "http://geoip.ubuntu.com/lookup"; | ||
4119 | 104 | return { | ||
4120 | 105 | getLatLong: function(params, apiCaller, onSuccess, onError) { | ||
4121 | 106 | var request = { type: "geolookup",url: _baseUrl}, | ||
4122 | 107 | resultHandler = (function(request, xmlDoc) { | ||
4123 | 108 | var coords = {}, | ||
4124 | 109 | childNodes = xmlDoc.childNodes; | ||
4125 | 110 | for(var i=0;i<childNodes.length;i++) { | ||
4126 | 111 | if(childNodes[i].nodeName === "Latitude") { | ||
4127 | 112 | coords.lat = childNodes[i].firstChild.nodeValue; | ||
4128 | 113 | } else if(childNodes[i].nodeName === "Longitude") { | ||
4129 | 114 | coords.lon = childNodes[i].firstChild.nodeValue; | ||
4130 | 115 | } | ||
4131 | 116 | } | ||
4132 | 117 | onSuccess(coords); | ||
4133 | 118 | }), | ||
4134 | 119 | retryHandler = (function(err) { | ||
4135 | 120 | console.log("geolookup retry of "+err.request.url); | ||
4136 | 121 | apiCaller(request, resultHandler, onError); | ||
4137 | 122 | }); | ||
4138 | 123 | apiCaller(request, resultHandler, retryHandler); | ||
4139 | 124 | } | ||
4140 | 125 | } | ||
4141 | 126 | })(); | ||
4142 | 127 | |||
4143 | 128 | var GeonamesApi = (function() { | ||
4144 | 129 | /** | ||
4145 | 130 | provides neccessary methods for requesting and preparing data from Geonames.org | ||
4146 | 131 | */ | ||
4147 | 132 | var _baseUrl = "http://api.geonames.org/"; | ||
4148 | 133 | var _username = "uweatherdev" | ||
4149 | 134 | var _addParams = "&maxRows=25&featureClass=P" | ||
4150 | 135 | // | ||
4151 | 136 | function _buildSearchResult(request, data) { | ||
4152 | 137 | var searchResult = { locations: [], request: request }; | ||
4153 | 138 | if(data.geonames) { | ||
4154 | 139 | data.geonames.forEach(function(r) { | ||
4155 | 140 | searchResult.locations.push({ | ||
4156 | 141 | name: r.name, | ||
4157 | 142 | coord: {lat: r.lat, lon: r.lng}, | ||
4158 | 143 | country: r.countryCode, | ||
4159 | 144 | countryName: r.countryName, | ||
4160 | 145 | timezone: r.timezone, | ||
4161 | 146 | adminName1: r.adminName1, | ||
4162 | 147 | adminName2: r.adminName2, | ||
4163 | 148 | adminName3: r.adminName3, | ||
4164 | 149 | population: r.population, | ||
4165 | 150 | services: { | ||
4166 | 151 | "geonames": r.geonameId | ||
4167 | 152 | } | ||
4168 | 153 | }); | ||
4169 | 154 | }) | ||
4170 | 155 | } | ||
4171 | 156 | return searchResult; | ||
4172 | 157 | } | ||
4173 | 158 | // | ||
4174 | 159 | return { | ||
4175 | 160 | // | ||
4176 | 161 | search: function(mode, params, apiCaller, onSuccess, onError) { | ||
4177 | 162 | var request, | ||
4178 | 163 | retryHandler = (function(err) { | ||
4179 | 164 | console.log("search retry of "+err.request.url); | ||
4180 | 165 | apiCaller(request, searchResponseHandler, onError); | ||
4181 | 166 | }), | ||
4182 | 167 | searchResponseHandler = function(request, data) { | ||
4183 | 168 | onSuccess(_buildSearchResult(request, data)); | ||
4184 | 169 | }; | ||
4185 | 170 | if(mode === "point") { | ||
4186 | 171 | request = { type: "search", | ||
4187 | 172 | url: _baseUrl+ "findNearbyPlaceNameJSON?style=full&username="+encodeURIComponent(_username) | ||
4188 | 173 | +"&lat="+encodeURIComponent(params.coords.lat)+"&lng="+encodeURIComponent(params.coords.lon) | ||
4189 | 174 | +_addParams} | ||
4190 | 175 | } else { | ||
4191 | 176 | request = { type: "search", | ||
4192 | 177 | url: _baseUrl+ "searchJSON?style=full&username="+encodeURIComponent(_username) | ||
4193 | 178 | +"&name_startsWith="+encodeURIComponent(params.name)+_addParams} | ||
4194 | 179 | } | ||
4195 | 180 | apiCaller(request, searchResponseHandler, retryHandler); | ||
4196 | 181 | } | ||
4197 | 182 | } | ||
4198 | 183 | |||
4199 | 184 | })(); | ||
4200 | 185 | |||
4201 | 186 | var OpenWeatherMapApi = (function() { | ||
4202 | 187 | /** | ||
4203 | 188 | provides neccessary methods for requesting and preparing data from OpenWeatherMap.org | ||
4204 | 189 | */ | ||
4205 | 190 | var _baseUrl = "http://api.openweathermap.org/data/2.5/"; | ||
4206 | 191 | // | ||
4207 | 192 | var _serviceName = "openweathermap"; | ||
4208 | 193 | // | ||
4209 | 194 | var _icon_map = { | ||
4210 | 195 | "01d": "sun", | ||
4211 | 196 | "01n": "moon", | ||
4212 | 197 | "02d": "cloud_sun", | ||
4213 | 198 | "02n": "cloud_moon", | ||
4214 | 199 | "03d": "cloud_sun", | ||
4215 | 200 | "03n": "cloud_moon", | ||
4216 | 201 | "04d": "cloud", | ||
4217 | 202 | "04n": "cloud", | ||
4218 | 203 | "09d": "rain", | ||
4219 | 204 | "09n": "rain", | ||
4220 | 205 | "10d": "rain", | ||
4221 | 206 | "10n": "rain", | ||
4222 | 207 | "11d": "thunder", | ||
4223 | 208 | "11n": "thunder", | ||
4224 | 209 | "13d": "snow_shower", | ||
4225 | 210 | "13n": "snow_shower", | ||
4226 | 211 | "50d": "fog", | ||
4227 | 212 | "50n": "fog" | ||
4228 | 213 | } | ||
4229 | 214 | // | ||
4230 | 215 | function _buildDataPoint(date, data) { | ||
4231 | 216 | var result = { | ||
4232 | 217 | timestamp: data.dt, | ||
4233 | 218 | date: date, | ||
4234 | 219 | metric: { | ||
4235 | 220 | temp:data.main.temp, | ||
4236 | 221 | windSpeed: calcKph(data.wind.speed), | ||
4237 | 222 | rain: data.main.rain || ((data.rain) ? data.rain["3h"] : false ) || 0, | ||
4238 | 223 | snow: data.main.snow || ((data.snow) ? data.snow["3h"] : false ) || 0 | ||
4239 | 224 | }, | ||
4240 | 225 | imperial: { | ||
4241 | 226 | temp: calcFahrenheit(data.main.temp), | ||
4242 | 227 | windSpeed: calcMph(data.wind.speed), | ||
4243 | 228 | rain: calcInch(data.main.rain || ((data.rain) ? data.rain["3h"] : false ) || 0), | ||
4244 | 229 | snow: calcInch(data.main.snow || ((data.snow) ? data.snow["3h"] : false ) ||0) | ||
4245 | 230 | }, | ||
4246 | 231 | humidity: data.main.humidity, | ||
4247 | 232 | pressure: data.main.pressure, | ||
4248 | 233 | windDeg: data.wind.deg, | ||
4249 | 234 | windDir: calcWindDir(data.wind.deg), | ||
4250 | 235 | icon: _icon_map[data.weather[0].icon], | ||
4251 | 236 | condition: data.weather[0].main | ||
4252 | 237 | }; | ||
4253 | 238 | if(data.id !== undefined) { | ||
4254 | 239 | result["service"] = _serviceName; | ||
4255 | 240 | result["service_id"] = data.id; | ||
4256 | 241 | } | ||
4257 | 242 | return result; | ||
4258 | 243 | } | ||
4259 | 244 | // | ||
4260 | 245 | function _buildDayFormat(date, data) { | ||
4261 | 246 | var result = { | ||
4262 | 247 | date: date, | ||
4263 | 248 | timestamp: data.dt, | ||
4264 | 249 | metric: { | ||
4265 | 250 | tempMin: data.temp.min, | ||
4266 | 251 | tempMax: data.temp.max, | ||
4267 | 252 | windSpeed: calcKph(data.speed), | ||
4268 | 253 | rain: data.rain || 0, | ||
4269 | 254 | snow: data.snow || 0 | ||
4270 | 255 | }, | ||
4271 | 256 | imperial: { | ||
4272 | 257 | tempMin: calcFahrenheit(data.temp.min), | ||
4273 | 258 | tempMax: calcFahrenheit(data.temp.max), | ||
4274 | 259 | windSpeed: calcMph(data.speed), | ||
4275 | 260 | rain: calcInch(data.rain || 0), | ||
4276 | 261 | snow: calcInch(data.snow || 0) | ||
4277 | 262 | }, | ||
4278 | 263 | pressure: data.pressure, | ||
4279 | 264 | humidity: data.humidity, | ||
4280 | 265 | icon: _icon_map[data.weather[0].icon], | ||
4281 | 266 | condition: data.weather[0].main, | ||
4282 | 267 | windDeg: data.deg, | ||
4283 | 268 | windDir: calcWindDir(data.deg), | ||
4284 | 269 | hourly: [] | ||
4285 | 270 | } | ||
4286 | 271 | return result; | ||
4287 | 272 | } | ||
4288 | 273 | // | ||
4289 | 274 | function formatResult(data, location) { | ||
4290 | 275 | var tmpResult = {}, | ||
4291 | 276 | result = [], | ||
4292 | 277 | day=null, | ||
4293 | 278 | offset=(location.timezone && location.timezone.gmtOffset) ? location.timezone.gmtOffset*60*60*1000: 0, | ||
4294 | 279 | localNow = getLocationTime(new Date().getTime()+offset), | ||
4295 | 280 | todayDate; | ||
4296 | 281 | print("["+location.name+"] "+JSON.stringify(localNow)) | ||
4297 | 282 | // add openweathermap id for faster responses | ||
4298 | 283 | if(location.services && !location.services[_serviceName] && data["current"].id) { | ||
4299 | 284 | location.services[_serviceName] = data["current"].id | ||
4300 | 285 | } | ||
4301 | 286 | // | ||
4302 | 287 | data["daily"]["list"].forEach(function(dayData) { | ||
4303 | 288 | var date = getLocationTime(((dayData.dt*1000)-1000)+offset), // minus 1 sec to handle +/-12 TZ | ||
4304 | 289 | day = date.year+"-"+date.month+"-"+date.date; | ||
4305 | 290 | if(!todayDate) { | ||
4306 | 291 | if(localNow.year+"-"+localNow.month+"-"+localNow.date > day) { | ||
4307 | 292 | // skip "yesterday" | ||
4308 | 293 | return; | ||
4309 | 294 | } | ||
4310 | 295 | todayDate = date; | ||
4311 | 296 | } | ||
4312 | 297 | tmpResult[day] = _buildDayFormat(date, dayData); | ||
4313 | 298 | }) | ||
4314 | 299 | // | ||
4315 | 300 | var today = todayDate.year+"-"+todayDate.month+"-"+todayDate.date | ||
4316 | 301 | tmpResult[today]["current"] = _buildDataPoint(todayDate, data["current"]); | ||
4317 | 302 | if(data["forecast"] !== undefined) { | ||
4318 | 303 | data["forecast"]["list"].forEach(function(hourData) { | ||
4319 | 304 | var dateData = getLocationTime((hourData.dt*1000)+offset), | ||
4320 | 305 | day = dateData.year+"-"+dateData.month+"-"+dateData.date; | ||
4321 | 306 | if(tmpResult[day]) { | ||
4322 | 307 | tmpResult[day]["hourly"].push(_buildDataPoint(dateData, hourData)); | ||
4323 | 308 | } | ||
4324 | 309 | }) | ||
4325 | 310 | } | ||
4326 | 311 | // | ||
4327 | 312 | for(var d in tmpResult) { | ||
4328 | 313 | result.push(tmpResult[d]); | ||
4329 | 314 | } | ||
4330 | 315 | return result; | ||
4331 | 316 | } | ||
4332 | 317 | // | ||
4333 | 318 | function _getUrls(params) { | ||
4334 | 319 | var urls = { | ||
4335 | 320 | current: "", | ||
4336 | 321 | daily: "", | ||
4337 | 322 | forecast: "" | ||
4338 | 323 | }, | ||
4339 | 324 | latLongParams = "&lat="+encodeURIComponent(params.location.coord.lat) | ||
4340 | 325 | + "&lon="+encodeURIComponent(params.location.coord.lon); | ||
4341 | 326 | if(params.location.services && params.location.services[_serviceName]) { | ||
4342 | 327 | urls.current = _baseUrl + "weather?units="+params.units+"&id="+params.location.services[_serviceName]; | ||
4343 | 328 | urls.daily = _baseUrl + "forecast/daily?id="+params.location.services[_serviceName]+"&cnt=10&units="+params.units | ||
4344 | 329 | urls.forecast = _baseUrl + "forecast?id="+params.location.services[_serviceName]+"&units="+params.units | ||
4345 | 330 | |||
4346 | 331 | } else if (params.location.coord) { | ||
4347 | 332 | urls.current = _baseUrl + "weather?units="+params.units+latLongParams; | ||
4348 | 333 | urls.daily = _baseUrl+"forecast/daily?cnt=10&units="+params.units+latLongParams; | ||
4349 | 334 | urls.forecast = _baseUrl+"forecast?units="+params.units+latLongParams; | ||
4350 | 335 | } | ||
4351 | 336 | return urls; | ||
4352 | 337 | } | ||
4353 | 338 | // | ||
4354 | 339 | return { | ||
4355 | 340 | // | ||
4356 | 341 | getData: function(params, apiCaller, onSuccess, onError) { | ||
4357 | 342 | var urls = _getUrls(params), | ||
4358 | 343 | handlerMap = { | ||
4359 | 344 | current: { type: "current",url: urls.current}, | ||
4360 | 345 | daily: { type: "daily",url: urls.daily}, | ||
4361 | 346 | forecast: { type: "forecast", url: urls.forecast}}, | ||
4362 | 347 | response = { | ||
4363 | 348 | location: params.location, | ||
4364 | 349 | db: (params.db) ? params.db : null, | ||
4365 | 350 | format: RESPONSE_DATA_VERSION | ||
4366 | 351 | }, | ||
4367 | 352 | respData = {}, | ||
4368 | 353 | addDataToResponse = (function(request, data) { | ||
4369 | 354 | var formattedResult; | ||
4370 | 355 | respData[request.type] = data; | ||
4371 | 356 | if(respData["current"] !== undefined | ||
4372 | 357 | && respData["forecast"] !== undefined | ||
4373 | 358 | && respData["daily"] !== undefined) { | ||
4374 | 359 | response["data"] = formatResult(respData, params.location) | ||
4375 | 360 | onSuccess(response); | ||
4376 | 361 | } | ||
4377 | 362 | }), | ||
4378 | 363 | onErrorHandler = (function(err) { | ||
4379 | 364 | onError(err); | ||
4380 | 365 | }), | ||
4381 | 366 | retryHandler = (function(err) { | ||
4382 | 367 | console.log("retry of "+err.request.url); | ||
4383 | 368 | var retryFunc = handlerMap[err.request.type]; | ||
4384 | 369 | apiCaller(retryFunc, addDataToResponse, onErrorHandler); | ||
4385 | 370 | }); | ||
4386 | 371 | // | ||
4387 | 372 | apiCaller(handlerMap.current, addDataToResponse, retryHandler); | ||
4388 | 373 | apiCaller(handlerMap.forecast, addDataToResponse, retryHandler); | ||
4389 | 374 | apiCaller(handlerMap.daily, addDataToResponse, retryHandler); | ||
4390 | 375 | } | ||
4391 | 376 | } | ||
4392 | 377 | |||
4393 | 378 | })(); | ||
4394 | 379 | |||
4395 | 380 | var WeatherChannelApi = (function() { | ||
4396 | 381 | /** | ||
4397 | 382 | provides neccessary methods for requesting and preparing data from OpenWeatherMap.org | ||
4398 | 383 | */ | ||
4399 | 384 | var _baseUrl = "http://wxdata.weather.com/wxdata/"; | ||
4400 | 385 | // | ||
4401 | 386 | var _serviceName = "weatherchannel"; | ||
4402 | 387 | // | ||
4403 | 388 | // see http://s.imwx.com/v.20131006.223722/img/wxicon/72/([0-9]+).png | ||
4404 | 389 | var _iconMap = { | ||
4405 | 390 | "0": "thunder", // ?? | ||
4406 | 391 | "1": "thunder", // ?? | ||
4407 | 392 | "2": "thunder", // ?? | ||
4408 | 393 | "3": "thunder", // ?? | ||
4409 | 394 | "4": "thunder", //T-Storms | ||
4410 | 395 | "5": "snow_rain", //Rain / Snow | ||
4411 | 396 | "6": "snow_rain", // ?? | ||
4412 | 397 | "7": "snow_rain", //Wintry Mix | ||
4413 | 398 | "8": "scattered", //Freezing Drizzle | ||
4414 | 399 | "9": "scattered", //Drizzle | ||
4415 | 400 | "10": "rain", // ?? | ||
4416 | 401 | "11": "rain", //Showers | ||
4417 | 402 | "12": "rain", //Rain | ||
4418 | 403 | "13": "snow_shower", // ?? | ||
4419 | 404 | "14": "snow_shower", //Snow shower/Light snow | ||
4420 | 405 | "15": "snow_shower", // | ||
4421 | 406 | "16": "snow_shower", //Snow | ||
4422 | 407 | "17": "thunder", // Hail?? | ||
4423 | 408 | "18": "snow_rain", // Rain / Snow ?? | ||
4424 | 409 | "19": "fog", //Fog ?? | ||
4425 | 410 | "20": "fog", //Fog | ||
4426 | 411 | "21": "fog", //Haze | ||
4427 | 412 | "22": "fog", // ?? | ||
4428 | 413 | "23": "fog", // Wind ?? | ||
4429 | 414 | "24": "overcast", //Partly Cloudy / Wind | ||
4430 | 415 | "25": "overcast", // ?? | ||
4431 | 416 | "26": "overcast",//Cloudy | ||
4432 | 417 | "27": "cloud_moon",//Mostly Cloudy | ||
4433 | 418 | "28": "cloud_sun", //Mostly Cloudy | ||
4434 | 419 | "29": "cloud_moon", //Partly Cloudy | ||
4435 | 420 | "30": "cloud_sun", //Partly Cloudy | ||
4436 | 421 | "31": "moon", //Clear | ||
4437 | 422 | "32": "sun", //Sunny | ||
4438 | 423 | "33": "cloud_moon", //Mostly Clear | ||
4439 | 424 | "34": "cloud_sun", //Mostly Sunny | ||
4440 | 425 | "35": "snow_rain", // ?? | ||
4441 | 426 | "36": "sun", //Sunny | ||
4442 | 427 | "37": "thunder", //Isolated T-Storms | ||
4443 | 428 | "38": "thunder", //Scattered T-Storms | ||
4444 | 429 | "39": "scattered", //Scattered Showers | ||
4445 | 430 | "40": "rain", // ?? | ||
4446 | 431 | "41": "snow", //Scattered Snow Showers | ||
4447 | 432 | "42": "snow_shower", // ?? | ||
4448 | 433 | "43": "snow_shower", // ?? | ||
4449 | 434 | "44": "fog", // ?? | ||
4450 | 435 | "45": "scattered", // ?? | ||
4451 | 436 | "46": "snow_shower", //Snow Showers Early | ||
4452 | 437 | "47": "thunder" //Isolated T-Storms | ||
4453 | 438 | }; | ||
4454 | 439 | // | ||
4455 | 440 | function _buildDataPoint(date, dataObj) { | ||
4456 | 441 | var data = dataObj["Observation"] || dataObj, | ||
4457 | 442 | result = { | ||
4458 | 443 | timestamp: data.date || data.dateTime, | ||
4459 | 444 | date: date, | ||
4460 | 445 | metric: { | ||
4461 | 446 | temp: data.temp, | ||
4462 | 447 | tempFeels: data.feelsLike, | ||
4463 | 448 | windSpeed: data.wSpeed | ||
4464 | 449 | }, | ||
4465 | 450 | imperial: { | ||
4466 | 451 | temp: calcFahrenheit(data.temp), | ||
4467 | 452 | tempFeels: calcFahrenheit(data.feelsLike), | ||
4468 | 453 | windSpeed: convertKphToMph(data.wSpeed) | ||
4469 | 454 | }, | ||
4470 | 455 | precipType: (data.precip_type !== undefined) ? data.precip_type : null, | ||
4471 | 456 | propPrecip: (data.pop !== undefined) ? data.pop : null, | ||
4472 | 457 | humidity: data.humid, | ||
4473 | 458 | pressure: data.pressure, | ||
4474 | 459 | windDeg: data.wDir, | ||
4475 | 460 | windDir: data.wDirText, | ||
4476 | 461 | icon: _iconMap[(data.wxIcon||data.icon)], | ||
4477 | 462 | condition: data.text || data.wDesc, | ||
4478 | 463 | uv: data.uv | ||
4479 | 464 | }; | ||
4480 | 465 | if(_iconMap[data.wxIcon||data.icon] === undefined) { | ||
4481 | 466 | print("ICON MISSING POINT: "+(data.wxIcon||data.icon)+" "+result.condition) | ||
4482 | 467 | } | ||
4483 | 468 | return result; | ||
4484 | 469 | } | ||
4485 | 470 | // | ||
4486 | 471 | function _buildDayFormat(date, data, now) { | ||
4487 | 472 | var partData = (now > data.validDate || data.day === undefined) ? data.night : data.day, | ||
4488 | 473 | result = { | ||
4489 | 474 | date: date, | ||
4490 | 475 | timestamp: data.validDate, | ||
4491 | 476 | metric: { | ||
4492 | 477 | tempMin: data.minTemp, | ||
4493 | 478 | tempMax: data.maxTemp, | ||
4494 | 479 | windSpeed: partData.wSpeed | ||
4495 | 480 | }, | ||
4496 | 481 | imperial: { | ||
4497 | 482 | tempMin: calcFahrenheit(data.minTemp), | ||
4498 | 483 | tempMax: calcFahrenheit(data.maxTemp !== undefined ? data.maxTemp : data.minTemp), | ||
4499 | 484 | windSpeed: convertKphToMph(partData.wSpeed) | ||
4500 | 485 | }, | ||
4501 | 486 | precipType: partData.precip_type, | ||
4502 | 487 | propPrecip: partData.pop, | ||
4503 | 488 | pressure: null, | ||
4504 | 489 | humidity: partData.humid, | ||
4505 | 490 | icon: _iconMap[partData.icon], | ||
4506 | 491 | condition: partData.phrase, | ||
4507 | 492 | windDeg: partData.wDir, | ||
4508 | 493 | windDir: partData.wDirText, | ||
4509 | 494 | uv: partData.uv, | ||
4510 | 495 | hourly: [] | ||
4511 | 496 | } | ||
4512 | 497 | if(_iconMap[partData.icon] === undefined) { | ||
4513 | 498 | print("ICON MISSING DAY: "+partData.icon+" "+result.condition) | ||
4514 | 499 | } | ||
4515 | 500 | return result; | ||
4516 | 501 | } | ||
4517 | 502 | // | ||
4518 | 503 | function formatResult(combinedData, location) { | ||
4519 | 504 | var tmpResult = {}, result = [], | ||
4520 | 505 | day=null, todayDate, | ||
4521 | 506 | offset=(location.timezone && location.timezone.gmtOffset) ? location.timezone.gmtOffset*60*60*1000: 0, | ||
4522 | 507 | now = new Date().getTime(), | ||
4523 | 508 | nowMs = parseInt(now/1000), | ||
4524 | 509 | localNow = getLocationTime(now+offset), | ||
4525 | 510 | data = { | ||
4526 | 511 | "location": combinedData[0]["Location"], | ||
4527 | 512 | "daily": combinedData[0]["DailyForecasts"], | ||
4528 | 513 | "forecast": combinedData[0]["HourlyForecasts"], | ||
4529 | 514 | "current": combinedData[0]["StandardObservation"], | ||
4530 | 515 | }; | ||
4531 | 516 | print("["+location.name+"] "+JSON.stringify(localNow)); | ||
4532 | 517 | // add openweathermap id for faster responses | ||
4533 | 518 | if(location.services && !location.services[_serviceName] && data["location"].key) { | ||
4534 | 519 | location.services[_serviceName] = data["location"].key | ||
4535 | 520 | } | ||
4536 | 521 | // only 5 days of forecast for TWC | ||
4537 | 522 | for(var x=0;x<5;x++) { | ||
4538 | 523 | var dayData = data["daily"][x], | ||
4539 | 524 | date = getLocationTime(((dayData.validDate*1000)-1000)+offset); // minus 1 sec to handle +/-12 TZ | ||
4540 | 525 | day = date.year+"-"+date.month+"-"+date.date; | ||
4541 | 526 | if(!todayDate) { | ||
4542 | 527 | if(localNow.year+"-"+localNow.month+"-"+localNow.date > day) { | ||
4543 | 528 | // skip "yesterday" | ||
4544 | 529 | continue; | ||
4545 | 530 | } | ||
4546 | 531 | todayDate = date; | ||
4547 | 532 | } | ||
4548 | 533 | tmpResult[day] = _buildDayFormat(date, dayData, nowMs); | ||
4549 | 534 | } | ||
4550 | 535 | // | ||
4551 | 536 | if(data["forecast"] !== undefined) { | ||
4552 | 537 | data["forecast"].forEach(function(hourData) { | ||
4553 | 538 | var dateData = getLocationTime((hourData.dateTime*1000)+offset), | ||
4554 | 539 | day = dateData.year+"-"+dateData.month+"-"+dateData.date; | ||
4555 | 540 | if(tmpResult[day]) { | ||
4556 | 541 | tmpResult[day]["hourly"].push(_buildDataPoint(dateData, hourData)); | ||
4557 | 542 | } | ||
4558 | 543 | }) | ||
4559 | 544 | } | ||
4560 | 545 | // | ||
4561 | 546 | if(data["current"]) { | ||
4562 | 547 | var today = todayDate.year+"-"+todayDate.month+"-"+todayDate.date; | ||
4563 | 548 | tmpResult[today]["current"] = _buildDataPoint(todayDate, data["current"]); | ||
4564 | 549 | // if the icon is missing, use the first from the hourly forecast | ||
4565 | 550 | if(!tmpResult[today]["current"].icon && tmpResult[today]["hourly"] && tmpResult[today]["hourly"].length > 0) { | ||
4566 | 551 | tmpResult[today]["current"].icon = tmpResult[today]["hourly"][0].icon; | ||
4567 | 552 | } | ||
4568 | 553 | // if condition text is missing, use the condition from the first hourly forecast | ||
4569 | 554 | if((tmpResult[today]["current"].condition === "-" || tmpResult[today]["current"].condition === undefined) | ||
4570 | 555 | && (tmpResult[today]["hourly"] && tmpResult[today]["hourly"].length > 0)) { | ||
4571 | 556 | tmpResult[today]["current"].condition = tmpResult[today]["hourly"][0].condition; | ||
4572 | 557 | } | ||
4573 | 558 | } | ||
4574 | 559 | // | ||
4575 | 560 | for(var d in tmpResult) { | ||
4576 | 561 | result.push(tmpResult[d]); | ||
4577 | 562 | } | ||
4578 | 563 | return result; | ||
4579 | 564 | } | ||
4580 | 565 | // | ||
4581 | 566 | function _getUrl(params) { | ||
4582 | 567 | var url, serviceId, | ||
4583 | 568 | baseParams = { | ||
4584 | 569 | key: params.api_key, | ||
4585 | 570 | units: (params.units === "metric") ? "m" : "e", | ||
4586 | 571 | locale: Qt.locale().name, | ||
4587 | 572 | hours: "48", | ||
4588 | 573 | }, | ||
4589 | 574 | commands = { | ||
4590 | 575 | "mobileaggregation": "mobile/mobagg/", | ||
4591 | 576 | }; | ||
4592 | 577 | if(params.location.services && params.location.services[_serviceName]) { | ||
4593 | 578 | serviceId = encodeURIComponent(params.location.services[_serviceName]); | ||
4594 | 579 | url = _baseUrl+commands["mobileaggregation"]+serviceId+".js?"+parameterize(baseParams); | ||
4595 | 580 | } else if (params.location.coord) { | ||
4596 | 581 | var coord = {lat: params.location.coord.lat, lng: params.location.coord.lon}; | ||
4597 | 582 | url = _baseUrl+commands["mobileaggregation"]+"get.js?"+parameterize(baseParams)+"&"+ | ||
4598 | 583 | parameterize(coord); | ||
4599 | 584 | } | ||
4600 | 585 | return url; | ||
4601 | 586 | } | ||
4602 | 587 | // | ||
4603 | 588 | return { | ||
4604 | 589 | getData: function(params, apiCaller, onSuccess, onError) { | ||
4605 | 590 | var url = _getUrl(params), | ||
4606 | 591 | handlerMap = { | ||
4607 | 592 | all: { type: "all", url: url} | ||
4608 | 593 | }, | ||
4609 | 594 | response = { | ||
4610 | 595 | location: params.location, | ||
4611 | 596 | db: (params.db) ? params.db : null, | ||
4612 | 597 | format: RESPONSE_DATA_VERSION | ||
4613 | 598 | }, | ||
4614 | 599 | addDataToResponse = (function(request, data) { | ||
4615 | 600 | var formattedResult; | ||
4616 | 601 | response["data"] = formatResult(data, params.location); | ||
4617 | 602 | onSuccess(response); | ||
4618 | 603 | }), | ||
4619 | 604 | onErrorHandler = (function(err) { | ||
4620 | 605 | onError(err); | ||
4621 | 606 | }); | ||
4622 | 607 | apiCaller(handlerMap.all, addDataToResponse, onErrorHandler); | ||
4623 | 608 | } | ||
4624 | 609 | } | ||
4625 | 610 | })(); | ||
4626 | 611 | |||
4627 | 612 | var WeatherApi = (function(_services) { | ||
4628 | 613 | /** | ||
4629 | 614 | proxy for requesting weather apis, the passed _services are providing the respective api endpoints | ||
4630 | 615 | and formatters to build a uniform response object | ||
4631 | 616 | */ | ||
4632 | 617 | function _getService(name) { | ||
4633 | 618 | if(_services[name] !== undefined) { | ||
4634 | 619 | return _services[name]; | ||
4635 | 620 | } | ||
4636 | 621 | return _services["weatherchannel"]; | ||
4637 | 622 | } | ||
4638 | 623 | // | ||
4639 | 624 | function _sendRequest(request, onSuccess, onError) { | ||
4640 | 625 | var xmlHttp = new XMLHttpRequest(); | ||
4641 | 626 | if (xmlHttp) { | ||
4642 | 627 | console.log("Sent request URL: " + request.url); | ||
4643 | 628 | xmlHttp.open('GET', request.url, true); | ||
4644 | 629 | xmlHttp.onreadystatechange = function () { | ||
4645 | 630 | try { | ||
4646 | 631 | if (xmlHttp.readyState == 4) { | ||
4647 | 632 | if(xmlHttp.status === 200) { | ||
4648 | 633 | if(xmlHttp.responseXML) { | ||
4649 | 634 | onSuccess(request, xmlHttp.responseXML.documentElement); | ||
4650 | 635 | } else { | ||
4651 | 636 | var json = JSON.parse(xmlHttp.responseText); | ||
4652 | 637 | onSuccess(request,json); | ||
4653 | 638 | } | ||
4654 | 639 | } else { | ||
4655 | 640 | onError({ | ||
4656 | 641 | msg: "wrong response http code, got "+xmlHttp.status, | ||
4657 | 642 | request: request | ||
4658 | 643 | }); | ||
4659 | 644 | } | ||
4660 | 645 | } | ||
4661 | 646 | } catch (e) { | ||
4662 | 647 | print("Exception: "+e) | ||
4663 | 648 | onError({msg: "wrong response data format", request: request}); | ||
4664 | 649 | } | ||
4665 | 650 | }; | ||
4666 | 651 | xmlHttp.send(null); | ||
4667 | 652 | } | ||
4668 | 653 | } | ||
4669 | 654 | // | ||
4670 | 655 | return { | ||
4671 | 656 | // | ||
4672 | 657 | geoLookup: function(params, onSuccess, onError) { | ||
4673 | 658 | var service = _getService('geoip'), | ||
4674 | 659 | geoNameService = _getService('geonames'), | ||
4675 | 660 | lookupHandler = function(data) { | ||
4676 | 661 | print("Geolookup: "+JSON.stringify(data)) | ||
4677 | 662 | geoNameService.search("point", {coords:data}, _sendRequest, onSuccess, onError); | ||
4678 | 663 | }; | ||
4679 | 664 | service.getLatLong(params, _sendRequest, lookupHandler, onError) | ||
4680 | 665 | }, | ||
4681 | 666 | // | ||
4682 | 667 | search: function(mode, params, onSuccess, onError) { | ||
4683 | 668 | var service = _getService('geonames'); | ||
4684 | 669 | service.search(mode, params, _sendRequest, onSuccess, onError); | ||
4685 | 670 | }, | ||
4686 | 671 | // | ||
4687 | 672 | getLocationData: function(params, onSuccess, onError) { | ||
4688 | 673 | var service = _getService(params.service); | ||
4689 | 674 | service.getData(params, _sendRequest, onSuccess, onError); | ||
4690 | 675 | }, | ||
4691 | 676 | } | ||
4692 | 677 | })({ | ||
4693 | 678 | "openweathermap": OpenWeatherMapApi, | ||
4694 | 679 | "weatherchannel": WeatherChannelApi, | ||
4695 | 680 | "geonames": GeonamesApi, | ||
4696 | 681 | "geoip": GeoipApi | ||
4697 | 682 | }); | ||
4698 | 683 | |||
4699 | 684 | var sendRequest = function(message, responseCallback) { | ||
4700 | 685 | // handles the response data | ||
4701 | 686 | var finished = function(result) { | ||
4702 | 687 | // print result to get data for test json files | ||
4703 | 688 | // print(JSON.stringify(result)); | ||
4704 | 689 | //WorkerScript.sendMessage({ | ||
4705 | 690 | responseCallback({ | ||
4706 | 691 | action: message.action, | ||
4707 | 692 | result: result | ||
4708 | 693 | }) | ||
4709 | 694 | } | ||
4710 | 695 | // handles errors | ||
4711 | 696 | var onError = function(err) { | ||
4712 | 697 | console.log(JSON.stringify(err, null, true)); | ||
4713 | 698 | //WorkerScript.sendMessage({ 'error': err}) | ||
4714 | 699 | responseCallback({ 'error': err}) | ||
4715 | 700 | } | ||
4716 | 701 | // keep order of locations, sort results | ||
4717 | 702 | var sortDataResults = function(locA, locB) { | ||
4718 | 703 | return locA.db.id - locB.db.id; | ||
4719 | 704 | } | ||
4720 | 705 | // perform the api calls | ||
4721 | 706 | if(message.action === "searchByName") { | ||
4722 | 707 | WeatherApi.search("name", message.params, finished, onError); | ||
4723 | 708 | } else if(message.action === "searchByPoint") { | ||
4724 | 709 | WeatherApi.search("point", message.params, finished, onError); | ||
4725 | 710 | } else if(message.action === "getGeoIp") { | ||
4726 | 711 | WeatherApi.geoLookup(message.params, finished, onError); | ||
4727 | 712 | } else if(message.action === "updateData") { | ||
4728 | 713 | var locLength = message.params.locations.length, | ||
4729 | 714 | locUpdated = 0, | ||
4730 | 715 | result = [], | ||
4731 | 716 | now = new Date().getTime(); | ||
4732 | 717 | if(locLength > 0) { | ||
4733 | 718 | message.params.locations.forEach(function(loc) { | ||
4734 | 719 | var updatedHnd = function (newData, cached) { | ||
4735 | 720 | locUpdated += 1; | ||
4736 | 721 | if(cached === true) { | ||
4737 | 722 | newData["save"] = false; | ||
4738 | 723 | } else { | ||
4739 | 724 | newData["save"] = true; | ||
4740 | 725 | newData["updated"] = new Date().getTime(); | ||
4741 | 726 | } | ||
4742 | 727 | result.push(newData); | ||
4743 | 728 | if(locUpdated === locLength) { | ||
4744 | 729 | result.sort(sortDataResults); | ||
4745 | 730 | finished(result); | ||
4746 | 731 | } | ||
4747 | 732 | }, | ||
4748 | 733 | params = { | ||
4749 | 734 | location:loc.location, | ||
4750 | 735 | db: loc.db, | ||
4751 | 736 | units: 'metric', | ||
4752 | 737 | service: message.params.service, | ||
4753 | 738 | api_key: message.params.api_key, | ||
4754 | 739 | interval: message.params.interval | ||
4755 | 740 | }, | ||
4756 | 741 | secsFromLastFetch = (now-loc.updated)/1000; | ||
4757 | 742 | if( message.params.force===true || loc.format !== RESPONSE_DATA_VERSION || secsFromLastFetch > params.interval){ | ||
4758 | 743 | // data older than 30min, location is new or data format is deprecated | ||
4759 | 744 | WeatherApi.getLocationData(params, updatedHnd, onError); | ||
4760 | 745 | } else { | ||
4761 | 746 | console.log("["+loc.location.name+"] returning cached data, time from last fetch: "+secsFromLastFetch) | ||
4762 | 747 | updatedHnd(loc, true); | ||
4763 | 748 | } | ||
4764 | 749 | }) | ||
4765 | 750 | } else { | ||
4766 | 751 | finished(result); | ||
4767 | 752 | } | ||
4768 | 753 | } | ||
4769 | 754 | } | ||
4770 | 0 | 755 | ||
4771 | === added file 'app/data/key.js' | |||
4772 | --- app/data/key.js 1970-01-01 00:00:00 +0000 | |||
4773 | +++ app/data/key.js 2015-06-28 23:49:12 +0000 | |||
4774 | @@ -0,0 +1,1 @@ | |||
4775 | 1 | var twcKey = ""; | ||
4776 | 0 | 2 | ||
4777 | === added directory 'app/graphics' | |||
4778 | === added file 'app/graphics/Big-Rain.png' | |||
4779 | 1 | Binary files app/graphics/Big-Rain.png 1970-01-01 00:00:00 +0000 and app/graphics/Big-Rain.png 2015-06-28 23:49:12 +0000 differ | 3 | Binary files app/graphics/Big-Rain.png 1970-01-01 00:00:00 +0000 and app/graphics/Big-Rain.png 2015-06-28 23:49:12 +0000 differ |
4780 | === added file 'app/graphics/CMakeLists.txt' | |||
4781 | --- app/graphics/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4782 | +++ app/graphics/CMakeLists.txt 2015-06-28 23:49:12 +0000 | |||
4783 | @@ -0,0 +1,5 @@ | |||
4784 | 1 | file(GLOB IMAGE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.png *.svg) | ||
4785 | 2 | |||
4786 | 3 | add_custom_target(ubuntu-weather-app_graphics_IMAGEFiles ALL SOURCES ${IMAGE_FILES}) | ||
4787 | 4 | |||
4788 | 5 | install(FILES ${IMAGE_FILES} DESTINATION ${UBUNTU-WEATHER_APP_DIR}/graphics) | ||
4789 | 0 | 6 | ||
4790 | === added file 'app/graphics/Cloudy-Circles.png' | |||
4791 | 1 | Binary files app/graphics/Cloudy-Circles.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy-Circles.png 2015-06-28 23:49:12 +0000 differ | 7 | Binary files app/graphics/Cloudy-Circles.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy-Circles.png 2015-06-28 23:49:12 +0000 differ |
4792 | === added file 'app/graphics/Cloudy-Night.png' | |||
4793 | 2 | Binary files app/graphics/Cloudy-Night.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy-Night.png 2015-06-28 23:49:12 +0000 differ | 8 | Binary files app/graphics/Cloudy-Night.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy-Night.png 2015-06-28 23:49:12 +0000 differ |
4794 | === added file 'app/graphics/Cloudy-Snow.png' | |||
4795 | 3 | Binary files app/graphics/Cloudy-Snow.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy-Snow.png 2015-06-28 23:49:12 +0000 differ | 9 | Binary files app/graphics/Cloudy-Snow.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy-Snow.png 2015-06-28 23:49:12 +0000 differ |
4796 | === added file 'app/graphics/Cloudy.png' | |||
4797 | 4 | Binary files app/graphics/Cloudy.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy.png 2015-06-28 23:49:12 +0000 differ | 10 | Binary files app/graphics/Cloudy.png 1970-01-01 00:00:00 +0000 and app/graphics/Cloudy.png 2015-06-28 23:49:12 +0000 differ |
4798 | === added file 'app/graphics/Fog.png' | |||
4799 | 5 | Binary files app/graphics/Fog.png 1970-01-01 00:00:00 +0000 and app/graphics/Fog.png 2015-06-28 23:49:12 +0000 differ | 11 | Binary files app/graphics/Fog.png 1970-01-01 00:00:00 +0000 and app/graphics/Fog.png 2015-06-28 23:49:12 +0000 differ |
4800 | === added file 'app/graphics/Raindrop.png' | |||
4801 | 6 | Binary files app/graphics/Raindrop.png 1970-01-01 00:00:00 +0000 and app/graphics/Raindrop.png 2015-06-28 23:49:12 +0000 differ | 12 | Binary files app/graphics/Raindrop.png 1970-01-01 00:00:00 +0000 and app/graphics/Raindrop.png 2015-06-28 23:49:12 +0000 differ |
4802 | === added file 'app/graphics/Showers.png' | |||
4803 | 7 | Binary files app/graphics/Showers.png 1970-01-01 00:00:00 +0000 and app/graphics/Showers.png 2015-06-28 23:49:12 +0000 differ | 13 | Binary files app/graphics/Showers.png 1970-01-01 00:00:00 +0000 and app/graphics/Showers.png 2015-06-28 23:49:12 +0000 differ |
4804 | === added file 'app/graphics/Starry-Night.png' | |||
4805 | 8 | Binary files app/graphics/Starry-Night.png 1970-01-01 00:00:00 +0000 and app/graphics/Starry-Night.png 2015-06-28 23:49:12 +0000 differ | 14 | Binary files app/graphics/Starry-Night.png 1970-01-01 00:00:00 +0000 and app/graphics/Starry-Night.png 2015-06-28 23:49:12 +0000 differ |
4806 | === added file 'app/graphics/Stormy.png' | |||
4807 | 9 | Binary files app/graphics/Stormy.png 1970-01-01 00:00:00 +0000 and app/graphics/Stormy.png 2015-06-28 23:49:12 +0000 differ | 15 | Binary files app/graphics/Stormy.png 1970-01-01 00:00:00 +0000 and app/graphics/Stormy.png 2015-06-28 23:49:12 +0000 differ |
4808 | === added file 'app/graphics/Sunny.png' | |||
4809 | 10 | Binary files app/graphics/Sunny.png 1970-01-01 00:00:00 +0000 and app/graphics/Sunny.png 2015-06-28 23:49:12 +0000 differ | 16 | Binary files app/graphics/Sunny.png 1970-01-01 00:00:00 +0000 and app/graphics/Sunny.png 2015-06-28 23:49:12 +0000 differ |
4810 | === added file 'app/graphics/Windy-n-Snow.png' | |||
4811 | 11 | Binary files app/graphics/Windy-n-Snow.png 1970-01-01 00:00:00 +0000 and app/graphics/Windy-n-Snow.png 2015-06-28 23:49:12 +0000 differ | 17 | Binary files app/graphics/Windy-n-Snow.png 1970-01-01 00:00:00 +0000 and app/graphics/Windy-n-Snow.png 2015-06-28 23:49:12 +0000 differ |
4812 | === added file 'app/graphics/extended-information_chance-of-rain.svg' | |||
4813 | --- app/graphics/extended-information_chance-of-rain.svg 1970-01-01 00:00:00 +0000 | |||
4814 | +++ app/graphics/extended-information_chance-of-rain.svg 2015-06-28 23:49:12 +0000 | |||
4815 | @@ -0,0 +1,153 @@ | |||
4816 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
4817 | 2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||
4818 | 3 | |||
4819 | 4 | <svg | ||
4820 | 5 | xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
4821 | 6 | xmlns:cc="http://creativecommons.org/ns#" | ||
4822 | 7 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
4823 | 8 | xmlns:svg="http://www.w3.org/2000/svg" | ||
4824 | 9 | xmlns="http://www.w3.org/2000/svg" | ||
4825 | 10 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | ||
4826 | 11 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | ||
4827 | 12 | width="90" | ||
4828 | 13 | height="90" | ||
4829 | 14 | id="svg6138" | ||
4830 | 15 | version="1.1" | ||
4831 | 16 | inkscape:version="0.91pre2 r" | ||
4832 | 17 | viewBox="0 0 90 90.000001" | ||
4833 | 18 | sodipodi:docname="weather-chance-of-rain02.svg"> | ||
4834 | 19 | <defs | ||
4835 | 20 | id="defs6140" /> | ||
4836 | 21 | <sodipodi:namedview | ||
4837 | 22 | id="base" | ||
4838 | 23 | pagecolor="#ffffff" | ||
4839 | 24 | bordercolor="#666666" | ||
4840 | 25 | borderopacity="1.0" | ||
4841 | 26 | inkscape:pageopacity="0.0" | ||
4842 | 27 | inkscape:pageshadow="2" | ||
4843 | 28 | inkscape:zoom="5.0931702" | ||
4844 | 29 | inkscape:cx="112.1011" | ||
4845 | 30 | inkscape:cy="19.378885" | ||
4846 | 31 | inkscape:document-units="px" | ||
4847 | 32 | inkscape:current-layer="g6442" | ||
4848 | 33 | showgrid="true" | ||
4849 | 34 | fit-margin-top="0" | ||
4850 | 35 | fit-margin-left="0" | ||
4851 | 36 | fit-margin-right="0" | ||
4852 | 37 | fit-margin-bottom="0" | ||
4853 | 38 | inkscape:snap-global="true" | ||
4854 | 39 | inkscape:snap-bbox="true" | ||
4855 | 40 | inkscape:bbox-paths="true" | ||
4856 | 41 | inkscape:snap-bbox-midpoints="true" | ||
4857 | 42 | inkscape:snap-bbox-edge-midpoints="true" | ||
4858 | 43 | inkscape:bbox-nodes="true" | ||
4859 | 44 | inkscape:object-paths="true" | ||
4860 | 45 | inkscape:snap-intersection-paths="true" | ||
4861 | 46 | inkscape:object-nodes="true" | ||
4862 | 47 | inkscape:snap-smooth-nodes="true" | ||
4863 | 48 | inkscape:snap-midpoints="true" | ||
4864 | 49 | inkscape:snap-others="true" | ||
4865 | 50 | inkscape:snap-object-midpoints="true" | ||
4866 | 51 | inkscape:snap-center="true" | ||
4867 | 52 | showguides="false" | ||
4868 | 53 | inkscape:guide-bbox="true"> | ||
4869 | 54 | <inkscape:grid | ||
4870 | 55 | type="xygrid" | ||
4871 | 56 | id="grid6700" | ||
4872 | 57 | empspacing="6" /> | ||
4873 | 58 | <sodipodi:guide | ||
4874 | 59 | orientation="0,1" | ||
4875 | 60 | position="90,87" | ||
4876 | 61 | id="guide4064" /> | ||
4877 | 62 | <sodipodi:guide | ||
4878 | 63 | orientation="0,1" | ||
4879 | 64 | position="89,84" | ||
4880 | 65 | id="guide4066" /> | ||
4881 | 66 | <sodipodi:guide | ||
4882 | 67 | orientation="1,0" | ||
4883 | 68 | position="3,69" | ||
4884 | 69 | id="guide4068" /> | ||
4885 | 70 | <sodipodi:guide | ||
4886 | 71 | orientation="1,0" | ||
4887 | 72 | position="6,60" | ||
4888 | 73 | id="guide4070" /> | ||
4889 | 74 | <sodipodi:guide | ||
4890 | 75 | orientation="1,0" | ||
4891 | 76 | position="87,58" | ||
4892 | 77 | id="guide4072" /> | ||
4893 | 78 | <sodipodi:guide | ||
4894 | 79 | orientation="1,0" | ||
4895 | 80 | position="84,47" | ||
4896 | 81 | id="guide4074" /> | ||
4897 | 82 | <sodipodi:guide | ||
4898 | 83 | orientation="0,1" | ||
4899 | 84 | position="77,3" | ||
4900 | 85 | id="guide4076" /> | ||
4901 | 86 | <sodipodi:guide | ||
4902 | 87 | orientation="0,1" | ||
4903 | 88 | position="81,6" | ||
4904 | 89 | id="guide4078" /> | ||
4905 | 90 | <sodipodi:guide | ||
4906 | 91 | orientation="1,0" | ||
4907 | 92 | position="81,25" | ||
4908 | 93 | id="guide4080" /> | ||
4909 | 94 | <sodipodi:guide | ||
4910 | 95 | orientation="0,1" | ||
4911 | 96 | position="78,9" | ||
4912 | 97 | id="guide4082" /> | ||
4913 | 98 | <sodipodi:guide | ||
4914 | 99 | orientation="0,1" | ||
4915 | 100 | position="79,81" | ||
4916 | 101 | id="guide4084" /> | ||
4917 | 102 | <sodipodi:guide | ||
4918 | 103 | orientation="1,0" | ||
4919 | 104 | position="9,39" | ||
4920 | 105 | id="guide4086" /> | ||
4921 | 106 | </sodipodi:namedview> | ||
4922 | 107 | <metadata | ||
4923 | 108 | id="metadata6143"> | ||
4924 | 109 | <rdf:RDF> | ||
4925 | 110 | <cc:Work | ||
4926 | 111 | rdf:about=""> | ||
4927 | 112 | <dc:format>image/svg+xml</dc:format> | ||
4928 | 113 | <dc:type | ||
4929 | 114 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | ||
4930 | 115 | <dc:title></dc:title> | ||
4931 | 116 | </cc:Work> | ||
4932 | 117 | </rdf:RDF> | ||
4933 | 118 | </metadata> | ||
4934 | 119 | <g | ||
4935 | 120 | inkscape:label="Layer 1" | ||
4936 | 121 | inkscape:groupmode="layer" | ||
4937 | 122 | id="layer1" | ||
4938 | 123 | transform="translate(-283.57144,-358.79068)"> | ||
4939 | 124 | <g | ||
4940 | 125 | transform="translate(169.57144,223.42822)" | ||
4941 | 126 | id="g5937" | ||
4942 | 127 | inkscape:export-filename="envelope02.png" | ||
4943 | 128 | inkscape:export-xdpi="90" | ||
4944 | 129 | inkscape:export-ydpi="90" /> | ||
4945 | 130 | <g | ||
4946 | 131 | id="g6442" | ||
4947 | 132 | transform="translate(-753.45981,336.4283)"> | ||
4948 | 133 | <rect | ||
4949 | 134 | style="fill:none;stroke:none" | ||
4950 | 135 | id="rect1687" | ||
4951 | 136 | width="90" | ||
4952 | 137 | height="90" | ||
4953 | 138 | x="1037.0312" | ||
4954 | 139 | y="22.362379" /> | ||
4955 | 140 | <path | ||
4956 | 141 | style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:125%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:end;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:end;fill:#808080;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" | ||
4957 | 142 | d="M 44.929688 12.066406 C 34.037288 12.066406 24.849688 14.943458 17.367188 20.697266 C 9.7896875 26.523909 6 33.624202 6 42 C 7.7011 40.603306 9.6530686 39.474739 11.855469 38.615234 C 14.075869 37.773637 16.4573 37.353516 19 37.353516 C 21.5427 37.353516 23.914587 37.773637 26.117188 38.615234 C 28.337486 39.474739 30.2989 40.603306 32 42 C 33.7011 40.603306 35.653069 39.474739 37.855469 38.615234 C 40.075769 37.773637 42.4573 37.353516 45 37.353516 C 47.5427 37.353516 49.914586 37.773637 52.117188 38.615234 C 54.337487 39.474739 56.2989 40.603306 58 42 L 58.654297 42 C 60.235137 40.784631 62.009869 39.776665 64 39 C 66.2203 38.158403 68.601831 37.738281 71.144531 37.738281 C 73.687231 37.738281 76.059119 38.158403 78.261719 39 C 80.268226 39.776743 82.052173 40.784465 83.634766 42 L 84 42 C 84 33.624202 80.210313 26.523909 72.632812 20.697266 C 65.055613 14.943458 55.822287 12.066406 44.929688 12.066406 z " | ||
4958 | 143 | transform="translate(1037.0313,22.36238)" | ||
4959 | 144 | id="path4181" /> | ||
4960 | 145 | <path | ||
4961 | 146 | style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:125%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-indent:0;text-align:end;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:end;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.00000048;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" | ||
4962 | 147 | d="m 1079.0312,28.363281 0,66.335938 0.01,0.09766 c 0.015,0.226687 0.022,0.780446 0.022,1.509766 0,1.918939 -0.4328,2.763898 -1.0039,3.289062 l -0.01,0.0059 -0.01,0.0078 c -0.6357,0.592743 -1.5903,1.007813 -3.4297,1.007813 -1.8313,0 -2.8017,-0.41364 -3.461,-1.015626 -0.5541,-0.519673 -0.9882,-1.37472 -0.9882,-3.294921 0,-0.72932 0.01,-1.281931 0.021,-1.501953 l -5.9863,-0.410157 c -0.041,0.598238 -0.035,1.18279 -0.035,1.91211 0,2.983063 0.8627,5.791367 2.9003,7.691407 l 0.01,0.008 0.01,0.006 c 1.9716,1.8129 4.6659,2.60547 7.5332,2.60547 2.8642,0 5.5555,-0.79304 7.5136,-2.61524 2.0532,-1.89396 2.9356,-4.70919 2.9356,-7.695307 0,-0.72932 0.01,-1.312724 -0.033,-1.904297 l 0.01,0.197265 0,-67.236328 -6,1 z" | ||
4963 | 148 | id="path4225" | ||
4964 | 149 | inkscape:connector-curvature="0" | ||
4965 | 150 | sodipodi:nodetypes="cccscccscsccscccscsccccc" /> | ||
4966 | 151 | </g> | ||
4967 | 152 | </g> | ||
4968 | 153 | </svg> | ||
4969 | 0 | 154 | ||
4970 | === added file 'app/graphics/extended-information_humidity.svg' | |||
4971 | --- app/graphics/extended-information_humidity.svg 1970-01-01 00:00:00 +0000 | |||
4972 | +++ app/graphics/extended-information_humidity.svg 2015-06-28 23:49:12 +0000 | |||
4973 | @@ -0,0 +1,147 @@ | |||
4974 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
4975 | 2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||
4976 | 3 | |||
4977 | 4 | <svg | ||
4978 | 5 | xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
4979 | 6 | xmlns:cc="http://creativecommons.org/ns#" | ||
4980 | 7 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
4981 | 8 | xmlns:svg="http://www.w3.org/2000/svg" | ||
4982 | 9 | xmlns="http://www.w3.org/2000/svg" | ||
4983 | 10 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | ||
4984 | 11 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | ||
4985 | 12 | width="90" | ||
4986 | 13 | height="90" | ||
4987 | 14 | id="svg6138" | ||
4988 | 15 | version="1.1" | ||
4989 | 16 | inkscape:version="0.91pre2 r" | ||
4990 | 17 | viewBox="0 0 90 90.000001" | ||
4991 | 18 | sodipodi:docname="weather-chance-of-rain.svg"> | ||
4992 | 19 | <defs | ||
4993 | 20 | id="defs6140" /> | ||
4994 | 21 | <sodipodi:namedview | ||
4995 | 22 | id="base" | ||
4996 | 23 | pagecolor="#ffffff" | ||
4997 | 24 | bordercolor="#666666" | ||
4998 | 25 | borderopacity="1.0" | ||
4999 | 26 | inkscape:pageopacity="0.0" | ||
5000 | 27 | inkscape:pageshadow="2" |