Merge lp:~vthompson/ubuntu-weather-app/reboot-allow-adding-duplicate-current-location into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Victor Thompson
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
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.

To post a comment you must log in.

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, RefreshIntervalPage.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

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

Subscribers

People subscribed via source and target branches