Initial import
authorRoman Moravcik <roman.moravcik@gmail.com>
Thu, 3 Mar 2011 14:43:43 +0000 (15:43 +0100)
committerRoman Moravcik <roman.moravcik@gmail.com>
Thu, 3 Mar 2011 14:43:43 +0000 (15:43 +0100)
24 files changed:
deployment.pri [new file with mode: 0644]
medard.desktop [new file with mode: 0644]
medard.png [new file with mode: 0644]
medard.pro [new file with mode: 0644]
medard.svg [new file with mode: 0644]
qtc_packaging/debian_fremantle/README [new file with mode: 0644]
qtc_packaging/debian_fremantle/changelog [new file with mode: 0644]
qtc_packaging/debian_fremantle/compat [new file with mode: 0644]
qtc_packaging/debian_fremantle/control [new file with mode: 0644]
qtc_packaging/debian_fremantle/copyright [new file with mode: 0644]
qtc_packaging/debian_fremantle/rules [new file with mode: 0755]
src/forecastwidget.cpp [new file with mode: 0644]
src/forecastwidget.h [new file with mode: 0644]
src/main.cpp [new file with mode: 0644]
src/mainwindow.cpp [new file with mode: 0644]
src/mainwindow.h [new file with mode: 0644]
src/medarddownloader.cpp [new file with mode: 0644]
src/medarddownloader.h [new file with mode: 0644]
translations/medard_cs.qm [new file with mode: 0644]
translations/medard_cs.ts [new file with mode: 0644]
translations/medard_en.qm [new file with mode: 0644]
translations/medard_en.ts [new file with mode: 0644]
translations/medard_sk.qm [new file with mode: 0644]
translations/medard_sk.ts [new file with mode: 0644]

