Initial import of version 0.3 v0.3-1
authorRoman Moravcik <roman.moravcik@gmail.com>
Mon, 28 Mar 2011 11:12:17 +0000 (13:12 +0200)
committerRoman Moravcik <roman.moravcik@gmail.com>
Mon, 28 Mar 2011 11:12:17 +0000 (13:12 +0200)
26 files changed:
deployment.pri [new file with mode: 0644]
gpsdata.desktop [new file with mode: 0644]
gpsdata.png [new file with mode: 0644]
gpsdata.pro [new file with mode: 0644]
gpsdata.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/compass.cpp [new file with mode: 0644]
src/compass.h [new file with mode: 0644]
src/gpscompasswindow.cpp [new file with mode: 0644]
src/gpscompasswindow.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/satellitesignalstrength.cpp [new file with mode: 0644]
src/satellitesignalstrength.h [new file with mode: 0644]
src/satellitesignalstrengthwindow.cpp [new file with mode: 0644]
src/satellitesignalstrengthwindow.h [new file with mode: 0644]
src/satelliteview.cpp [new file with mode: 0644]
src/satelliteview.h [new file with mode: 0644]
src/satelliteviewwindow.cpp [new file with mode: 0644]
src/satelliteviewwindow.h [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/gpsdata.desktop b/gpsdata.desktop
new file mode 100644 (file)
index 0000000..2a86584
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Terminal=false
+Name=GPSData
+Exec=/opt/usr/bin/gpsdata
+Icon=gpsdata
+X-Window-Icon=
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
diff --git a/gpsdata.png b/gpsdata.png
new file mode 100644 (file)
index 0000000..c681b17
Binary files /dev/null and b/gpsdata.png differ
diff --git a/gpsdata.pro b/gpsdata.pro
new file mode 100644 (file)
index 0000000..4fa1b87
--- /dev/null
@@ -0,0 +1,52 @@
+# Add files and directories to ship with the application 
+# by adapting the examples below.
+# file1.source = myfile
+# dir1.source = mydir
+DEPLOYMENTFOLDERS = # file1 dir1
+
+# Avoid auto screen rotation
+DEFINES += ORIENTATIONLOCK
+
+# Needs to be defined for Symbian
+#DEFINES += NETWORKACCESS
+
+symbian {
+TARGET.UID3 = 0xECDDA32D
+TARGET.CAPABILITY = Location
+}
+
+# If your application uses the Qt Mobility libraries, uncomment
+# the following lines and add the respective components to the 
+# MOBILITY variable. 
+CONFIG += mobility
+MOBILITY += location
+
+QT += dbus
+
+contains(QT_CONFIG, opengl): QT += opengl
+
+SOURCES += \
+    src/satelliteviewwindow.cpp \
+    src/satelliteview.cpp \
+    src/mainwindow.cpp \
+    src/main.cpp \
+    src/satellitesignalstrength.cpp \
+    src/gpscompasswindow.cpp \
+    src/compass.cpp
+HEADERS += \
+    src/satelliteviewwindow.h \
+    src/satelliteview.h \
+    src/mainwindow.h \
+    src/satellitesignalstrength.h \
+    src/gpscompasswindow.h \
+    src/compass.h
+FORMS += 
+
+symbian {
+SOURCES += src/satellitesignalstrengthwindow.cpp
+HEADERS += src/satellitesignalstrengthwindow.h
+}
+
+# Please do not modify the following two lines. Required for deployment.
+include(deployment.pri)
+qtcAddDeployment()
diff --git a/gpsdata.svg b/gpsdata.svg
new file mode 100644 (file)
index 0000000..c8442e1
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="text/ecmascript" zoomAndPan="magnify" baseProfile="tiny" contentStyleType="text/css" version="0.0" width="44px" preserveAspectRatio="xMidYMid meet" viewBox="0 0 44 44" height="44px" x="0" y="0">\r
+    <defs>\r
+        <linearGradient xlink:type="simple" xlink:actuate="onLoad" xlink:show="other">\r
+            <stop stop-opacity="1" stop-color="#000000" offset="0"/>\r
+            <stop stop-opacity="0" stop-color="#000000" offset="1"/>\r
+        </linearGradient>\r
+        <linearGradient x1="-7.9363394" y1="2.4509284" x2="-10.153846" gradientUnits="userSpaceOnUse" y2="21.941645" xlink:type="simple" xlink:actuate="onLoad" xlink:show="other">\r
+            <stop stop-opacity="1" stop-color="#000000" offset="0"/>\r
+            <stop stop-opacity="0" stop-color="#000000" offset="1"/>\r
+        </linearGradient>\r
+        <linearGradient x1="-7.9363394" y1="2.4509284" x2="-10.153846" gradientUnits="userSpaceOnUse" y2="21.941645" xlink:type="simple" xlink:actuate="onLoad" id="linearGradient3217" xlink:show="other">\r
+            <stop stop-opacity="1" stop-color="#000000" offset="0"/>\r
+            <stop stop-opacity="0" stop-color="#000000" offset="1"/>\r
+        </linearGradient>\r
+    </defs>\r
+    <g>\r
+        <path d="M 39.37799 25.22998 L 39.37799 10.57599 C 39.37799 10.02298 38.92899 9.574982 38.37799 9.574982 L 6.998993 9.574982 C 6.446991 9.574982 5.998993 10.02298 5.998993 10.57599 L 5.998993 36.0 C 5.998993 36.55099 6.446991 37.0 6.998993 37.0 L 22.64197 37.0 C 26.76898 42.35898 35.12097 42.44998 39.20297 36.547 C 41.56598 33.10699 41.56998 28.63898 39.37799 25.22998 z " fill-opacity="0.1999817" stroke-opacity="0.1999817"/>\r
+        <path d="M 40.0 30.75497 C 40.0 25.42798 7.0 33.73398 7.0 33.73398 L 7.0 36.0 L 23.14899 36.0 C 28.61697 43.60199 40.0 39.53497 40.0 30.75497 z " fill-opacity="0.5" stroke-opacity="0.5"/>\r
+        <rect width="44" fill="none" height="44"/>\r
+        <linearGradient x1="22.689" y1="9.550781" x2="22.689" gradientUnits="userSpaceOnUse" y2="34.86069" xlink:type="simple" xlink:actuate="onLoad" id="SVGID_1_" xlink:show="other">\r
+            <stop stop-color="#b2b2b2" offset="0"/>\r
+            <stop stop-color="#acacac" offset="0.2015991"/>\r
+            <stop stop-color="#9c9c9c" offset="0.465271"/>\r
+            <stop stop-color="#818181" offset="0.762085"/>\r
+            <stop stop-color="#666666" offset="1"/>\r
+        </linearGradient>\r
+        <rect x="6.998993" width="31.379" fill="url(#SVGID_1_)" y="9.575989" height="25.42398"/>\r
+        <path fill="#f2f2f2" d="M 38.37799 16.78897 L 33.11398 20.55896 L 30.12 16.38098 L 38.37799 10.465 L 38.37799 9.575989 L 30.11002 9.575989 L 17.93301 18.30096 L 11.68402 9.575989 L 6.998993 9.575989 L 6.998993 12.54498 L 13.43198 21.52396 L 6.998993 26.13095 L 6.998993 32.94196 L 23.08499 35.0 L 34.72598 22.80899 L 38.37796 20.194 L 38.37796 16.78897 z M 23.375 25.896 L 21.15701 22.79999 L 27.871 17.991 L 30.08798 21.08701 L 23.375 25.896 z "/>\r
+        <linearGradient x1="11.75537" y1="30.18259" x2="25.92538" gradientUnits="userSpaceOnUse" y2="50.9491" xlink:type="simple" xlink:actuate="onLoad" id="SVGID_2_" xlink:show="other">\r
+            <stop stop-color="#79cd19" offset="0"/>\r
+            <stop stop-color="#1b6332" offset="1"/>\r
+        </linearGradient>\r
+        <polygon fill="url(#SVGID_2_)" points="16.655,26.02499 6.998993,32.94098 6.998993,35 23.08499,35 "/>\r
+        <path d="M 38.37799 22.93597 C 35.06598 19.23898 29.505 18.35098 25.181 21.16498 C 20.61899 24.13599 19.09399 30.19699 21.974 34.99997 L 38.37799 34.99997 L 38.37799 22.93597 z " fill-opacity="0.5" stroke-opacity="0.5"/>\r
+        <linearGradient x1="30.75537" y1="22.1904" x2="30.75537" gradientUnits="userSpaceOnUse" y2="54.9119" xlink:type="simple" xlink:actuate="onLoad" id="SVGID_3_" xlink:show="other">\r
+            <stop stop-color="#e3e3e3" offset="0"/>\r
+            <stop stop-color="#404040" offset="1"/>\r
+        </linearGradient>\r
+        <path fill="url(#SVGID_3_)" d="M 39.99899 29.754 C 39.99899 34.86099 35.85898 38.99997 30.75598 38.99997 C 25.651 38.99997 21.51199 34.86099 21.51199 29.754 C 21.51199 24.64999 25.651 20.51199 30.75598 20.51199 C 35.85898 20.51199 39.99899 24.64999 39.99899 29.754 z "/>\r
+        <linearGradient x1="30.75537" y1="38.72067" x2="30.75537" gradientUnits="userSpaceOnUse" y2="22.05328" xlink:type="simple" xlink:actuate="onLoad" id="SVGID_4_" xlink:show="other">\r
+            <stop stop-color="#e3e3e3" offset="0"/>\r
+            <stop stop-color="#404040" offset="1"/>\r
+        </linearGradient>\r
+        <path fill="url(#SVGID_4_)" d="M 22.77298 29.754 C 22.77499 25.34601 26.34598 21.77399 30.75497 21.77399 L 30.75497 21.77399 C 35.16296 21.77399 38.73398 25.34598 38.73596 29.754 L 38.73596 29.754 C 38.73398 34.16397 35.16296 37.73697 30.75497 37.73697 L 30.75497 37.73697 C 26.34698 37.737 22.77499 34.164 22.77298 29.754 L 22.77298 29.754 z "/>\r
+        <linearGradient x1="30.75439" y1="37.41208" x2="30.75439" gradientUnits="userSpaceOnUse" y2="22.6561" xlink:type="simple" xlink:actuate="onLoad" id="SVGID_5_" xlink:show="other">\r
+            <stop stop-color="#3687ff" offset="0"/>\r
+            <stop stop-color="#051f7d" offset="1"/>\r
+        </linearGradient>\r
+        <path fill="url(#SVGID_5_)" d="M 23.31799 29.754 C 23.32599 33.86298 26.64798 37.18597 30.75598 37.19299 L 30.75598 37.19299 C 34.86298 37.185 38.18597 33.86301 38.19196 29.754 L 38.19196 29.754 C 38.18597 25.647 34.86398 22.32501 30.75598 22.31799 L 30.75598 22.31799 C 26.64798 22.32498 23.32599 25.646 23.31799 29.754 L 23.31799 29.754 z "/>\r
+        <path fill="#ffffff" d="M 37.58698 27.51398 C 36.62799 24.66901 33.94199 22.61899 30.77499 22.61899 C 26.79898 22.61899 23.57898 25.84 23.57898 29.81299 C 23.57898 31.18497 23.97098 32.46097 24.63699 33.55197 L 37.58698 27.51398 z " fill-opacity="0.25" stroke-opacity="0.25"/>\r
+        <polygon fill="#ffffff" points="36.65799,31.254 35.181,31.254 35.181,28.258 36.646,28.258 36.646,28.55899 35.61298,28.55899 35.61298,29.48199 36.45297,29.48199 36.45297,29.78497 35.61298,29.78497 35.61298,30.95297 36.65799,30.95297 "/>\r
+        <polygon fill="#ffffff" points="27.32498,28.258 26.61697,31.254 26.172,31.254 25.59097,28.80798 24.95099,31.254 24.48398,31.254 23.85498,28.258 24.31598,28.258 24.76898,30.66397 25.39798,28.258 25.86298,28.258 26.431,30.66397 26.94199,28.258 "/>\r
+        <path fill="#ffffff" d="M 31.431 33.75299 C 31.24301 33.711 31.07401 33.69098 30.92001 33.69098 C 30.60101 33.69098 30.38202 33.85599 30.38202 34.12799 C 30.38202 34.54797 30.84702 34.59897 31.28799 34.97198 C 31.466 35.12396 31.56699 35.32697 31.56699 35.57397 C 31.56699 36.15997 31.22501 36.45297 30.54199 36.45297 C 30.336 36.45297 30.13602 36.42596 29.94101 36.37097 L 29.94101 36.06 C 30.16699 36.12198 30.362 36.15399 30.53 36.15399 C 30.91699 36.15399 31.13199 35.966 31.13199 35.672 C 31.13199 35.42401 31.04199 35.30499 30.55798 35.03101 C 30.23001 34.841 29.94699 34.63602 29.94699 34.18701 C 29.94699 33.617 30.383 33.392 30.892 33.392 C 31.08499 33.392 31.26498 33.41299 31.43097 33.453 L 31.43097 33.75299 z "/>\r
+        <polygon fill="#ffffff" points="31.73999,26.08798 31.41898,26.08798 30.185,23.85699 30.185,26.08798 29.76898,26.08798 29.76898,23.09198 30.12299,23.09198 31.32498,25.25998 31.32498,23.09198 31.73999,23.09198 "/>\r
+        <polygon fill="#ffffff" fill-opacity="0.6999817" stroke-opacity="0.6999817" points="31.52197,29.94699 34.08698,29.59598 31.51398,29.24399 31.931,28.43198 31.12399,28.84399 30.77298,26.29898 30.42099,28.84198 29.60699,28.422 30.03098,29.24399 27.457,29.59598 30.02298,29.94699 29.60199,30.75998 30.41898,30.336 30.77298,32.91199 31.125,30.33398 31.935,30.75 "/>\r
+    </g>\r
+    <g transform="translate(21.941645,2.5676393)">\r
+        <path stroke-linecap="butt" stroke-dashoffset="0" fill-opacity="0.97368421" fill="#ff0000" stroke-linejoin="round" stroke-dasharray="none" d="M -8.65625 8.624998 C -10.975517 8.63144 -12.850901 10.332596 -12.84375 12.421931 C -12.841723 13.01413 -12.677488 13.579183 -12.40625 14.077736 L -8.625 27.124336 L -4.71875 13.877897 L -4.75 13.877897 C -4.538845 13.424523 -4.4357123 12.944264 -4.4375 12.421931 L -6.90625 12.421931 C -6.89657 12.492259 -6.875319 12.54892 -6.875 12.621769 C -6.87212 13.534014 -7.6283503 14.274761 -8.5625 14.277574 C -9.49665 14.280387 -10.27837 13.562562 -10.28125 12.650317 C -10.28413 11.738073 -9.527899 10.997325 -8.59375 10.994512 C -7.7349105 10.991926 -7.017692 11.61225 -6.90625 12.421931 L -4.4375 12.393382 C -4.447416 10.305647 -6.338747 8.618561 -8.65625 8.624998 z " stroke="#000000" stroke-width="0" stroke-opacity="0.49342107" stroke-miterlimit="4"/>\r
+        <path stroke-linecap="butt" stroke-dashoffset="0" fill-opacity="1" fill="url(#linearGradient3217)" stroke-linejoin="round" stroke-dasharray="none" d="M -8.65625 8.624998 C -10.975517 8.63144 -12.850901 10.332596 -12.84375 12.421931 C -12.841723 13.01413 -12.677488 13.579183 -12.40625 14.077736 L -8.625 27.124336 L -4.71875 13.877897 L -4.75 13.877897 C -4.538845 13.424523 -4.4357123 12.944264 -4.4375 12.421931 L -6.90625 12.421931 C -6.89657 12.492259 -6.875319 12.54892 -6.875 12.621769 C -6.87212 13.534014 -7.6283503 14.274761 -8.5625 14.277574 C -9.49665 14.280387 -10.27837 13.562562 -10.28125 12.650317 C -10.28413 11.738073 -9.527899 10.997325 -8.59375 10.994512 C -7.7349105 10.991926 -7.017692 11.61225 -6.90625 12.421931 L -4.4375 12.393382 C -4.447416 10.305647 -6.338747 8.618561 -8.65625 8.624998 z " stroke="#000000" stroke-width="0" stroke-opacity="0.49342107" stroke-miterlimit="4"/>\r
+    </g>\r
+</svg>\r
diff --git a/qtc_packaging/debian_fremantle/README b/qtc_packaging/debian_fremantle/README
new file mode 100644 (file)
index 0000000..9547fe7
--- /dev/null
@@ -0,0 +1,6 @@
+The Debian Package gpsdata
+----------------------------
+
+Comments regarding the Package
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Å t, 03 feb 2011 12:38:40 +0100
diff --git a/qtc_packaging/debian_fremantle/changelog b/qtc_packaging/debian_fremantle/changelog
new file mode 100644 (file)
index 0000000..35f7996
--- /dev/null
@@ -0,0 +1,17 @@
+gpsdata (0.3-1) unstable; urgency=low
+
+  * Maemo5: Don't update screen when it's locked.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Mon, 28 Mar 2011 13:05:25 +0200
+
+gpsdata (0.2-1) unstable; urgency=low
+
+  * Fixed build on symbian target.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Tue, 15 Feb 2011 07:59:11 +0100
+
+gpsdata (0.1-1) unstable; urgency=low
+
+  * Initial version.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Mon, 07 Feb 2011 14:32:29 +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..03f0d94
--- /dev/null
@@ -0,0 +1,110 @@
+Source: gpsdata
+Section: user/navigation
+Priority: optional
+Maintainer: Roman Moravcik <roman.moravcik@gmail.com>
+Build-Depends: debhelper (>= 5), libqt4-dev
+Standards-Version: 3.7.3
+Homepage: <insert the upstream URL, if relevant>
+
+Package: gpsdata
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: A simple GPS status application and compass.
+ GPSData is an application displaying extended GPS informations (direction, ground
+ and vertical speeds, magnetic variation, horizontal and vertical accuracies, ...),
+ current position of GPS satellites on the sky and contains a simple GPS compass.
+XB-Maemo-Ic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UVt9uN1+vF6/VicxYgzQSR
+ cJhIJEI4HCaRyAT3UCg09tZbbx07derUaeAAMEHmG8EFz8fvCAIAhBDlwGqg
+ Cni0urrat3Pnzrtra2trNE3TF6s7NjY22t7efuHAgQMfW5Z1CTgCxICubJF/
+ znvvFAIAhBClwCoya/a7gM12u93d0tJSVV1d7XO73S6Xy+UwDMOIRCLxUCgU
+ Pn36dGBgYCBMJtKfBkaAEJnAt6jxcIcRACCE0AE/mRlHAxrJeEUhmS8+p6fu
+ BDA2JR+TMdwkY3jWgJf1fXcaAdMQQnjIkFDMzRWrIENCmrmruggQBMYWG+9Z
+ 33OnEjCNqY+1PWSGhT4lksy6PgnEpZw6arqV9u90Av6/8Zn/h4nPCVhuBZYb
+ /wd67UkALBo43AAAAABJRU5ErkJggg==
+
diff --git a/qtc_packaging/debian_fremantle/copyright b/qtc_packaging/debian_fremantle/copyright
new file mode 100644 (file)
index 0000000..51562b6
--- /dev/null
@@ -0,0 +1,38 @@
+This package was debianized by Roman Moravcik <roman.moravcik@gmail.com> on
+Å t, 03 feb 2011 12:38:40 +0100.
+
+It was downloaded from <url://example.com>
+
+Upstream Author(s):
+
+    Roman Moravcik <roman.moravcik@gmail.com>
+
+Copyright:
+
+    <Copyright (C) 2001 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..6578d53
--- /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/gpsdata.sgml > gpsdata.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/gpsdata.
+       $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/gpsdata 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/compass.cpp b/src/compass.cpp
new file mode 100644 (file)
index 0000000..7636b46
--- /dev/null
@@ -0,0 +1,355 @@
+/*
+ *  GPSData 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 "compass.h"
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifdef Q_WS_MAEMO_5
+#define LABEL_FONT_HIGH 44
+#else
+#define LABEL_FONT_HIGH 14
+#endif
+
+#ifdef Q_WS_MAEMO_5
+#define LABEL_FONT_SMALL 26
+#else
+#define LABEL_FONT_SMALL 8
+#endif
+
+#define GPS_MIN_GROUND_SPEED 1  /* 3.6 km/h */
+#define SENSOR_CALIBRATION_THRESHOLD 0.5
+
+#define WIDGET_MARGIN 8
+
+void Compass::updateWidget(const int azimuth, double calibration)
+{
+    m_azimuth = azimuth;
+    if (m_azimuth == 360)
+        m_azimuth = 0;
+
+    m_sensorCalibLevel = calibration;
+
+    if (calibration > 0) {
+        m_locked = true;
+
+        if (m_azimuth != m_compassAzimuth) {
+            if (m_rotateTimer->isActive())
+                m_rotateTimer->stop();
+
+            m_rotateTimer->start();
+        }
+    } else {
+        if (calibration == 0)
+            m_locked = false;
+
+        if (m_rotateTimer->isActive())
+            m_rotateTimer->stop();
+
+        update();
+    }
+}
+
+void Compass::updateWidget(const int azimuth, bool locked, int speed)
+{
+    m_azimuth = azimuth;
+    if (m_azimuth == 360)
+        m_azimuth = 0;
+
+    m_locked = locked;
+    m_gpsSpeed = speed;
+
+    if (speed >= GPS_MIN_GROUND_SPEED) {
+        if (m_azimuth != m_compassAzimuth) {
+            if (m_rotateTimer->isActive())
+                m_rotateTimer->stop();
+
+            m_rotateTimer->start();
+        }
+    } else {
+        if (m_rotateTimer->isActive())
+            m_rotateTimer->stop();
+
+        update();
+    }
+}
+
+void Compass::paintEvent(QPaintEvent * /* event */)
+{
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing);
+
+    double widget_width = 0;
+    double widget_height = 0;
+    double widget_x = 0;
+    double widget_y = 0;
+
+    if (rect().width() < rect().height()) {
+        /* Portrait orientation */
+        widget_width = rect().width() - 2 * WIDGET_MARGIN;
+        widget_height = widget_width;
+        widget_x = rect().x() + WIDGET_MARGIN;
+        widget_y = rect().y() + (rect().height() - widget_height) / 2.0;
+    } else {
+        /* Landscape orientation */
+        widget_height = rect().height() - 2 * WIDGET_MARGIN;
+        widget_width = widget_height;
+        widget_x = rect().x() + (rect().width() - widget_width) / 2.0;
+        widget_y = rect().y() + WIDGET_MARGIN;
+    }
+
+    /* Draw azimuth/warning */
+    paintAzimuth(painter, rect());
+
+    QMatrix matrix;
+    matrix.translate(widget_x + widget_width / 2.0, widget_y + widget_height / 2.0);
+    matrix.rotate(360 - m_compassAzimuth);
+    painter.setMatrix(matrix);
+
+    /* Draw compass */
+    QRectF compassArea(0, 0, widget_width, widget_height);
+    paintCompass(painter, compassArea);
+}
+
+void Compass::paintAzimuth(QPainter &painter, const QRectF &area)
+{
+    QFont font = QApplication::font();
+    font.setPointSize(LABEL_FONT_SMALL);
+    painter.setFont(font);
+    painter.setPen(QApplication::palette().color(QPalette::Text));
+
+    double azimuth_offset = (area.height() - area.width()) / 4.0 -
+                            painter.fontMetrics().height() + 2.0 * WIDGET_MARGIN;
+    QRectF azimuthArea(area.x(), area.y() + azimuth_offset, area.width(), painter.fontMetrics().height());
+
+    if (m_locked) {
+        QString s;
+        QChar degree(0x00B0);
+
+        s = QString("%1%2")
+            .arg(QString::number(m_compassAzimuth))
+            .arg(degree);
+
+        if (m_type == Compass::Gps) {
+            if (m_gpsSpeed < GPS_MIN_GROUND_SPEED)
+                painter.setPen(m_azimuthLabelWarnColor);
+        } else if (m_type == Compass::Sensor) {
+            if (m_sensorCalibLevel < SENSOR_CALIBRATION_THRESHOLD)
+                painter.setPen(m_azimuthLabelWarnColor);
+        }
+        painter.drawText(azimuthArea, Qt::AlignCenter, s);
+    } else {
+        if (m_type == Compass::Gps)
+            painter.drawText(azimuthArea, Qt::AlignCenter, tr("GPS not locked"));
+        else if (m_type == Compass::Sensor)
+            painter.drawText(azimuthArea, Qt::AlignCenter, tr("Compass not calibrated"));
+    }
+}
+
+void Compass::paintCompass(QPainter &painter, const QRectF &area)
+{
+    double compass_radius = area.width() / 2.0;
+    double compass_x = area.x() - compass_radius;
+    double compass_y = area.y() - compass_radius;
+
+    /* Labels */
+    QString label[8] = {tr("N"), tr("NE"), tr("E"), tr("SE"), tr("S"), tr("SW"), tr("W"), tr("NW")};
+    double label_height = area.height() / 3.6;
+    double label_offset = area.width() / 14.4;
+    for (int i = 0; i < 8; i++) {
+        QFont font = QApplication::font();
+        double label_y;        
+
+        if ((i % 2) == 0) {
+            font.setPointSize(LABEL_FONT_HIGH);
+            label_y = compass_y;
+        } else {
+            font.setPointSize(LABEL_FONT_SMALL);
+            label_y = compass_y + label_offset;
+        }
+        QRectF labelArea(compass_x, label_y, area.width(), label_height);
+        painter.setFont(font);
+        painter.drawText(labelArea, Qt::AlignCenter, label[i]);
+        painter.rotate(45);
+    }
+
+    /* Compass scale */
+    QRectF compassArea(compass_x, compass_y, area.width(), area.height());
+    painter.setPen(QPen(m_scaleColor, 3));
+    painter.drawArc(compassArea, 0, 5760);
+
+    for (int angle = 0; angle < 360; angle += 2) {
+        double angle_rad = angle * M_PI / 180.0;
+
+        double x1 = (compass_radius - (area.width() / 18.0)) * qCos(angle_rad);
+        double y1 = (compass_radius - (area.width() / 18.0)) * qSin(angle_rad);
+        double x2 = compass_radius * qCos(angle_rad);
+        double y2 = compass_radius * qSin(angle_rad);
+
+        if (angle % 30)
+            painter.setPen(QPen(m_scaleColor, 0));
+        else
+            painter.setPen(QPen(m_scaleColor, 3));
+
+        painter.drawLine(QLineF(x1, y1, x2, y2));
+    }
+
+    /* Compass windrose NE/SE/SW/NW */
+    painter.setPen(m_windroseBckColor);
+    for (int angle = 45; angle < 360; angle += 90) {
+        double angle_rad1 = angle * M_PI / 180.0;
+        double angle_rad2 = (angle - 90) * M_PI / 180.0;
+        double angle_rad3 = (angle + 90) * M_PI / 180.0;
+        double temp1 = compass_radius - (area.width() / 3.6);
+        double temp2 = area.width() / 16.0;
+
+        double x1 = temp1 * qCos(angle_rad1);
+        double y1 = temp1 * qSin(angle_rad1);
+        double x2 = temp2 * qCos(angle_rad2);
+        double y2 = temp2 * qSin(angle_rad2);
+        double x3 = temp2 * qCos(angle_rad3);
+        double y3 = temp2 * qSin(angle_rad3);
+        QPointF triangle1[3] = { QPointF(x1, y1), QPointF(x2, y2), QPointF(area.x(), area.y()) };
+        painter.setBrush(m_windroseBckColor);
+        painter.drawPolygon(triangle1, 3);
+
+        QPointF triangle2[3] = { QPointF(x1, y1), QPointF(x3, y3), QPointF(area.x(), area.y()) };
+        painter.setBrush(m_windroseColor);
+        painter.drawPolygon(triangle2, 3);
+    }
+
+    /* Compass windrose N/E/S/W */
+    for (int angle = 0; angle < 360; angle += 90) {
+        double angle_rad1 = angle * M_PI / 180.0;
+        double angle_rad2 = (angle - 45) * M_PI / 180.0;
+        double angle_rad3 = (angle + 45) * M_PI / 180.0;
+        double temp1 = compass_radius - (area.width() / 4.5);
+        double temp2 = area.width() / 16.0;
+
+        double x1 = temp1 * qCos(angle_rad1);
+        double y1 = temp1 * qSin(angle_rad1);
+        double x2 = temp2 * qCos(angle_rad2);
+        double y2 = temp2 * qSin(angle_rad2);
+        double x3 = temp2 * qCos(angle_rad3);
+        double y3 = temp2 * qSin(angle_rad3);
+        QPointF triangle1[3] = { QPointF(x1, y1), QPointF(x2, y2), QPointF(area.x(), area.y()) };
+        if (angle == 270)
+            painter.setBrush(m_windroseNorthColor);
+        else
+            painter.setBrush(m_windroseBckColor);
+
+        painter.drawPolygon(triangle1, 3);
+
+        QPointF triangle2[3] = { QPointF(x1, y1), QPointF(x3, y3), QPointF(area.x(), area.y()) };
+        painter.setBrush(m_windroseColor);
+        painter.drawPolygon(triangle2, 3);
+    }
+
+    /* Red cursor */
+    double x1 = area.x() + (area.width() / 12.0);
+    double y1 = compass_y - 5;
+    double x2 = area.x() - (area.width() / 12.0);
+    double y2 = compass_y - 5;
+    double x3 = area.x();
+    double y3 = compass_y + (area.height() / 18.0) - 5;
+    QPointF triangle[3] = { QPointF(x1, y1), QPointF(x2, y2), QPointF(x3, y3) };
+
+    painter.rotate(m_compassAzimuth - 360);
+    painter.setPen(m_windroseNorthColor);
+    painter.setBrush(m_windroseNorthColor);
+    painter.drawPolygon(triangle, 3);
+}
+
+void Compass::moveTimerEvent()
+{
+    if (m_locked)
+    {
+        int delta = qAbs(m_azimuth - m_compassAzimuth);
+        if (delta > 180)
+            delta = 360 - delta;
+
+        int step = 1;
+        if (delta > 30)
+            step = 4;
+        else if (delta > 20)
+            step = 3;
+        else if (delta > 10)
+            step = 2;
+        else
+            step = 1;
+
+        if (m_azimuth > m_compassAzimuth) {
+            if ((m_azimuth - m_compassAzimuth) < 180)
+                m_compassAzimuth += step;
+            else
+                m_compassAzimuth -= step;
+        } else {
+            if ((m_compassAzimuth - m_azimuth) < 180)
+                m_compassAzimuth -= step;
+            else
+                m_compassAzimuth += step;
+        }
+
+        if (m_compassAzimuth >= 360)
+            m_compassAzimuth = m_compassAzimuth - 360;
+        else if (m_compassAzimuth < 0)
+            m_compassAzimuth = 360 + m_compassAzimuth;
+
+        if (m_azimuth == m_compassAzimuth)
+            m_rotateTimer->stop();
+    } else {
+        m_rotateTimer->stop();
+    }
+
+    update();
+}
+
+#ifdef QT_NO_OPENGL
+Compass::Compass(CompassType type) : QWidget()
+#else
+Compass::Compass(CompassType type) : QGLWidget(QGLFormat(QGL::SampleBuffers), 0)
+#endif
+{
+    m_type = type;
+    m_compassAzimuth = 0;
+    m_azimuth = 0;
+    m_locked = false;
+    m_gpsSpeed = 0;
+    m_sensorCalibLevel = 0;
+
+    m_azimuthLabelWarnColor = QColor(255, 0, 0);
+    m_scaleColor = QColor(153, 153, 153);
+    m_windroseNorthColor = QColor(255, 0, 0);
+    m_windroseColor = QColor(153, 153, 153);
+    m_windroseBckColor = QColor(74, 69, 66);
+
+    m_rotateTimer = new QTimer();
+    m_rotateTimer->setInterval(70);
+    connect(m_rotateTimer, SIGNAL(timeout()), this, SLOT(moveTimerEvent()));
+}
+
+Compass::~Compass()
+{
+    if (m_rotateTimer->isActive())
+        m_rotateTimer->stop();
+}
diff --git a/src/compass.h b/src/compass.h
new file mode 100644 (file)
index 0000000..f30ea82
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ *  GPSData 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 COMPASS_H
+#define COMPASS_H
+
+#ifdef QT_NO_OPENGL
+#include <QWidget>
+#else
+#include <QGLWidget>
+#endif
+#include <QTimer>
+
+#ifdef QT_NO_OPENGL
+class Compass : public QWidget
+#else
+class Compass : public QGLWidget
+#endif
+{
+  Q_OBJECT
+
+public:
+    enum CompassType
+    {
+        Gps = 0,
+        Sensor = 1
+    };
+
+    Compass(CompassType type);
+    ~Compass();
+
+    void updateWidget(const int azimuth, double calibration);
+    void updateWidget(const int azimuth, bool locked, int speed);
+
+private slots:
+    void moveTimerEvent();
+
+private:
+    CompassType m_type;
+    int m_azimuth;
+    int m_compassAzimuth;
+    bool m_locked;
+    int m_gpsSpeed;
+    double m_sensorCalibLevel;
+
+    QColor m_azimuthLabelWarnColor;
+    QColor m_scaleColor;
+    QColor m_windroseNorthColor;
+    QColor m_windroseColor;
+    QColor m_windroseBckColor;
+
+    void paintAzimuth(QPainter &painter, const QRectF &area);
+    void paintCompass(QPainter &painter, const QRectF &area);
+
+    QTimer *m_rotateTimer;
+
+protected:
+    void paintEvent(QPaintEvent *event);
+};
+
+#endif // GCOMPASS_H
diff --git a/src/gpscompasswindow.cpp b/src/gpscompasswindow.cpp
new file mode 100644 (file)
index 0000000..1dba3b5
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  GPSData 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 "gpscompasswindow.h"
+
+GpsCompassWindow::GpsCompassWindow(QWidget *parent) : QMainWindow(parent)
+{
+    m_screenLocked = false;
+
+    createUi();
+
+    connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool)));
+}
+
+GpsCompassWindow::~GpsCompassWindow()
+{
+    delete m_compass;
+}
+
+void GpsCompassWindow::createUi()
+{
+#if defined(Q_OS_SYMBIAN)
+    setAttribute(Qt::WA_DeleteOnClose);
+#elif defined(Q_WS_MAEMO_5)
+    setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+
+    /* Workaround to show compass widget maximized */
+    showMaximized();
+#endif
+
+    setWindowTitle(tr("GPS compass"));
+
+    m_compass = new Compass(Compass::Gps);
+    setCentralWidget(m_compass);
+
+#ifdef Q_OS_SYMBIAN
+    QAction* backSoftkey = new QAction(tr("Back"), this);
+    backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey);
+    connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close()));
+    addAction(backSoftkey);
+#endif
+}
+
+void GpsCompassWindow::onScreenLocked(bool locked)
+{
+    m_screenLocked = locked;
+}
+
+void GpsCompassWindow::onPositionUpdated(const QGeoPositionInfo &position)
+{
+    if (m_screenLocked)
+        return;
+
+    if (position.hasAttribute(QGeoPositionInfo::Direction)) {
+        m_compass->updateWidget(position.attribute(QGeoPositionInfo::Direction), true,
+                                position.attribute(QGeoPositionInfo::GroundSpeed));
+    } else {
+        m_compass->updateWidget(0, false, 0);
+    }
+}
+
+void GpsCompassWindow::setPositionInfoSource(QGeoPositionInfoSource *positionInfoSource)
+{
+    m_position = positionInfoSource;
+    if (m_position) {
+        connect(m_position, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this,
+                SLOT(onPositionUpdated(const QGeoPositionInfo &)));
+
+        m_position->requestUpdate();
+    }
+}
diff --git a/src/gpscompasswindow.h b/src/gpscompasswindow.h
new file mode 100644 (file)
index 0000000..b071c8a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  GPSData 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 GPSCOMPASSWINDOW_H
+#define GPSCOMPASSWINDOW_H
+
+#include <QMainWindow>
+#include <QWidget>
+
+#include <QGeoPositionInfoSource>
+
+#include "compass.h"
+
+QTM_USE_NAMESPACE
+
+class GpsCompassWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    GpsCompassWindow(QWidget *parent = 0);
+    ~GpsCompassWindow();
+
+    void setPositionInfoSource(QGeoPositionInfoSource *positionInfoSource);
+
+private slots:
+    void onScreenLocked(bool locked);
+    void onPositionUpdated(const QGeoPositionInfo &position);
+
+private:
+    void createUi();
+
+private:
+    bool m_screenLocked;
+
+    QGeoPositionInfoSource *m_position;
+
+    Compass *m_compass;
+};
+
+#endif // GPSCOMPASSWINDOW_H
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..db26e07
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  GPSData 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 "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication app(argc, argv);
+
+    MainWindow window;
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+    window.showMaximized();
+#else
+    window.show();
+#endif
+
+    return app.exec();
+}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
new file mode 100644 (file)
index 0000000..892ed58
--- /dev/null
@@ -0,0 +1,434 @@
+/*
+ *  GPSData 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 <QString>
+#include <QChar>
+#include <qnumeric.h>
+
+#ifdef Q_OS_SYMBIAN
+#include <eikenv.h>
+#include <eikappui.h>
+#include <aknenv.h>
+#include <aknappui.h>
+#endif
+
+#ifdef Q_WS_MAEMO_5
+#include <QtDBus>
+#endif
+
+#include "mainwindow.h"
+#include "gpscompasswindow.h"
+#include "satelliteviewwindow.h"
+
+#ifdef Q_OS_SYMBIAN
+#include "satellitesignalstrengthwindow.h"
+#endif
+
+MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
+{
+    m_satellitesInView = 0;
+    m_satellitesInUse = 0;
+#ifdef Q_WS_MAEMO_5
+    m_screenLocked = false;
+#endif
+
+    m_position = QGeoPositionInfoSource::createDefaultSource(0);
+    if (m_position) {
+        connect(m_position, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this,
+                SLOT(onPositionUpdated(const QGeoPositionInfo &)));
+
+        m_position->setUpdateInterval(3);
+        m_position->startUpdates();
+    }
+
+    m_satellite = QGeoSatelliteInfoSource::createDefaultSource(0);
+    if (m_satellite) {
+        connect(m_satellite, SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)), this,
+                SLOT(onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)));
+        connect(m_satellite, SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)), this,
+                SLOT(onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)));
+
+        m_satellite->startUpdates();
+    }
+
+    createUi();
+    createMenu();
+    updateUi();
+
+#ifdef Q_WS_MAEMO_5
+    registerScreenLockMonitor();
+#endif
+}
+
+MainWindow::~MainWindow()
+{
+    if (m_satellite) {
+        m_satellite->stopUpdates();
+        delete m_satellite;
+    }
+
+    if (m_position) {
+        m_position->stopUpdates();
+        delete m_position;
+    }
+}
+void MainWindow::createUi()
+{
+    QWidget *widget = new QWidget;
+    setCentralWidget(widget);
+
+#ifdef Q_OS_SYMBIAN
+    const CAknAppUiBase::TAppUiOrientation uiOrientation = CAknAppUi::EAppUiOrientationPortrait;
+    CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
+    TRAPD(error,
+          if (appUi)
+          appUi->SetOrientationL(uiOrientation);
+            );
+    Q_UNUSED(error)
+#elif defined(Q_WS_MAEMO_5)
+    setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+#endif
+
+    setWindowTitle(tr("GPSData"));
+
+    QVBoxLayout *mainLayout = new QVBoxLayout();
+    widget->setLayout(mainLayout);
+
+    QFormLayout *layout = new QFormLayout();
+    layout->setMargin(8);
+    layout->setSpacing(8);
+    layout->setLabelAlignment(Qt::AlignLeft);
+    mainLayout->addLayout(layout);
+
+    m_latitude = new QLabel();
+    m_latitude->setDisabled(true);
+    layout->addRow(tr("Latitude:"), m_latitude);
+
+    m_longitude = new QLabel();
+    m_longitude->setDisabled(true);
+    layout->addRow(tr("Longtitude:"), m_longitude);
+
+    m_accuracy = new QLabel();
+    m_accuracy->setDisabled(true);
+    layout->addRow(tr("Accuracy:"), m_accuracy);
+
+    m_altitude = new QLabel();
+    m_altitude->setDisabled(true);
+    layout->addRow(tr("Altitude:"), m_altitude);
+
+    m_altitudeAccuracy = new QLabel();
+    m_altitudeAccuracy->setDisabled(true);
+    layout->addRow(tr("Altitude accura.:"), m_altitudeAccuracy);
+
+    m_direction = new QLabel();
+    m_direction->setDisabled(true);
+    layout->addRow(tr("Direction:"), m_direction);
+
+    m_magneticDeclination = new QLabel();
+    m_magneticDeclination->setDisabled(true);
+    layout->addRow(tr("Magnetic declin.:"), m_magneticDeclination);
+
+    m_groundSpeed = new QLabel();
+    m_groundSpeed->setDisabled(true);
+    layout->addRow(tr("Ground speed:"), m_groundSpeed);
+
+    m_verticalSpeed = new QLabel();
+    m_verticalSpeed->setDisabled(true);
+    layout->addRow(tr("Vertical speed:"), m_verticalSpeed);
+
+    m_mode = new QLabel();
+    m_mode->setDisabled(true);
+    layout->addRow(tr("Mode:"), m_mode);
+
+    m_time = new QLabel();
+    m_time->setDisabled(true);
+    layout->addRow(tr("GPS Timestamp:"), m_time);
+
+    m_satUsedView = new QLabel();
+    m_satUsedView->setDisabled(true);
+    layout->addRow(tr("Used/View sat.:"), m_satUsedView);
+
+#ifdef Q_WS_MAEMO_5
+    m_satelliteSignalStrength = new SatelliteSignalStrength();
+    m_satelliteSignalStrength->showTitle(true);
+    mainLayout->addWidget(m_satelliteSignalStrength);
+#endif
+}
+
+void MainWindow::createMenu()
+{
+
+#if defined(Q_OS_SYMBIAN)
+    QAction *menuSoftkey = new QAction(tr("Menu"), this);
+    menuSoftkey->setSoftKeyRole(QAction::PositiveSoftKey);
+    addAction(menuSoftkey);
+
+    QMenu *menu = new QMenu();
+    menuSoftkey->setMenu(menu);
+#else
+    QMenuBar *menu = new QMenuBar();
+    setMenuBar(menu);
+#endif
+
+#ifdef Q_OS_SYMBIAN
+    QAction *satelliteSignalStrengthAction = new QAction(tr("Signal strength"), this);
+    menu->addAction(satelliteSignalStrengthAction);
+    connect(satelliteSignalStrengthAction, SIGNAL(triggered()), this, SLOT(onSatelliteSignalStrengthMenuClicked()));
+#endif
+
+    QAction *satelliteViewAction = new QAction(tr("Satellite view"), this);
+    menu->addAction(satelliteViewAction);
+    connect(satelliteViewAction, SIGNAL(triggered()), this, SLOT(onSatelliteViewMenuClicked()));
+
+    QAction *gpsCompassAction = new QAction(tr("GPS compass"), this);
+    menu->addAction(gpsCompassAction);
+    connect(gpsCompassAction, SIGNAL(triggered()), this, SLOT(onGpsCompassMenuClicked()));
+}
+
+
+void MainWindow::updateUi()
+{
+    /* Don't update if window is not visible */
+    if (!isVisible())
+        return;
+
+    if (m_positionInfo.isValid()){
+        m_latitude->setText(convertCoordinate(m_positionInfo.coordinate().latitude(), LatitudeCoordinate));
+        m_longitude->setText(convertCoordinate(m_positionInfo.coordinate().longitude(), LongitudeCoordinate));
+
+        if ((!qIsNaN(m_positionInfo.coordinate().altitude())) &&
+            (m_positionInfo.coordinate().type() != QGeoCoordinate::InvalidCoordinate)) {
+            m_altitude->setText(formatLength(m_positionInfo.coordinate().altitude()));
+
+            if (m_positionInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
+                m_altitudeAccuracy->setText(formatLength(m_positionInfo.attribute(QGeoPositionInfo::VerticalAccuracy)));
+            else
+                m_altitudeAccuracy->clear();
+        } else {
+            m_altitude->clear();
+            m_altitudeAccuracy->clear();
+        }
+
+        if (m_positionInfo.coordinate().type() == QGeoCoordinate::Coordinate2D)
+            m_mode->setText("2D");
+        else if (m_positionInfo.coordinate().type() == QGeoCoordinate::Coordinate3D)
+            m_mode->setText("3D");
+        else
+            m_mode->clear();
+
+        m_time->setText(m_positionInfo.timestamp().toString("dd.MM.yyyy hh:mm:ss"));
+
+        if (m_positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+            m_accuracy->setText(formatLength(m_positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy)));
+        else
+            m_accuracy->clear();
+
+        if (m_positionInfo.hasAttribute(QGeoPositionInfo::GroundSpeed))
+            m_groundSpeed->setText(convertSpeed(m_positionInfo.attribute(QGeoPositionInfo::GroundSpeed)));
+        else
+            m_groundSpeed->clear();
+
+        if (m_positionInfo.hasAttribute(QGeoPositionInfo::VerticalSpeed))
+            m_verticalSpeed->setText(convertSpeed(m_positionInfo.attribute(QGeoPositionInfo::VerticalSpeed)));
+        else
+            m_verticalSpeed->clear();
+
+        if (m_positionInfo.hasAttribute(QGeoPositionInfo::Direction))
+            m_direction->setText(formatDirection(m_positionInfo.attribute(QGeoPositionInfo::Direction)));
+        else
+            m_direction->clear();
+
+        if (m_positionInfo.hasAttribute(QGeoPositionInfo::MagneticVariation))
+            m_magneticDeclination->setText(formatDirection(m_positionInfo.attribute(QGeoPositionInfo::MagneticVariation)));
+        else
+            m_magneticDeclination->clear();
+
+        m_satUsedView->setText(QString::number(m_satellitesInUse) + " / " + QString::number(m_satellitesInView));
+    } else {
+        m_latitude->setText(tr("Waiting for GPS data"));
+        m_longitude->clear();
+        m_accuracy->clear();
+        m_altitude->clear();
+        m_altitudeAccuracy->clear();
+        m_direction->clear();
+        m_groundSpeed->clear();
+        m_verticalSpeed->clear();
+        m_mode->clear();
+        m_time->clear();
+        m_satUsedView->clear();
+    }
+}
+
+QString MainWindow::convertCoordinate(double coordinate, CoordinateType type) const
+{
+    QString s;
+    QChar degree(0x00B0);
+
+    double coordinateAbs = qAbs(coordinate);
+    double coordinateMin = (coordinateAbs - int(coordinateAbs)) * 60;
+    double coordinateSec = (coordinateMin - int(coordinateMin)) * 60;
+
+    s = QString("%1%2 %3' %4\"")
+        .arg(QString::number(int(coordinateAbs)))
+        .arg(degree)
+        .arg(QString::number(int(coordinateMin)))
+        .arg(QString::number(coordinateSec, 'f', 3));
+
+    if (type == LatitudeCoordinate) {
+        if (coordinate > 0)
+            s.append(" N");
+        else
+            s.append(" S");
+    } else {
+        if (coordinate > 0)
+            s.append(" E");
+        else
+            s.append(" W");
+    }
+
+    return s;
+}
+
+QString MainWindow::convertSpeed(double speed) const
+{
+    QString s;
+
+    s.sprintf("%.2f km/h", speed * 3.6);
+
+    return s;
+}
+
+QString MainWindow::formatLength(double length) const
+{
+    QString s;
+
+    if (length > 10000)
+        s.sprintf("%.2f km", length / 10000);
+    else
+        s.sprintf("%.2f m", length);
+
+    return s;
+}
+
+QString MainWindow::formatDirection(double length) const
+{
+    QString s;
+    QChar degree(0x00B0);
+
+    s = QString("%1%2").arg(QString::number(length, 'f', 2)).arg(degree);
+
+    return s;
+}
+
+void MainWindow::onPositionUpdated(const QGeoPositionInfo &position)
+{
+#ifdef Q_WS_MAEMO_5
+    if (m_screenLocked)
+        return;
+#endif
+
+    if (position.isValid()) {
+        m_positionInfo = position;
+        updateUi();
+    }
+}
+
+void MainWindow::onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+#ifdef Q_WS_MAEMO_5
+    if (m_screenLocked)
+        return;
+
+    m_satelliteSignalStrength->updateWidget(satellites, false);
+#endif
+    m_satellitesInView = satellites.count();
+    updateUi();
+}
+
+void MainWindow::onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+#ifdef Q_WS_MAEMO_5
+    if (m_screenLocked)
+        return;
+
+    m_satelliteSignalStrength->updateWidget(satellites, true);
+#endif
+    m_satellitesInUse = satellites.count();
+    updateUi();
+}
+
+#ifdef Q_OS_SYMBIAN
+void MainWindow::satelliteSignalStrengthMenuClicked()
+{
+    SatelliteSignalStrengthWindow *satelliteSignalStrengthWindow = new SatelliteSignalStrengthWindow(this);
+    satelliteSignalStrengthWindow->setSatelliteInfoSource(m_satellite);
+    satelliteSignalStrengthWindow->showMaximized();
+}
+#endif
+
+void MainWindow::onSatelliteViewMenuClicked()
+{
+    SatelliteViewWindow *satelliteViewWindow = new SatelliteViewWindow(this);
+    satelliteViewWindow->setSatelliteInfoSource(m_satellite);
+#if defined(Q_OS_SYMBIAN)
+    satelliteViewWindow->showMaximized();
+#elif defined(Q_WS_MAEMO_5)
+    satelliteViewWindow->show();
+#endif
+}
+
+void MainWindow::onGpsCompassMenuClicked()
+{
+    GpsCompassWindow *gpsCompassWindow = new GpsCompassWindow(this);
+    gpsCompassWindow->setPositionInfoSource(m_position);
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+    gpsCompassWindow->showMaximized();
+#else
+    gpsCompassWindow->show();
+#endif
+}
+
+#ifdef Q_WS_MAEMO_5
+void MainWindow::registerScreenLockMonitor()
+{
+    QDBusConnection::systemBus().connect("",
+                                         "/com/nokia/mce/signal",
+                                         "com.nokia.mce.signal",
+                                         "tklock_mode_ind",
+                                         this,
+                                         SLOT(onScreenLocked(QString)));
+}
+
+void MainWindow::onScreenLocked(QString state)
+{
+    bool locked;
+
+    if(state == "unlocked")
+        locked = false;
+    else
+        locked = true;
+
+    if (m_screenLocked != locked) {
+        m_screenLocked = locked;
+        emit screenLocked(m_screenLocked);
+    }
+}
+#endif
diff --git a/src/mainwindow.h b/src/mainwindow.h
new file mode 100644 (file)
index 0000000..8930707
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  GPSData 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 <QWidget>
+#include <QDialog>
+#include <QLabel>
+
+#include <QGeoPositionInfo>
+#include <QGeoPositionInfoSource>
+#include <QGeoSatelliteInfo>
+#include <QGeoSatelliteInfoSource>
+
+#ifdef Q_WS_MAEMO_5
+#include "satellitesignalstrength.h"
+#endif
+
+QTM_USE_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    enum CoordinateType
+    {
+        LatitudeCoordinate = 0,
+        LongitudeCoordinate = 1
+    };
+
+    MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+signals:
+    void screenLocked(bool locked);
+
+private slots:
+    void onPositionUpdated(const QGeoPositionInfo &position);
+
+    void onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+    void onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+
+#ifdef Q_OS_SYMBIAN
+    void onSatelliteSignalStrengthMenuClicked();
+#endif
+    void onSatelliteViewMenuClicked();
+    void onGpsCompassMenuClicked();
+
+#ifdef Q_WS_MAEMO_5
+    void onScreenLocked(QString state);
+#endif
+
+private:
+    void createUi();
+    void updateUi();
+
+    void createMenu();
+
+#ifdef Q_WS_MAEMO_5
+    void registerScreenLockMonitor();
+#endif
+
+    QString convertCoordinate(double speed, CoordinateType type) const;
+    QString convertSpeed(double speed) const;
+    QString formatLength(double length) const;
+    QString formatDirection(double length) const;
+
+private:
+    QGeoPositionInfoSource *m_position;
+    QGeoSatelliteInfoSource *m_satellite;
+
+    QGeoPositionInfo m_positionInfo;
+    int m_satellitesInView;
+    int m_satellitesInUse;
+
+    QLabel *m_latitude;
+    QLabel *m_longitude;
+    QLabel *m_accuracy;
+    QLabel *m_altitude;
+    QLabel *m_altitudeAccuracy;
+    QLabel *m_direction;
+    QLabel *m_magneticDeclination;
+    QLabel *m_groundSpeed;
+    QLabel *m_verticalSpeed;
+    QLabel *m_mode;
+    QLabel *m_time;
+    QLabel *m_satUsedView;
+
+#ifdef Q_WS_MAEMO_5
+    SatelliteSignalStrength *m_satelliteSignalStrength;
+
+    bool m_screenLocked;
+#endif
+};
+
+#endif // MAINWINDOW_H
diff --git a/src/satellitesignalstrength.cpp b/src/satellitesignalstrength.cpp
new file mode 100644 (file)
index 0000000..948b70a
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ *  GPSData 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 "satellitesignalstrength.h"
+
+void SatelliteSignalStrength::updateWidget(const QList<QGeoSatelliteInfo> &satellites, bool inUseList)
+{
+    if (inUseList)
+        m_satellitesInUse = satellites;
+    else
+        m_satellitesInView = satellites;
+
+    update();
+}
+
+void SatelliteSignalStrength::showTitle(bool show)
+{
+    m_showTitle = show;
+}
+
+void SatelliteSignalStrength::paintEvent(QPaintEvent * /* event */)
+{
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing);
+
+    int title_height = 0;
+    if (m_showTitle) {
+        int title_x = rect().x() + m_margin;
+        int title_y = rect().y() + m_margin;
+        int title_width = rect().width() - (2 * m_margin);
+        title_height = painter.fontMetrics().height();
+        QRectF titleArea(title_x, title_y, title_width, title_height);
+
+        /* Draw title */
+        paintTitle(painter, titleArea);
+     }
+
+    /* Signal strength graph */
+    int graph_x = rect().x();
+    int graph_y = rect().y() + title_height + m_spacing;
+    int graph_width = rect().width();
+    int graph_height = rect().height() - title_height - m_spacing;
+    QRectF graphArea(graph_x, graph_y, graph_width, graph_height);
+
+    /* Signal strength bar graphs */
+    for (int index = 1; index <= m_numOfSatellites; ++index) {
+        paintBarGraph(painter, graphArea, index);
+    }
+}
+
+void SatelliteSignalStrength::paintTitle(QPainter &painter, const QRectF &area)
+{
+    painter.setPen(QApplication::palette().color(QPalette::Text));
+    painter.drawText(area, Qt::AlignLeft, tr("Signal strength:"));
+}
+
+void SatelliteSignalStrength::paintBarGraph(QPainter &painter, const QRectF &area, int index)
+{
+    /* Bar graph backround */
+    double barGraphBackground_x;
+    double barGraphBackground_y;
+    double barGraphBackground_width = (double) (area.width() - (2.0 * m_margin) -
+                                      (m_spacing * (m_numOfSatellitesInRow - 1))) / (double) m_numOfSatellitesInRow;
+    double barGraphBackground_height = (double) (area.height() - (2.0 * m_margin) -
+                                       (2.0 * m_spacing)) / (double) m_numOfRows;
+
+    if (index <= m_numOfSatellitesInRow) {
+        barGraphBackground_x = area.x() + m_margin +
+                               ((index - 1) * (barGraphBackground_width + m_spacing));
+        barGraphBackground_y = area.y() + m_margin;
+    } else {
+        barGraphBackground_x = area.x() + m_margin +
+                               (((index - 1) - m_numOfSatellitesInRow) * (barGraphBackground_width + m_spacing));
+        barGraphBackground_y = area.y() + m_margin + (2.0 * m_spacing) + barGraphBackground_height;
+    }
+    QRectF barGraphBackgroundArea(barGraphBackground_x, barGraphBackground_y,
+                                  barGraphBackground_width, barGraphBackground_height);
+
+    painter.setPen(m_barGraphBorderColor);
+    painter.setBrush(m_barGraphBackgroundColor);
+    painter.drawRect(barGraphBackgroundArea);
+
+    bool inUse = false;
+    int signalStrength = 0;
+
+    for (int iter = 0; iter < m_satellitesInView.count(); iter++) {
+        if (m_satellitesInView.at(iter).prnNumber() == index) {
+            signalStrength = m_satellitesInView.at(iter).signalStrength();
+            break;
+        }
+    }
+    for (int iter = 0; iter < m_satellitesInUse.count(); iter++) {
+        if (m_satellitesInUse.at(iter).prnNumber() == index) {
+            signalStrength = m_satellitesInUse.at(iter).signalStrength();
+            inUse = true;
+            break;
+        }
+    }
+
+    if (signalStrength > 0) {
+        if (inUse) {
+            painter.setPen(m_barGraphInUseColor);
+            painter.setBrush(m_barGraphInUseColor);
+        } else {
+            painter.setPen(m_barGraphInViewColor);
+            painter.setBrush(m_barGraphInViewColor);
+        }
+
+        double level_width = barGraphBackground_width - 2.0;
+        double level_height = (double) signalStrength * (barGraphBackground_height - 2.0) / 100.0;
+        double level_x = barGraphBackground_x + 1.0;
+        double level_y = barGraphBackground_y + barGraphBackground_height - level_height - 1.0;
+
+        QRectF barGraphLevelArea(level_x, level_y, level_width, level_height);
+        painter.drawRect(barGraphLevelArea);
+    }
+
+    /* Satellite's PRN must be painter over the level bar */
+    QFont font = QApplication::font();
+    font.setPixelSize(12);
+    painter.setFont(font);
+    painter.setPen(QApplication::palette().color(QPalette::Text));
+    painter.drawText(barGraphBackgroundArea, Qt::AlignCenter, QString::number(index));
+}
+
+SatelliteSignalStrength::SatelliteSignalStrength(QWidget *parent) : QWidget(parent)
+{
+    m_barGraphBorderColor = QColor(0, 0, 0);
+    m_barGraphBackgroundColor = QColor(74, 69, 66);
+    m_barGraphInViewColor = QColor(153, 153, 153);
+    m_barGraphInUseColor = QColor(51, 191, 51);
+}
diff --git a/src/satellitesignalstrength.h b/src/satellitesignalstrength.h
new file mode 100644 (file)
index 0000000..eadcafb
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  GPSData 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 SATELLITESIGNALSTRENGTH_H
+#define SATELLITESIGNALSTRENGTH_H
+
+#include <QWidget>
+
+#include <QGeoSatelliteInfo>
+
+QTM_USE_NAMESPACE
+
+class SatelliteSignalStrength : public QWidget
+{
+  Q_OBJECT
+
+public:
+    SatelliteSignalStrength(QWidget *parent = 0);
+
+    void updateWidget(const QList<QGeoSatelliteInfo> &satellites, bool inUseList);
+    void showTitle(bool show);
+
+private:
+    bool m_showTitle;
+    static const int m_margin = 8;
+    static const int m_spacing = 8;
+    static const int m_numOfSatellites = 32;
+    static const int m_numOfRows = 2;
+    static const int m_numOfSatellitesInRow = m_numOfSatellites / m_numOfRows;
+
+    QColor m_barGraphBorderColor;
+    QColor m_barGraphBackgroundColor;
+    QColor m_barGraphInViewColor;
+    QColor m_barGraphInUseColor;
+
+    QList<QGeoSatelliteInfo> m_satellitesInView;
+    QList<QGeoSatelliteInfo> m_satellitesInUse;
+
+    void paintTitle(QPainter &painter, const QRectF &area);
+    void paintBarGraph(QPainter &painter, const QRectF &area, int index);
+
+protected:
+    void paintEvent(QPaintEvent *event);
+};
+
+#endif // SATELLITESIGNALSTRENGTH_H
diff --git a/src/satellitesignalstrengthwindow.cpp b/src/satellitesignalstrengthwindow.cpp
new file mode 100644 (file)
index 0000000..8265e54
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *  GPSData 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 "satellitesignalstrengthwindow.h"
+
+#ifdef Q_OS_SYMBIAN
+SatelliteSignalStrengthWindow::SatelliteSignalStrengthWindow(QWidget *parent) : QMainWindow(parent)
+{
+    m_screenLocked = false;
+
+    createUi();
+
+    connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool)));
+}
+
+void SatelliteSignalStrengthWindow::createUi()
+{
+    setAttribute(Qt::WA_DeleteOnClose);
+
+    setWindowTitle(tr("Signal strength"));
+
+    m_satelliteSignalStrength = new SatelliteSignalStrength();
+    m_satelliteSignalStrength->showTitle(false);
+    setCentralWidget(m_satelliteSignalStrength);
+
+    QAction* backSoftkey = new QAction(tr("Back"), this);
+    backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey);
+    connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close()));
+    addAction(backSoftkey);
+}
+
+void SatelliteSignalStrengthWindow::onScreenLocked(bool locked)
+{
+    m_screenLocked = locked;
+}
+
+void SatelliteSignalStrengthWindow::onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+    if (m_screenLocked)
+        return;
+
+    m_satelliteSignalStrength->updateWidget(satellites, false);
+}
+
+void SatelliteSignalStrengthWindow::onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+    if (m_screenLocked)
+        return;
+
+    m_satelliteSignalStrength->updateWidget(satellites, true);
+}
+
+void SatelliteSignalStrengthWindow::setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource)
+{
+    m_satellite = satelliteInfoSource;
+    if (m_satellite) {
+        connect(m_satellite, SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)), this,
+                SLOT(onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)));
+        connect(m_satellite, SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)), this,
+                SLOT(onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)));
+
+        m_satellite->requestUpdate();
+    }
+}
+#endif
diff --git a/src/satellitesignalstrengthwindow.h b/src/satellitesignalstrengthwindow.h
new file mode 100644 (file)
index 0000000..60b88de
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  GPSData 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 SATELLITESIGNALSTRENGTHWINDOW_H
+#define SATELLITESIGNALSTRENGTHWINDOW_H
+
+#include <QMainWindow>
+#include <QWidget>
+
+#include <QGeoSatelliteInfoSource>
+
+#include "satellitesignalstrength.h"
+
+QTM_USE_NAMESPACE
+
+#ifdef Q_OS_SYMBIAN
+
+class SatelliteSignalStrengthWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    SatelliteSignalStrengthWindow(QWidget *parent = 0);
+
+    void setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource);
+
+private slots:
+    void onScreenLocked(bool locked);
+    void onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+    void onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+
+private:
+    void createUi();
+
+private:
+    bool m_screenLocked;
+
+    QGeoSatelliteInfoSource *m_satellite;
+
+    SatelliteSignalStrength *m_satelliteSignalStrength;
+};
+
+#endif
+
+#endif // SATELLITESIGNALSTRENGTHWINDOW_H
diff --git a/src/satelliteview.cpp b/src/satelliteview.cpp
new file mode 100644 (file)
index 0000000..b90822f
--- /dev/null
@@ -0,0 +1,196 @@
+/*
+ *  GPSData 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 "satelliteview.h"
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+void SatelliteView::updateWidget(const QList<QGeoSatelliteInfo> &satellites, bool inUseList)
+{
+    if (inUseList)
+        m_satellitesInUse = satellites;
+    else
+        m_satellitesInView = satellites;
+
+    update();
+}
+
+void SatelliteView::paintEvent(QPaintEvent * /* event */)
+{
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing);
+
+    double widget_width = 0;
+    double widget_height = 0;
+    double widget_x = 0;
+    double widget_y = 0;
+
+    if (rect().width() < rect().height()) {
+        /* Portrait orientation */
+        widget_width = rect().width() - (2 * m_margin);
+        widget_height = widget_width;
+        widget_x = rect().x() + m_margin;
+        widget_y = rect().y() + (rect().height() - widget_height) / 2.0;
+    } else {
+        /* Landscape orientation */
+        widget_height = rect().height() - (2 * m_margin);
+        widget_width = widget_height;
+        widget_x = rect().x() + (rect().width() - widget_width) / 2.0;
+        widget_y = rect().y() + m_margin;
+    }
+    QRectF widgetArea(widget_x, widget_y, widget_width, widget_height);
+
+    /* Draw N/E/S/W labels */
+    paintLabels(painter, widgetArea);
+
+    int label_height = painter.fontMetrics().height();
+    int label_width = label_height;
+    double grid_x = widget_x + m_margin + label_width;
+    double grid_y =  widget_y + m_margin + label_height;
+    double grid_width = widget_width - (2 * m_margin) - (2 * label_width);
+    double grid_height = widget_height - (2 * m_margin) - (2 * label_height);
+    QRectF gridArea(grid_x, grid_y, grid_width, grid_height);
+
+    /* Draw grid */
+    paintGrid(painter, gridArea);
+
+    /* Draw satellites in view */
+    for (int index = 1; index <= m_numOfSatellites; ++index) {
+        paintSatellite(painter, gridArea, index);
+    }
+}
+
+void SatelliteView::paintLabels(QPainter &painter, const QRectF &area)
+{
+    int label_height = painter.fontMetrics().height();
+    int label_width = label_height;
+
+    painter.setPen(QApplication::palette().color(QPalette::Text));
+
+    /* "North" label */
+    QRect northLabel(area.x(), area.y(), area.width(), label_height);
+    painter.drawText(northLabel, Qt::AlignCenter, tr("N"));
+
+    /* "South" label */
+    QRect southLabel(area.x(), area.y() + area.height() - label_height, area.width(), label_height);
+    painter.drawText(southLabel, Qt::AlignCenter, tr("S"));
+
+    /* "West" label */
+    QRect westLabel(area.x(), area.y(), label_width, area.height());
+    painter.drawText(westLabel, Qt::AlignCenter, tr("W"));
+
+    /* "East" label */
+    QRect eastLabel(area.x() + area.width() - label_width, area.y(), label_width, area.height());
+    painter.drawText(eastLabel, Qt::AlignCenter, tr("E"));
+}
+
+void SatelliteView::paintGrid(QPainter &painter, const QRectF &area)
+{
+    painter.setPen(m_graphGridColor);
+    for (int i = 0; i < 3; i++) {
+        double grid_width =  area.width() * (3.0 - i) / 3.0;
+        double grid_height = area.height() * (3.0 - i) / 3.0;
+        double grid_x = area.x() + (area.width() * i / 6.0);
+        double grid_y = area.y() + (area.height() * i / 6.0);
+
+        QRectF gridArea(grid_x, grid_y, grid_width, grid_height);
+        painter.drawArc(gridArea, 0, 5760);
+    }
+
+    /* Grid */
+    painter.drawLine(area.x(), area.y() + area.height() / 2.0, area.x() + area.width(), area.y() + area.height() / 2.0);
+    painter.drawLine(area.x() + area.width() / 2.0, area.y(), area.x() + area.width() / 2.0, area.y() + area.height());
+
+}
+
+void SatelliteView::paintSatellite(QPainter &painter, const QRectF &area, int index)
+{
+    double center_x = area.x() + (double) area.width() / 2.0;
+    double center_y = area.y() + (double) area.height() / 2.0;
+
+    bool inUse = false;
+    int satelliteElevation = -1;
+    int satelliteAzimuth = 0;
+    for (int iter = 0; iter < m_satellitesInView.count(); iter++) {
+        if (m_satellitesInView.at(iter).prnNumber() == index) {
+            if (m_satellitesInView.at(iter).hasAttribute(QGeoSatelliteInfo::Elevation))
+                satelliteElevation = m_satellitesInView.at(iter).attribute(QGeoSatelliteInfo::Elevation);
+
+            if (m_satellitesInView.at(iter).hasAttribute(QGeoSatelliteInfo::Azimuth))
+                satelliteAzimuth = m_satellitesInView.at(iter).attribute(QGeoSatelliteInfo::Azimuth);
+            break;
+        }
+    }
+    for (int iter = 0; iter < m_satellitesInUse.count(); iter++) {
+        if (m_satellitesInUse.at(iter).prnNumber() == index) {
+            inUse = true;
+            break;
+        }
+    }
+
+    /* Display only visible satellites */
+    if (satelliteElevation >= 0) {
+        int satellite_width = 30;
+        int satellite_height = 30;
+        double temp = (180 - satelliteElevation) * (double) area.width() / 360.0;
+        double satellite_x = temp * qCos((satelliteAzimuth - 90) * M_PI / 180.0) +
+                             center_x - (double) (satellite_width / 2.0);
+        double satellite_y = temp * qSin((satelliteAzimuth - 90) * M_PI / 180.0) +
+                             center_y - (double) (satellite_height / 2.0);
+        QRectF satelliteArea(satellite_x, satellite_y, satellite_width, satellite_height);
+
+        /* Draw a small circle with PRN number inside */
+        painter.setPen(m_satelliteBorderColor);
+        if (inUse)
+            painter.setBrush(m_satelliteInUseColor);
+        else
+            painter.setBrush(m_satellitehInViewColor);
+        painter.drawChord(satelliteArea, 0, 5760);
+
+        int panel_width = 10;
+        painter.setBrush(m_satelliteSolarPanelColor);
+        QRectF solarPanelLArea(satellite_x - panel_width, satellite_y,
+                               panel_width, satellite_height);
+        painter.drawRect(solarPanelLArea);
+
+        QRectF solarPanelRArea(satellite_x + satellite_width, satellite_y,
+                               panel_width, satellite_height);
+        painter.drawRect(solarPanelRArea);
+
+        /* Satellite's PRN must be painter over the satellite circle */
+        QFont font = QApplication::font();
+        font.setPixelSize(12);
+        painter.setFont(font);
+        painter.setPen(m_satelliteBorderColor);
+        painter.drawText(satelliteArea, Qt::AlignCenter, QString::number(index));
+    }
+}
+
+SatelliteView::SatelliteView(QWidget *parent) : QWidget(parent)
+{
+    m_graphGridColor = QColor(74, 69, 66);
+    m_satelliteBorderColor = QColor(0, 0, 0);
+    m_satelliteSolarPanelColor = QColor(0, 75, 255);
+    m_satellitehInViewColor = QColor(153, 153, 153);
+    m_satelliteInUseColor = QColor(51, 191, 51);
+}
diff --git a/src/satelliteview.h b/src/satelliteview.h
new file mode 100644 (file)
index 0000000..d4f1387
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  GPSData 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 SATELLITEVIEW_H
+#define SATELLITEVIEW_H
+
+#include <QWidget>
+
+#include <QGeoSatelliteInfo>
+
+QTM_USE_NAMESPACE
+
+class SatelliteView : public QWidget
+{
+  Q_OBJECT
+
+public:
+    SatelliteView(QWidget *parent = 0);
+
+    void updateWidget(const QList<QGeoSatelliteInfo> &satellites, bool inUseList);
+
+private:
+    static const int m_margin = 8;
+    static const int m_numOfSatellites = 32;
+
+    QColor m_graphGridColor;
+    QColor m_satelliteBorderColor;
+    QColor m_satelliteSolarPanelColor;
+    QColor m_satellitehInViewColor;
+    QColor m_satelliteInUseColor;
+
+    QList<QGeoSatelliteInfo> m_satellitesInView;
+    QList<QGeoSatelliteInfo> m_satellitesInUse;
+
+    void paintLabels(QPainter &painter, const QRectF &area);
+    void paintGrid(QPainter &painter, const QRectF &area);
+    void paintSatellite(QPainter &painter, const QRectF &area, int index);
+
+protected:
+    void paintEvent(QPaintEvent *event);
+};
+
+#endif // SATELLITEVIEW_H
diff --git a/src/satelliteviewwindow.cpp b/src/satelliteviewwindow.cpp
new file mode 100644 (file)
index 0000000..c0cdcdf
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  GPSData 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 "satelliteviewwindow.h"
+
+SatelliteViewWindow::SatelliteViewWindow(QWidget *parent) : QMainWindow(parent)
+{
+    m_screenLocked = false;
+
+    createUi();
+
+    connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool)));
+}
+
+void SatelliteViewWindow::createUi()
+{
+#if defined(Q_OS_SYMBIAN)
+    setAttribute(Qt::WA_DeleteOnClose);
+#elif defined(Q_WS_MAEMO_5)
+    setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+    setWindowFlags(Qt::Dialog);
+#endif
+
+    setWindowTitle(tr("Satellite view"));
+
+    m_satelliteView = new SatelliteView();
+#ifdef Q_WS_MAEMO_5
+    m_satelliteView->setMinimumSize(480, 480);
+#endif
+    setCentralWidget(m_satelliteView);
+
+#ifdef Q_OS_SYMBIAN
+    QAction* backSoftkey = new QAction(tr("Back"), this);
+    backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey);
+    connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close()));
+    addAction(backSoftkey);
+#endif
+}
+
+void SatelliteViewWindow::onScreenLocked(bool locked)
+{
+    m_screenLocked = locked;
+}
+
+void SatelliteViewWindow::onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+    if (m_screenLocked)
+        return;
+
+    m_satelliteView->updateWidget(satellites, false);
+}
+
+void SatelliteViewWindow::onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+    if (m_screenLocked)
+        return;
+
+    m_satelliteView->updateWidget(satellites, true);
+}
+
+void SatelliteViewWindow::setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource)
+{
+    m_satellite = satelliteInfoSource;
+    if (m_satellite) {
+        connect(m_satellite, SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)), this,
+                SLOT(onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)));
+        connect(m_satellite, SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)), this,
+                SLOT(onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)));
+
+        m_satellite->requestUpdate();
+    }
+}
diff --git a/src/satelliteviewwindow.h b/src/satelliteviewwindow.h
new file mode 100644 (file)
index 0000000..b942b15
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  GPSData 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 SATELLITEVIEWWINDOW_H
+#define SATELLITEVIEWWINDOW_H
+
+#include <QMainWindow>
+#include <QWidget>
+
+#include <QGeoSatelliteInfoSource>
+
+#include "satelliteview.h"
+
+QTM_USE_NAMESPACE
+
+class SatelliteViewWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    SatelliteViewWindow(QWidget *parent = 0);
+
+    void setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource);
+
+private slots:
+    void onScreenLocked(bool locked);
+    void onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+    void onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+
+private:
+    void createUi();
+
+private:
+    bool m_screenLocked;
+
+    QGeoSatelliteInfoSource *m_satellite;
+
+    SatelliteView *m_satelliteView;
+};
+
+#endif // SATELLITEVIEWWINDOW_H