Merge lp:~martin-borho/ubuntu-weather-app/reboot-fix-missing-current-condition2 into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Superseded
Proposed branch: lp:~martin-borho/ubuntu-weather-app/reboot-fix-missing-current-condition2
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 6230 lines (+5898/-0) (has conflicts)
57 files modified
.bzrignore (+19/-0)
CMakeLists.txt (+108/-0)
COPYING (+674/-0)
README (+11/-0)
README.translations (+40/-0)
app/CMakeLists.txt (+18/-0)
app/components/CMakeLists.txt (+7/-0)
app/components/DayDelegate.qml (+95/-0)
app/components/FastScroll.js (+130/-0)
app/components/FastScroll.qml (+321/-0)
app/components/HeaderRow.qml (+65/-0)
app/components/HomeGraphic.qml (+38/-0)
app/components/HomeHourly.qml (+92/-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/MultiSelectHeadState.qml (+72/-0)
app/components/MultiSelectListView.qml (+52/-0)
app/components/PageWithBottomEdge.qml (+411/-0)
app/components/WeatherListItem.qml (+139/-0)
app/components/WeatherListView.qml (+32/-0)
app/data/CMakeLists.txt (+5/-0)
app/data/CitiesList.js (+65/-0)
app/data/Storage.qml (+189/-0)
app/data/WeatherApi.js (+755/-0)
app/data/key.js (+1/-0)
app/graphics/CMakeLists.txt (+5/-0)
app/ubuntu-weather-app.qml (+237/-0)
app/ui/AddLocationPage.qml (+300/-0)
app/ui/CMakeLists.txt (+7/-0)
app/ui/HomePage.qml (+148/-0)
app/ui/LocationPane.qml (+183/-0)
app/ui/LocationsPage.qml (+167/-0)
app/ui/SettingsPage.qml (+61/-0)
app/ui/settings/CMakeLists.txt (+5/-0)
app/ui/settings/DataProviderPage.qml (+53/-0)
app/ui/settings/RefreshIntervalPage.qml (+56/-0)
app/ui/settings/UnitsPage.qml (+77/-0)
backend/CMakeLists.txt (+29/-0)
debian/changelog (+173/-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 (+128/-0)
tests/CMakeLists.txt (+3/-0)
tests/autopilot/CMakeLists.txt (+8/-0)
ubuntu-weather-app.apparmor (+6/-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:~martin-borho/ubuntu-weather-app/reboot-fix-missing-current-condition2
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Ubuntu Weather Developers Pending
Review via email: mp+255226@code.launchpad.net

Commit message

Fix for missing condition-text in TWC current data (StandardObservation in api). Conditions for TWC/OWM aligned, so conditional statement simplified in LocationPane.

Description of the change

* Fix for missing condition text in twc current data (StandardObservation in api).
* Conditions for twc/owm already aligned, so conditional statement simplified in LocationPane.

To post a comment you must log in.
29. By Martin Borho

fix for missing condition text in twc current data (StandardObservation in api). Conditions for twc/owm aligned, so condtional statement simplified in LocationPane

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
30. By Martin Borho

typo and readability

Unmerged revisions

30. By Martin Borho

typo and readability

29. By Martin Borho

fix for missing condition text in twc current data (StandardObservation in api). Conditions for twc/owm aligned, so condtional statement simplified in LocationPane

28. By Martin Borho

Area label (subtitle) for locations in AddLocationPage are now more verbose, when location name and country are not unique.

Approved by Ubuntu Phone Apps Jenkins Bot, Victor Thompson.

27. By Martin Borho

Flatten out ListModel in LocationPage and using needed data directly from the location objects.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

26. By Martin Borho

Fix for missing condtion and icon at TWC.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

25. By Andrew Hayzen

* Use suru theme for icons instead of embedded
* Fix errors with using right/left in a Row in the LocationsPage.qml.

Approved by Ubuntu Phone Apps Jenkins Bot, Martin Borho.

24. By Victor Thompson

* Do not show divider on first HomeHourly delegate.
* Make dividers lighter.

Approved by Martin Borho, Ubuntu Phone Apps Jenkins Bot.

23. By Victor Thompson

* Fix eliding on LocationsPage
* Hide condition data on LocationsPage when in multiselect mode.

Approved by Martin Borho, Ubuntu Phone Apps Jenkins Bot.

22. By Victor Thompson

* Revert WorkerScript, but still initialize app with stored data. Fixes: https://bugs.launchpad.net/bugs/1432260.

Approved by Martin Borho, Ubuntu Phone Apps Jenkins Bot.

21. By Martin Borho

To prevent a blank app at startup:

* reimplemented worker calls for data requests
* starts up the app with stored data and spins off a refresh request in a worker
.

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

Subscribers

People subscribed via source and target branches