diff --git a/deployment.pri b/deployment.pri
new file mode 100644 (file)
index 0000000..04b1b16
--- /dev/null
@@ -0,0 +1,111 @@
+# checksum 0x2939 version 0x20001
+# This file was generated by an application wizard of Qt Creator.
+# The code below handles deployment to Symbian and Maemo, aswell as copying
+# of the application data to shadow build directories on desktop.
+# It is recommended not to modify this file, since newer versions of Qt Creator
+# may offer an updated version of it.
+
+defineTest(qtcAddDeployment) {
+for(deploymentfolder, DEPLOYMENTFOLDERS) {
+    item = item$${deploymentfolder}
+    itemsources = $${item}.sources
+    $$itemsources = $$eval($${deploymentfolder}.source)
+    itempath = $${item}.path
+    $$itempath= $$eval($${deploymentfolder}.target)
+    export($$itemsources)
+    export($$itempath)
+    DEPLOYMENT += $$item
+}
+
+MAINPROFILEPWD = $$PWD
+
+symbian {
+    ICON = $${TARGET}.svg
+    TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
+    contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -lcone
+    contains(DEFINES, NETWORKACCESS):TARGET.CAPABILITY += NetworkServices
+} else:win32 {
+    copyCommand =
+    for(deploymentfolder, DEPLOYMENTFOLDERS) {
+        source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
+        source = $$replace(source, /, \\)
+        sourcePathSegments = $$split(source, \\)
+        target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
+        target = $$replace(target, /, \\)
+        !isEqual(source,$$target) {
+            !isEmpty(copyCommand):copyCommand += &&
+            copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
+        }
+    }
+    !isEmpty(copyCommand) {
+        copyCommand = @echo Copying application data... && $$copyCommand
+        copydeploymentfolders.commands = $$copyCommand
+        first.depends = $(first) copydeploymentfolders
+        export(first.depends)
+        export(copydeploymentfolders.commands)
+        QMAKE_EXTRA_TARGETS += first copydeploymentfolders
+    }
+} else:unix {
+    maemo5 {
+        installPrefix = /opt/usr
+        desktopfile.path = /usr/share/applications/hildon
+    } else {
+        installPrefix = /usr/local
+        desktopfile.path = /usr/share/applications
+        copyCommand =
+        for(deploymentfolder, DEPLOYMENTFOLDERS) {
+            source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
+            source = $$replace(source, \\, /)
+            macx {
+                target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
+            } else {
+                target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
+            }
+            target = $$replace(target, \\, /)
+            sourcePathSegments = $$split(source, /)
+            targetFullPath = $$target/$$last(sourcePathSegments)
+            !isEqual(source,$$targetFullPath) {
+                !isEmpty(copyCommand):copyCommand += &&
+                copyCommand += $(MKDIR) \"$$target\"
+                copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
+            }
+        }
+        !isEmpty(copyCommand) {
+            copyCommand = @echo Copying application data... && $$copyCommand
+            copydeploymentfolders.commands = $$copyCommand
+            first.depends = $(first) copydeploymentfolders
+            export(first.depends)
+            export(copydeploymentfolders.commands)
+            QMAKE_EXTRA_TARGETS += first copydeploymentfolders
+        }
+    }
+    for(deploymentfolder, DEPLOYMENTFOLDERS) {
+        item = item$${deploymentfolder}
+        itemfiles = $${item}.files
+        $$itemfiles = $$eval($${deploymentfolder}.source)
+        itempath = $${item}.path
+        $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target)
+        export($$itemfiles)
+        export($$itempath)
+        INSTALLS += $$item
+    }
+    icon.files = $${TARGET}.png
+    icon.path = /usr/share/icons/hicolor/64x64/apps
+    desktopfile.files = $${TARGET}.desktop
+    target.path = $${installPrefix}/bin
+    export(icon.files)
+    export(icon.path)
+    export(desktopfile.files)
+    export(desktopfile.path)
+    export(target.path)
+    INSTALLS += desktopfile icon target
+}
+
+export (ICON)
+export (INSTALLS)
+export (DEPLOYMENT)
+export (TARGET.EPOCHEAPSIZE)
+export (TARGET.CAPABILITY)
+export (LIBS)
+export (QMAKE_EXTRA_TARGETS)
+}
diff --git a/medard.desktop b/medard.desktop
new file mode 100644 (file)
index 0000000..3bb23af
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Terminal=false
+Name=Medard
+Exec=/opt/usr/bin/medard
+Icon=medard
+X-Window-Icon=
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
diff --git a/medard.png b/medard.png
new file mode 100644 (file)
index 0000000..b5d40cd
Binary files /dev/null and b/medard.png differ
diff --git a/medard.pro b/medard.pro
new file mode 100644 (file)
index 0000000..b69ddad
--- /dev/null
@@ -0,0 +1,46 @@
+# Add files and directories to ship with the application 
+# by adapting the examples below.
+# file1.source = myfile
+# dir1.source = mydir
+translations.source = \
+    translations/medard_cs.qm \
+    translations/medard_en.qm \
+    translations/medard_sk.qm
+
+DEPLOYMENTFOLDERS = translations
+
+QT += network
+
+# Avoid auto screen rotation
+DEFINES += ORIENTATIONLOCK
+
+# Needs to be defined for Symbian
+DEFINES += NETWORKACCESS
+
+symbian:TARGET.UID3 = 0xE49E7B8A
+
+# If your application uses the Qt Mobility libraries, uncomment
+# the following lines and add the respective components to the 
+# MOBILITY variable. 
+# CONFIG += mobility
+# MOBILITY +=
+
+SOURCES += \
+    src/forecastwidget.cpp \
+    src/medarddownloader.cpp \
+    src/mainwindow.cpp \
+    src/main.cpp
+HEADERS += \
+    src/forecastwidget.h \
+    src/medarddownloader.h \
+    src/mainwindow.h
+FORMS +=
+
+TRANSLATIONS += \
+    translations/medard_cs.qm \
+    translations/medard_en.ts \
+    translations/medard_sk.ts
+
+# Please do not modify the following two lines. Required for deployment.
+include(deployment.pri)
+qtcAddDeployment()
diff --git a/medard.svg b/medard.svg
new file mode 100644 (file)
index 0000000..566acfa
--- /dev/null
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   height="44px"
+   version="1.1"
+   viewBox="0 0 44 44"
+   width="44px"
+   x="0px"
+   y="0px"
+   id="svg2"
+   inkscape:version="0.47 r22583"
+   sodipodi:docname="qt.svg">
+  <metadata
+     id="metadata18">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs16">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 22 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="44 : 22 : 1"
+       inkscape:persp3d-origin="22 : 14.666667 : 1"
+       id="perspective2836" />
+  </defs>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1920"
+     inkscape:window-height="1020"
+     id="namedview14"
+     showgrid="false"
+     inkscape:zoom="21.454545"
+     inkscape:cx="49.412871"
+     inkscape:cy="21.894358"
+     inkscape:window-x="-4"
+     inkscape:window-y="-4"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g3" />
+  <g
+     transform="matrix(0.18308778,0,0,0.18308778,6.6100946,3.2385199)"
+     id="g3">
+    <path
+       d="M 43.09,0.3586 C 40.94,0.0036 38.84,-0.0824 36.81,0.0776 31.968136,0.39505671 27.122677,0.73638425 22.28,1.0696 9.62,2.0816 0,12.4996 0,26.8896 l 0,169.7 14.19,13.2 28.87,-209.42 0.03,-0.011 z"
+       style="fill:#006225"
+       id="path5"
+       sodipodi:nodetypes="cccccccc" />
+    <path
+       d="m 174.4,160 c 0,12.5 -7.75,24.07 -17.57,25.77 L 14.23,209.73 V 25.93 C 14.23,9.21 27.57,-2.27 43.12,0.3 l 131.3,21.52 v 138.2 z"
+       style="fill:#80c342"
+       id="path7" />
+    <path
+       d="m 154.9,80.96 -12.96,-0.598 0,0.278 6.945,0.32 6.016,0 z"
+       style="fill:#006225"
+       id="path11" />
+    <path
+       d="m 144.6,135.6 c 0.66,0.328 1.43,0.476 2.351,0.476 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 h -6.015 c -1.821,0.832 -3.532,1.457 -5.176,1.848 z"
+       style="fill:#006225"
+       id="path13" />
+    <path
+       id="path17"
+       style="fill:#ffffff"
+       d="m 91.15,132.4 c 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -4.34,0 -7.68,2.535 -10.01,7.625 -2.52,5.543 -3.793,17.04 -3.793,34.44 0,16.82 1.238,28.75 3.734,35.75 2.356,6.672 5.879,9.976 10.5,9.976 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 m 17.98,3.75 c -4.117,9.707 -10.39,16.06 -18.99,19 0.867,4.449 2.176,7.441 3.922,9.019 1.351,1.211 3.433,1.821 6.222,1.821 0.805,0 1.668,-0.055 2.59,-0.157 v 13.12 l -5.961,0.782 c -1.758,0.23 -3.426,0.343 -5.004,0.343 -5.218,0 -9.445,-1.265 -12.62,-3.824 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 1.629,0 3.309,0.102 5.043,0.305 11.95,1.375 20.62,7.016 26.26,16.79 5.535,9.562 8.254,23.27 8.254,41.26 0,16.48 -2,29.45 -6.043,39.02 z M 130.4,45.91 l 11.52,1.238 0,20.21 12.96,0.914 0,12.68 -12.96,-0.598 0,46.33 c 0,4.032 0.445,6.625 1.34,7.789 0.8,1.067 2.046,1.594 3.71,1.594 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 v 11.65 c -5.136,2.258 -10.18,3.598 -15.12,4.02 -0.718,0.055 -1.41,0.086 -2.078,0.086 -4.48,0 -7.906,-1.301 -10.25,-3.934 -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.535 L 118.046,79.25 V 65.66 l 7.586,0.547 4.773,-20.3 z" />
+    <path
+       d="m 100.3,166 c 0.809,0 1.672,-0.055 2.59,-0.157 H 98.054 C 98.73,165.949 99.507,166 100.3,166 z"
+       style="fill:#006225"
+       id="path19" />
+    <path
+       id="path21"
+       style="fill:#006225"
+       d="m 84.85,63.98 c 2.336,5.997 3.484,16.92 3.484,32.81 0,17.7 -1.16,29.57 -3.512,35.62 -1.894,4.879 -4.527,7.902 -7.863,9.07 0.965,0.368 1.992,0.551 3.078,0.551 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -1.09,0 -2.117,0.16 -3.082,0.481 h -0.004 c 3.601,1.121 6.379,4.215 8.336,9.261 z m -2.344,114.3 c -0.113,-0.05 -0.227,-0.105 -0.336,-0.16 -0.012,-0.004 -0.023,-0.012 -0.035,-0.015 -0.102,-0.051 -0.207,-0.106 -0.309,-0.157 -0.019,-0.011 -0.039,-0.019 -0.058,-0.031 -0.09,-0.051 -0.184,-0.098 -0.278,-0.148 -0.027,-0.016 -0.054,-0.036 -0.086,-0.051 -0.082,-0.043 -0.164,-0.09 -0.242,-0.137 -0.039,-0.023 -0.078,-0.047 -0.113,-0.07 -0.07,-0.039 -0.145,-0.082 -0.215,-0.125 -0.047,-0.031 -0.094,-0.059 -0.14,-0.09 -0.059,-0.039 -0.118,-0.074 -0.176,-0.113 -0.059,-0.039 -0.114,-0.075 -0.168,-0.114 -0.051,-0.031 -0.102,-0.066 -0.149,-0.097 -0.066,-0.047 -0.132,-0.094 -0.195,-0.137 -0.039,-0.027 -0.078,-0.055 -0.113,-0.082 -0.078,-0.055 -0.153,-0.113 -0.231,-0.172 -0.023,-0.016 -0.05,-0.035 -0.078,-0.055 -0.098,-0.078 -0.199,-0.156 -0.297,-0.234 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 h -6.351 c -10.15,0.008 -18.22,3.977 -24,12.04 -6.855,9.563 -10.34,24.64 -10.34,45.07 0,18.95 2.547,33.44 7.551,43.34 4.934,9.75 12.05,15.56 21.19,17.5 1.989,9.641 5.09,16.16 9.297,19.54 3.176,2.559 7.403,3.824 12.62,3.824 0.098,0 0.199,0 0.297,-0.004 h 5.539 c -3.406,-0.05 -6.383,-0.66 -8.906,-1.828 L 82.498,178.28 z M 128.4,145.6 c -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.57 l -6.226,-0.285 v -13.59 h -6.016 v 3.035 c 0.871,3.273 1.555,6.82 2.063,10.64 l 4.164,0.192 v 51.36 c 0,6.723 1.367,11.62 4.09,14.67 2.343,2.633 5.765,3.934 10.25,3.934 h 6.015 c -4.48,0 -7.906,-1.301 -10.25,-3.934 z m 2.043,-99.66 -6.016,0 -4.668,19.88 5.911,0.422 4.773,-20.3 z" />
+  </g>
+</svg>
diff --git a/qtc_packaging/debian_fremantle/README b/qtc_packaging/debian_fremantle/README
new file mode 100644 (file)
index 0000000..afe3c6b
--- /dev/null
@@ -0,0 +1,6 @@
+The Debian Package medard
+----------------------------
+
+Comments regarding the Package
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Ut, 22 feb 2011 15:15:13 +0100
diff --git a/qtc_packaging/debian_fremantle/changelog b/qtc_packaging/debian_fremantle/changelog
new file mode 100644 (file)
index 0000000..5c79056
--- /dev/null
@@ -0,0 +1,5 @@
+medard (0.1.1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Ut, 22 feb 2011 15:15:13 +0100
diff --git a/qtc_packaging/debian_fremantle/compat b/qtc_packaging/debian_fremantle/compat
new file mode 100644 (file)
index 0000000..7f8f011
--- /dev/null
@@ -0,0 +1 @@
+7
diff --git a/qtc_packaging/debian_fremantle/control b/qtc_packaging/debian_fremantle/control
new file mode 100644 (file)
index 0000000..5e0e4db
--- /dev/null
@@ -0,0 +1,17 @@
+Source: medard
+Section: user/hidden
+Priority: optional
+Maintainer: Roman Moravcik <roman.moravcik@gmail.com>
+Build-Depends: debhelper (>= 5), libqt4-dev
+Standards-Version: 3.7.3
+
+Package: medard
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Weather forecasts from MEDARD project
+ Simple application to show weather forecast for Middle Europe and
+ the Czech Republic. The weather forecast is based on the numeric
+ weather prediction model MM5 of PSU/NCAR.
+ .
+ http://www.medard-online.cz/index.php
+XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAF0NJREFUaIGVmmmMZNd133/3vqVeLV1d1dVdve8z3bMPh5wRKXJoUpQtOSIcyYg/JDYCJJDywRJsJDCQxIIFxJYjwzGCBHASwZSSDwGkxIGTWFDk0FooUdJw0Qw5w+EsPdP7UmvXvr96792bD9XTFKlYQe6XQr337n3/e+655/8/5z7B/6P93a9+bio0HH/RjoWuovWL9Uw5FU3FMR0LaUiyt7aZvLiAFalhR7p0qxME3qDv4XcMxlMfQgUBfbdN2ljAVPbf+K6aVcTDKwv0nkZ8WWnvW//p9z+V/Xn4xM+7+fmtlz7eKtRfHppMgh5c83p9DNNAmgZCCipbBdz2A868OIZG47tRmrk5ALoPo0T2n0FLn5ifJO4nHg3zf22HoQy+6L//otbf+JefXv7U/9cEPr/1VU8IzPePoxFCHP++N4IiknoXEIRiFqDoVifo1UfRKGgOIW5cIeYnGfKSaD7Q/6jlcneZnDhLTRVZO3iF+d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kPvKGqhEl6pSZCWCC3o9zrfAN53Fuy7bs/sdFo8dWUcFUS49sbbnFp9/ChxF0SisywsOICmWNhjYfE0SkG20Gc8fYZ8EYRU+PiE7XG2NwckaJkTlM0izO8iZUCcFkJoTHrIapaRlCTQcOHDIX7ybp9xujS0y/TFRYLAp7D5NghJp1EmUh9Bo/3x1cXffd8EBHzWtp2XHMch6kC3F3ByKUKlARydXwXK4e59TTwqSI6cplrVtNoCrWw6XRvDgExoe5B9hQ1Mv4UO9QjG+jB1C6YPMEyfQeFWYOJT3W3gFxTzJyzyLQeHFg5dzFCXaHoaaWhmV65AYAxOtSdziK752T/41KX7R7jf3/7eb/zHLz7/3K//HipDq1UgFH+Kth6UH8peBisSQWsFAqoH25xKPAtIypUtIrOTNJbfhLltlLdJYs5CGLD7+gOWf2GaILDRSFLePqvOBjE6XP9WidlZyeoFm//5Tc35X5mhzDQZptl7ExIzF/D7HghNp9zk317+nfdhNj84gf/ytU9/QY3qf3723CfMetfCGdlFo5FCIpCDMiODvFc6NsVYBqtt0h3zCBbewlq9R3Rsn2aujukclSalgdIGwggYpci8sc84JQwUSycMFk6a5DM+S5MKi4DBuYzASVRRarBiAun3m73PfhCv8cELAE/9s6f/InQlP9NJbZwKzXURIxWYzCMPpxHaIO3NUK7vEB+fQKfzBCfv4Tx1nfiJe8SSOZQwkKZE2hKBwAwZ2FGbmGiRpEKUOmH69LRNJKS482qF5y91iE7EKFRNvPAwDRIYliSSatGtjXzDGc3+2r869YW//iDWn/u1CsDnfvzHU4mp1IsIfXXnjZsvnnjudEoqQfPgLabSFZYX+0RoUNrrUj/sM/TERQIEe40kQkIoZiMQ5O+PMX0qz7jIwO4G1UOPM5eHyHz7IWN2navPSd7JptnOmuX04+m9vLH85V5Hfesz0f/6cz+3+T/98KG5e2OWsgAAAABJRU5ErkJggg==
diff --git a/qtc_packaging/debian_fremantle/copyright b/qtc_packaging/debian_fremantle/copyright
new file mode 100644 (file)
index 0000000..fa8674e
--- /dev/null
@@ -0,0 +1,38 @@
+This package was debianized by Roman Moravcik <roman.moravcik@gmail.com> on
+Ut, 22 feb 2011 15:15:13 +0100.
+
+It was downloaded from <url://example.com>
+
+Upstream Author(s):
+
+    Roman Moravcik <roman.moravcik@gmail.com>
+
+Copyright:
+
+    <Copyright (C) 2011 Roman Moravcik>
+
+License:
+
+    This package is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This package is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this package; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+
+The Debian packaging is (C) 2011, Roman Moravcik <roman.moravcik@gmail.com> and
+is licensed under the GPL, see above.
+
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
diff --git a/qtc_packaging/debian_fremantle/rules b/qtc_packaging/debian_fremantle/rules
new file mode 100755 (executable)
index 0000000..d694ffc
--- /dev/null
@@ -0,0 +1,91 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+
+       touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp  
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+       #docbook-to-man debian/medard.sgml > medard.1
+
+       touch $@
+
+clean: 
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       $(MAKE) clean
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/medard.
+       $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/medard install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+#      dh_install
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       # dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_perl
+#      dh_makeshlibs
+       dh_installdeb
+       # dh_shlibdeps                      # Uncomment this line for publishing!
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/src/forecastwidget.cpp b/src/forecastwidget.cpp
new file mode 100644 (file)
index 0000000..82ae3cb
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <QtGui>
+
+#include "forecastwidget.h"
+
+ForecastWidget::ForecastWidget(QWidget *parent) : QWidget(parent)
+{
+    m_filename.clear();
+    m_error = false;
+}
+
+void ForecastWidget::setImage(const QString &filename)
+{
+    m_filename = filename;
+    m_error = false;
+    update();
+}
+
+void ForecastWidget::clearImage(bool error)
+{
+    m_filename.clear();
+    m_error = error;
+    update();
+}
+
+void ForecastWidget::paintEvent(QPaintEvent * /* event */)
+{
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing);
+
+    QRect widgetArea(rect().x(), rect().y(), rect().width(), 408);
+
+    painter.setPen(QColor(0, 0, 0));
+    painter.setBrush(QColor(255, 255, 255));
+    painter.drawRect(widgetArea);
+
+    if (m_error) {
+        painter.drawText(widgetArea, Qt::AlignCenter, tr("Download failed!"));
+    } else {
+        if (!m_filename.isEmpty()) {
+            QImage image(m_filename);
+            painter.drawImage(widgetArea, image);
+        } else {
+            painter.drawText(widgetArea, Qt::AlignCenter, tr("Downloading image..."));
+        }
+    }
+}
diff --git a/src/forecastwidget.h b/src/forecastwidget.h
new file mode 100644 (file)
index 0000000..e498582
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef FORECASTWIDGET_H
+#define FORECASTWIDGET_H
+
+#include <QWidget>
+#include <QString>
+
+class ForecastWidget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    ForecastWidget(QWidget *parent = 0);
+
+    void setImage(const QString &filename);
+    void clearImage(bool error);
+
+protected:
+    void paintEvent(QPaintEvent *event);
+
+private:
+    QString m_filename;
+    bool m_error;
+};
+
+#endif // FORECASTWIDGET_H
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..8ae1d03
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <QApplication>
+#include <QTranslator>
+#include <QLocale>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication app(argc, argv);
+
+    QString translatorFileName = "medard_" + QLocale::system().name();
+    QTranslator translator;
+    if (translator.load(translatorFileName, "/opt/usr/share/medard/"))
+        app.installTranslator(&translator);
+
+    MainWindow window;
+    window.showMaximized();
+
+    return app.exec();
+}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
new file mode 100644 (file)
index 0000000..d76a17c
--- /dev/null
@@ -0,0 +1,340 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <QtGui>
+#include <QSettings>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
+{
+    m_downloader = new MedardDownloader();
+
+    connect(m_downloader, SIGNAL(downloadFinished(const QString &, const QDateTime &)), this,
+            SLOT(downloadedFinished(const QString &, const QDateTime &)));
+    connect(m_downloader, SIGNAL(downloadFailed()), this, SLOT(downloadFailed()));
+
+    m_forecast = new ForecastWidget();
+    m_forecast->setFixedSize(m_downloader->getImageSize());
+
+    m_forecastTypeLabel = new QLabel();
+    m_forecastTypeLabel->setAlignment(Qt::AlignCenter);
+    m_forecastTypeLabel->setFixedSize(220, 80);
+
+    m_forecastInitialDateLabel = new QLabel();
+    m_forecastInitialDateLabel->setAlignment(Qt::AlignCenter);
+    m_forecastInitialDateLabel->setDisabled(true);
+
+    m_forecastDateLabel = new QLabel();
+    m_forecastDateLabel->setAlignment(Qt::AlignCenter);
+
+    m_downloadRetryButton = new QPushButton(tr("Download again"));
+
+    connect(m_downloadRetryButton, SIGNAL(clicked()), this, SLOT(downloadAgainClicked()));
+
+    m_minusDayButton = new QPushButton(tr("-1 d"));
+    m_plusDayButton = new QPushButton(tr("+1 d"));
+    m_minusHourButton = new QPushButton(tr("-1 h"));
+    m_plusHourButton = new QPushButton(tr("+1 h"));
+
+    connect(m_minusDayButton, SIGNAL(clicked()), this, SLOT(minusDayClicked()));
+    connect(m_plusDayButton, SIGNAL(clicked()), this, SLOT(plusDayClicked()));
+    connect(m_minusHourButton, SIGNAL(clicked()), this, SLOT(minusHourClicked()));
+    connect(m_plusHourButton, SIGNAL(clicked()), this, SLOT(plusHourClicked()));
+
+    setupUi();
+    setupMenu();
+
+    loadSettings();
+}
+
+MainWindow::~MainWindow()
+{
+    delete m_downloader;
+}
+
+void MainWindow::setupUi()
+{
+#ifdef Q_WS_MAEMO_5
+    setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+#endif
+    setWindowTitle(tr("Medard"));
+
+    QWidget *widget = new QWidget;
+    setCentralWidget(widget);
+
+    QHBoxLayout *mainLayout = new QHBoxLayout();
+    mainLayout->setMargin(8);
+    mainLayout->setSpacing(4);
+    widget->setLayout(mainLayout);
+
+    mainLayout->addWidget(m_forecast);
+    mainLayout->addSpacing(4);
+
+    QVBoxLayout *layout = new QVBoxLayout();
+    mainLayout->addLayout(layout);
+
+    layout->addWidget(m_forecastTypeLabel);
+    layout->addWidget(m_forecastDateLabel);
+    layout->addSpacing(20);
+    layout->addWidget(m_forecastInitialDateLabel);
+    layout->addSpacing(20);
+    layout->addWidget(m_downloadRetryButton);
+
+    QHBoxLayout *dayNavigationBox = new QHBoxLayout();
+    dayNavigationBox->addWidget(m_minusDayButton);
+    dayNavigationBox->addWidget(m_plusDayButton);
+    layout->addLayout(dayNavigationBox);
+
+    QHBoxLayout *hourNavigationBox = new QHBoxLayout();
+    hourNavigationBox->addWidget(m_minusHourButton);
+    hourNavigationBox->addWidget(m_plusHourButton);
+    layout->addLayout(hourNavigationBox);
+
+    hideNavigationButtons(false);
+}
+
+void MainWindow::setupMenu()
+{
+    QMenuBar *menu = new QMenuBar();
+    setMenuBar(menu);
+
+    m_domainActionGroup = new QActionGroup(this);
+    m_domainActionGroup->setExclusive(true);
+
+    QAction *domainAction;
+    domainAction = new QAction(tr("Europe"), m_domainActionGroup);
+    domainAction->setCheckable(true);
+    domainAction = new QAction(tr("Czech Republic"), m_domainActionGroup);
+    domainAction ->setCheckable(true);
+    menu->addActions(m_domainActionGroup->actions());
+    connect(m_domainActionGroup, SIGNAL(triggered(QAction *)), this, SLOT(forecastDomainChanged(QAction *)));
+
+    QAction *seaLevelPreasureAction = new QAction(tr("Sea Level Pressure"), this);
+    menu->addAction(seaLevelPreasureAction);
+    connect(seaLevelPreasureAction, SIGNAL(triggered()), this, SLOT(seaLevelPreasureMenuClicked()));
+
+    QAction *precipitationAction = new QAction(tr("Precipitation"), this);
+    menu->addAction(precipitationAction);
+    connect(precipitationAction, SIGNAL(triggered()), this, SLOT(precipitationMenuClicked()));
+
+    QAction *windVelocityAction = new QAction(tr("Wind Velocity"), this);
+    menu->addAction(windVelocityAction);
+    connect(windVelocityAction, SIGNAL(triggered()), this, SLOT(windVelocityMenuClicked()));
+
+    QAction *cloudinessAction = new QAction(tr("Cloudiness"), this);
+    menu->addAction(cloudinessAction);
+    connect(cloudinessAction, SIGNAL(triggered()), this, SLOT(cloudinessMenuClicked()));
+
+    QAction *temperatureAction = new QAction(tr("Temperature"), this);
+    menu->addAction(temperatureAction);
+    connect(temperatureAction, SIGNAL(triggered()), this, SLOT(temperatureMenuClicked()));
+}
+
+void MainWindow::loadSettings()
+{
+    QSettings settings;
+
+    int forecastDomain = settings.value("ForecastDomain").toInt();
+    int forecastType = settings.value("ForecastType").toInt();
+
+    m_downloader->setForecastDomain((MedardDownloader::ForecastDomain) forecastDomain);
+    m_domainActionGroup->actions().at(forecastDomain)->setChecked(true);
+
+    switch ((MedardDownloader::ForecastType) forecastType) {
+        case MedardDownloader::SeaLevelPressure:
+            seaLevelPreasureMenuClicked();
+            break;
+
+        case MedardDownloader::Precipitation:
+            precipitationMenuClicked();
+            break;
+
+        case MedardDownloader::WindVelocity:
+            windVelocityMenuClicked();
+            break;
+
+        case MedardDownloader::Cloudiness:
+            cloudinessMenuClicked();
+            break;
+
+        case MedardDownloader::Temperature:
+            temperatureMenuClicked();
+            break;
+    }
+}
+
+void MainWindow::showNavigationButtons()
+{
+    m_downloadRetryButton->hide();
+
+    m_minusDayButton->show();
+    m_plusDayButton->show();
+    m_minusHourButton->show();
+    m_plusHourButton->show();
+}
+
+void MainWindow::hideNavigationButtons(bool showRetryButton)
+{
+    if (showRetryButton)
+        m_downloadRetryButton->show();
+    else
+        m_downloadRetryButton->hide();
+
+    m_minusDayButton->hide();
+    m_plusDayButton->hide();
+    m_minusHourButton->hide();
+    m_plusHourButton->hide();
+}
+
+void MainWindow::updateNavigationButtons()
+{
+    if ((m_downloader->getForecastDateOffset() - 24) < m_downloader->getMinForecastDateOffset()) {
+        m_minusDayButton->setDisabled(true);
+        m_plusDayButton->setDisabled(false);
+    } else if ((m_downloader->getForecastDateOffset() + 24) > m_downloader->getMaxForecastDateOffset()) {
+        m_minusDayButton->setDisabled(false);
+        m_plusDayButton->setDisabled(true);
+    } else {
+        m_minusDayButton->setDisabled(false);
+        m_plusDayButton->setDisabled(false);
+    }
+
+    if ((m_downloader->getForecastDateOffset() - 1) < m_downloader->getMinForecastDateOffset()) {
+        m_minusHourButton->setDisabled(true);
+        m_plusHourButton->setDisabled(false);
+    } else if ((m_downloader->getForecastDateOffset() + 1) > m_downloader->getMaxForecastDateOffset()) {
+        m_minusHourButton->setDisabled(false);
+        m_plusHourButton->setDisabled(true);
+    } else {
+        m_minusHourButton->setDisabled(false);
+        m_plusHourButton->setDisabled(false);
+    }
+}
+
+void MainWindow::seaLevelPreasureMenuClicked()
+{
+    forecastTypeChanged(tr("Sea Level Pressure"), MedardDownloader::SeaLevelPressure);
+}
+
+void MainWindow::precipitationMenuClicked()
+{
+    forecastTypeChanged(tr("Precipitation"), MedardDownloader::Precipitation);
+}
+
+void MainWindow::windVelocityMenuClicked()
+{
+    forecastTypeChanged(tr("Wind Velocity"), MedardDownloader::WindVelocity);
+}
+
+void MainWindow::cloudinessMenuClicked()
+{
+    forecastTypeChanged(tr("Cloudiness"), MedardDownloader::Cloudiness);
+}
+
+void MainWindow::temperatureMenuClicked()
+{
+    forecastTypeChanged(tr("Temperature"), MedardDownloader::Temperature);
+}
+
+void MainWindow::downloadAgainClicked()
+{
+    m_forecast->clearImage(false);
+    m_downloader->downloadImage();
+
+    hideNavigationButtons(false);
+}
+
+void MainWindow::plusDayClicked()
+{
+    forecastDateOffsetChanged(+24);
+}
+
+void MainWindow::minusDayClicked()
+{
+    forecastDateOffsetChanged(-24);
+}
+
+void MainWindow::plusHourClicked()
+{
+    forecastDateOffsetChanged(+1);
+}
+
+void MainWindow::minusHourClicked()
+{
+    forecastDateOffsetChanged(-1);
+}
+
+void MainWindow::forecastTypeChanged(const QString label, MedardDownloader::ForecastType type)
+{
+    m_forecastTypeLabel->setText(label);
+    m_forecast->clearImage(false);
+    m_downloader->setForecastType(type);
+    m_downloader->downloadImage();
+
+    QSettings settings;
+    settings.setValue("ForecastType", type);
+}
+
+void MainWindow::forecastDateOffsetChanged(int offset)
+{
+    m_forecast->clearImage(false);
+    m_downloader->setForecastDateOffset(m_downloader->getForecastDateOffset() + offset);
+    m_downloader->downloadImage();
+}
+
+void MainWindow::forecastDomainChanged(QAction *action)
+{
+    int forecastDomain = m_domainActionGroup->actions().indexOf(action);
+
+    m_forecast->clearImage(false);
+
+    if (forecastDomain == 0)
+        m_downloader->setForecastDomain(MedardDownloader::Europe);
+    else
+        m_downloader->setForecastDomain(MedardDownloader::CzechRepublic);
+
+    m_downloader->downloadImage();
+
+    QSettings settings;
+    settings.setValue("ForecastDomain", forecastDomain);
+}
+
+void MainWindow::downloadedFinished(const QString &filename, const QDateTime &date)
+{
+    m_forecast->setImage(filename);
+    m_forecastInitialDateLabel->setText(tr("Forecast from:\n") +
+                                          m_downloader->getForecastInitialDate().toString("dd.MM.yyyy hh:mm"));
+
+    /* upcase the first letter of name of day */
+    QString temp = date.toString("dddd\ndd.MM.yyyy hh:mm");
+    m_forecastDateLabel->setText(temp.replace(0, 1, temp.at(0).toUpper()));
+
+    showNavigationButtons();
+    updateNavigationButtons();
+}
+
+void MainWindow::downloadFailed()
+{
+    m_forecast->clearImage(true);
+    m_forecastInitialDateLabel->setText("");
+    m_forecastDateLabel->setText("");
+
+    hideNavigationButtons(true);
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
new file mode 100644 (file)
index 0000000..a281e5b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QActionGroup>
+#include <QLabel>
+#include <QPushButton>
+
+#include "forecastwidget.h"
+#include "medarddownloader.h"
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = 0);
+    virtual ~MainWindow();
+
+private slots:
+    void seaLevelPreasureMenuClicked();
+    void precipitationMenuClicked();
+    void windVelocityMenuClicked();
+    void cloudinessMenuClicked();
+    void temperatureMenuClicked();
+
+    void downloadAgainClicked();
+
+    void plusDayClicked();
+    void minusDayClicked();
+    void plusHourClicked();
+    void minusHourClicked();
+
+    void forecastTypeChanged(const QString label, MedardDownloader::ForecastType type);
+    void forecastDateOffsetChanged(int offset);
+    void forecastDomainChanged(QAction *action);
+
+    void downloadedFinished(const QString &filename, const QDateTime &date);
+    void downloadFailed();
+
+private:
+    void setupUi();
+    void setupMenu();
+    void loadSettings();
+
+    void showNavigationButtons();
+    void hideNavigationButtons(bool showRetryButton);
+    void updateNavigationButtons();
+
+private:
+    MedardDownloader *m_downloader;
+
+    ForecastWidget *m_forecast;
+    QLabel *m_forecastTypeLabel;
+    QLabel *m_forecastInitialDateLabel;
+    QLabel *m_forecastDateLabel;
+
+    QPushButton *m_downloadRetryButton;
+
+    QPushButton *m_minusDayButton;
+    QPushButton *m_plusDayButton;
+    QPushButton *m_minusHourButton;
+    QPushButton *m_plusHourButton;
+
+    QActionGroup *m_domainActionGroup;
+};
+
+#endif // MAINWINDOW_H
diff --git a/src/medarddownloader.cpp b/src/medarddownloader.cpp
new file mode 100644 (file)
index 0000000..a4a1b1e
--- /dev/null
@@ -0,0 +1,380 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <QDebug>
+#include <QTimer>
+#include <QImage>
+#include <QDir>
+#include <QFile>
+
+#include "medarddownloader.h"
+
+#define DOWNLOAD_CACHE_DIR ".cache/medard-downloader"
+
+#define MEDARD_URL "http://www.medard-online.cz"
+#define MEDARD_IMAGE_URL "http://www.medard-online.cz/scripts/getimage.php?initDate=%1&domain=%2&variable=%3&offset=%4"
+
+#define FC_SEA_LEVEL_PRESSURE "slp"
+#define FC_PRECIPITATION "precip"
+#define FC_WIND_VELOCITY "wv"
+#define FC_CLOUDINESS "cloud"
+#define FC_TEMPERATURE "temp"
+
+#define FD_EUROPE "1"
+#define FD_CZECH_REPUBLIC "2"
+
+#define MIN_OFFSET 0
+#define MAX_OFFSET 72
+
+#define IMAGE_WIDTH 556
+#define IMAGE_HEIGHT 408
+
+#define MAX_DOWNLOAD_RETRIES 3
+
+MedardDownloader::MedardDownloader() : QObject()
+{
+    m_forecastType = FC_SEA_LEVEL_PRESSURE;
+    m_forecastDomain = FD_EUROPE;
+    m_forecastInitialDateCode.clear();
+    m_forecastDateOffset = 0;
+
+    m_network = new QNetworkAccessManager();
+    m_reply = 0;
+
+    m_retryCounter = 0;
+    m_retryTimer = new QTimer();
+    m_retryTimer->setInterval(5000);
+    connect(m_retryTimer, SIGNAL(timeout()), this, SLOT(retryTimerEvent()));
+
+    m_cachePath = QString("%1/%2")
+                  .arg(QDir().homePath())
+                  .arg(DOWNLOAD_CACHE_DIR);
+
+    createCacheDirectory();
+}
+
+MedardDownloader::~MedardDownloader()
+{
+    if (m_retryTimer->isActive())
+        m_retryTimer->stop();
+
+    if (m_reply) {
+        m_reply->abort();
+        delete m_reply;
+    }
+}
+
+QSize MedardDownloader::getImageSize()
+{
+    return QSize(IMAGE_WIDTH, IMAGE_HEIGHT);
+}
+
+void MedardDownloader::setForecastType(ForecastType type)
+{
+    switch (type) {
+        case SeaLevelPressure:
+            m_forecastType = FC_SEA_LEVEL_PRESSURE;
+            break;
+
+        case Precipitation:
+            m_forecastType = FC_PRECIPITATION;
+            break;
+
+        case WindVelocity:
+            m_forecastType = FC_WIND_VELOCITY;
+            break;
+
+        case Cloudiness:
+            m_forecastType = FC_CLOUDINESS;
+            break;
+
+        case Temperature:
+            m_forecastType = FC_TEMPERATURE;
+            break;
+    }
+}
+
+void MedardDownloader::setForecastDomain(ForecastDomain domain)
+{
+    switch (domain) {
+        case Europe:
+            m_forecastDomain = FD_EUROPE;
+            break;
+
+        case CzechRepublic:
+            m_forecastDomain = FD_CZECH_REPUBLIC;
+            break;
+    }
+}
+
+void MedardDownloader::setForecastInitialDate(QDateTime date)
+{
+    QString offset;
+
+    m_forecastInitialDate = date.toUTC();
+
+    if (date.toUTC().time().hour() >= 18) {
+        m_forecastInitialDate.setTime(QTime(18, 0, 0));
+        offset = "12";
+    } else if (date.toUTC().time().hour() >= 12) {
+        m_forecastInitialDate.setTime(QTime(12, 0, 0));
+        offset = "06";
+    } else if (date.toUTC().time().hour() >= 6) {
+        m_forecastInitialDate.setTime(QTime(6, 0, 0));
+        offset = "00";
+    } else {
+        m_forecastInitialDate.setTime(QTime(0, 0, 0));
+        offset = "18";
+    }
+
+    if (offset == "18") {
+        /* use previous day */
+        m_forecastInitialDateCode = QString("%1_%2")
+                                    .arg(date.addDays(-1).toUTC().toString("yyMMdd"))
+                                    .arg(offset);
+    } else {
+        /* use current day */
+        m_forecastInitialDateCode = QString("%1_%2")
+                                    .arg(date.toUTC().toString("yyMMdd"))
+                                    .arg(offset);
+    }
+
+    cleanCacheDirectory();
+}
+
+QDateTime MedardDownloader::getForecastInitialDate()
+{
+    return m_forecastInitialDate.toLocalTime();
+}
+
+QDateTime MedardDownloader::getForecastDate()
+{
+    return m_forecastInitialDate.addSecs(3600 * m_forecastDateOffset).toLocalTime();
+}
+
+void MedardDownloader::setForecastDateOffset(int offset)
+{
+    m_forecastDateOffset = offset;
+    if (m_forecastDateOffset > MAX_OFFSET)
+        m_forecastDateOffset = MAX_OFFSET;
+
+    if (m_forecastDateOffset < MIN_OFFSET)
+        m_forecastDateOffset = MIN_OFFSET;
+}
+
+void MedardDownloader::retryTimerEvent()
+{
+    if (m_retryTimer->isActive())
+        m_retryTimer->stop();
+
+    downloadImage();
+}
+
+void MedardDownloader::tryDownloadImageAgain()
+{
+    m_retryCounter++;
+
+    if (m_retryCounter < MAX_DOWNLOAD_RETRIES) {
+        m_retryTimer->start();
+    } else {
+        m_retryCounter = 0;
+        emit downloadFailed();
+    }
+}
+
+void MedardDownloader::clearDownloadRequest()
+{
+    qDebug() << "clearDownloadRequest: m_reply=" << m_reply;
+
+    delete m_reply;
+    m_reply = 0;
+}
+
+void MedardDownloader::downloadImageFinished()
+{ 
+    qDebug() << "downloadImageFinished: m_reply=" << m_reply;
+
+    QByteArray picture = m_reply->readAll();
+
+    if (picture.isNull() || picture.size() <= 0)
+        return;
+
+    m_retryCounter = 0;
+
+    QImage image;
+    if (!image.loadFromData(picture, "png"))
+        return;
+
+    QString filename = QString("%1/%2_%3_%4_%5.png")
+                       .arg(m_cachePath)
+                       .arg(m_forecastType)
+                       .arg(m_forecastDomain)
+                       .arg(m_forecastInitialDateCode)
+                       .arg(QString().number(m_forecastDateOffset));
+
+    if ((image.width() == 512) && (image.height() == 512)) {
+        QImage croped(512, 400, QImage::Format_ARGB32_Premultiplied);
+        croped = image.copy(0, 52, 512, IMAGE_HEIGHT);
+        croped.save(filename, "png");
+    } else {
+        QImage croped(560, 400, QImage::Format_ARGB32_Premultiplied);
+        croped = image.copy(10, 96, IMAGE_WIDTH, IMAGE_HEIGHT);
+        croped.save(filename, "png");
+    }
+
+    qDebug() << "downloadImageFinished: downloadFinished=" << filename;
+    emit downloadFinished(filename, getForecastDate());
+
+    QTimer::singleShot(0, this, SLOT(clearDownloadRequest()));
+}
+
+void MedardDownloader::downloadImageError(QNetworkReply::NetworkError /* code */)
+{
+    tryDownloadImageAgain();
+    QTimer::singleShot(0, this, SLOT(clearDownloadRequest()));
+}
+
+void MedardDownloader::downloadImage()
+{
+    qDebug() << "downloadImage: retry=" << m_retryCounter << "date:" << m_forecastInitialDate.toString("dd.MM.yyyy hh:mm");
+
+    if (m_forecastInitialDateCode.isNull()) {
+        retrieveForecastInitialDate();
+        tryDownloadImageAgain();
+        return;
+    }
+
+    QString filename = QString("%1/%2_%3_%4_%5.png")
+                       .arg(m_cachePath)
+                       .arg(m_forecastType)
+                       .arg(m_forecastDomain)
+                       .arg(m_forecastInitialDateCode)
+                       .arg(QString().number(m_forecastDateOffset));
+
+    if (isDownloaded(filename)) {
+        qDebug() << "downloadImage: downloadFinished=" << filename;
+
+        emit downloadFinished(filename, getForecastDate());
+        return;
+    }
+
+    QString imageUrl = QString(MEDARD_IMAGE_URL)
+                               .arg(m_forecastInitialDateCode)
+                               .arg(m_forecastDomain)
+                               .arg(m_forecastType)
+                               .arg(QString().number(m_forecastDateOffset));
+
+    QUrl url(imageUrl);
+    QNetworkRequest request(url);
+
+    if (m_reply)
+        clearDownloadRequest();
+    m_reply = m_network->get(request);
+
+    connect(m_reply, SIGNAL(finished()), this, SLOT(downloadImageFinished()));
+    connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
+            SLOT(downloadImageError(QNetworkReply::NetworkError)));
+}
+
+bool MedardDownloader::isDownloaded(const QString filename)
+{
+    return QFile(filename).exists();
+}
+
+int MedardDownloader::getForecastDateOffset()
+{
+    return m_forecastDateOffset;
+}
+
+int MedardDownloader::getMinForecastDateOffset()
+{
+    return MIN_OFFSET;
+}
+
+int MedardDownloader::getMaxForecastDateOffset()
+{
+    return MAX_OFFSET;
+}
+
+void MedardDownloader::retrieveForecastInitialDateFinished()
+{
+    qDebug() << "retrieveForecastInitialDateFinished: m_reply=" << m_reply;
+
+    QByteArray data = m_reply->readAll();
+
+    int index1 = data.indexOf("var fcst_initDatestamp=\"", 0);
+    int index2 = data.indexOf("\";", index1);
+    if (index1 != -1) {
+        QString temp;
+        for (int i = index1 + 24; i < index2; i++) {
+            temp.append(data.at(i));
+        }
+        QDateTime date = QDateTime::fromTime_t(temp.toULong() + 6 * 3600);
+        if (!date.isNull()) {
+            setForecastInitialDate(date.toLocalTime());
+
+            int forecastDateOffset = date.toLocalTime().secsTo(QDateTime().currentDateTime()) / 3600;
+            setForecastDateOffset(forecastDateOffset);
+        }
+        m_retryCounter = 0;
+    }
+
+    QTimer::singleShot(0, this, SLOT(clearDownloadRequest()));
+}
+
+void MedardDownloader::retrieveForecastInitialDateError(QNetworkReply::NetworkError /* code */)
+{
+    qDebug() << "retrieveForecastInitialDateError: m_reply=" << m_reply;
+}
+
+void MedardDownloader::retrieveForecastInitialDate()
+{
+    qDebug() << "retrieveForecastInitialDate: m_reply=" << m_reply;
+
+    QString serverUrl = QString(MEDARD_URL);
+
+    QUrl url(serverUrl);
+    QNetworkRequest request(url);
+
+    if (m_reply)
+        clearDownloadRequest();
+    m_reply = m_network->get(request);
+
+    connect(m_reply, SIGNAL(finished()), this, SLOT(retrieveForecastInitialDateFinished()));
+    connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
+            SLOT(retrieveForecastInitialDateError(QNetworkReply::NetworkError)));
+}
+
+void MedardDownloader::createCacheDirectory()
+{
+    QDir cacheDir(m_cachePath);
+    if (!cacheDir.exists())
+        cacheDir.mkpath(cacheDir.path());
+}
+
+void MedardDownloader::cleanCacheDirectory()
+{
+    QDir cacheDir(m_cachePath);
+    QStringList list = cacheDir.entryList();
+    for (int i = 0; i < list.size(); i++) {
+        if (!list.at(i).contains(m_forecastInitialDateCode)) {
+            QFile(m_cachePath + "/" + list.at(i)).remove();
+        }
+    }
+}
diff --git a/src/medarddownloader.h b/src/medarddownloader.h
new file mode 100644 (file)
index 0000000..4bb671c
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ *  Medard for Maemo.
+ *  Copyright (C) 2011 Roman Moravcik
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef MEDARDDOWNLOADER_H
+#define MEDARDDOWNLOADER_H
+
+#include <QObject>
+#include <QDateTime>
+#include <QString>
+#include <QSize>
+#include <QTimer>
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkReply>
+
+class MedardDownloader : public QObject
+{
+    Q_OBJECT
+
+public:
+    enum ForecastType {
+        SeaLevelPressure = 0,
+        Precipitation = 1,
+        WindVelocity = 2,
+        Cloudiness = 3,
+        Temperature  = 4
+    };
+
+    enum ForecastDomain {
+        Europe = 0,
+        CzechRepublic = 1
+    };
+
+    MedardDownloader();
+    ~MedardDownloader();
+
+    void setForecastType(ForecastType type);
+
+    void setForecastDomain(ForecastDomain domain);
+
+    void setForecastInitialDate(QDateTime date);
+    QDateTime getForecastInitialDate();
+    QDateTime getForecastDate();
+
+    void setForecastDateOffset(int offset);
+    int getForecastDateOffset();
+    int getMinForecastDateOffset();
+    int getMaxForecastDateOffset();
+
+    void downloadImage();
+
+    QSize getImageSize();
+
+signals:
+    void downloadFinished(const QString &filename, const QDateTime &date);
+    void downloadFailed();
+
+private slots:
+    void retryTimerEvent();
+    void clearDownloadRequest();
+
+    void downloadImageFinished();
+    void downloadImageError(QNetworkReply::NetworkError code);
+
+    void retrieveForecastInitialDateFinished();
+    void retrieveForecastInitialDateError(QNetworkReply::NetworkError code);
+
+private:
+    void tryDownloadImageAgain();
+    bool isDownloaded(const QString filename);
+
+    void retrieveForecastInitialDate();
+
+    void createCacheDirectory();
+    void cleanCacheDirectory();
+
+private:
+    QDateTime m_forecastInitialDate;
+    QString m_forecastInitialDateCode;
+    int m_forecastDateOffset;
+    QString m_forecastType;
+    QString m_forecastDomain;
+
+    QNetworkAccessManager *m_network;
+    QNetworkReply *m_reply;
+
+    int m_retryCounter;
+    QTimer *m_retryTimer;
+
+    QString m_cachePath;
+};
+
+#endif // MEDARDDOWNLOADER_H
diff --git a/translations/medard_cs.qm b/translations/medard_cs.qm
new file mode 100644 (file)
index 0000000..be651ee
--- /dev/null
@@ -0,0 +1 @@
+<¸d\18Êï\9c\95Í!\1c¿`¡½Ý
\ No newline at end of file
diff --git a/translations/medard_cs.ts b/translations/medard_cs.ts
new file mode 100644 (file)
index 0000000..d634808
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="cs_CZ" sourcelanguage="cs_CZ">
+<context>
+    <name>ForecastWidget</name>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="51"/>
+        <source>Download failed!</source>
+        <translation>Stahování se nezdařilo!</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="57"/>
+        <source>Downloading image...</source>
+        <translation>Stahování obrázku...</translation>
+    </message>
+</context>
+<context>
+    <name>MainWindow</name>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="169"/>
+        <location filename="../src/mainwindow.cpp" line="273"/>
+        <source>Sea Level Pressure</source>
+        <translation>Atmosférický tlak</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="173"/>
+        <location filename="../src/mainwindow.cpp" line="278"/>
+        <source>Precipitation</source>
+        <translation>Srážky (mm/2h)</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="177"/>
+        <location filename="../src/mainwindow.cpp" line="283"/>
+        <source>Wind Velocity</source>
+        <translation>Rychlost větru</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="181"/>
+        <location filename="../src/mainwindow.cpp" line="288"/>
+        <source>Cloudiness</source>
+        <translation>Oblačnost</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="185"/>
+        <location filename="../src/mainwindow.cpp" line="293"/>
+        <source>Temperature</source>
+        <translation>Teplota</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="362"/>
+        <source>Forecast from:
+</source>
+        <translation type="unfinished">Předpověď z:
+</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="162"/>
+        <source>Europe</source>
+        <translation>Evropa</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="90"/>
+        <source>Download again</source>
+        <translation>Stáhnout znovu</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="94"/>
+        <source>-1 d</source>
+        <translation>-1 d</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="95"/>
+        <source>+1 d</source>
+        <translation>+1 d</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="96"/>
+        <source>-1 h</source>
+        <translation>-1 h</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="97"/>
+        <source>+1 h</source>
+        <translation>+1 h</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="164"/>
+        <source>Czech Republic</source>
+        <translation>Česká republika</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="120"/>
+        <source>Medard</source>
+        <translation>Medard</translation>
+    </message>
+    <message>
+        <source>Initial date:
+</source>
+        <translation type="obsolete">Počiatočný dátum:
+</translation>
+    </message>
+</context>
+</TS>
diff --git a/translations/medard_en.qm b/translations/medard_en.qm
new file mode 100644 (file)
index 0000000..4600867
Binary files /dev/null and b/translations/medard_en.qm differ
diff --git a/translations/medard_en.ts b/translations/medard_en.ts
new file mode 100644 (file)
index 0000000..078928a
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+<context>
+    <name>ForecastWidget</name>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="51"/>
+        <source>Download failed!</source>
+        <translation>Download failed!</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="57"/>
+        <source>Downloading image...</source>
+        <translation>Downloading image...</translation>
+    </message>
+</context>
+<context>
+    <name>MainWindow</name>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="169"/>
+        <location filename="../src/mainwindow.cpp" line="273"/>
+        <source>Sea Level Pressure</source>
+        <translation>Sea Level Pressure</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="173"/>
+        <location filename="../src/mainwindow.cpp" line="278"/>
+        <source>Precipitation</source>
+        <translation>Precipitation</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="177"/>
+        <location filename="../src/mainwindow.cpp" line="283"/>
+        <source>Wind Velocity</source>
+        <translation>Wind Velocity</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="181"/>
+        <location filename="../src/mainwindow.cpp" line="288"/>
+        <source>Cloudiness</source>
+        <translation>Cloudiness</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="185"/>
+        <location filename="../src/mainwindow.cpp" line="293"/>
+        <source>Temperature</source>
+        <translation>Temperature</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="362"/>
+        <source>Forecast from:
+</source>
+        <translation>Forecast from:
+</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="162"/>
+        <source>Europe</source>
+        <translation>Europe</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="90"/>
+        <source>Download again</source>
+        <translation>Download again</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="94"/>
+        <source>-1 d</source>
+        <translation>-1 d</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="95"/>
+        <source>+1 d</source>
+        <translation>+1 d</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="96"/>
+        <source>-1 h</source>
+        <translation>-1 h</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="97"/>
+        <source>+1 h</source>
+        <translation>+1 h</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="164"/>
+        <source>Czech Republic</source>
+        <translation>Czech Republic</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="120"/>
+        <source>Medard</source>
+        <translation>Medard</translation>
+    </message>
+    <message>
+        <source>Initial date:
+</source>
+        <translation type="obsolete">Initial date:
+</translation>
+    </message>
+</context>
+</TS>
diff --git a/translations/medard_sk.qm b/translations/medard_sk.qm
new file mode 100644 (file)
index 0000000..3fac29f
Binary files /dev/null and b/translations/medard_sk.qm differ
diff --git a/translations/medard_sk.ts b/translations/medard_sk.ts
new file mode 100644 (file)
index 0000000..ad7463c
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="sk_SK" sourcelanguage="sk_SK">
+<context>
+    <name>ForecastWidget</name>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="51"/>
+        <source>Download failed!</source>
+        <translation>S‌ťahovanie zlyhalo!</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="57"/>
+        <source>Downloading image...</source>
+        <translation>Sťahujem obrázok...</translation>
+    </message>
+</context>
+<context>
+    <name>MainWindow</name>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="169"/>
+        <location filename="../src/mainwindow.cpp" line="273"/>
+        <source>Sea Level Pressure</source>
+        <translation>Atmosferický tlak</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="173"/>
+        <location filename="../src/mainwindow.cpp" line="278"/>
+        <source>Precipitation</source>
+        <translation>Zrážky (mm/2h)</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="177"/>
+        <location filename="../src/mainwindow.cpp" line="283"/>
+        <source>Wind Velocity</source>
+        <translation>Rýchlosť vetra</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="181"/>
+        <location filename="../src/mainwindow.cpp" line="288"/>
+        <source>Cloudiness</source>
+        <translation>Oblačnosť</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="185"/>
+        <location filename="../src/mainwindow.cpp" line="293"/>
+        <source>Temperature</source>
+        <translation>Teplota</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="362"/>
+        <source>Forecast from:
+</source>
+        <translation>Predpove‌ď z:
+</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="162"/>
+        <source>Europe</source>
+        <translation>Európa</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="90"/>
+        <source>Download again</source>
+        <translation>Sťiahnuť znova</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="94"/>
+        <source>-1 d</source>
+        <translation>-1 d</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="95"/>
+        <source>+1 d</source>
+        <translation>+1 d</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="96"/>
+        <source>-1 h</source>
+        <translation>-1 h</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="97"/>
+        <source>+1 h</source>
+        <translation>+1 h</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="164"/>
+        <source>Czech Republic</source>
+        <translation>Česká republika</translation>
+    </message>
+    <message>
+        <location filename="../src/mainwindow.cpp" line="120"/>
+        <source>Medard</source>
+        <translation>Medard</translation>
+    </message>
+    <message>
+        <source>Initial date:
+</source>
+        <translation type="obsolete">Počiatočný dátum:
+</translation>
+    </message>
+</context>
+</TS>