--- /dev/null
+<RCC>
+ <qresource prefix="/reittiopas">
+ <file alias="bus">data/icons/reittiopas/maemo-mapper-bus.png</file>
+ <file alias="ferry">data/icons/reittiopas/maemo-mapper-ferry.png</file>
+ <file alias="metro">data/icons/reittiopas/maemo-mapper-metro.png</file>
+ <file alias="train">data/icons/reittiopas/maemo-mapper-train.png</file>
+ <file alias="tram">data/icons/reittiopas/maemo-mapper-tram.png</file>
+ <file alias="walk">data/icons/reittiopas/maemo-mapper-walk.png</file>
+ </qresource>
+</RCC>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<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"
+ width="129.32375"
+ height="21.637915"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.46"
+ sodipodi:docname="maemo-mapper-reittiopas-icons.svg"
+ sodipodi:version="0.32"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2824"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2906"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2935"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3036"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3050"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3072"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3152"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3227"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3342"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective4135"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="3.959798"
+ inkscape:cx="63.727377"
+ inkscape:cy="-20.537488"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1050"
+ inkscape:window-height="800"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ inkscape:window-maximized="1"
+ inkscape:showpageshadow="false"
+ showborder="false" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-235.07788,-517.92067)">
+ <g
+ id="g2886"
+ transform="translate(0.17849731,2.8162323)"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/128x128/maemo-mapper-bus.png"
+ inkscape:export-xdpi="577.42999"
+ inkscape:export-ydpi="577.42999">
+ <g
+ inkscape:export-ydpi="289.17194"
+ inkscape:export-xdpi="289.17194"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/64x64/maemo-mapper-bus.png"
+ id="g2875">
+ <rect
+ style="fill:#193695;fill-opacity:1;stroke:none"
+ id="rect2830"
+ width="19.950514"
+ height="19.918922"
+ x="344.27261"
+ y="516.82343"
+ ry="1.9571706" />
+ <g
+ id="g2861">
+ <rect
+ ry="1.022532"
+ y="519.99615"
+ x="348.30356"
+ height="12.991072"
+ width="12.008929"
+ id="rect2834"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <rect
+ style="fill:#193695;fill-opacity:1;stroke:none"
+ id="rect2836"
+ width="9.9107151"
+ height="7.0535717"
+ x="349.35266"
+ y="521.29083"
+ ry="0.55518919" />
+ <path
+ transform="matrix(0.82857143,0,0,0.82857143,59.934301,90.790155)"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ sodipodi:ry="0.78125"
+ sodipodi:rx="0.78125"
+ sodipodi:cy="530.91132"
+ sodipodi:cx="351.0491"
+ id="path2838"
+ style="fill:#193695;fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#193695;fill-opacity:1;stroke:none"
+ id="path2840"
+ sodipodi:cx="351.0491"
+ sodipodi:cy="530.91132"
+ sodipodi:rx="0.78125"
+ sodipodi:ry="0.78125"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ transform="matrix(0.82857143,0,0,0.82857143,66.94323,90.790155)" />
+ </g>
+ <g
+ id="g2871"
+ transform="translate(-0.02231234,0)">
+ <rect
+ ry="0.55518919"
+ y="532.18359"
+ x="349.46426"
+ height="2.7232144"
+ width="1.9196428"
+ id="rect2867"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ id="rect2869"
+ width="1.9196428"
+ height="2.7232144"
+ x="357.27676"
+ y="532.18359"
+ ry="0.55518919" />
+ </g>
+ </g>
+ </g>
+ <g
+ id="g3013"
+ transform="translate(-0.22271729,0.45124205)"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/16x16/maemo-mapper-ferry.png"
+ inkscape:export-xdpi="72.292984"
+ inkscape:export-ydpi="72.292984">
+ <rect
+ ry="1.9571706"
+ y="519.18842"
+ x="321.0069"
+ height="19.918922"
+ width="19.950514"
+ id="rect2830-8"
+ style="fill:#00aee7;fill-opacity:1;stroke:none" />
+ <g
+ transform="matrix(1,0,0,1.0495379,0.09152746,-26.219436)"
+ id="g3000">
+ <path
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ d="m 323.46875,531.584 1,2.68488 c 0,0.57804 0.79864,1.05356 1.8125,1.05356 l 9.21875,0 c 1.01386,0 1.8125,-0.47552 1.8125,-1.05356 l 1,-2.68488 c -0.79721,-1.03549 -2.04097,-0.98088 -3.38143,-1.2167 -1.34047,-0.23581 -2.77764,-0.76207 -3.96169,-0.76207 -1.28107,0.0837 -2.69996,0.6115 -4.02671,0.8272 -1.32675,0.21569 -2.56137,0.11922 -3.47392,1.15157 z"
+ id="rect2963"
+ sodipodi:nodetypes="cccccczczc" />
+ <path
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ d="m 325.78125,524.6169 0,4.98621 c 0,0 1.69271,0 2.53906,0 0.84636,0 2.53906,-0.36414 2.53906,-0.36414 l 2.53907,0.36414 2.53906,0 0,-4.98621 -10.15625,0 z"
+ id="rect2967"
+ sodipodi:nodetypes="ccsccccc" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ id="rect2969"
+ width="2.4622469"
+ height="3.6390722"
+ x="329.62543"
+ y="521.94464"
+ ry="0.58786494" />
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ id="rect2971"
+ width="15.783633"
+ height="0.75527918"
+ x="322.99881"
+ y="535.60834"
+ ry="0.37763959" />
+ <g
+ id="g2992"
+ transform="matrix(1,0,0,1.0875465,0.03067094,-46.956752)">
+ <g
+ id="g2982">
+ <rect
+ style="fill:#00aee7;fill-opacity:1;stroke:none"
+ id="rect2974"
+ width="1.2946428"
+ height="1.25"
+ x="326.60712"
+ y="527.80859"
+ ry="0.26785016" />
+ <rect
+ ry="0.26785016"
+ y="527.80859"
+ x="328.4375"
+ height="1.25"
+ width="1.2946428"
+ id="rect2976"
+ style="fill:#00aee7;fill-opacity:1;stroke:none" />
+ </g>
+ <g
+ transform="translate(5.3125,0)"
+ id="g2986">
+ <rect
+ ry="0.26785016"
+ y="527.80859"
+ x="326.60712"
+ height="1.25"
+ width="1.2946428"
+ id="rect2988"
+ style="fill:#00aee7;fill-opacity:1;stroke:none" />
+ <rect
+ style="fill:#00aee7;fill-opacity:1;stroke:none"
+ id="rect2990"
+ width="1.2946428"
+ height="1.25"
+ x="328.4375"
+ y="527.80859"
+ ry="0.26785016" />
+ </g>
+ </g>
+ </g>
+ </g>
+ <g
+ id="g3132"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/16x16/maemo-mapper-metro.png"
+ inkscape:export-xdpi="72.18"
+ inkscape:export-ydpi="72.18"
+ transform="translate(-4.5146484,0.36194761)">
+ <rect
+ style="fill:#fb6500;fill-opacity:1;stroke:none"
+ id="rect2830-8-3"
+ width="19.950514"
+ height="19.918922"
+ x="301.6319"
+ y="519.27771"
+ ry="1.9571706" />
+ <g
+ transform="translate(0,-0.9709661)"
+ id="g3122">
+ <g
+ id="g3112"
+ transform="matrix(1,0,0,0.91065292,-0.44642857,47.285796)">
+ <g
+ transform="translate(3.9285734,-2.4107084)"
+ id="g3102">
+ <rect
+ ry="1.022532"
+ y="525.15234"
+ x="302.12054"
+ height="12.991072"
+ width="12.008929"
+ id="rect2834-4"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <rect
+ style="fill:#fb6500;fill-opacity:1;stroke:none"
+ id="rect2836-7"
+ width="9.9107151"
+ height="7.0535717"
+ x="303.16965"
+ y="526.44702"
+ ry="0.55518919" />
+ <g
+ transform="translate(0.08929196,0)"
+ id="g3108">
+ <path
+ sodipodi:type="arc"
+ style="fill:#fb6500;fill-opacity:1;stroke:none"
+ id="path2838-7"
+ sodipodi:cx="351.0491"
+ sodipodi:cy="530.91132"
+ sodipodi:rx="0.78125"
+ sodipodi:ry="0.78125"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ transform="matrix(0.82857144,0,0,0.82857144,13.215563,96.660648)" />
+ <path
+ transform="matrix(0.82857144,0,0,0.82857144,21.11735,96.660648)"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ sodipodi:ry="0.78125"
+ sodipodi:rx="0.78125"
+ sodipodi:cy="530.91132"
+ sodipodi:cx="351.0491"
+ id="path2840-3"
+ style="fill:#fb6500;fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ </g>
+ </g>
+ </g>
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ id="rect3120"
+ width="5"
+ height="1.4285715"
+ x="309.10715"
+ y="535.66571"
+ ry="0.28573519" />
+ </g>
+ </g>
+ <g
+ id="g3194"
+ transform="translate(0.1237101,0)">
+ <g
+ id="g3191" />
+ </g>
+ <g
+ id="g3205"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/128x128/maemo-mapper-train.png"
+ inkscape:export-xdpi="577.42999"
+ inkscape:export-ydpi="577.42999"
+ transform="translate(-4.0641876,0.36194761)">
+ <g
+ transform="translate(-24.117392,0)"
+ id="g3158"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/16x16/maemo-mapper-metro.png"
+ inkscape:export-xdpi="72.18"
+ inkscape:export-ydpi="72.18">
+ <rect
+ style="fill:#ce1141;fill-opacity:1;stroke:none"
+ id="rect3160"
+ width="19.950514"
+ height="19.918922"
+ x="301.6319"
+ y="519.27771"
+ ry="1.9571706" />
+ <g
+ transform="translate(0,-0.9709661)"
+ id="g3162">
+ <g
+ id="g3164"
+ transform="matrix(1,0,0,0.91065292,-0.44642857,47.285796)">
+ <g
+ transform="translate(3.9285734,-2.4107084)"
+ id="g3166">
+ <path
+ id="rect3168"
+ d="m 303.13525,524.40901 c -0.56648,0 -1,0.48549 -1,1.0795 l 0,11.47873 c 0,0.59401 0.43352,1.07951 1,1.07951 l 1.25,0 0,0.57573 -1.09375,0 c -0.1583,0 -0.28125,0.14157 -0.28125,0.32385 l 0,1.00754 c 0,0.18228 0.12295,0.32385 0.28125,0.32385 l 9.65625,0 c 0.1583,0 0.28125,-0.14157 0.28125,-0.32385 l 0,-1.00754 c 0,-0.18228 -0.12295,-0.32385 -0.28125,-0.32385 l -1.0625,0 0,-0.57573 1.21875,0 c 0.56648,0 1.03125,-0.4855 1.03125,-1.07951 l 0,-11.47873 c 0,-0.59401 -0.46477,-1.0795 -1.03125,-1.0795 l -9.96875,0 z m 2.625,13.63774 4.71875,0 0,0.57573 -4.71875,0 0,-0.57573 z"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <rect
+ style="fill:#ce1141;fill-opacity:1;stroke:none"
+ id="rect3170"
+ width="9.9107151"
+ height="6.3672514"
+ x="303.16965"
+ y="527.1333"
+ ry="0.50116861" />
+ <g
+ transform="translate(0.08929196,0)"
+ id="g3172">
+ <g
+ transform="translate(-0.0453027,0)"
+ id="g3180">
+ <path
+ transform="matrix(1.0087656,0,0,1.0087656,-50.052442,0.9935338)"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ sodipodi:ry="0.78125"
+ sodipodi:rx="0.78125"
+ sodipodi:cy="530.91132"
+ sodipodi:cx="351.0491"
+ id="path3174"
+ style="fill:#ce1141;fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ce1141;fill-opacity:1;stroke:none"
+ id="path3176"
+ sodipodi:cx="351.0491"
+ sodipodi:cy="530.91132"
+ sodipodi:rx="0.78125"
+ sodipodi:ry="0.78125"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ transform="matrix(1.0087656,0,0,1.0087656,-42.038036,0.9935338)" />
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ <rect
+ ry="0.50116861"
+ y="522.22827"
+ x="285.83798"
+ height="1.2053572"
+ width="3.3035715"
+ id="rect3203"
+ style="fill:#ce1141;fill-opacity:1;stroke:none" />
+ </g>
+ <g
+ id="g3319"
+ inkscape:export-filename="/home/salva/Desktop/maemo-mapper-reittiopas-icons/16x16/maemo-mapper-tram.png"
+ inkscape:export-xdpi="72.18"
+ inkscape:export-ydpi="72.18"
+ transform="translate(-4.2450714,0.36194761)">
+ <rect
+ style="fill:#00ab67;fill-opacity:1;stroke:none"
+ id="rect3237"
+ width="19.950514"
+ height="19.918922"
+ x="254.02846"
+ y="519.27771"
+ ry="1.9571706" />
+ <g
+ transform="translate(0.04464286,-0.1382311)"
+ id="g3306">
+ <g
+ id="g3293"
+ transform="translate(0.29258313,23.758674)">
+ <g
+ transform="matrix(0.84216366,0,0,0.96504877,1.2023017,-4.800965)"
+ id="g3239">
+ <g
+ id="g3241"
+ transform="matrix(1,0,0,0.91065292,-0.44642857,47.285796)">
+ <g
+ transform="translate(3.9285734,-2.4107084)"
+ id="g3243">
+ <path
+ sodipodi:nodetypes="cccccccccccccccccccccccccc"
+ id="path3245"
+ d="m 303.13525,524.40901 c -0.56648,0 -1,0.48549 -1,1.0795 l 0,11.47873 c 0,0.59401 0.43352,1.07951 1,1.07951 l 1.25,0 0,1.15991 -1.75637,0 c -0.1583,0 -0.28125,0.14157 -0.28125,0.32385 l 0,0.42336 c 0,0.18228 0.12295,0.32385 0.28125,0.32385 l 11.29955,0 c 0.1583,0 0.28125,-0.14157 0.28125,-0.32385 l 0,-0.42336 c 0,-0.18228 -0.12295,-0.32385 -0.28125,-0.32385 l -2.04318,0 0,-1.15991 1.21875,0 c 0.56648,0 1.03125,-0.4855 1.03125,-1.07951 l 0,-11.47873 c 0,-0.59401 -0.46477,-1.0795 -1.03125,-1.0795 l -9.96875,0 z m 2.625,13.63774 4.71875,0 0,1.15991 -4.71875,0 0,-1.15991 z"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <rect
+ style="fill:#00ac67;fill-opacity:1;stroke:none"
+ id="rect3247"
+ width="9.2215891"
+ height="7.8404045"
+ x="303.56168"
+ y="525.86334"
+ ry="0.61712098" />
+ <g
+ transform="translate(0.08929196,0)"
+ id="g3249">
+ <g
+ transform="translate(-0.0453027,0)"
+ id="g3251">
+ <path
+ transform="matrix(1.0087656,0,0,1.0087656,-50.052442,0.9935338)"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ sodipodi:ry="0.78125"
+ sodipodi:rx="0.78125"
+ sodipodi:cy="530.91132"
+ sodipodi:cx="351.0491"
+ id="path3253"
+ style="fill:#00ab67;fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#00ab67;fill-opacity:1;stroke:none"
+ id="path3255"
+ sodipodi:cx="351.0491"
+ sodipodi:cy="530.91132"
+ sodipodi:rx="0.78125"
+ sodipodi:ry="0.78125"
+ d="m 351.83035,530.91132 c 0,0.43147 -0.34977,0.78125 -0.78125,0.78125 -0.43147,0 -0.78125,-0.34978 -0.78125,-0.78125 0,-0.43148 0.34978,-0.78125 0.78125,-0.78125 0.43148,0 0.78125,0.34977 0.78125,0.78125 z"
+ transform="matrix(1.0087656,0,0,1.0087656,-42.038036,0.9935338)" />
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ <rect
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ id="rect3304"
+ width="3.7053573"
+ height="1.1607143"
+ x="262.10638"
+ y="521.4693"
+ ry="0.40181187" />
+ </g>
+ </g>
+ <g
+ id="g3497"
+ transform="translate(11.111678,22.728432)"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <rect
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ id="rect2498"
+ width="19.950514"
+ height="19.918922"
+ x="215.25363"
+ y="496.51663"
+ ry="1.9571706" />
+ <g
+ transform="matrix(7.9656517e-2,0,0,8.8314679e-2,215.34234,496.56756)"
+ id="g3486">
+ <g
+ id="g8150"
+ transform="matrix(25.900445,0,0,-25.900445,134.32984,53.145434)">
+ <path
+ d="M 0,0 C 0.326,-0.025 0.611,0.219 0.637,0.543 C 0.663,0.869 0.42,1.154 0.094,1.18 C -0.232,1.205 -0.518,0.963 -0.543,0.637 C -0.568,0.311 -0.325,0.025 0,0"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path8152" />
+ </g>
+ <g
+ id="g8154"
+ transform="matrix(25.900445,0,0,-25.900445,121.35393,59.4179)">
+ <path
+ d="M 0,0 C 0.116,0.08 0.26,0.135 0.415,0.123 C 0.618,0.105 0.786,-0.02 0.886,-0.174 L 1.484,-1.357 L 2.298,-1.918 C 2.368,-1.971 2.41,-2.059 2.403,-2.152 C 2.392,-2.299 2.263,-2.408 2.115,-2.396 C 2.071,-2.395 2.036,-2.377 1.993,-2.357 L 1.104,-1.746 C 1.077,-1.723 1.056,-1.697 1.038,-1.666 L 0.813,-1.223 L 0.547,-2.404 L 1.597,-3.645 C 1.62,-3.684 1.636,-3.727 1.646,-3.771 L 1.929,-5.27 C 1.928,-5.303 1.933,-5.324 1.931,-5.352 C 1.913,-5.572 1.72,-5.736 1.499,-5.719 C 1.317,-5.705 1.181,-5.568 1.138,-5.402 L 0.87,-3.998 L 0.019,-3.064 L -0.181,-3.975 C -0.187,-4.018 -0.243,-4.107 -0.261,-4.145 L -1.078,-5.523 C -1.161,-5.65 -1.297,-5.73 -1.454,-5.719 C -1.675,-5.701 -1.84,-5.508 -1.822,-5.287 C -1.817,-5.225 -1.791,-5.16 -1.769,-5.115 L -1.007,-3.838 L -0.374,-1.025 L -0.788,-1.361 L -1.007,-2.363 C -1.036,-2.49 -1.153,-2.596 -1.292,-2.584 C -1.438,-2.572 -1.549,-2.445 -1.538,-2.297 L -1.532,-2.262 L -1.271,-1.094 C -1.257,-1.041 -1.228,-0.998 -1.188,-0.965 L 0,0 z"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path8156" />
+ </g>
+ </g>
+ </g>
+ </g>
+</svg>
#include "addressdialog.h"\r
-#include "location.h"\r
-#include "ytv.h"\r
-#include "locations.h"\r
+#include "logic/location.h"\r
+#include "logic/ytv.h"\r
+#include "logic/locations.h"\r
\r
#include <QWidget>\r
#include <QDialog>\r
QXmlStreamReader xml(this->m_reply->readAll());\r
//Remove the reply. Hopefully also removes the connection.\r
//delete this->m_reply;\r
- this->m_reply = 0;\r
+ this->m_reply->deleteLater();\r
\r
bool responseHasError = false;\r
this->m_places = QList<Location*>();\r
if (address == (*it)->label())\r
{\r
qDebug() << "Found item from list: " << *it;\r
- ret = new Location(*it);\r
+ ret = new Location(**it);\r
qDebug() << "After assignment: " << ret;\r
}\r
}\r
#include "gpscontroller.h"
-#include "locations.h"
+#include "logic/locations.h"
#include <QObject>
#include <QGeoPositionInfo>
#ifndef GPSCONTROLLER_H
#define GPSCONTROLLER_H
-#include "location.h"
+#include "logic/location.h"
#include <QObject>
#include <QGeoPositionInfo>
--- /dev/null
+#include "favoriteselectiondialog.h"
+#include "ui_favoriteselectiondialog.h"
+
+#include "src/logic/locations.h"
+
+#include <QDebug>
+
+static const QString CUSTOMIZE = "Customize";
+
+FavoriteSelectionDialog::FavoriteSelectionDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::FavoriteSelectionDialog)
+{
+ ui->setupUi(this);
+
+ this->setAttribute(Qt::WA_Maemo5AutoOrientation);
+
+ Locations* locations = Locations::GetInstance();
+
+ QStringList locs;
+ for (int index = 1; index <= locations->size(); ++index)
+ {
+ Location* loc = locations->getLocation(index);
+ if (loc && loc->isValid())
+ {
+ qDebug() << "Adding location to display: " << loc->label();
+ locs << loc->label();
+ }
+ }
+
+ this->ui->locations->addItems(locs);
+
+}
+
+FavoriteSelectionDialog::~FavoriteSelectionDialog()
+{
+ delete ui;
+}
+
+void FavoriteSelectionDialog::on_locations_itemClicked(QListWidgetItem* item)
+{
+ Locations *locations = Locations::GetInstance();
+ Location* selected = locations->getLocation(item->text());
+ emit(this->selectedLocation(selected));
+ this->deleteLater();
+}
+
+void FavoriteSelectionDialog::on_modify_button_clicked()
+{
+ emit(this->customizeRequested());
+ this->deleteLater();
+}
--- /dev/null
+#ifndef FAVORITESELECTIONDIALOG_H
+#define FAVORITESELECTIONDIALOG_H
+
+#include <QDialog>
+
+class Location;
+class QListWidgetItem;
+
+namespace Ui {
+ class FavoriteSelectionDialog;
+}
+
+class FavoriteSelectionDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit FavoriteSelectionDialog(QWidget *parent = 0);
+ ~FavoriteSelectionDialog();
+
+signals:
+ void selectedLocation(Location*);
+ void customizeRequested();
+
+private:
+ Ui::FavoriteSelectionDialog *ui;
+
+private slots:
+ void on_modify_button_clicked();
+ void on_locations_itemClicked(QListWidgetItem* item);
+};
+
+#endif // FAVORITESELECTIONDIALOG_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FavoriteSelectionDialog</class>
+ <widget class="QDialog" name="FavoriteSelectionDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Select favorite</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="modify_button">
+ <property name="text">
+ <string>Modify list</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="locations"/>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>FavoriteSelectionDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>FavoriteSelectionDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+#include "locationsdisplaywindow.h"
+#include "ui_locationsdisplaywindow.h"
+
+#include "src/logic/locations.h"
+
+#include "src/addressdialog.h"
+
+#include <QDebug>
+#include <QListWidgetItem>
+#include <QListWidget>
+#include <QList>
+
+const QString invalidPostText = " - Invalid address";
+const QString editText = "Edit list";
+
+QString getLocName(const QListWidgetItem *item);
+Location* getSelectedLocation(QList<QListWidgetItem*> list);
+/*QString getLocName(const QListWidgetItem *item);
+Location* getSelectedLocation(QList<QListWidgetItem*> list);*/
+
+LocationsDisplayWindow::LocationsDisplayWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::LocationsDisplayWindow)
+{
+ ui->setupUi(this);
+
+#ifdef Q_WS_MAEMO_5
+ this->setAttribute(Qt::WA_Maemo5StackedWindow);
+#endif
+
+ this->populateLocations();
+
+ Locations *locations = Locations::GetInstance();
+ connect(locations, SIGNAL(locationsChanged()), this, SLOT(populateLocations()));
+
+ this->ui->buttonsStacked->adjustSize();
+ this->ui->locationsWidget->adjustSize();
+}
+
+LocationsDisplayWindow::~LocationsDisplayWindow()
+{
+ delete ui;
+}
+
+void LocationsDisplayWindow::populateLocations()
+{
+ this->ui->locationsWidget->clear();
+ qDebug() << "Populating locations";
+ Locations *locations = Locations::GetInstance();
+
+ QStringList locs;
+ for (int index = 1; index <= locations->size(); ++index)
+ {
+ qDebug() << "Adding location: " << locations->getLocation(index)->label();
+ Location* loc = locations->getLocation(index);
+ QString dispName = loc->label();
+ if (!loc->isValid())
+ dispName.append(invalidPostText);
+ locs << dispName;
+ }
+ this->ui->locationsWidget->addItems(locs);
+ qDebug() << "Locations populated";
+}
+
+
+void LocationsDisplayWindow::editLocation(QListWidgetItem *item)
+{
+ /// TODO
+ /*if (!item) return;
+
+ Locations *locations = Locations::GetInstance();
+ QString findText = getLocName(item);
+ Location *loc = locations->getLocation(findText);
+ if (!loc)
+ qDebug() << "No location with label " << findText << " was found from locations.";
+ else
+ {
+ AddressDialog *dialog = new AddressDialog(this, loc);
+ dialog->show();
+ }*/
+}
+
+QString LocationsDisplayWindow::getLocName(const QListWidgetItem *item)
+{
+ if (!item) return NULL;
+ QString retText = item->text();
+ if (retText.contains(" - Invalid address", Qt::CaseSensitive))
+ retText.chop(18);
+ return retText;
+}
+
+Location* LocationsDisplayWindow::getSelectedLocation(QList<QListWidgetItem*> list)
+{
+ if (list.size() == 0)
+ {
+ qDebug() << "No item is selected";
+ return NULL;
+ }
+ QListWidgetItem *item = list.at(0);
+ QString name = getLocName(item);
+ qDebug() << "Selected item is" << name;
+ Locations *locations = Locations::GetInstance();
+ return locations->getLocation(name);
+}
+
+void LocationsDisplayWindow::on_newLocButton_clicked()
+{
+ /// TODO
+ /*AddressDialog *dialog = new AddressDialog(this);
+ dialog->show();*/
+}
+
+void LocationsDisplayWindow::on_upButton_clicked()
+{
+ qDebug() << "Move up called";
+ Location* loc = this->getSelectedLocation(this->ui->locationsWidget->selectedItems());
+ if (!loc)
+ qDebug() << "No location with selected label was found from locations.";
+ else
+ {
+ Locations *locations = Locations::GetInstance();
+ locations->lowerLocationIndex(loc->label());
+ }
+}
+
+void LocationsDisplayWindow::on_downButton_clicked()
+{
+ qDebug() << "Move down called";
+ Location* loc = this->getSelectedLocation(this->ui->locationsWidget->selectedItems());
+ if (!loc)
+ qDebug() << "No location with selected label was found from locations.";
+ else
+ {
+ Locations *locations = Locations::GetInstance();
+ locations->increaseLocationIndex(loc->label());
+ }
+}
+
+void LocationsDisplayWindow::on_deleteButton_clicked()
+{
+ qDebug() << "Remove called";
+ Location* loc = this->getSelectedLocation(this->ui->locationsWidget->selectedItems());
+ if (!loc)
+ qDebug() << "No location with selected label was found from locations.";
+ else
+ {
+ Locations *locations = Locations::GetInstance();
+ locations->removeLocation(loc);
+ }
+}
+
+void LocationsDisplayWindow::on_customizeButton_clicked()
+{
+ this->ui->buttonsStacked->setCurrentIndex(1);
+}
+
+void LocationsDisplayWindow::on_doneButton_clicked()
+{
+ this->ui->buttonsStacked->setCurrentIndex(0);
+}
+
+void LocationsDisplayWindow::on_locationsWidget_itemClicked(QListWidgetItem* item)
+{
+ if (this->ui->buttonsStacked->currentIndex() == 0)
+ this->editLocation(item);
+}
+
+void LocationsDisplayWindow::on_locationsWidget_clicked(QModelIndex index){}
--- /dev/null
+#ifndef LOCATIONSDISPLAYWINDOW_H
+#define LOCATIONSDISPLAYWINDOW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+class QListWidgetItem;
+class Location;
+
+namespace Ui {
+ class LocationsDisplayWindow;
+}
+
+class LocationsDisplayWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit LocationsDisplayWindow(QWidget *parent = 0);
+ ~LocationsDisplayWindow();
+
+public slots:
+ void populateLocations();
+
+private slots:
+ void on_locationsWidget_itemClicked(QListWidgetItem* item);
+ void on_locationsWidget_clicked(QModelIndex index); // Unneeded
+ void on_doneButton_clicked();
+ void on_deleteButton_clicked();
+ void on_downButton_clicked();
+ void on_upButton_clicked();
+ void on_customizeButton_clicked();
+ void on_newLocButton_clicked();
+
+private: // Methods
+ void editLocation(QListWidgetItem*);
+ Location* getSelectedLocation(QList<QListWidgetItem*>);
+ QString getLocName(const QListWidgetItem *item);
+
+private: // Variables
+ Ui::LocationsDisplayWindow *ui;
+};
+
+#endif // LOCATIONSDISPLAYWINDOW_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LocationsDisplayWindow</class>
+ <widget class="QMainWindow" name="LocationsDisplayWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>281</width>
+ <height>257</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QStackedWidget" name="buttonsStacked">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <widget class="QWidget" name="page">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="newLocButton">
+ <property name="text">
+ <string>Add new location</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="customizeButton">
+ <property name="text">
+ <string>Customize list</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="page_2">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QPushButton" name="upButton">
+ <property name="text">
+ <string>Up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="downButton">
+ <property name="text">
+ <string>Down</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deleteButton">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="doneButton">
+ <property name="text">
+ <string>Done</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="locationsWidget"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>281</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "routelegwidget.h"
+#include "ui_routelegwidget.h"
+
+RouteLegWidget::RouteLegWidget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::RouteLegWidget)
+{
+ ui->setupUi(this);
+}
+
+RouteLegWidget::~RouteLegWidget()
+{
+ delete ui;
+}
+
+void RouteLegWidget::setDisplay(RouteLeg *leg)
+{
+#ifdef Q_WS_MAEMO_5
+ int picSize = 40;
+#else
+ int picSize = 20;
+#endif
+ if (leg->type == WALK)
+ {
+ this->ui->image->setPixmap(QIcon(":/reittiopas/walk").pixmap(picSize));
+ this->ui->image->adjustSize();
+ this->ui->lineSymbol->setText("");
+ this->ui->lineSymbol->adjustSize();
+ return;
+ }
+ this->ui->lineSymbol->setText("<b>" + leg->symbol + "</b>");
+ this->ui->lineSymbol->adjustSize();
+ switch (leg->type)
+ {
+ case BUS:
+ this->ui->image->setPixmap(QIcon(":/reittiopas/bus").pixmap(picSize));
+ break;
+ case FERRY:
+ this->ui->image->setPixmap(QIcon(":/reittiopas/ferry").pixmap(picSize));
+ break;
+ case SUB:
+ this->ui->image->setPixmap(QIcon(":/reittiopas/metro").pixmap(picSize));
+ break;
+ case TRAIN:
+ this->ui->image->setPixmap(QIcon(":/reittiopas/train").pixmap(picSize));
+ break;
+ case TRAM:
+ this->ui->image->setPixmap(QIcon(":/reittiopas/tram").pixmap(picSize));
+ break;
+ }
+ this->ui->image->adjustSize();
+}
--- /dev/null
+#ifndef ROUTELEGWIDGET_H
+#define ROUTELEGWIDGET_H
+
+#include <QWidget>
+
+#include "src/logic/routeleg.h"
+
+namespace Ui {
+ class RouteLegWidget;
+}
+
+class RouteLegWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit RouteLegWidget(QWidget *parent = 0);
+ ~RouteLegWidget();
+
+ void setDisplay(RouteLeg* leg);
+
+private:
+ Ui::RouteLegWidget *ui;
+};
+
+#endif // BUSWIDGET_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RouteLegWidget</class>
+ <widget class="QWidget" name="RouteLegWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>74</width>
+ <height>49</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>1</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="image">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lineSymbol">
+ <property name="text">
+ <string>stopName</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "routeoneitemwidget.h"
+#include "ui_routeoneitemwidget.h"
+
+RouteOneItemWidget::RouteOneItemWidget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::RouteOneItemWIdget)
+{
+ ui->setupUi(this);
+}
+
+RouteOneItemWidget::~RouteOneItemWidget()
+{
+ delete ui;
+}
+
+void RouteOneItemWidget::setDuration(QTime &time)
+{
+ QString disp;
+ int hours = time.hour();
+ if (hours > 0)
+ disp.append(QString::number(hours) + " h ");
+ disp.append(QString::number(time.minute()) + " min");
+ this->ui->duration->setText(disp);
+ this->ui->duration->adjustSize();
+}
+
+void RouteOneItemWidget::setEndTime(QDateTime &time)
+{
+ this->ui->endTime->setText(time.toString("hh:mm"));
+ this->ui->endTime->adjustSize();
+}
+
+void RouteOneItemWidget::setStartTime(QDateTime &time)
+{
+ this->ui->startTime->setText(time.toString("hh:mm"));
+ this->ui->startTime->adjustSize();
+}
+
+void RouteOneItemWidget::setStopTime(QDateTime &time)
+{
+ if (time == QDateTime())
+ {
+ /*QLabel *duration = this->ui->duration;
+ this->ui->gridLayout->removeWidget(duration);
+ this->ui->gridLayout->addWidget(duration, 0, 2, 1, 2);*/
+ this->ui->stopTime->hide();
+ }
+ else
+ {
+ this->ui->stopTime->setText(time.toString("<b>hh:mm</b>"));
+ this->ui->stopTime->adjustSize();
+ }
+}
+
+void RouteOneItemWidget::setItemsWidget(QLayout *layout)
+{
+ this->ui->routeItems->setLayout(layout);
+ this->ui->routeItems->adjustSize();
+}
--- /dev/null
+#ifndef ROUTEONEITEMWIDGET_H
+#define ROUTEONEITEMWIDGET_H
+
+#include <QWidget>
+#include <QDateTime>
+
+namespace Ui {
+ class RouteOneItemWIdget;
+}
+
+class RouteOneItemWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit RouteOneItemWidget(QWidget *parent = 0);
+ ~RouteOneItemWidget();
+
+ void setStartTime(QDateTime& time);
+ void setEndTime(QDateTime& time);
+ void setStopTime(QDateTime& time);
+ void setDuration(QTime& time);
+ void setItemsWidget(QLayout *widget);
+
+private:
+ Ui::RouteOneItemWIdget *ui;
+};
+
+#endif // ROUTEONEITEMWIDGET_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RouteOneItemWIdget</class>
+ <widget class="QWidget" name="RouteOneItemWIdget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>935</width>
+ <height>336</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="startTime">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="stopTime">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="duration">
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <property name="text">
+ <string>duration</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="endTime">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QWidget" name="routeItems" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "routeresultwidget.h"
+#include "ui_routeresultwidget.h"
+
+#include "routelegwidget.h"
+#include "routeoneitemwidget.h"
+
+#include "src/logic/routeleg.h"
+
+#include <QLabel>
+#include <QList>
+#include <QScrollArea>
+#include <QScrollBar>
+#include <QDebug>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QTime>
+
+RouteResultWidget::RouteResultWidget(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::RouteResultWidget),
+ routes()
+{
+
+ ui->setupUi(this);
+#ifdef Q_WS_MAEMO_5
+ this->setAttribute(Qt::WA_Maemo5StackedWindow);
+ connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(rotationEvent()));
+ //this->setObjectName(this->parent()->objectName());
+ //this->resize(800, 480);
+#endif
+ this->setWindowTitle(QCoreApplication::applicationName());
+}
+
+RouteResultWidget::~RouteResultWidget()
+{
+ delete ui;
+}
+
+void RouteResultWidget::addRoute(RouteNew *route)
+{
+ RouteOneItemWidget *item = new RouteOneItemWidget();
+
+ QHBoxLayout *layout = new QHBoxLayout();
+
+ item->setStartTime(route->startTime);
+ item->setEndTime(route->endTime);
+
+ RouteLeg *leg = route->route.at(0);
+ if (leg->type == WALK)
+ {
+ if (route->route.size() > 1)
+ leg = route->route.at(1);
+ else
+ leg = NULL;
+ }
+ if (leg == NULL)
+ {
+ QDateTime none;
+ item->setStopTime(none);
+ }
+ else
+ item->setStopTime(leg->startPoint->departure_time);
+
+ QTime duration = QTime().addSecs(route->startTime.secsTo(route->endTime));
+ qDebug() << "Duration:" << duration;
+ qDebug() << "Seconds:" << route->startTime.secsTo(route->endTime);
+ item->setDuration(duration);
+
+ QList<RouteLeg*>::const_iterator iter;
+ for (iter = route->route.constBegin(); iter != route->route.constEnd(); iter++)
+ {
+ RouteLegWidget *leg_widget = new RouteLegWidget();
+ leg_widget->setDisplay(*iter);
+ layout->addWidget(leg_widget);
+ layout->setSpacing(0);
+ }
+
+ item->setItemsWidget(layout);
+
+ this->routes.append(item); // Might be unnecessary
+
+ QListWidgetItem *listItem = new QListWidgetItem("");
+ item->adjustSize();
+
+ qDebug() << "Item size:" << item->size().width();
+ qDebug() << "SizeHint:" << item->sizeHint().width();
+ qDebug() << "Min:" << item->minimumWidth();
+ qDebug() << "Max:" << item->maximumWidth();
+
+ listItem->setSizeHint(item->sizeHint());
+ this->ui->routesArea->addItem(listItem);
+ this->ui->routesArea->setItemWidget(listItem, item);
+
+ //this->ui->routesArea->setMinimumWidth(this->ui->routesArea->sizeHint().width());
+}
--- /dev/null
+#ifndef ROUTERESULTWIDGET_H
+#define ROUTERESULTWIDGET_H
+
+#include <QMainWindow>
+
+#include "routeoneitemwidget.h"
+
+#include "src/logic/routenew.h"
+
+namespace Ui {
+ class RouteResultWidget;
+}
+
+class RouteResultWidget : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit RouteResultWidget(QWidget *parent = 0);
+ ~RouteResultWidget();
+
+ void addRoute(RouteNew *route);
+
+private slots:
+
+private:
+ Ui::RouteResultWidget *ui;
+
+ QList<RouteOneItemWidget*> routes; // May be unnecessary
+};
+
+#endif // ROUTERESULTWIDGET_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RouteResultWidget</class>
+ <widget class="QMainWindow" name="RouteResultWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>123</width>
+ <height>120</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QListWidget" name="routesArea">
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>123</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "searchdisplay.h"
+#include "ui_searchdisplay.h"
+
+#include "routeresultwidget.h"
+#include "favoriteselectiondialog.h"
+#include "locationsdisplaywindow.h"
+
+#include "src/logic/locations.h"
+#include "src/logic/routefinder.h"
+
+#include <QDebug>
+
+SearchDisplay::SearchDisplay(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::SearchDisplay),
+ route_finder(NULL)
+{
+ qDebug() << "Start constructor";
+ ui->setupUi(this);
+ this->setWindowTitle(QCoreApplication::applicationName());
+ qDebug() << "Application name:" << QCoreApplication::applicationName();
+
+ Locations *locations = Locations::GetInstance();
+ this->connect(locations, SIGNAL(locationsChanged()), SLOT(locations_changed()));
+
+#ifdef Q_WS_MAEMO_5
+ this->setAttribute(Qt::WA_Maemo5StackedWindow);
+ this->setAttribute(Qt::WA_Maemo5AutoOrientation);
+
+ this->ui->fromHorizontalLayout->removeWidget(this->ui->from_combo);
+ this->ui->from_combo->deleteLater();
+ //this->ui->from_favorites->setIcon(QIcon::fromTheme("edit-copy"));
+ //this->ui->from_favorites->setText("Fav");
+
+ this->ui->destHorizontalLayout->removeWidget(this->ui->dest_combo);
+ this->ui->dest_combo->deleteLater();
+ //this->ui->from_favorites->setIcon(QIcon::fromTheme("edit-copy"));
+ //this->ui->dest_favorites->setText("Fav");
+
+ this->from_selected = NULL;
+ this->dest_selected = NULL;
+ this->edit_window = NULL;
+
+#else
+ QWidget *widget = new QWidget();
+ QVBoxLayout *layout = new QVBoxLayout();
+ widget->setLayout(layout);
+
+ this->tabs = new QTabWidget();
+ this->tabs->setTabsClosable(true);
+ this->ui->centralwidget->setParent(this->tabs);
+ this->tabs->addTab(this->ui->centralwidget, "Search");
+
+ this->connect(this->tabs, SIGNAL(tabCloseRequested(int)), SLOT(tabclosed(int)));
+
+ layout->addWidget(this->tabs);
+ this->setCentralWidget(widget);
+
+ this->ui->fromHorizontalLayout->removeWidget(this->ui->from_favorites);
+ this->ui->from_favorites->deleteLater();
+ this->ui->destHorizontalLayout->removeWidget(this->ui->dest_favorites);
+ this->ui->dest_favorites->deleteLater();
+
+ this->updateLocationLists();
+
+ this->on_from_combo_currentIndexChanged(this->ui->from_combo->currentText());
+ this->ui->dest_combo->setCurrentIndex(1);
+
+#endif
+
+ qDebug() << "Finish constructor";
+}
+
+SearchDisplay::~SearchDisplay()
+{
+ delete ui;
+}
+
+void SearchDisplay::updateLocationLists()
+{
+ qDebug() << "Start updateLocationLists";
+#ifndef Q_WS_MAEMO_5
+ this->ui->from_combo->blockSignals(true);
+ this->ui->dest_combo->blockSignals(true);
+ this->ui->from_combo->clear();
+ this->ui->dest_combo->clear();
+ //this->ui->from_combo->blockSignals(false);
+ //this->ui->dest_combo->blockSignals(false);
+
+ /// TODO: Add GPS location if GPS is selected.
+
+
+
+
+ QStringList locs;
+ Locations *locations = Locations::GetInstance();
+ for (int index = 1; index <= locations->size(); ++index)
+ {
+ Location* loc = locations->getLocation(index);
+ if (loc && loc->isValid())
+ {
+ qDebug() << "Adding location: " << loc->label();
+ locs << loc->label();
+
+ }
+ }
+ //this->ui->from_combo->blockSignals(true);
+ //this->ui->dest_combo->blockSignals(true);
+ this->ui->from_combo->addItems(locs);
+ this->ui->dest_combo->addItems(locs);
+
+ this->ui->from_combo->blockSignals(false);
+ this->ui->dest_combo->blockSignals(false);
+#endif
+ qDebug() << "Finish updateLocationLists";
+}
+
+void SearchDisplay::locations_changed()
+{
+ qDebug() << "Start locations_changed";
+
+#ifndef Q_WS_MAEMO_5
+ QString from_old = this->ui->from_combo->currentText();
+ QString dest_old = this->ui->dest_combo->currentText();
+
+ this->updateLocationLists();
+
+ qDebug() << "Reselecting old items.";
+ int from_id = this->ui->from_combo->findText(from_old);
+ if (from_id >= 0)
+ this->ui->from_combo->setCurrentIndex(from_id);
+ else
+ this->on_from_combo_currentIndexChanged(this->ui->from_combo->currentText());
+
+ int dest_id = this->ui->dest_combo->findText(dest_old);
+ if (dest_id >= 0)
+ this->ui->dest_combo->setCurrentIndex(dest_id);
+ else
+ this->on_dest_combo_currentIndexChanged(this->ui->dest_combo->currentText());
+#endif
+ qDebug() << "Finish locations_changed";
+}
+
+void SearchDisplay::on_searchButton_clicked()
+{
+ qDebug() << "Start on_search_button_clicked";
+ if (this->route_finder != NULL)
+ {
+#ifdef Q_WS_MAEMO_5
+ this->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+#endif
+ this->route_finder->disconnect(this, SLOT(route_finder_finished()));
+ delete this->route_finder;
+ }
+ // Check for empty search fields.
+ QString empty;
+ if (this->ui->from_edit->text() == empty)
+ {
+ qDebug() << "From field is empty. No search is made.";
+ return;
+ }
+ if (this->ui->dest_edit->text() == empty)
+ {
+ qDebug() << "Dest field is empty. No search is made.";
+ return;
+ }
+
+ Location *from, *dest;
+#ifdef Q_WS_MAEMO_5
+ from = this->from_selected;
+ dest = this->dest_selected;
+#else
+ Locations* locations = Locations::GetInstance();
+ from = locations->getLocation(this->ui->from_combo->currentText());
+ dest = locations->getLocation(this->ui->dest_combo->currentText());
+#endif
+ if (from != NULL && this->ui->from_edit->text() == from->address()) {
+ qDebug() << "Written text matches the text in the combo box";
+ from = new Location(*from);
+ } else {
+ qDebug() << "Written text differs from the text in the combo box.";
+ from = new Location("Temp");
+ from->setAddress(this->ui->from_edit->text());
+ }
+
+ if (dest != NULL && this->ui->dest_edit->text() == dest->address()) {
+ qDebug() << "Written text matches the text in the combo box";
+ dest = new Location(*dest);
+ } else {
+ qDebug() << "Written text differs from the text in the combo box.";
+ dest = new Location("Temp");
+ dest->setAddress(this->ui->dest_edit->text());
+ }
+
+ qDebug() << "Starting route search";
+
+ this->route_finder = new RouteFinder(*from, *dest);
+ delete from;
+ delete dest;
+ this->connect(this->route_finder, SIGNAL(finished()), SLOT(route_finder_finished()));
+#ifdef Q_WS_MAEMO_5
+ this->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+#endif
+ qDebug() << "Finished on_search_button_clicked.";
+}
+
+void SearchDisplay::route_finder_finished()
+{
+ qDebug() << "Received signal from successful route finder";
+#ifdef Q_WS_MAEMO_5
+ RouteResultWidget *results = new RouteResultWidget(this);
+#else
+ RouteResultWidget *results = new RouteResultWidget();
+#endif
+
+ for (int i = 0; i < this->route_finder->getNumberOfRoutes(); i++)
+ results->addRoute(this->route_finder->getRoute(i));
+
+#ifdef Q_WS_MAEMO_5
+ this->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ results->show();
+#else
+ int cur = this->tabs->addTab(results, "Route" + QString::number(this->tabs->count()));
+ this->tabs->setCurrentIndex(cur);
+#endif
+ qDebug() << "Finish route_finder_finished";
+}
+
+void SearchDisplay::setEditText(QLineEdit* edit, QString& text)
+{
+ qDebug() << "Start setEditText";
+ Locations* locations = Locations::GetInstance();
+ Location* loc = locations->getLocation(text);
+ if (loc)
+ edit->setText(loc->address());
+ qDebug() << "Finish setEditText";
+}
+
+
+void SearchDisplay::on_from_combo_currentIndexChanged(QString text)
+{
+#ifndef Q_WS_MAEMO_5
+ qDebug() << "New FROM location selected.";
+ setEditText(this->ui->from_edit, text);
+ qDebug() << "Finish on_from_combo_currentIndexChanged";
+#endif
+}
+
+
+void SearchDisplay::on_dest_combo_currentIndexChanged(QString text)
+{
+#ifndef Q_WS_MAEMO_5
+ qDebug() << "New DEST location selected.";
+ setEditText(this->ui->dest_edit, text);
+ qDebug() << "Finish on_dest_combo_currentIndexChanged";
+#endif
+}
+
+
+#ifndef Q_WS_MAEMO_5
+void SearchDisplay::tabclosed(int index)
+{
+ qDebug() << "Tab close requested. Nr" << index;
+ if (index == 0)
+ {
+ qDebug() << "First tab requested to be closed.";
+ return;
+ }
+ this->tabs->removeTab(index);
+}
+#endif //Q_WS_MAEMO_5
+
+void SearchDisplay::on_from_favorites_clicked()
+{
+#ifdef Q_WS_MAEMO_5
+ qDebug() << "FROM Favorites button clicked";
+ FavoriteSelectionDialog *dialog = new FavoriteSelectionDialog();
+ this->connect(dialog, SIGNAL(selectedLocation(Location*)), SLOT(from_selection_selected(Location*)));
+ this->connect(dialog, SIGNAL(customizeRequested()), SLOT(customize_requested()));
+ dialog->show();
+#endif
+}
+
+
+void SearchDisplay::on_dest_favorites_clicked()
+{
+#ifdef Q_WS_MAEMO_5
+ qDebug() << "DEST Favorites button clicked";
+ FavoriteSelectionDialog *dialog = new FavoriteSelectionDialog();
+ this->connect(dialog, SIGNAL(selectedLocation(Location*)), SLOT(dest_selection_selected(Location*)));
+ this->connect(dialog, SIGNAL(customizeRequested()), SLOT(customize_requested()));
+ dialog->show();
+#endif
+}
+
+#ifdef Q_WS_MAEMO_5
+void SearchDisplay::from_selection_selected(Location *location)
+{
+ if (location == NULL)
+ {
+ qDebug() << "NULL location received from FavoriteSelectionDialog.";
+ return;
+ }
+ this->from_selected = location;
+ this->ui->from_edit->setText(this->from_selected->address());
+}
+
+void SearchDisplay::dest_selection_selected(Location *location)
+{
+ if (location == NULL)
+ {
+ qDebug() << "NULL location received from FavoriteSelectionDialog.";
+ return;
+ }
+ this->dest_selected = location;
+ this->ui->dest_edit->setText(this->dest_selected->address());
+}
+
+void SearchDisplay::customize_requested()
+{
+ qDebug() << "Customizing favorites requested.";
+
+ if (!this->edit_window)
+ this->edit_window = new LocationsDisplayWindow(this);
+ this->edit_window->show();
+}
+
+#endif
--- /dev/null
+#ifndef SEARCHDISPLAY_H
+#define SEARCHDISPLAY_H
+
+#include <QMainWindow>
+#include <QLineEdit>
+
+#include "routeresultwidget.h"
+#include "locationsdisplaywindow.h"
+#include "favoriteselectiondialog.h"
+
+#include "src/logic/routefinder.h"
+
+
+namespace Ui {
+ class SearchDisplay;
+}
+
+class SearchDisplay : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit SearchDisplay(QWidget *parent = 0);
+ ~SearchDisplay();
+
+public slots:
+ void locations_changed();
+
+private slots:
+ void on_dest_favorites_clicked();
+ void on_from_favorites_clicked();
+ void on_dest_combo_currentIndexChanged(QString );
+ void on_from_combo_currentIndexChanged(QString );
+ void on_searchButton_clicked();
+
+ void route_finder_finished();
+
+private:
+ void setEditText(QLineEdit*, QString&);
+ void updateLocationLists();
+
+ Ui::SearchDisplay *ui;
+ RouteFinder *route_finder;
+
+#ifdef Q_WS_MAEMO_5
+private slots:
+ void from_selection_selected(Location*);
+ void dest_selection_selected(Location*);
+ void customize_requested();
+private:
+ Location *from_selected;
+ Location *dest_selected;
+ LocationsDisplayWindow *edit_window;
+#else
+
+private slots:
+ void tabclosed(int index);
+private:
+ QTabWidget *tabs;
+#endif
+};
+
+
+#endif // SEARCHDISPLAY_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SearchDisplay</class>
+ <widget class="QMainWindow" name="SearchDisplay">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>697</width>
+ <height>369</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="fromHorizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="from_edit">
+ <property name="placeholderText">
+ <string>From</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="from_combo"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="from_favorites">
+ <property name="text">
+ <string>Fav</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="destHorizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="dest_edit">
+ <property name="placeholderText">
+ <string>Destination</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="dest_combo"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="dest_favorites">
+ <property name="text">
+ <string>Fav</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="searchButton">
+ <property name="text">
+ <string>Search</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>697</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <tabstops>
+ <tabstop>from_edit</tabstop>
+ <tabstop>from_combo</tabstop>
+ <tabstop>from_favorites</tabstop>
+ <tabstop>dest_edit</tabstop>
+ <tabstop>dest_combo</tabstop>
+ <tabstop>dest_favorites</tabstop>
+ <tabstop>searchButton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
+++ /dev/null
-#include "location.h"
-
-#include "ytv.h"
-
-#include <QString>
-#include <QObject>
-#include <QNetworkAccessManager>
-#include <QUrl>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QXmlStreamReader>
-#include <QDebug>
-#include <QXmlStreamAttributes>
-#include <QStringRef>
-#include <QGeoPositionInfo>
-
-#include <math.h>
-
-const double KkjZoneInfo[6][2] = {
- {18.0, 500000.0},
- {21.0, 1500000.0},
- {24.0, 2500000.0},
- {27.0, 3500000.0},
- {30.0, 4500000.0},
- {33.0, 5500000.0}
-};
-
-#ifdef Q_WS_MAEMO_5
-QTM_USE_NAMESPACE
-#endif
-
- Location::Location( const QString &x, const QString &y, const QString &label ) :
- m_label(label),
- m_address(QString()),
- m_x(x),
- m_y(y),
- m_valid(true)
-{
-}
-#ifdef Q_WS_MAEMO_5
-Location::Location(const QGeoPositionInfo &positionInfo, const QString &label) :
- m_label(label),
- m_address(QString()),
- m_x("0"),
- m_y("0"),
- m_valid(false)
-{
- setLocation(positionInfo);
-}
-
-void Location::setLocation(const QGeoPositionInfo &positionInfo)
-{
- qDebug() << "Setting new location based on GeoPositionInfo";
- qreal latitude = positionInfo.coordinate().latitude();
- qreal longitude = positionInfo.coordinate().longitude();
-
- //qDebug() << "Calculating new values";
-
- KKJ outX(0);
- KKJ outY(0);
-
- WGS84lola_to_KKJxy( longitude, latitude, &outX, &outY);
-
- /*qDebug() << "Storing new values";
- qDebug() << "x";
- qDebug() << outX;
- qDebug() << "y";
- qDebug() << outY;*/
-
- //qDebug() << "Setting x";
- //this->m_x = QString("%1").arg(outX);
- this->m_x.setNum(outX);
- //qDebug() << "Setting y";
- //this->m_y = QString("%1").arg(outY);
- this->m_y.setNum(outY);
- //qDebug() << "Setting as valid";
- this->m_valid = true;
- emit(becomeValid());
- //qDebug() << "Location set";
-}
-#endif
-
-void Location::setPosition(const QString &x, const QString &y)
-{
- this->m_x = x;
- this->m_y = y;
- this->m_valid = true;
-}
-
-Location::Location(const QString &label) :
- m_label(label),
- m_address(QString()),
- m_x("0"),
- m_y("0"),
- m_valid(false)
-{
-}
-
-Location::Location(const Location *location) :
- m_label(location->m_label),
- m_address(location->m_address),
- m_x(location->m_x),
- m_y(location->m_y),
- m_valid(location->m_valid)
-{
-}
-
-QString Location::x() const
-{
- return m_x;
-}
-
-QString Location::y() const
-{
- return m_y;
-}
-
-void Location::setLabel(const QString &label)
-{
- m_label = label;
-}
-
-QString Location::label() const
-{
- return m_label;
-}
-
-void Location::setAddress(const QString &address)
-{
- m_address = address;
-}
-
-QString Location::address() const
-{
- return m_address;
-}
-
-bool Location::isValid() const
-{
- return m_valid;
-}
-
-// Degrees to radians
-double radians(double deg)
-{
- return deg * M_PI / 180.0;
-}
-
-// Radians to degrees
-double degrees(double rad)
-{
- return rad * 180.0 / M_PI;
-}
-
-// Function: KKJ_Zone_I
-int KKJ_Zone_I(KKJ easting)
-{
- int zoneNumber = floor(easting / 1000000.0);
- if (zoneNumber < 0 || zoneNumber > 5) {
- zoneNumber = -1;
- }
-
- return zoneNumber;
-}
-
-// Function: KKJ_Zone_Lo
-int KKJ_Zone_Lo(double kkjlo)
-{
- // determine the zonenumber from KKJ easting
- // takes KKJ zone which has center meridian
- // longitude nearest (in math value) to
- // the given KKJ longitude
- int zoneNumber = 5;
- while (zoneNumber >= 0) {
- if (fabs(kkjlo - KkjZoneInfo[zoneNumber][0]) <= 1.5) {
- break;
- }
- zoneNumber--;
- }
-
- return zoneNumber;
-}
-
-
-// Function: KKJlalo_to_WGS84lalo
-void KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude)
-{
- double dLa = radians(0.124867E+01 + -0.269982E+00 * kkjla + 0.191330E+00 * kkjlo + 0.356119E-02 * kkjla * kkjla + -0.122312E-02 * kkjla * kkjlo + -0.335514E-03 * kkjlo * kkjlo) / 3600.0;
- double dLo = radians(-0.286111E+02 + 0.114183E+01 * kkjla + -0.581428E+00 * kkjlo + -0.152421E-01 * kkjla * kkjla + 0.118177E-01 * kkjla * kkjlo + 0.826646E-03 * kkjlo * kkjlo) / 3600.0;
-
- *outLatitude = degrees(radians(kkjla) + dLa);
- *outLongitude = degrees(radians(kkjlo) + dLo);
-}
-
-
-// Function: WGS84lalo_to_KKJlalo
-void WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude)
-{
- double dLa = radians(-0.124766E+01 + 0.269941E+00 * latitude + -0.191342E+00 * longitude + -0.356086E-02 * latitude * latitude + 0.122353E-02 * latitude * longitude + 0.335456E-03 * longitude * longitude) / 3600.0;
- double dLo = radians(0.286008E+02 + -0.114139E+01 * latitude + 0.581329E+00 * longitude + 0.152376E-01 * latitude * latitude + -0.118166E-01 * latitude * longitude + -0.826201E-03 * longitude * longitude) / 3600.0;
-
- *outLatitude = degrees(radians(latitude) + dLa);
- *outLongitude = degrees(radians(longitude) + dLo);
-}
-
-
-// Function: KKJlalo_to_KKJxy
-void KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY)
-{
- // Hayford ellipsoid
- double a = 6378388.0;
- double f = 1.0 / 297.0;
- double b = (1.0 - f) * a;
- double bb = b * b;
- double c = (a / b) * a;
- double ee = (a * a - bb) / bb;
- double n = (a - b) / (a + b);
- double nn = n * n;
-
- double Lo = radians(lon) - radians(KkjZoneInfo[zoneNumber][0]);
- double cosLa = cos(radians(lat));
- double NN = ee * cosLa * cosLa;
- double LaF = atan(tan(radians(lat)) / cos(Lo * sqrt(1.0 + NN)));
- double cosLaF = cos(LaF);
- double t = (tan(Lo) * cosLaF) / sqrt(1.0 + ee * cosLaF * cosLaF);
- double A = a / (1.0 + n);
- double A1 = A * (1.0 + nn / 4.0 + nn * nn / 64.0);
- double A2 = A * 1.5 * n * (1.0 - nn / 8.0);
- double A3 = A * 0.9375 * nn * (1.0 - nn / 4.0);
- double A4 = A * 35.0 / 48.0 * nn * n;
-
- *outY = A1 * LaF - A2 * sin(2.0 * LaF) + A3 * sin(4.0 * LaF) - A4 * sin(6.0 * LaF);
- *outX = c * log(t + sqrt(1.0 + t * t)) + 500000.0 + zoneNumber * 1000000.0;
-}
-
-// Function: KKJxy_to_KKJlalo
-void KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude)
-{
- // Scan iteratively the target area, until find matching
- // KKJ coordinate value. Area is defined with Hayford Ellipsoid.
- int zoneNumber = KKJ_Zone_I(x);
- double minLo = radians(18.5);
- double maxLo = radians(32.0);
- double minLa = radians(59.0);
- double maxLa = radians(70.5);
-
- int i = 1;
- KKJ tmpX, tmpY;
-
- while (i < 35) {
- double deltaLo = maxLo - minLo;
- double deltaLa = maxLa - minLa;
- *outLongitude = degrees(minLo + 0.5 * deltaLo);
- *outLatitude = degrees(minLa + 0.5 * deltaLa);
- KKJlola_to_KKJxy(*outLongitude, *outLatitude, zoneNumber, &tmpX, &tmpY);
- if (tmpY < y) {
- minLa = minLa + 0.45 * deltaLa;
- } else {
- maxLa = minLa + 0.55 * deltaLa;
- }
-
- if (tmpX < x) {
- minLo = minLo + 0.45 * deltaLo;
- } else {
- maxLo = minLo + 0.55 * deltaLo;
- }
-
- i++;
- }
-}
-
-void WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY)
-{
- double kkjlo, kkjla;
-
- WGS84lola_to_KKJlola(longitude, latitude, &kkjlo, &kkjla);
- int zoneNumber = KKJ_Zone_Lo(kkjlo);
- KKJlola_to_KKJxy(kkjlo, kkjla, zoneNumber, outX, outY);
-}
-
-void KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude)
-{
- double kkjlo, kkjla;
-
- KKJxy_to_KKJlola(x, y, &kkjlo, &kkjla);
- KKJlola_to_WGS84lola(kkjlo, kkjla, outLongitude, outLatitude);
-
-}
+++ /dev/null
-#ifndef LOCATION_H
-#define LOCATION_H
-
-#include <QString>
-#include <QObject>
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QGeoPositionInfo>
-#include <math.h>
-
-QTM_USE_NAMESPACE;
-
-class Location : public QObject
-{
- Q_OBJECT
-
-public:
- Location( const QString &x, const QString &y, const QString &label=QString() );
- Location( const QGeoPositionInfo &positionInfo, const QString &label=QString() );
- Location( const QString &label=QString() );
- Location(const Location* location);
-
- QString x() const;
-
- QString y() const;
-
- void setLocation( const QGeoPositionInfo &positionInfo );
-
- void setPosition(const QString &x, const QString &y);
-
- void setAddress( const QString &address );
- QString address() const;
-
- void setLabel( const QString &label );
- QString label() const;
-
- bool isValid() const;
-
-Q_SIGNALS:
- void becomeValid();
- void becomeInValid();
- void busy( bool busy );
-
-private:
- QString m_label;
- QString m_address;
- QString m_x;
- QString m_y;
- bool m_valid;
-};
-
-
-typedef uint KKJ;
-
-/**
- * Transformes WGS84 longitude/latitude coordinates to KKJ x/y coordinates.
- * @param longitude the input longitude in degrees
- * @param latitude the input latitude in degrees
- * @param outX the result x (easting)
- * @param outY the result y (northing)
- */
-void WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY);
-
-/**
- * Transformes KKJ x/y coordinates to WGS84 longitude/latitude coordinates.
- * @param x the input x (easting)
- * @param y the input y (northing)
- * @param outLongitude the result longitude in degrees
- * @param outLatitude the result latitude in degrees
- */
-void KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude);
-
-// Degrees to radians
-double radians(double deg);
-
-// Radians to degrees
-double degrees(double rad);
-
-// Constants
-// Longitude0 and Center meridian of KKJ bands
-//static const double KkjZoneInfo[][2];
-
-// Function: KKJ_Zone_I
-int KKJ_Zone_I(KKJ easting);
-
-// Function: KKJ_Zone_Lo
-int KKJ_Zone_Lo(double kkjlo);
-
-// Function: KKJlalo_to_WGS84lalo
-void KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude);
-
-// Function: WGS84lalo_to_KKJlalo
-void WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude);
-
-// Function: KKJlalo_to_KKJxy
-void KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY);
-
-// Function: KKJxy_to_KKJlalo
-void KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude);
-
-
-#endif // LOCATION_H
+++ /dev/null
-#include "locations.h"
-#include "location.h"
-
-#include <QDebug>
-#include <QHash>
-#include <QSettings>
-#include <QString>
-#include <QStringList>
-#include <QCoreApplication>
-#include <QMap>
-#include <QMapIterator>
-#include <QList>
-
-Locations* Locations::m_instance = 0;
-
-Locations* Locations::GetInstance()
-{
- if (m_instance == 0)
- m_instance = new Locations();
-
- return m_instance;
-}
-
-/*void Locations::destroyLocations()
-{
- delete m_instance;
-}*/
-
-Locations::Locations() :
- m_locationStorage(QHash<QString,Location *>()),
- m_indexStorage(QList<QString>()),
- m_gpsLocation(new Location("GPS"))
-{
- this->restoreLocations();
- qDebug() << "Size of index storage:" << this->m_indexStorage.size();
-}
-
-/*Locations::~Locations()
-{
- QHash<QString,Location*>::iterator it, ite;
- for (it = this->m_locationStorage.begin(), ite = this->m_locationStorage.end(); it != ite; ++it)
- {
- delete it.value();
- }
- this->m_locationStorage.empty();
- delete m_gpsLocation;
-}*/
-
-bool Locations::addEditLocation(Location *location)
-{
- bool addedNew=false;
-
- if ( !this->m_locationStorage.contains(location->label())) {
- qDebug() << "Adding location" << location->label();
- this->m_locationStorage[location->label()] = location;
- qDebug() << "Index storage:";
- qDebug() << this->m_indexStorage;
- qDebug() << "Size of index storage:" << this->m_indexStorage.size();
- this->m_indexStorage.append(location->label());
- qDebug() << "Index storage after inserting location:";
- qDebug() << this->m_indexStorage;
- addedNew = true;
- } else {
- qDebug() << "A location with the same label (" << location->label() << ") already exists.";
- this->m_locationStorage.remove(location->label());
- this->m_locationStorage[location->label()] = location;
- }
- emit(locationsChanged());
-
- // save the location to settings
- this->saveLocation(location);
-
- return addedNew;
-}
-
-void Locations::restoreLocations()
-{
- QSettings settings;
-
- settings.beginGroup("Locations");
- QStringList labels = settings.childGroups();
-
- QMap<QString, int> tempIndex = QMap<QString, int>();
-
- for( int i=0; i<labels.size(); ++i ) {
- QString label = labels[i];
- settings.beginGroup(label);
- QString address, x, y;
- bool valid = false;
- if (settings.contains("address")) {
- address = settings.value( "address" ).toString();
- if (settings.contains("x")) {
- x = settings.value( "x" ).toString();
- if (settings.contains("y")) {
- y = settings.value( "y" ).toString();
- valid = true;
- }
- }
- }
- int index = settings.value("index").toInt();
- settings.endGroup();
-
- qDebug() << "Restoring " << label;
- Location *location;
- if (valid) {
- location = new Location( x, y, label );
- location->setAddress(address);
- }
- else
- location = new Location(label);
-
- this->m_locationStorage[label] = location;
- this->m_indexStorage.append(label);
- if (index != 0)
- tempIndex.insert(label, index);
- }
-
- settings.endGroup();
-
- qDebug() << "Locations indexes before restoring positions";
- qDebug() << this->m_indexStorage;
- qDebug() << "Restoring these locations positions.";
- qDebug() << tempIndex;
-
- // Swap locations to correct indexes.
- QMap<QString, int>::iterator it, ite;
- for (it = tempIndex.begin(), ite = tempIndex.end(); it != ite; ++it)
- {
- int oldIndex = this->m_indexStorage.indexOf(it.key());
- // Only operate on this item if current index is not the same as specified
- if (it.value() != oldIndex + 1)
- {
- // Move to last if requested index is greater than the number of items.
- if (it.value() >= this->m_indexStorage.size()) {
- this->m_indexStorage.swap(oldIndex, this->m_indexStorage.size() - 1);
- }
- else {
- this->m_indexStorage.swap(oldIndex, it.value() - 1);
- }
- }
- }
-
- qDebug() << "Locations indexes after positions are restored.";
- qDebug() << this->m_indexStorage;
-}
-
-void Locations::saveLocation(Location *location)
-{
- if (!location) {
- qDebug() << "Null location given to saveLocation. Aborting";
- return;
- }
- qDebug() << "Saving location " << location->label();
- QSettings settings;
- settings.beginGroup("Locations");
- settings.beginGroup(location->label() );
- if (location->isValid()) {
- settings.setValue( "address", location->address() );
- settings.setValue( "x", location->x() );
- settings.setValue( "y", location->y() );
- }
- else {
- if (settings.contains("address")) settings.remove("address");
- if (settings.contains("x")) settings.remove("x");
- if (settings.contains("y")) settings.remove("y");
- }
- settings.setValue("index", this->m_indexStorage.indexOf(location->label()) + 1);
- settings.endGroup();
- settings.endGroup();
-}
-
-bool Locations::removeLocation(Location *location)
-{
- bool succeeded = false;
- qDebug() << "Trying to remove location " << location->label();
- QSettings settings;
- settings.beginGroup("Locations");
- if (settings.contains("" + location->label() + "/index"))
- {
- qDebug() << "Given location exists in settings -> removing it";
- settings.remove(location->label());
- succeeded = true;
- }
- settings.endGroup();
-
- if (this->m_locationStorage.contains(location->label()))
- {
- qDebug() << "Given location exists in locations list -> removing it";
- this->m_locationStorage.remove(location->label());
- //int remIndex = this->m_indexStorage.value(location->label());
- this->m_indexStorage.removeOne(location->label());
- /*for (int ind = 0; ind < this->m_indexStorage.size(); ++ind)
- {
- if (this->m_indexStorage.value(this->m_indexStorage > remIndex)
- {
- it.value() -= 1;
- this->saveLocation(this->getLocation(it.key()), it.value());
- }
- }*/
- emit(locationsChanged());
- }
- return succeeded;
-}
-
-Location *Locations::getLocation(const QString &label) const
-{
- qDebug() << "requesting location " << label;
- Location *retVal = 0;
-
- if (this->m_locationStorage.contains(label)) {
- qDebug() << "found location " << label;
- retVal = this->m_locationStorage[label];
- } else {
- qDebug() << "didn't find location " << label;
- }
-
- return retVal;
-}
-
-/*void Locations::changeIndex(const QString &label, const int &index, bool signal)
-{
- int oldIndex = this->m_indexStorage.value(label);
- if (index == oldIndex)
- return;
-
- qDebug() << "Index map before moving " << label << " from index " << oldIndex << " to index " << index;
- qDebug() << this->m_indexStorage;
- QHash<QString, int>::iterator it, ite;
- if (index < oldIndex)
- {
- for (it = this->m_indexStorage.begin(), ite = this->m_indexStorage.end(); it != ite; ++it)
- {
- if (it.value() >= index && it.value() < oldIndex)
- {
- this->saveLocation(this->getLocation(label), ++(it.value()));
- }
- }
- }
- else
- for (it = this->m_indexStorage.begin(), ite = this->m_indexStorage.end(); it != ite; ++it)
- if (it.value() <= index && it.value() > oldIndex)
- this->saveLocation(this->getLocation(label), --(it.value()));
-
- this->m_indexStorage[label] = index;
- this->saveLocation(this->getLocation(label), index);
-
- qDebug() << "Index map after move";
- qDebug() << this->m_indexStorage;
- if (signal)
- emit(locationsChanged());
-}*/
-
-Location *Locations::getLocation(const int &index) const
-{
- qDebug() << "Getting location for index" << index;
- Location *loc = 0;
- /*QString label;
- if (this->findLabel(index, label))
- {
- qDebug() << "Found a label with given index " << index;
- qDebug() << "Found label is " << label;
- loc = this->getLocation(label);
- }*/
- if (index <= 0 || index > this->m_indexStorage.size())
- return loc;
-
- QString label = this->m_indexStorage.at(index - 1);
- loc = this->m_locationStorage.value(label);
- return loc;
-}
-
-/*bool Locations::findLabel(const int &index, QString &label) const
-{
- qDebug() << "Finding label for index" << index << ". Number of items in indexStorage:" << this->m_indexStorage.size() << ". Number of items in locationStorage:" << this->m_locationStorage.size();
- qDebug() << "Location storage";
- qDebug() << this->m_locationStorage;
- qDebug() << "Index storage";
- qDebug() << this->m_indexStorage;
-
- if (index > this->m_indexStorage.size() || index < 1)
- return false;
- bool found = false;
- QHash<QString, int>::const_iterator it, ite;
- for (it = this->m_indexStorage.constBegin(), ite = this->m_indexStorage.constEnd(); it != ite; ++it)
- {
- if (it.value() == index)
- {
- label = it.key();
- qDebug() << "Found label is " << label;
- found = true;
- break;
- }
- }
- qDebug() << "Returning from label search.";
- return found;
-}*/
-
-/*const QHash<QString, Location *>& Locations::getLocations() const
-{
- return this->m_locationStorage;
-}*/
-
-Location *Locations::getGpsLocation() const
-{
- qDebug() << "GPS location requested.";
- return this->m_gpsLocation;
-}
-
-bool Locations::increaseLocationIndex(const QString &label)
-{
- if (!this->m_indexStorage.contains(label))
- {
- qDebug() << "Given label \"" << label << "\" does not exist in indexStorage.";
- qDebug() << "Contents of indexStorage: " << this->m_indexStorage;
- return false;
- }
- qDebug() << "Increasing index by one for label" << label;
- int oldIndex = this->m_indexStorage.indexOf(label);
- if (oldIndex == -1)
- return false;
- if (oldIndex == this->m_indexStorage.size() - 1)
- return false;
- this->m_indexStorage.move(oldIndex, oldIndex + 1);
- this->saveLocation(this->m_locationStorage.value(label));
- emit(locationsChanged());
- /*QString otherLabel;
- if (this->findLabel(oldIndex + 1, otherLabel))
- {
- this->m_indexStorage[label] = oldIndex + 1;
- this->m_indexStorage[otherLabel] = oldIndex;
- done = true;
- emit(locationsChanged());
- }*/
- return true;
-}
-
-bool Locations::lowerLocationIndex(const QString &label)
-{
- if (!this->m_indexStorage.contains(label))
- return false;
- qDebug() << "Lowering index by one for label" << label;
- int oldIndex = this->m_indexStorage.indexOf(label);
- if (oldIndex == -1) //Not found
- return false;
- if (oldIndex == 0) // Already first
- return false;
- this->m_indexStorage.move(oldIndex, oldIndex - 1);
- this->saveLocation(this->m_locationStorage.value(label));
- emit(locationsChanged());
- /*QString otherLabel;
- if (this->findLabel(oldIndex - 1, otherLabel))
- {
- this->m_indexStorage[label] = oldIndex - 1;
- this->m_indexStorage[otherLabel] = oldIndex;
- done = true;
- emit(locationsChanged());
- }*/
- return true;
-}
-
-int Locations::size() const
-{
- return this->m_locationStorage.size();
-}
+++ /dev/null
-#ifndef LOCATIONS_H
-#define LOCATIONS_H
-
-#include "location.h"
-
-#include <QHash>
-#include <QList>
-#include <QString>
-#include <QObject>
-
-class Locations: public QObject
-{
- Q_OBJECT
-
-public:
- static Locations *GetInstance();
- //static void destroyLocations();
-
- bool addEditLocation(Location *location);
- bool removeLocation(Location *location);
-
- bool increaseLocationIndex(const QString &label);
- bool lowerLocationIndex(const QString &label);
-
- Location *getLocation(const QString &label) const;
- Location *getLocation(const int&) const;
- Location *getGpsLocation() const;
- int size() const;
-
- //const QHash<QString, Location *>& getLocations() const;
-
-signals:
- void locationsChanged();
-
-private:
- Locations();
- //~Locations();
- Locations(const Locations&);
- void operator=(const Locations&);
-
- void restoreLocations();
- void saveLocation(Location *location);
- bool findLabel(const int &index, QString &label) const;
- void changeIndex(const QString &label, const int &index, bool signal = true);
-
- QHash<QString, Location*> m_locationStorage;
- QList<QString> m_indexStorage;
- Location* m_gpsLocation;
-
- static Locations *m_instance;
-};
-#endif // LOCATIONS_H
+++ /dev/null
-#include "locationsdisplaywindow.h"
-#include "ui_locationsdisplaywindow.h"
-#include "locations.h"
-#include "addressdialog.h"
-
-#include <QDebug>
-#include <QListWidgetItem>
-#include <QListWidget>
-#include <QList>
-
-const QString invalidPostText = " - Invalid address";
-const QString editText = "Edit list";
-
-QString getLocName(const QListWidgetItem *item);
-Location* getSelectedLocation(QList<QListWidgetItem*> list);
-/*QString getLocName(const QListWidgetItem *item);
-Location* getSelectedLocation(QList<QListWidgetItem*> list);*/
-
-LocationsDisplayWindow::LocationsDisplayWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::LocationsDisplayWindow)
-{
- ui->setupUi(this);
-#ifdef Q_WS_MAEMO_5
- this->setAttribute(Qt::WA_Maemo5StackedWindow);
-#endif
- QAction *editListAction = new QAction(editText, this->ui->menuBar);
- this->ui->menuBar->addAction(editListAction);
- connect(editListAction, SIGNAL(triggered()), this, SLOT(showEditOptions()));
-//#endif
- this->ui->editViewWidget->hide();
-
- connect(this->ui->newLocButton, SIGNAL(clicked()), this, SLOT(addAddress()));
- connect(this->ui->locationsWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(editLocation(QListWidgetItem*)));
- connect(this->ui->deleteButton, SIGNAL(clicked()), this, SLOT(remove()));
- connect(this->ui->upButton, SIGNAL(clicked()), this, SLOT(moveUp()));
- connect(this->ui->downButton, SIGNAL(clicked()), this, SLOT(moveDown()));
- connect(this->ui->doneButton, SIGNAL(clicked()), this, SLOT(closeEditOptions()));
-
- this->populateLocations();
-
- Locations *locations = Locations::GetInstance();
- connect(locations, SIGNAL(locationsChanged()), this, SLOT(populateLocations()));
-}
-
-LocationsDisplayWindow::~LocationsDisplayWindow()
-{
- delete ui;
-}
-
-void LocationsDisplayWindow::showEditOptions()
-{
- disconnect(this->ui->locationsWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(editLocation(QListWidgetItem*)));
- this->ui->defaultViewWidget->hide();
- this->ui->editViewWidget->show();
-}
-
-void LocationsDisplayWindow::closeEditOptions()
-{
- connect(this->ui->locationsWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(editLocation(QListWidgetItem*)));
- this->ui->defaultViewWidget->show();
- this->ui->editViewWidget->hide();
-}
-
-void LocationsDisplayWindow::populateLocations()
-{
- this->ui->locationsWidget->clear();
- qDebug() << "Populating locations";
- Locations *locations = Locations::GetInstance();
-
- for (int index = 1; index <= locations->size(); ++index)
- {
- qDebug() << "Adding location: " << locations->getLocation(index)->label();
- Location* loc = locations->getLocation(index);
- QString dispName = loc->label();
- if (!loc->isValid())
- dispName.append(invalidPostText);
- new QListWidgetItem(dispName, this->ui->locationsWidget);
- }
- qDebug() << "Locations populated";
-}
-
-void LocationsDisplayWindow::addAddress()
-{
- AddressDialog *dialog = new AddressDialog(this);
- dialog->show();
-}
-
-void LocationsDisplayWindow::editLocation(QListWidgetItem *item)
-{
- if (!item) return;
-
- Locations *locations = Locations::GetInstance();
- QString findText = getLocName(item);
- Location *loc = locations->getLocation(findText);
- if (!loc)
- qDebug() << "No location with label " << findText << " was found from locations.";
- else
- {
- AddressDialog *dialog = new AddressDialog(this, loc);
- dialog->show();
- }
-}
-
-QString getLocName(const QListWidgetItem *item)
-{
- if (!item) return 0;
- QString retText = item->text();
- if (retText.contains(" - Invalid address", Qt::CaseSensitive))
- retText.chop(18);
- return retText;
-}
-
-void LocationsDisplayWindow::remove()
-{
- qDebug() << "Remove called";
- Location* loc = getSelectedLocation(this->ui->locationsWidget->selectedItems());
- if (!loc)
- qDebug() << "No location with selected label was found from locations.";
- else
- {
- Locations *locations = Locations::GetInstance();
- locations->removeLocation(loc);
- }
-}
-
-Location* getSelectedLocation(QList<QListWidgetItem*> list)
-{
- if (list.size() == 0)
- {
- qDebug() << "No item is selected";
- return 0;
- }
- QListWidgetItem *item = list.at(0);
- QString name = getLocName(item);
- qDebug() << "Selected item is" << name;
- Locations *locations = Locations::GetInstance();
- return locations->getLocation(name);
-}
-
-void LocationsDisplayWindow::moveUp()
-{
- qDebug() << "Move up called";
- Location* loc = getSelectedLocation(this->ui->locationsWidget->selectedItems());
- if (!loc)
- qDebug() << "No location with selected label was found from locations.";
- else
- {
- Locations *locations = Locations::GetInstance();
- locations->lowerLocationIndex(loc->label());
- }
-}
-
-void LocationsDisplayWindow::moveDown()
-{
- qDebug() << "Move down called";
- Location* loc = getSelectedLocation(this->ui->locationsWidget->selectedItems());
- if (!loc)
- qDebug() << "No location with selected label was found from locations.";
- else
- {
- Locations *locations = Locations::GetInstance();
- locations->increaseLocationIndex(loc->label());
- }
-}
-
+++ /dev/null
-#ifndef LOCATIONSDISPLAYWINDOW_H
-#define LOCATIONSDISPLAYWINDOW_H
-
-#include <QMainWindow>
-
-class QListWidgetItem;
-
-namespace Ui {
- class LocationsDisplayWindow;
-}
-
-class LocationsDisplayWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit LocationsDisplayWindow(QWidget *parent = 0);
- ~LocationsDisplayWindow();
-
-public slots:
- void populateLocations();
-
-private slots:
- void showEditOptions();
- void editLocation(QListWidgetItem*);
- void closeEditOptions();
- void remove();
- void moveUp();
- void moveDown();
- void addAddress();
-
-private:
- Ui::LocationsDisplayWindow *ui;
-};
-
-#endif // LOCATIONSDISPLAYWINDOW_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>LocationsDisplayWindow</class>
- <widget class="QMainWindow" name="LocationsDisplayWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>480</width>
- <height>640</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>MainWindow</string>
- </property>
- <widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QWidget" name="defaultViewWidget" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="newLocButton">
- <property name="text">
- <string>Add new location</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QWidget" name="editViewWidget" native="true">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QPushButton" name="upButton">
- <property name="text">
- <string>Up</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="downButton">
- <property name="text">
- <string>Down</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteButton">
- <property name="text">
- <string>Delete</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="doneButton">
- <property name="text">
- <string>Done</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QListWidget" name="locationsWidget"/>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menuBar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>480</width>
- <height>21</height>
- </rect>
- </property>
- </widget>
- <action name="actionSdfasf">
- <property name="text">
- <string>sdfasf</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections/>
-</ui>
--- /dev/null
+#include "location.h"
+
+#include "ytv.h"
+
+#include <QString>
+#include <QObject>
+#include <QNetworkAccessManager>
+#include <QUrl>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QXmlStreamReader>
+#include <QDebug>
+#include <QXmlStreamAttributes>
+#include <QStringRef>
+#include <QGeoPositionInfo>
+
+#include <math.h>
+
+const double KkjZoneInfo[6][2] = {
+ {18.0, 500000.0},
+ {21.0, 1500000.0},
+ {24.0, 2500000.0},
+ {27.0, 3500000.0},
+ {30.0, 4500000.0},
+ {33.0, 5500000.0}
+};
+
+#ifdef Q_WS_MAEMO_5
+QTM_USE_NAMESPACE
+#endif
+
+ Location::Location( const QString &x, const QString &y, const QString &label ) :
+ m_label(label),
+ m_address(QString()),
+ m_x(x),
+ m_y(y),
+ m_valid(true)
+{
+}
+#ifdef Q_WS_MAEMO_5
+Location::Location(const QGeoPositionInfo &positionInfo, const QString &label) :
+ m_label(label),
+ m_address(QString()),
+ m_x("0"),
+ m_y("0"),
+ m_valid(false)
+{
+ setLocation(positionInfo);
+}
+
+void Location::setLocation(const QGeoPositionInfo &positionInfo)
+{
+ qDebug() << "Setting new location based on GeoPositionInfo";
+ qreal latitude = positionInfo.coordinate().latitude();
+ qreal longitude = positionInfo.coordinate().longitude();
+
+ //qDebug() << "Calculating new values";
+
+ KKJ outX(0);
+ KKJ outY(0);
+
+ WGS84lola_to_KKJxy( longitude, latitude, &outX, &outY);
+
+ /*qDebug() << "Storing new values";
+ qDebug() << "x";
+ qDebug() << outX;
+ qDebug() << "y";
+ qDebug() << outY;*/
+
+ //qDebug() << "Setting x";
+ //this->m_x = QString("%1").arg(outX);
+ this->m_x.setNum(outX);
+ //qDebug() << "Setting y";
+ //this->m_y = QString("%1").arg(outY);
+ this->m_y.setNum(outY);
+ //qDebug() << "Setting as valid";
+ this->m_valid = true;
+ //emit(becomeValid());
+ //qDebug() << "Location set";
+}
+#endif
+
+void Location::setPosition(const QString &x, const QString &y)
+{
+ this->m_x = x;
+ this->m_y = y;
+ this->m_valid = true;
+}
+
+Location::Location(const QString &label) :
+ m_label(label),
+ m_address(QString()),
+ m_x("0"),
+ m_y("0"),
+ m_valid(false)
+{
+}
+
+Location::Location(const Location &other) :
+ m_label(other.m_label),
+ m_address(other.m_address),
+ m_x(other.m_x),
+ m_y(other.m_y),
+ m_valid(other.m_valid)
+{
+}
+
+/*Location* Location::copy_Location(const Location *other)
+{
+ Location *ret = new Location(other->m_x, other->m_y, other->m_label);
+ ret->m_address = other->m_address;
+ ret->m_valid = other->m_valid;
+ return ret;
+}*/
+
+
+QString Location::x() const
+{
+ return m_x;
+}
+
+QString Location::y() const
+{
+ return m_y;
+}
+
+void Location::setLabel(const QString &label)
+{
+ m_label = label;
+}
+
+QString Location::label() const
+{
+ return m_label;
+}
+
+void Location::setAddress(const QString &address)
+{
+ m_address = address;
+}
+
+QString Location::address() const
+{
+ return m_address;
+}
+
+bool Location::isValid() const
+{
+ return m_valid;
+}
+
+// Degrees to radians
+double radians(double deg)
+{
+ return deg * M_PI / 180.0;
+}
+
+// Radians to degrees
+double degrees(double rad)
+{
+ return rad * 180.0 / M_PI;
+}
+
+// Function: KKJ_Zone_I
+int KKJ_Zone_I(KKJ easting)
+{
+ int zoneNumber = floor(easting / 1000000.0);
+ if (zoneNumber < 0 || zoneNumber > 5) {
+ zoneNumber = -1;
+ }
+
+ return zoneNumber;
+}
+
+// Function: KKJ_Zone_Lo
+int KKJ_Zone_Lo(double kkjlo)
+{
+ // determine the zonenumber from KKJ easting
+ // takes KKJ zone which has center meridian
+ // longitude nearest (in math value) to
+ // the given KKJ longitude
+ int zoneNumber = 5;
+ while (zoneNumber >= 0) {
+ if (fabs(kkjlo - KkjZoneInfo[zoneNumber][0]) <= 1.5) {
+ break;
+ }
+ zoneNumber--;
+ }
+
+ return zoneNumber;
+}
+
+
+// Function: KKJlalo_to_WGS84lalo
+void KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude)
+{
+ double dLa = radians(0.124867E+01 + -0.269982E+00 * kkjla + 0.191330E+00 * kkjlo + 0.356119E-02 * kkjla * kkjla + -0.122312E-02 * kkjla * kkjlo + -0.335514E-03 * kkjlo * kkjlo) / 3600.0;
+ double dLo = radians(-0.286111E+02 + 0.114183E+01 * kkjla + -0.581428E+00 * kkjlo + -0.152421E-01 * kkjla * kkjla + 0.118177E-01 * kkjla * kkjlo + 0.826646E-03 * kkjlo * kkjlo) / 3600.0;
+
+ *outLatitude = degrees(radians(kkjla) + dLa);
+ *outLongitude = degrees(radians(kkjlo) + dLo);
+}
+
+
+// Function: WGS84lalo_to_KKJlalo
+void WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude)
+{
+ double dLa = radians(-0.124766E+01 + 0.269941E+00 * latitude + -0.191342E+00 * longitude + -0.356086E-02 * latitude * latitude + 0.122353E-02 * latitude * longitude + 0.335456E-03 * longitude * longitude) / 3600.0;
+ double dLo = radians(0.286008E+02 + -0.114139E+01 * latitude + 0.581329E+00 * longitude + 0.152376E-01 * latitude * latitude + -0.118166E-01 * latitude * longitude + -0.826201E-03 * longitude * longitude) / 3600.0;
+
+ *outLatitude = degrees(radians(latitude) + dLa);
+ *outLongitude = degrees(radians(longitude) + dLo);
+}
+
+
+// Function: KKJlalo_to_KKJxy
+void KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY)
+{
+ // Hayford ellipsoid
+ double a = 6378388.0;
+ double f = 1.0 / 297.0;
+ double b = (1.0 - f) * a;
+ double bb = b * b;
+ double c = (a / b) * a;
+ double ee = (a * a - bb) / bb;
+ double n = (a - b) / (a + b);
+ double nn = n * n;
+
+ double Lo = radians(lon) - radians(KkjZoneInfo[zoneNumber][0]);
+ double cosLa = cos(radians(lat));
+ double NN = ee * cosLa * cosLa;
+ double LaF = atan(tan(radians(lat)) / cos(Lo * sqrt(1.0 + NN)));
+ double cosLaF = cos(LaF);
+ double t = (tan(Lo) * cosLaF) / sqrt(1.0 + ee * cosLaF * cosLaF);
+ double A = a / (1.0 + n);
+ double A1 = A * (1.0 + nn / 4.0 + nn * nn / 64.0);
+ double A2 = A * 1.5 * n * (1.0 - nn / 8.0);
+ double A3 = A * 0.9375 * nn * (1.0 - nn / 4.0);
+ double A4 = A * 35.0 / 48.0 * nn * n;
+
+ *outY = A1 * LaF - A2 * sin(2.0 * LaF) + A3 * sin(4.0 * LaF) - A4 * sin(6.0 * LaF);
+ *outX = c * log(t + sqrt(1.0 + t * t)) + 500000.0 + zoneNumber * 1000000.0;
+}
+
+// Function: KKJxy_to_KKJlalo
+void KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude)
+{
+ // Scan iteratively the target area, until find matching
+ // KKJ coordinate value. Area is defined with Hayford Ellipsoid.
+ int zoneNumber = KKJ_Zone_I(x);
+ double minLo = radians(18.5);
+ double maxLo = radians(32.0);
+ double minLa = radians(59.0);
+ double maxLa = radians(70.5);
+
+ int i = 1;
+ KKJ tmpX, tmpY;
+
+ while (i < 35) {
+ double deltaLo = maxLo - minLo;
+ double deltaLa = maxLa - minLa;
+ *outLongitude = degrees(minLo + 0.5 * deltaLo);
+ *outLatitude = degrees(minLa + 0.5 * deltaLa);
+ KKJlola_to_KKJxy(*outLongitude, *outLatitude, zoneNumber, &tmpX, &tmpY);
+ if (tmpY < y) {
+ minLa = minLa + 0.45 * deltaLa;
+ } else {
+ maxLa = minLa + 0.55 * deltaLa;
+ }
+
+ if (tmpX < x) {
+ minLo = minLo + 0.45 * deltaLo;
+ } else {
+ maxLo = minLo + 0.55 * deltaLo;
+ }
+
+ i++;
+ }
+}
+
+void WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY)
+{
+ double kkjlo, kkjla;
+
+ WGS84lola_to_KKJlola(longitude, latitude, &kkjlo, &kkjla);
+ int zoneNumber = KKJ_Zone_Lo(kkjlo);
+ KKJlola_to_KKJxy(kkjlo, kkjla, zoneNumber, outX, outY);
+}
+
+void KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude)
+{
+ double kkjlo, kkjla;
+
+ KKJxy_to_KKJlola(x, y, &kkjlo, &kkjla);
+ KKJlola_to_WGS84lola(kkjlo, kkjla, outLongitude, outLatitude);
+
+}
--- /dev/null
+#ifndef LOCATION_H
+#define LOCATION_H
+
+#include <QString>
+#include <QObject>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QGeoPositionInfo>
+#include <math.h>
+
+QTM_USE_NAMESPACE;
+
+class Location
+{
+
+public:
+ Location( const QString &x, const QString &y, const QString &label=QString() );
+ Location( const QGeoPositionInfo &positionInfo, const QString &label=QString() );
+ Location( const QString &label=QString() );
+ Location(const Location &location);
+ //Location(const Location *location);
+
+
+ QString x() const;
+
+ QString y() const;
+
+ void setLocation( const QGeoPositionInfo &positionInfo );
+
+ void setPosition(const QString &x, const QString &y);
+
+ void setAddress( const QString &address );
+ QString address() const;
+
+ void setLabel( const QString &label );
+ QString label() const;
+
+ bool isValid() const;
+
+/*Q_SIGNALS:
+ void becomeValid();
+ void becomeInValid();
+ void busy( bool busy );*/
+
+private:
+ QString m_label;
+ QString m_address;
+ QString m_x;
+ QString m_y;
+ bool m_valid;
+};
+
+
+typedef uint KKJ;
+
+/**
+ * Transformes WGS84 longitude/latitude coordinates to KKJ x/y coordinates.
+ * @param longitude the input longitude in degrees
+ * @param latitude the input latitude in degrees
+ * @param outX the result x (easting)
+ * @param outY the result y (northing)
+ */
+void WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY);
+
+/**
+ * Transformes KKJ x/y coordinates to WGS84 longitude/latitude coordinates.
+ * @param x the input x (easting)
+ * @param y the input y (northing)
+ * @param outLongitude the result longitude in degrees
+ * @param outLatitude the result latitude in degrees
+ */
+void KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude);
+
+// Degrees to radians
+double radians(double deg);
+
+// Radians to degrees
+double degrees(double rad);
+
+// Constants
+// Longitude0 and Center meridian of KKJ bands
+//static const double KkjZoneInfo[][2];
+
+// Function: KKJ_Zone_I
+int KKJ_Zone_I(KKJ easting);
+
+// Function: KKJ_Zone_Lo
+int KKJ_Zone_Lo(double kkjlo);
+
+// Function: KKJlalo_to_WGS84lalo
+void KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude);
+
+// Function: WGS84lalo_to_KKJlalo
+void WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude);
+
+// Function: KKJlalo_to_KKJxy
+void KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY);
+
+// Function: KKJxy_to_KKJlalo
+void KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude);
+
+
+#endif // LOCATION_H
--- /dev/null
+#include "locationfinder.h"
+#include "ytv.h"
+
+#include <QString>
+#include <QUrl>
+#include <QXmlStreamReader>
+#include <QDebug>
+#include <QNetworkRequest>
+#include <stdexcept>
+
+#include <QTimer>
+
+LocationFinder::LocationFinder(QString address, QObject *parent) :
+ QObject(parent), address(address), reply(NULL),
+ places(QList<Location*>()), roadNames(QList<Location*>()),
+ stops(QList<Location*>()), invalidResponse(false)
+{
+ QUrl fullUrl(Ytv::Url);
+
+ fullUrl.addEncodedQueryItem( "key", this->address.toAscii().toPercentEncoding() );
+ fullUrl.addQueryItem( "user", Ytv::Username );
+ fullUrl.addQueryItem( "pass", Ytv::Password );
+
+ qDebug() << "The query url: " << fullUrl.toString();
+
+ this->reply = Ytv::manager.get(QNetworkRequest(fullUrl));
+ connect(this->reply, SIGNAL(finished()), this, SLOT(processReply()));
+}
+
+LocationFinder::~LocationFinder()
+{
+ if (this->reply)
+ this->reply->deleteLater();
+
+ while (!this->places.isEmpty())
+ {
+ Location *loc = this->places.takeLast();
+ delete loc;
+ }
+ while (!this->roadNames.isEmpty())
+ {
+ Location *loc = this->roadNames.takeLast();
+ delete loc;
+ }
+ while (!this->stops.isEmpty())
+ {
+ Location *loc = this->stops.takeLast();
+ delete loc;
+ }
+}
+
+
+void LocationFinder::processReply()
+{
+ qDebug() << "Processing reply from Reittiopas in LocationFinder";
+ QXmlStreamReader xml(this->reply->readAll());
+
+ this->reply->disconnect(this, SLOT(searchFinished()));
+ this->reply->deleteLater();
+ this->reply = NULL;
+
+ while (!xml.atEnd())
+ {
+ qDebug() << "Reading next element";
+ xml.readNext();
+
+ if (xml.isStartElement())
+ {
+ QString xmlName(xml.name().toString());
+
+ if (xmlName == "LOC")
+ {
+ QXmlStreamAttributes attributes(xml.attributes());
+ QStringRef xAttribute( attributes.value("x") );
+ QStringRef yAttribute( attributes.value("y") );
+ QString newX( xAttribute.toString() );
+ QString newY( yAttribute.toString() );
+ QString category(attributes.value("category").toString());
+ QString name(attributes.value("name1").toString());
+ QString number(attributes.value("number").toString());
+ if (!number.isEmpty())
+ {
+ name.append(" ");
+ name.append(number);
+ }
+ name.append(", ");
+ name.append(attributes.value("city").toString());
+
+ if (category == "poi")
+ {
+ this->places.append(new Location(newX, newY, name));
+ }
+ else if (category == "street")
+ {
+ this->roadNames.append(new Location(newX, newY, name));
+ }
+ else if (category == "stop")
+ {
+ this->stops.append(new Location(newX, newY, name));
+ }
+ else
+ {
+ QString errorMessage("Unknown category: ");
+ errorMessage.append(category);
+ qDebug() << errorMessage;
+ }
+ }
+
+ if (xmlName == "ERROR") {
+ this->invalidResponse = true;
+ }
+
+ }
+ }
+
+ qDebug() << xml.errorString();
+ if ( xml.hasError() ) {
+ qDebug() << "Invalid response received from Ytv";
+ this->invalidResponse = true;
+ } else {
+ int locationsFound = this->places.size() + this->roadNames.size() + this->stops.size();
+ qDebug() << "Number of locations received: " + locationsFound;
+ }
+ qDebug() << "Exiting xml parsing.";
+
+ emit(finished());
+}
+
+bool LocationFinder::responseWasValid() const
+{
+ return !this->invalidResponse;
+}
+
+bool LocationFinder::locationsFound() const
+{
+ return (this->numberOfLocationsFound() > 0);
+}
+
+int LocationFinder::numberOfLocationsFound() const
+{
+ return this->numberOfPlaces() + this->numberOfRoadNames() + this->numberOfStops();
+}
+
+int LocationFinder::numberOfPlaces() const
+{
+ return this->places.size();
+}
+
+int LocationFinder::numberOfRoadNames() const
+{
+ return this->roadNames.size();
+}
+
+int LocationFinder::numberOfStops() const
+{
+ return this->stops.size();
+}
+
+Location* LocationFinder::getPlace(int index) const
+{
+ if (index < 0 || index >= this->places.size())
+ throw std::invalid_argument("Given index out of bounds.");
+
+ return new Location(*(this->places.at(index)));
+}
+
+Location* LocationFinder::getRoadName(int index) const
+{
+ if (index < 0 || index >= this->roadNames.size())
+ throw std::invalid_argument("Given index out of bounds.");
+
+ return new Location(*(this->roadNames.at(index)));
+}
+
+Location* LocationFinder::getStop(int index) const
+{
+ if (index < 0 || index >= this->stops.size())
+ throw std::invalid_argument("Given index out of bounds.");
+
+ return new Location(*(this->stops.at(index)));
+}
+
+const QList<Location*>& LocationFinder::getPlaces() const
+{
+ return this->places;
+}
+
+const QList<Location*>& LocationFinder::getRoadNames() const
+{
+ return this->roadNames;
+}
+
+const QList<Location*>& LocationFinder::getStops() const
+{
+ return this->stops;
+}
--- /dev/null
+#ifndef LOCATIONFINDER_H
+#define LOCATIONFINDER_H
+
+#include <QThread>
+#include <QNetworkReply>
+#include <QList>
+#include <QMutex>
+#include <QWaitCondition>
+#include "location.h"
+
+
+
+
+class LocationFinder : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LocationFinder(QString address, QObject *parent = 0);
+ ~LocationFinder();
+
+ bool responseWasValid() const;
+ bool locationsFound() const;
+ int numberOfLocationsFound() const;
+ int numberOfPlaces() const;
+ int numberOfRoadNames() const;
+ int numberOfStops() const;
+
+ /** The caller of these methods is responsible for deleting the Locations returned by these methods. */
+ Location* getPlace(int index) const;
+ Location* getRoadName(int index) const;
+ Location* getStop(int index) const;
+
+ /** These functions return lists of pointers to Locations.
+ The Locations will be deleted after LocationFinder is deleted, so use upper methods to get Locations that will not be deleted with this LocationFinder.*/
+ const QList<Location*>& getPlaces() const;
+ const QList<Location*>& getRoadNames() const;
+ const QList<Location*>& getStops() const;
+
+private slots:
+ void processReply();
+
+signals:
+ void finished();
+
+private:
+
+ QString address;
+ QNetworkReply *reply;
+ QList<Location*> places, roadNames, stops;
+ bool invalidResponse;
+};
+
+#endif // LOCATIONFINDER_H
--- /dev/null
+#include "locations.h"
+#include "location.h"
+
+#include <QDebug>
+#include <QHash>
+#include <QSettings>
+#include <QString>
+#include <QStringList>
+#include <QCoreApplication>
+#include <QMap>
+#include <QMapIterator>
+#include <QList>
+
+Locations* Locations::m_instance = 0;
+
+Locations* Locations::GetInstance()
+{
+ if (m_instance == 0)
+ m_instance = new Locations();
+
+ return m_instance;
+}
+
+/*void Locations::destroyLocations()
+{
+ delete m_instance;
+}*/
+
+Locations::Locations() :
+ m_locationStorage(QHash<QString,Location *>()),
+ m_indexStorage(QList<QString>()),
+ m_gpsLocation(new Location("GPS"))
+{
+ this->restoreLocations();
+ qDebug() << "Size of index storage:" << this->m_indexStorage.size();
+}
+
+/*Locations::~Locations()
+{
+ QHash<QString,Location*>::iterator it, ite;
+ for (it = this->m_locationStorage.begin(), ite = this->m_locationStorage.end(); it != ite; ++it)
+ {
+ delete it.value();
+ }
+ this->m_locationStorage.empty();
+ delete m_gpsLocation;
+}*/
+
+bool Locations::addEditLocation(Location *location)
+{
+ bool addedNew=false;
+
+ if ( !this->m_locationStorage.contains(location->label())) {
+ qDebug() << "Adding location" << location->label();
+ this->m_locationStorage[location->label()] = location;
+ qDebug() << "Index storage:";
+ qDebug() << this->m_indexStorage;
+ qDebug() << "Size of index storage:" << this->m_indexStorage.size();
+ this->m_indexStorage.append(location->label());
+ qDebug() << "Index storage after inserting location:";
+ qDebug() << this->m_indexStorage;
+ addedNew = true;
+ } else {
+ qDebug() << "A location with the same label (" << location->label() << ") already exists.";
+ this->m_locationStorage.remove(location->label());
+ this->m_locationStorage[location->label()] = location;
+ }
+ emit(locationsChanged());
+
+ // save the location to settings
+ this->saveLocation(location);
+
+ return addedNew;
+}
+
+void Locations::restoreLocations()
+{
+ QSettings settings;
+
+ settings.beginGroup("Locations");
+ QStringList labels = settings.childGroups();
+
+ QMap<QString, int> tempIndex = QMap<QString, int>();
+
+ for( int i=0; i<labels.size(); ++i ) {
+ QString label = labels[i];
+ settings.beginGroup(label);
+ QString address, x, y;
+ bool valid = false;
+ if (settings.contains("address")) {
+ address = settings.value( "address" ).toString();
+ if (settings.contains("x")) {
+ x = settings.value( "x" ).toString();
+ if (settings.contains("y")) {
+ y = settings.value( "y" ).toString();
+ valid = true;
+ }
+ }
+ }
+ int index = settings.value("index").toInt();
+ settings.endGroup();
+
+ qDebug() << "Restoring " << label;
+ Location *location;
+ if (valid) {
+ location = new Location( x, y, label );
+ location->setAddress(address);
+ }
+ else
+ location = new Location(label);
+
+ this->m_locationStorage[label] = location;
+ this->m_indexStorage.append(label);
+ if (index != 0)
+ tempIndex.insert(label, index);
+ }
+
+ settings.endGroup();
+
+ qDebug() << "Locations indexes before restoring positions";
+ qDebug() << this->m_indexStorage;
+ qDebug() << "Restoring these locations positions.";
+ qDebug() << tempIndex;
+
+ // Swap locations to correct indexes.
+ QMap<QString, int>::iterator it, ite;
+ for (it = tempIndex.begin(), ite = tempIndex.end(); it != ite; ++it)
+ {
+ int oldIndex = this->m_indexStorage.indexOf(it.key());
+ // Only operate on this item if current index is not the same as specified
+ if (it.value() != oldIndex + 1)
+ {
+ // Move to last if requested index is greater than the number of items.
+ if (it.value() >= this->m_indexStorage.size()) {
+ this->m_indexStorage.swap(oldIndex, this->m_indexStorage.size() - 1);
+ }
+ else {
+ this->m_indexStorage.swap(oldIndex, it.value() - 1);
+ }
+ }
+ }
+
+ qDebug() << "Locations indexes after positions are restored.";
+ qDebug() << this->m_indexStorage;
+}
+
+void Locations::saveLocation(Location *location)
+{
+ if (!location) {
+ qDebug() << "Null location given to saveLocation. Aborting";
+ return;
+ }
+ qDebug() << "Saving location " << location->label();
+ QSettings settings;
+ settings.beginGroup("Locations");
+ settings.beginGroup(location->label() );
+ if (location->isValid()) {
+ settings.setValue( "address", location->address() );
+ settings.setValue( "x", location->x() );
+ settings.setValue( "y", location->y() );
+ }
+ else {
+ if (settings.contains("address")) settings.remove("address");
+ if (settings.contains("x")) settings.remove("x");
+ if (settings.contains("y")) settings.remove("y");
+ }
+ settings.setValue("index", this->m_indexStorage.indexOf(location->label()) + 1);
+ settings.endGroup();
+ settings.endGroup();
+}
+
+bool Locations::removeLocation(Location *location)
+{
+ bool succeeded = false;
+ qDebug() << "Trying to remove location " << location->label();
+ QSettings settings;
+ settings.beginGroup("Locations");
+ if (settings.contains("" + location->label() + "/index"))
+ {
+ qDebug() << "Given location exists in settings -> removing it";
+ settings.remove(location->label());
+ succeeded = true;
+ }
+ settings.endGroup();
+
+ if (this->m_locationStorage.contains(location->label()))
+ {
+ qDebug() << "Given location exists in locations list -> removing it";
+ this->m_locationStorage.remove(location->label());
+ //int remIndex = this->m_indexStorage.value(location->label());
+ this->m_indexStorage.removeOne(location->label());
+ /*for (int ind = 0; ind < this->m_indexStorage.size(); ++ind)
+ {
+ if (this->m_indexStorage.value(this->m_indexStorage > remIndex)
+ {
+ it.value() -= 1;
+ this->saveLocation(this->getLocation(it.key()), it.value());
+ }
+ }*/
+ emit(locationsChanged());
+ }
+ return succeeded;
+}
+
+Location *Locations::getLocation(const QString &label) const
+{
+ qDebug() << "requesting location " << label;
+ Location *retVal = NULL;
+
+ if (this->m_locationStorage.contains(label)) {
+ qDebug() << "found location " << label;
+ retVal = this->m_locationStorage[label];
+ } else {
+ qDebug() << "didn't find location " << label;
+ }
+
+ return retVal;
+}
+
+/*void Locations::changeIndex(const QString &label, const int &index, bool signal)
+{
+ int oldIndex = this->m_indexStorage.value(label);
+ if (index == oldIndex)
+ return;
+
+ qDebug() << "Index map before moving " << label << " from index " << oldIndex << " to index " << index;
+ qDebug() << this->m_indexStorage;
+ QHash<QString, int>::iterator it, ite;
+ if (index < oldIndex)
+ {
+ for (it = this->m_indexStorage.begin(), ite = this->m_indexStorage.end(); it != ite; ++it)
+ {
+ if (it.value() >= index && it.value() < oldIndex)
+ {
+ this->saveLocation(this->getLocation(label), ++(it.value()));
+ }
+ }
+ }
+ else
+ for (it = this->m_indexStorage.begin(), ite = this->m_indexStorage.end(); it != ite; ++it)
+ if (it.value() <= index && it.value() > oldIndex)
+ this->saveLocation(this->getLocation(label), --(it.value()));
+
+ this->m_indexStorage[label] = index;
+ this->saveLocation(this->getLocation(label), index);
+
+ qDebug() << "Index map after move";
+ qDebug() << this->m_indexStorage;
+ if (signal)
+ emit(locationsChanged());
+}*/
+
+Location *Locations::getLocation(const int &index) const
+{
+ qDebug() << "Getting location for index" << index;
+ Location *loc = NULL;
+ /*QString label;
+ if (this->findLabel(index, label))
+ {
+ qDebug() << "Found a label with given index " << index;
+ qDebug() << "Found label is " << label;
+ loc = this->getLocation(label);
+ }*/
+ if (index <= 0 || index > this->m_indexStorage.size())
+ return loc;
+
+ QString label = this->m_indexStorage.at(index - 1);
+ loc = this->m_locationStorage.value(label);
+ return loc;
+}
+
+/*bool Locations::findLabel(const int &index, QString &label) const
+{
+ qDebug() << "Finding label for index" << index << ". Number of items in indexStorage:" << this->m_indexStorage.size() << ". Number of items in locationStorage:" << this->m_locationStorage.size();
+ qDebug() << "Location storage";
+ qDebug() << this->m_locationStorage;
+ qDebug() << "Index storage";
+ qDebug() << this->m_indexStorage;
+
+ if (index > this->m_indexStorage.size() || index < 1)
+ return false;
+ bool found = false;
+ QHash<QString, int>::const_iterator it, ite;
+ for (it = this->m_indexStorage.constBegin(), ite = this->m_indexStorage.constEnd(); it != ite; ++it)
+ {
+ if (it.value() == index)
+ {
+ label = it.key();
+ qDebug() << "Found label is " << label;
+ found = true;
+ break;
+ }
+ }
+ qDebug() << "Returning from label search.";
+ return found;
+}*/
+
+/*const QHash<QString, Location *>& Locations::getLocations() const
+{
+ return this->m_locationStorage;
+}*/
+
+Location *Locations::getGpsLocation() const
+{
+ qDebug() << "GPS location requested.";
+ return this->m_gpsLocation;
+}
+
+bool Locations::increaseLocationIndex(const QString &label)
+{
+ if (!this->m_indexStorage.contains(label))
+ {
+ qDebug() << "Given label \"" << label << "\" does not exist in indexStorage.";
+ qDebug() << "Contents of indexStorage: " << this->m_indexStorage;
+ return false;
+ }
+ qDebug() << "Increasing index by one for label" << label;
+ int oldIndex = this->m_indexStorage.indexOf(label);
+ if (oldIndex == -1)
+ return false;
+ if (oldIndex == this->m_indexStorage.size() - 1)
+ return false;
+ this->m_indexStorage.move(oldIndex, oldIndex + 1);
+ this->saveLocation(this->m_locationStorage.value(label));
+ emit(locationsChanged());
+ /*QString otherLabel;
+ if (this->findLabel(oldIndex + 1, otherLabel))
+ {
+ this->m_indexStorage[label] = oldIndex + 1;
+ this->m_indexStorage[otherLabel] = oldIndex;
+ done = true;
+ emit(locationsChanged());
+ }*/
+ return true;
+}
+
+bool Locations::lowerLocationIndex(const QString &label)
+{
+ if (!this->m_indexStorage.contains(label))
+ return false;
+ qDebug() << "Lowering index by one for label" << label;
+ int oldIndex = this->m_indexStorage.indexOf(label);
+ if (oldIndex == -1) //Not found
+ return false;
+ if (oldIndex == 0) // Already first
+ return false;
+ this->m_indexStorage.move(oldIndex, oldIndex - 1);
+ this->saveLocation(this->m_locationStorage.value(label));
+ emit(locationsChanged());
+ /*QString otherLabel;
+ if (this->findLabel(oldIndex - 1, otherLabel))
+ {
+ this->m_indexStorage[label] = oldIndex - 1;
+ this->m_indexStorage[otherLabel] = oldIndex;
+ done = true;
+ emit(locationsChanged());
+ }*/
+ return true;
+}
+
+int Locations::size() const
+{
+ return this->m_locationStorage.size();
+}
--- /dev/null
+#ifndef LOCATIONS_H
+#define LOCATIONS_H
+
+#include "location.h"
+
+#include <QHash>
+#include <QList>
+#include <QString>
+#include <QObject>
+
+class Locations: public QObject
+{
+ Q_OBJECT
+
+public:
+ static Locations *GetInstance();
+ //static void destroyLocations();
+
+ bool addEditLocation(Location *location);
+ bool removeLocation(Location *location);
+
+ bool increaseLocationIndex(const QString &label);
+ bool lowerLocationIndex(const QString &label);
+
+ Location *getLocation(const QString &label) const;
+ Location *getLocation(const int&) const;
+ Location *getGpsLocation() const;
+ int size() const;
+
+ //const QHash<QString, Location *>& getLocations() const;
+
+signals:
+ void locationsChanged();
+
+private:
+ Locations();
+ //~Locations();
+ Locations(const Locations&);
+ void operator=(const Locations&);
+
+ void restoreLocations();
+ void saveLocation(Location *location);
+ bool findLabel(const int &index, QString &label) const;
+ void changeIndex(const QString &label, const int &index, bool signal = true);
+
+ QHash<QString, Location*> m_locationStorage;
+ QList<QString> m_indexStorage;
+ Location* m_gpsLocation;
+
+ static Locations *m_instance;
+};
+#endif // LOCATIONS_H
--- /dev/null
+#include "routefinder.h"
+#include "location.h"
+#include "locationfinder.h"
+#include "ytv.h"
+#include "routenew.h"
+#include "routepointgenerator.h"
+#include "routeleggenerator.h"
+
+#include <QDebug>
+#include <QXmlStreamReader>
+#include <QStringList>
+#include <QDateTime>
+#include <QList>
+#include <stdexcept>
+#include <QCoreApplication>
+#include <QEventLoop>
+
+Location* getTopLocation(LocationFinder* finder);
+
+
+RouteFinder::RouteFinder(const Location &from, const Location &to, QObject *parent) :
+ QObject(parent), from(new Location(from)), to(new Location(to)),
+ reply(NULL), routes(QList<RouteNew*>())
+{
+ this->fromFinder = NULL;
+ if (!this->from->isValid())
+ {
+ qDebug() << "Find location for from address.";
+ this->fromFinder = new LocationFinder(this->from->address());
+ this->connect(this->fromFinder, SIGNAL(finished()), SLOT(fromLocationFound()));
+ }
+
+ this->toFinder = NULL;
+ if (!this->to->isValid())
+ {
+ qDebug() << "Find location for to address.";
+ this->toFinder = new LocationFinder(this->to->address());
+ this->connect(this->toFinder, SIGNAL(finished()), SLOT(toLocationFound()));
+ }
+
+ if (this->fromFinder == NULL && this->toFinder == NULL)
+ this->startRouteSearch();
+}
+
+void RouteFinder::fromLocationFound()
+{
+ qDebug() << "FROM location request is finished.";
+ if (!this->fromFinder->responseWasValid())
+ {
+ qDebug() << "Response from ytv for FROM location was not valid.";
+ return;
+ }
+ if (this->fromFinder->numberOfLocationsFound() == 0)
+ {
+ qDebug() << "No locations were found for FROM location";
+ return;
+ }
+ this->from = getTopLocation(this->fromFinder);
+
+ if (this->to->isValid())
+ this->startRouteSearch();
+}
+
+void RouteFinder::toLocationFound()
+{
+ qDebug() << "TO location request is finished.";
+ if (!this->toFinder->responseWasValid())
+ {
+ qDebug() << "Response from ytv for TO location was not valid.";
+ return;
+ }
+ if (this->toFinder->numberOfLocationsFound() == 0)
+ {
+ qDebug() << "No locations were found for TO location";
+ return;
+ }
+ this->to = getTopLocation(this->toFinder);
+
+ if (this->from->isValid())
+ this->startRouteSearch();
+}
+
+void RouteFinder::startRouteSearch()
+{
+ qDebug() << "Ready to search for route now.";
+
+ QUrl fullUrl( Ytv::Url );
+
+ QStringList a;
+ a << this->from->x() << this->from->y();
+ QStringList b;
+ b << this->to->x() << this->to->y();
+
+ fullUrl.addQueryItem( "a", a.join(",") );
+ fullUrl.addQueryItem( "b", b.join(",") );
+ fullUrl.addQueryItem( "show", QString::number(Ytv::ShowFiveResults) );
+ fullUrl.addQueryItem( "walkspeed", QString::number(Ytv::WalkSpeedFast) );
+ fullUrl.addQueryItem( "optimize", QString::number(Ytv::OptimizeDefault) );
+ fullUrl.addQueryItem( "user", Ytv::Username);
+ fullUrl.addQueryItem( "pass", Ytv::Password);
+
+ qDebug() << "The query url: " << fullUrl.toString();
+
+ this->reply = Ytv::manager.get(QNetworkRequest(fullUrl));
+ this->connect(this->reply, SIGNAL(finished()), SLOT(requestFinished()));
+}
+
+RouteFinder::~RouteFinder()
+{
+ delete this->from;
+ delete this->to;
+ delete this->fromFinder;
+ delete this->toFinder;
+ if (this->reply)
+ this->reply->deleteLater();
+
+ while (!this->routes.isEmpty())
+ {
+ RouteNew* route = this->routes.takeLast();
+ delete route;
+ }
+}
+
+Location* getTopLocation(LocationFinder* finder)
+{
+ Location* ret;
+ if (finder->numberOfPlaces() > 0)
+ ret = finder->getPlace(0);
+ else if (finder->numberOfRoadNames() > 0)
+ ret = finder->getRoadName(0);
+ else if (finder->numberOfStops() > 0)
+ ret = finder->getStop(0);
+ else
+ throw std::runtime_error("No locations found from given LocationFinder.");
+
+ return ret;
+}
+
+int RouteFinder::getNumberOfRoutes() const
+{
+ return this->routes.size();
+}
+
+RouteNew* RouteFinder::getRoute(int index) const
+{
+ if (index < 0 || index >= this->routes.size() )
+ throw std::invalid_argument("Given index out of bounds.");
+ RouteNew *ret = new RouteNew(*(this->routes.at(index)));
+ return ret;
+}
+
+QString parseLineSymbol(QString &code)
+{
+ /*
+Line code in the routing response is a unique code from the Register of Public Transport (JORE). The code the passengers know and which can be seen on the bus can be parsed from the JORE-code with the help of transport type id (attribute type in the response).
+
+Please note that there are some special cases such as 1300-series (subway), 1100-series (Helsinki night buses) and 1019 (ferry to Suomenlinna).
+JORE line codes are always 7 characters long. For example “2102T 1” which is JORE code for line 102T.
+
+The code consists of following parts:
+1. character = area/transport type code (e.g. 2)
+2.-4. character = line code (e.g. 102)
+5. character = letter variant (e.g. T)
+6. character = letter variant or numeric variant (numeric variants are usually not used for base routes and are not shown to the end users)
+7. character = direction (always 1 or 2), not shown to end users
+
+More detailed instructions can be asked from YTV.
+Area/transport types are:
+1=Helsinki internal traffic
+2=Espoo internal bus traffic and regional bus traffic from Helsinki to Espoo
+3=Local trains
+4=Vantaa internal bus traffic and regional bus traffic from Helsinki to Vantaa
+5=Regional transverse traffic in Espoo - Helsinki - Vantaa
+6=not in use
+7=U-lines (buses that drive also outside the YTV area of service)
+*/
+
+ QString retVal;
+
+ QString areaTransportTypeCode( code.mid(0,1) );
+ QString lineCode( code.mid(1,3) );
+ QString letterVariant( code.mid(4,1) );
+ QString letterNumberVariant( code.mid(5,1) );
+ QString direction( code.mid(6,1) );
+
+ lineCode.setNum( lineCode.toInt() );
+
+ retVal = lineCode;
+
+ if ( letterVariant != " " )
+ {
+ retVal += letterVariant;
+ }
+
+ return retVal;
+}
+
+
+QDateTime parseArrivalDeparture(QXmlStreamReader &reader)
+{
+ qDebug() << "Parsing ARRIVAL or DEPARTURE";
+
+ QXmlStreamAttributes attributes(reader.attributes());
+ QString date = attributes.value("date").toString();
+ QString time = attributes.value("time").toString();
+ QDateTime arrdep = RoutePointGenerator::parseDateTime(date, time);
+
+ reader.readNext();
+
+ qDebug() << "ARRIVAL or DEPARTURE parsed";
+
+ return arrdep;
+}
+
+RoutePoint* parsePoint(QXmlStreamReader &reader)
+{
+ qDebug() << "Parsing POINT";
+
+ QDateTime arrival, departure;
+ QString x, y;
+
+ QXmlStreamAttributes attributes(reader.attributes());
+ x = attributes.value("x").toString();
+ y = attributes.value("y").toString();
+
+ while (!reader.atEnd() && !(reader.name() == "POINT" && reader.tokenType() == QXmlStreamReader::EndElement))
+ {
+ reader.readNext();
+
+ if (reader.name() == "ARRIVAL" && reader.isStartElement())
+ {
+ arrival = parseArrivalDeparture(reader);
+ }
+ else if (reader.name() == "DEPARTURE" && reader.isStartElement())
+ {
+ departure = parseArrivalDeparture(reader);
+ }
+ }
+
+ RoutePoint *point = RoutePointGenerator::createPointPoint(arrival, departure, x, y);
+
+ qDebug() << "POINT parsed";
+
+ return point;
+}
+
+RoutePoint* parseMapLoc(QXmlStreamReader &reader)
+{
+ qDebug() << "Parsing MAPLOC";
+
+ QDateTime arrival, departure;
+ QString x, y, name;
+
+ QXmlStreamAttributes attributes(reader.attributes());
+ x = attributes.value("x").toString();
+ y = attributes.value("y").toString();
+
+ while (!reader.atEnd() && !(reader.name() == "MAPLOC" && reader.tokenType() == QXmlStreamReader::EndElement))
+ {
+ reader.readNext();
+
+ if (reader.name() == "ARRIVAL" && reader.isStartElement())
+ {
+ arrival = parseArrivalDeparture(reader);
+ }
+ else if (reader.name() == "DEPARTURE" && reader.isStartElement())
+ {
+ departure = parseArrivalDeparture(reader);
+ }
+ else if (reader.name() == "NAME" && reader.isStartElement())
+ {
+ // There may be zero, one or two NAME elements.
+ // Finnish name has attribute lang="1".
+ // Swedish name has attribute lang="2".
+ if (reader.attributes().value("lang") == "1")
+ name = reader.attributes().value("val").toString();
+ }
+ }
+
+ RoutePoint* point = RoutePointGenerator::createPointMapLocation(arrival, departure, x, y, name);
+
+ qDebug() << "MAPLOC parsed";
+
+ return point;
+}
+
+RoutePoint* parseStop(QXmlStreamReader &reader)
+{
+ qDebug() << "Parsing STOP";
+
+ QDateTime arrival, departure;
+ QString x, y, name;
+
+ QXmlStreamAttributes attributes(reader.attributes());
+ x = attributes.value("x").toString();
+ y = attributes.value("y").toString();
+
+ while (!reader.atEnd() && !(reader.name() == "STOP" && reader.tokenType() == QXmlStreamReader::EndElement))
+ {
+ reader.readNext();
+
+ if (reader.name() == "ARRIVAL" && reader.isStartElement())
+ {
+ arrival = parseArrivalDeparture(reader);
+ }
+ else if (reader.name() == "DEPARTURE" && reader.isStartElement())
+ {
+ departure = parseArrivalDeparture(reader);
+ }
+ else if (reader.name() == "NAME" && reader.isStartElement())
+ {
+ // There may be one or two NAME elements.
+ // Finnish name has attribute lang="1".
+ // Swedish name has attribute lang="2".
+ if (reader.attributes().value("lang") == "1")
+ name = reader.attributes().value("val").toString();
+ }
+ }
+
+ RoutePoint* point = RoutePointGenerator::createPointStop(arrival, departure, x, y, name);
+
+ qDebug() << "STOP parsed";
+
+ return point;
+}
+
+void parseLength(QXmlStreamReader &reader, QTime &time, double &distance)
+{
+ qDebug() << "Parsing LENGTH";
+ QXmlStreamAttributes attributes(reader.attributes());
+ time = RouteLegGenerator::parseTime(attributes.value("time").toString());
+ distance = attributes.value("dist").toString().toDouble();
+
+ reader.readNext();
+
+ qDebug() << "LENGTH parsed";
+
+ return;
+}
+
+RouteLeg* parseWalk(QXmlStreamReader &reader)
+{
+ qDebug() << "Parsing WALK";
+
+ double distance;
+ QTime time;
+ RoutePoint *startPoint, *endPoint;
+ QList<RoutePoint*> midpoints;// = QList<RoutePoint*>();
+
+ bool startFound = false;
+ bool endFound = false;
+
+ while (!reader.atEnd() && !(reader.name() == "WALK" && reader.tokenType() == QXmlStreamReader::EndElement))
+ {
+ reader.readNext();
+
+ if (reader.name() == "LENGTH" && reader.isStartElement())
+ {
+ // One LENGTH element in WALK.
+ parseLength(reader, time, distance);
+ }
+ else if (reader.name() == "POINT" && reader.isStartElement())
+ {
+ // Multiple POINT, MAPLOC or STOP elements may be found. All but first and last will be appended to midpoints list.
+ // If first one is not found yet, don't append point to list, but store it to startPoint.
+ // If first one is found but last one is not, don't append to list, but store it to endPoint.
+ // Else, append endPoint to list and store new one to endPoint.
+ if (!startFound)
+ {
+ startPoint = parsePoint(reader);
+ startFound = true;
+ }
+ else if (!endFound)
+ {
+ endPoint = parsePoint(reader);
+ endFound = true;
+ }
+ else
+ {
+ midpoints.append(endPoint);
+ endPoint = parsePoint(reader);
+ }
+ }
+ else if (reader.name() == "MAPLOC" && reader.isStartElement())
+ {
+ // Read comments from above. POINT
+ if (!startFound)
+ {
+ startPoint = parseMapLoc(reader);
+ startFound = true;
+ }
+ else if (!endFound)
+ {
+ endPoint = parseMapLoc(reader);
+ endFound = true;
+ }
+ else
+ {
+ midpoints.append(endPoint);
+ endPoint = parseMapLoc(reader);
+ }
+ }
+ else if (reader.name() == "STOP" && reader.isStartElement())
+ {
+ // Read comments from above. POINT
+ if (!startFound)
+ {
+ startPoint = parseStop(reader);
+ startFound = true;
+ }
+ else if (!endFound)
+ {
+ endPoint = parseStop(reader);
+ endFound = true;
+ }
+ else
+ {
+ midpoints.append(endPoint);
+ endPoint = parseStop(reader);
+ }
+ }
+ }
+
+ RouteLeg *walk = RouteLegGenerator::createLegWalk(distance, time, startPoint, endPoint, midpoints);
+
+ qDebug() << "WALK parsed.";
+
+ return walk;
+}
+
+RouteLeg* parseLine(QXmlStreamReader &reader)
+{
+ qDebug() << "Parsing LINE";
+
+ double distance;
+ QTime time;
+ RoutePoint *startPoint, *endPoint;
+ QList<RoutePoint*> midpoints;// = QList<RoutePoint*>();
+
+ bool startFound = false;
+ bool endFound = false;
+
+ QXmlStreamAttributes attributes(reader.attributes());
+ QString code = attributes.value("code").toString();
+ int type = attributes.value("type").toString().toInt();
+
+ while (!reader.atEnd() && !(reader.name() == "LINE" && reader.tokenType() == QXmlStreamReader::EndElement))
+ {
+ reader.readNext();
+
+ if (reader.name() == "LENGTH" && reader.isStartElement())
+ {
+ // One LENGTH element in WALK.
+ parseLength(reader, time, distance);
+ }
+ else if (reader.name() == "STOP" && reader.isStartElement())
+ {
+ // Multiple STOP elements may be found. No other LEG_TYPEs are possible. All but first and last will be appended to midpoints list.
+ // If first one is not found yet, don't append point to list, but store it to startPoint.
+ // If first one is found but last one is not, don't append to list, but store it to endPoint.
+ // Else, append endPoint to list and store new one to endPoint.
+ if (!startFound)
+ {
+ startPoint = parseStop(reader);
+ startFound = true;
+ }
+ else if (!endFound)
+ {
+ endPoint = parseStop(reader);
+ endFound = true;
+ }
+ else
+ {
+ midpoints.append(endPoint);
+ endPoint = parseStop(reader);
+ }
+ }
+ }
+
+ /* Types from reittiopas:
+ Transport types:
+ 1 Helsinki/bus
+ 2 Helsinki/tram
+ 3 Espoo internal
+ 4 Vantaa internal
+ 5 Regional traffic
+ 6 Metro traffic
+ 7 Ferry
+ 8 U-lines
+ 9 Other local traffic
+ 10 Long-distance traffic
+ 11 Express
+ 12 VR local traffic
+ 13 VR long-distance traffic
+ 14 All
+ 21 Helsinki service lines
+ 22 Helsinki night traffic
+ 23 Espoo service lines
+ 24 Vantaa service lines
+ 25 Regional night traffic
+ (types 9,10,11,13,14 are not used in the data)
+*/
+ RouteLeg* line = NULL;
+ if (type == 6)
+ {
+ // Metro
+ line = RouteLegGenerator::createLegSub(distance, time, startPoint, endPoint, midpoints);
+ }
+ else if (type == 2)
+ {
+ // Tram
+ QString symbol = parseLineSymbol(code);
+ line = RouteLegGenerator::createLegTram(distance, time, startPoint, endPoint, midpoints, symbol);
+ }
+ else if (type == 1 || type == 3 || type == 4 || type == 5 || type == 8 || type == 21 || type == 22 || type == 23 || type == 24 || type == 25)
+ {
+ // Bus
+ QString symbol = parseLineSymbol(code);
+ line = RouteLegGenerator::createLegBus(distance, time, startPoint, endPoint, midpoints, symbol);
+ }
+ else if (type == 7)
+ {
+ // Ferry
+ line = RouteLegGenerator::createLegFerry(distance, time, startPoint, endPoint, midpoints);
+ }
+ else if (type == 12)
+ {
+ // Train
+ QString symbol = parseLineSymbol(code);
+ symbol = symbol.mid(1,1);
+ line = RouteLegGenerator::createLegTrain(distance, time, startPoint, endPoint, midpoints, symbol);
+ }
+ else
+ qDebug() << "Type mismatch (" << type << "!!!! Returning NULL!!!!";
+
+ qDebug() << "LINE parsed.";
+
+ return line;
+}
+
+RouteNew* parseRoute(QXmlStreamReader &reader)
+{
+ QDateTime routeStartTime;
+ QDateTime routeEndTime;
+ RoutePoint *routeStartPoint;
+ RoutePoint *routeEndPoint;
+ double routeWalkingDistance = 0.0;
+ double routeDistance;
+ QList<RouteLeg*> routeSubRoute;
+
+ qDebug() << "Parsing route";
+ while (!reader.atEnd() && !(reader.name() == "ROUTE" && reader.tokenType() == QXmlStreamReader::EndElement))
+ {
+ // No attributes
+ reader.readNext();
+
+ if (reader.name() == "LENGTH" && reader.isStartElement())
+ {
+ // Only one LENGTH element per route.
+ QTime time;
+ parseLength(reader, time, routeDistance);
+ }
+ else if (reader.name() == "POINT" && reader.isStartElement())
+ {
+ // Two POINT elements per route. One for start and dest points.
+ // Start point has attribute uid="start" and dest has attribute uid="dest".
+ if (reader.attributes().value("uid") == "start")
+ routeStartPoint = parsePoint(reader);
+ else if (reader.attributes().value("uid") == "dest")
+ routeEndPoint = parsePoint(reader);
+ }
+ else if (reader.name() == "WALK" && reader.isStartElement())
+ {
+ routeSubRoute.append(parseWalk(reader));
+ }
+ else if (reader.name() == "LINE" && reader.isStartElement())
+ {
+ routeSubRoute.append(parseLine(reader));
+ }
+ }
+
+ routeStartTime = routeStartPoint->departure_time;
+ routeEndTime = routeEndPoint->arrival_time;
+ RouteNew *route = new RouteNew(routeStartTime, routeEndTime, routeStartPoint, routeEndPoint, routeWalkingDistance, routeDistance, routeSubRoute);
+
+ qDebug() << "Route parsed.";
+
+ return route;
+}
+
+void RouteFinder::requestFinished()
+{
+ qDebug() << "Route response received from Ytv.";
+
+ QXmlStreamReader xml(this->reply->readAll());
+
+ //this->reply->disconnect(this, SLOT(requestFinished()));
+ this->reply->deleteLater();
+ this->reply = NULL;
+
+ while (!xml.atEnd())
+ {
+ //qDebug() << "Reading next element";
+ xml.readNext();
+
+ QString xmlName(xml.name().toString());
+
+ //qDebug() << "Element name: " + xmlName + " Type: " + xml.tokenString();
+ if (xmlName == "ROUTE" && xml.isStartElement())
+ {
+ this->routes.append(parseRoute(xml));
+ }
+ }
+
+ qDebug() << "Finished processing RouteFinder";
+ emit(finished());
+ return;
+}
--- /dev/null
+#ifndef ROUTEFINDER_H
+#define ROUTEFINDER_H
+
+#include <QThread>
+#include <QMutex>
+
+#include "location.h"
+#include "routenew.h"
+#include "locationfinder.h"
+
+class RouteFinder : public QObject
+{
+ Q_OBJECT
+public:
+ explicit RouteFinder(const Location &from, const Location &to, QObject *parent = 0);
+ ~RouteFinder();
+
+ RouteNew* getRoute(int index) const;
+ int getNumberOfRoutes() const;
+
+signals:
+ void finished();
+
+public slots:
+
+private slots:
+ void fromLocationFound();
+ void toLocationFound();
+ void requestFinished();
+
+private:
+ void startRouteSearch();
+
+ Location *from, *to;
+ LocationFinder *fromFinder, *toFinder;
+ QNetworkReply *reply;
+
+ QList<RouteNew*> routes;
+};
+
+#endif // ROUTENEW_H
--- /dev/null
+#include "routeleg.h"
+
+RouteLeg::RouteLeg() :
+ type(WALK), distance(0), time(), startPoint(new RoutePoint()), endPoint(new RoutePoint()), midRoute(), symbol()
+{
+}
+
+RouteLeg::RouteLeg(LEG_TYPE type, double distance, QTime time, RoutePoint *start, RoutePoint *end, QList<RoutePoint*> midRoute, QString symbol) :
+ type(type), distance(distance), time(time), startPoint(start), endPoint(end), midRoute(midRoute), symbol(symbol)
+{
+}
+
+RouteLeg::RouteLeg(const RouteLeg &other) :
+ type(other.type), distance(other.distance), time(other.time), startPoint(new RoutePoint(*other.startPoint)),
+ endPoint(new RoutePoint(*other.endPoint)), midRoute(), symbol(other.symbol)
+{
+ QList<RoutePoint*>::const_iterator iter;
+ for (iter = other.midRoute.constBegin(); iter != other.midRoute.constEnd(); iter++)
+ {
+ this->midRoute.append(new RoutePoint(**iter));
+ }
+}
+
+RouteLeg& RouteLeg::operator=(const RouteLeg &other)
+{
+ if (this != &other)
+ {
+ RoutePoint *new_start = new RoutePoint(*other.startPoint);
+ RoutePoint *new_end = new RoutePoint(*other.endPoint);
+
+ QList<RoutePoint*> new_midpoints = QList<RoutePoint*>();
+ QList<RoutePoint*>::const_iterator iter;
+ for (iter = other.midRoute.constBegin(); iter != other.midRoute.constEnd(); iter++)
+ {
+ new_midpoints.append(new RoutePoint(**iter));
+ }
+
+ delete this->startPoint;
+ delete this->endPoint;
+ while (this->midRoute.size() > 0)
+ {
+ RoutePoint *point = this->midRoute.takeLast();
+ delete point;
+ }
+
+ this->midRoute = new_midpoints;
+ this->startPoint = new_start;
+ this->endPoint = new_end;
+ this->type = other.type;
+ this->distance = other.distance;
+ this->time = other.time;
+ this->symbol = other.symbol;
+ }
+
+ return *this;
+}
+
+RouteLeg::~RouteLeg()
+{
+ delete this->startPoint;
+ delete this->endPoint;
+ while (this->midRoute.size() > 0)
+ {
+ RoutePoint *point = this->midRoute.takeLast();
+ delete point;
+ }
+}
--- /dev/null
+#ifndef ROUTELEG_H
+#define ROUTELEG_H
+
+#include "location.h"
+//#include "route.h"
+#include "routepoint.h"
+#include <QString>
+#include <QList>
+#include <QTime>
+
+//namespace RouteLeg {
+enum LEG_TYPE {
+ BUS,
+ FERRY,
+ SUB,
+ TRAIN,
+ TRAM,
+ WALK
+};
+
+
+class RouteLeg
+{
+public:
+ RouteLeg();
+ RouteLeg(LEG_TYPE type, double distance, QTime time, RoutePoint *start, RoutePoint *end, QList<RoutePoint*> midRoute, QString symbol);
+ RouteLeg(const RouteLeg&);
+ RouteLeg& operator=(const RouteLeg&);
+ ~RouteLeg();
+
+ LEG_TYPE type;
+ double distance;
+ QTime time;
+ RoutePoint *startPoint;
+ RoutePoint *endPoint;
+ QList<RoutePoint*> midRoute;
+ QString symbol;
+};
+
+#endif // ROUTELEG_H
--- /dev/null
+#include "routeleggenerator.h"
+
+#include "routepoint.h"
+#include "routeleg.h"
+
+#include <QString>
+#include <QStringList>
+#include <QList>
+#include <QTime>
+
+static const QString WALK_SYMBOL = QString("Walk");
+static const QString SUB_SYMBOL = QString("M");
+
+
+RouteLeg* RouteLegGenerator::createLegWalk(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints)
+{
+ return new RouteLeg(WALK, distance, time, startPoint, endPoint, midpoints, WALK_SYMBOL);
+}
+
+RouteLeg* RouteLegGenerator::createLegBus(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints, QString line_symbol)
+{
+ return new RouteLeg(BUS, distance, time, startPoint, endPoint, midpoints, line_symbol);
+}
+
+RouteLeg* RouteLegGenerator::createLegTram(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints, QString line_symbol)
+{
+ return new RouteLeg(TRAM, distance, time, startPoint, endPoint, midpoints, line_symbol);
+}
+
+RouteLeg* RouteLegGenerator::createLegTrain(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints, QString line_symbol)
+{
+ return new RouteLeg(TRAIN, distance, time, startPoint, endPoint, midpoints, line_symbol);
+}
+
+RouteLeg* RouteLegGenerator::createLegSub(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints)
+{
+ return new RouteLeg(SUB, distance, time, startPoint, endPoint, midpoints, SUB_SYMBOL);
+}
+
+RouteLeg* RouteLegGenerator::createLegFerry(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints)
+{
+ return new RouteLeg(FERRY, distance, time, startPoint, endPoint, midpoints, SUB_SYMBOL);
+}
+
+
+QTime RouteLegGenerator::parseTime(QString time)
+{
+ QStringList split = time.split(".");
+ QString min = split.at(0);
+ int minutes = min.toInt();
+ int hours = 0;
+ while (minutes >= 60)
+ {
+ hours++;
+ minutes -= 60;
+ }
+ QString search = QString::number(hours) + "." + QString::number(minutes) + "." + split.at(1);
+
+ return QTime::fromString(search, "mm.zzz");
+}
--- /dev/null
+#ifndef ROUTELEGGENERATOR_H
+#define ROUTELEGGENERATOR_H
+
+#include "routepoint.h"
+#include "routeleg.h"
+#include <QString>
+#include <QTime>
+
+namespace RouteLegGenerator
+{
+ RouteLeg* createLegWalk(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints);
+ RouteLeg* createLegBus(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints, QString line_symbol);
+ RouteLeg* createLegTram(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints, QString line_symbol);
+ RouteLeg* createLegTrain(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints, QString line_symbol);
+ RouteLeg* createLegSub(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints);
+ RouteLeg* createLegFerry(double distance, QTime time, RoutePoint *startPoint, RoutePoint *endPoint, QList<RoutePoint*> midpoints);
+
+ QTime parseTime(QString time);
+};
+
+#endif // ROUTELEGGENERATOR_H
--- /dev/null
+#include "routenew.h"
+
+#include <QDebug>
+
+RouteNew::RouteNew() :
+ startTime(), endTime(), startPoint(new RoutePoint()), endPoint(new RoutePoint()), walkingDistance(0.0), distance(0.0), route()
+{
+}
+
+RouteNew::RouteNew(QDateTime startTime, QDateTime endTime, RoutePoint *startPoint, RoutePoint *endPoint, double walkingDistance, double distance, QList<RouteLeg*> route) :
+ startTime(startTime), endTime(endTime), startPoint(startPoint), endPoint(endPoint), walkingDistance(walkingDistance), distance(distance), route(route)
+{
+}
+
+RouteNew::RouteNew(const RouteNew &other) :
+ startTime(other.startTime), endTime(other.endTime), walkingDistance(other.walkingDistance), distance(other.distance), route()
+{
+ qDebug() << "Starting RouteNew copy constructor.";
+ this->startPoint = new RoutePoint(*other.startPoint);
+ this->endPoint = new RoutePoint(*other.endPoint);
+
+ QList<RouteLeg*>::const_iterator iter;
+ for (iter = other.route.constBegin(); iter != other.route.constEnd(); iter++)
+ this->route.append(new RouteLeg(**iter));
+
+ qDebug() << "Finishing RouteNew copy constructor.";
+}
+
+RouteNew& RouteNew::operator=(const RouteNew &other)
+{
+ if (this != &other)
+ {
+ RoutePoint *new_start = new RoutePoint(*other.startPoint);
+ RoutePoint *new_end = new RoutePoint(*other.endPoint);
+
+ QList<RouteLeg*> new_routelegs = QList<RouteLeg*>();
+ QList<RouteLeg*>::const_iterator iter;
+ for (iter = other.route.constBegin(); iter != other.route.constEnd(); iter++)
+ {
+ new_routelegs.append(new RouteLeg(**iter));
+ }
+
+ delete this->startPoint;
+ delete this->endPoint;
+ while (this->route.size() > 0)
+ {
+ RouteLeg *leg = this->route.takeLast();
+ delete leg;
+ }
+
+ this->route = new_routelegs;
+ this->startPoint = new_start;
+ this->endPoint = new_end;
+ this->startTime = other.startTime;
+ this->endTime = other.endTime;
+ this->walkingDistance = other.walkingDistance;
+ this->distance = other.distance;
+ }
+
+ return *this;
+}
+
+RouteNew::~RouteNew()
+{
+ delete this->startPoint;
+ delete this->endPoint;
+ while (this->route.size() > 0)
+ {
+ RouteLeg *leg = this->route.takeLast();
+ delete leg;
+ }
+}
--- /dev/null
+#ifndef ROUTENEW_H
+#define ROUTENEW_H
+
+#include "routepoint.h"
+#include "routeleg.h"
+#include <QDateTime>
+
+class RouteNew
+{
+public:
+ RouteNew();
+ RouteNew(QDateTime startTime, QDateTime endTime, RoutePoint *startPoint, RoutePoint *endPoint, double walkingDistance, double distance, QList<RouteLeg*> route);
+ RouteNew(const RouteNew&);
+ RouteNew& operator=(const RouteNew&);
+ ~RouteNew();
+
+ QDateTime startTime;
+ QDateTime endTime;
+ RoutePoint *startPoint;
+ RoutePoint *endPoint;
+ double walkingDistance;
+ double distance;
+ QList<RouteLeg*> route;
+
+};
+
+#endif // ROUTENEW_H
--- /dev/null
+#include "routepoint.h"
+
+RoutePoint::RoutePoint() :
+ type(POINT), arrival_time(), departure_time(), name(), x(), y()
+{
+}
+
+RoutePoint::RoutePoint(POINT_TYPE type, QDateTime arrival, QDateTime departure, QString x, QString y, QString name) :
+ type(type), arrival_time(arrival), departure_time(departure), name(name), x(x), y(y)
+{
+}
+
+/*RoutePoint::~RoutePoint()
+{
+ delete this->arrival_time;
+ delete this->departure_time;
+}*/
+
+/*RoutePoint::RoutePoint(const RoutePoint& other) :
+ type(other.type), arrival_time(new QDateTime(*other.arrival_time)), departure_time(new QDateTime(*other.departure_time)),
+ name(other.name), x(other.x), y(other.y)
+{
+}*/
+
+/*RoutePoint& RoutePoint::operator=(const RoutePoint& other)
+{
+ if (this != &other)
+ {
+ QDateTime *new_arrival = new QDateTime(*other.arrival_time);
+ QDateTime *new_departure = new QDateTime(*other.departure_time);
+
+ delete this->arrival_time;
+ delete this->departure_time;
+
+ this->arrival_time = new_arrival;
+ this->departure_time = new_departure;
+ this->type = other.type;
+ this->name = other.name;
+ this->x = other.x;
+ this->y = other.y;
+ }
+
+ return *this;
+}*/
--- /dev/null
+#ifndef ROUTEPOINT_H
+#define ROUTEPOINT_H
+
+#include <QDateTime>
+
+enum POINT_TYPE {
+ MAP_LOCATION,
+ POINT,
+ STOP
+};
+
+class RoutePoint
+{
+public:
+ RoutePoint();
+ RoutePoint(POINT_TYPE type, QDateTime arrival, QDateTime departure, QString x, QString y, QString name);
+ //~RoutePoint();
+ //RoutePoint(const RoutePoint&);
+ //RoutePoint& operator=(const RoutePoint&);
+
+ POINT_TYPE type;
+ QDateTime arrival_time, departure_time;
+ QString name, x, y;
+};
+
+#endif // ROUTEPOINT_H
--- /dev/null
+#include "routepointgenerator.h"
+
+#include "routepoint.h"
+#include <QString>
+#include <QDateTime>
+
+static const QString DEFAULT_NAME = QString("");
+
+
+RoutePoint* RoutePointGenerator::createPointStop(QDateTime arrival, QDateTime departure, QString x, QString y, QString name)
+{
+ return new RoutePoint(STOP, arrival, departure, x, y, name);
+}
+
+RoutePoint* RoutePointGenerator::createPointPoint(QDateTime arrival, QDateTime departure, QString x, QString y)
+{
+ return new RoutePoint(POINT, arrival, departure, x, y, DEFAULT_NAME);
+}
+
+RoutePoint* RoutePointGenerator::createPointMapLocation(QDateTime arrival, QDateTime departure, QString x, QString y, QString name)
+{
+ return new RoutePoint(MAP_LOCATION, arrival, departure, x, y, name);
+}
+
+QDateTime RoutePointGenerator::parseDateTime(QString &date, QString &time)
+{
+ return QDateTime::fromString(date + time, "yyyyMMddHHmm");
+}
--- /dev/null
+#ifndef ROUTEPOINTGENERATOR_H
+#define ROUTEPOINTGENERATOR_H
+
+#include "routepoint.h"
+#include <QString>
+#include <QDateTime>
+
+namespace RoutePointGenerator
+{
+ RoutePoint* createPointStop(QDateTime arrival, QDateTime departure, QString x, QString y, QString name);
+ RoutePoint* createPointPoint(QDateTime arrival, QDateTime departure, QString x, QString y);
+ RoutePoint* createPointMapLocation(QDateTime arrival, QDateTime departure, QString x, QString y, QString name = QString());
+
+ QDateTime parseDateTime(QString &date, QString &time);
+};
+
+#endif // ROUTEPOINTGENERATOR_H
--- /dev/null
+#include "ytv.h"
+
+#include <QNetworkReply>
+#include <QNetworkAccessManager>
+#include <QDebug>
+#include <QUrl>
+#include <QString>
+#include <QNetworkRequest>
+
+QNetworkReply* Ytv::searchAddress(const QString &address)
+{
+ qDebug() << "Searching for address (" << address << ")";
+
+ QUrl fullUrl(Url);
+
+ fullUrl.addEncodedQueryItem( "key", address.toAscii().toPercentEncoding() );
+ fullUrl.addQueryItem( "user", Username );
+ fullUrl.addQueryItem( "pass", Password );
+
+ qDebug() << "The query url: " << fullUrl.toString();
+
+ return manager.get(QNetworkRequest(fullUrl));
+};
--- /dev/null
+#ifndef YTV_H
+#define YTV_H
+
+#include <QString>
+#include <QNetworkAccessManager>
+
+class QNetworkReply;
+
+namespace Ytv {
+ const QString Url("http://api.reittiopas.fi/public-ytv/fi/api/");
+ const QString Username("zouba");
+ const QString Password("caf9r3ee");
+
+ //const QString Home( QByteArray::fromPercentEncoding( "Taivaanvuohentie%207%2CHelsinki" ) );
+ //const QString Work( QByteArray::fromPercentEncoding( "It%E4merenkatu%2011%2CHelsinki" ) );
+
+ enum {
+ WalkSpeedSlow=1,
+ WalkSpeedNormal=2,
+ WalkSpeedFast=3,
+ WalkSpeedRunning=4,
+ WalkSpeedCycling=5,
+ NoWalkSpeeds=5
+ };
+
+ enum {
+ ShowOneResult=1,
+ ShowThreeResults=3,
+ ShowFiveResults=5
+ };
+
+ enum {
+ OptimizeDefault=1,
+ OptimizeFastest=2,
+ OptimizeLeastTransfers=3,
+ OptimizeLeastWalking=4
+ };
+
+ static QNetworkAccessManager manager;
+
+ QNetworkReply* searchAddress(const QString &address);
+
+};
+
+#endif // YTH_H
#include "route.h"
#include "ui.h"
#include "uicontroller.h"
-#include "location.h"
+#include "logic/location.h"
#include "gpscontroller.h"
-#include "ytv.h"
-#include "locations.h"
+#include "logic/ytv.h"
+#include "logic/locations.h"
+
+#include "gui/searchdisplay.h"
#include <QDebug>
#include <QObject>
#include <QApplication>
#include <QMainWindow>
+#include <QLabel>
+
+//#define BUILD_TWO_GUIS 1
int main(int argc, char *argv[] )
{
Locations* locations = Locations::GetInstance();
Locations *other_locations = Locations::GetInstance();
+ if (locations->size() == 0)
+ {
+ locations->addEditLocation(new Location("2558542", "6676458", "Home"));
+ locations->addEditLocation(new Location("2540835", "6672773", "Work"));
+ }
+
+#ifdef Q_WS_MAEMO_5
+ SearchDisplay *mainWindow = new SearchDisplay();
+ //layout->addWidget(win);
+#else
+ //DesktopWindow* mainWindow = new DesktopWindow();
+ SearchDisplay *mainWindow = new SearchDisplay();
+#endif
+ mainWindow->show();
+
if (locations == other_locations)
qDebug() << "Same instance";
else
qDebug() << "!!NOT SAME INSTANCE!!";
- QMainWindow *mainWindow = new QMainWindow;
+#ifdef BUILD_TWO_GUIS
+#ifdef Q_WS_MAEMO_5
+ QMainWindow *oldMainWindow = new QMainWindow;
UiClass *ui = new UiClass;;
- ui->setupUi(mainWindow);
+ ui->setupUi(oldMainWindow);
UiController *uiController = new UiController( ui );
Route *route = new Route();
-#ifdef Q_WS_MAEMO_5
+//#ifdef Q_WS_MAEMO_5
GpsController *gpsController = new GpsController();
-#endif
+//#endif
QObject::connect(
route, SIGNAL( routeReady( QList<RouteData> ) ),
route, SIGNAL(busy(bool)),
ui, SLOT(setBusy(bool)));
-#ifdef Q_WS_MAEMO_5
+//#ifdef Q_WS_MAEMO_5
QObject::connect(
ui->m_UseGpsAction, SIGNAL(toggled(bool)), gpsController, SLOT(useGPS(bool)));
-#endif
-
- mainWindow->show();
+//#endif
+ oldMainWindow->show();
+#endif // Q_WS_MAEMO_5
+#endif // BUILD_TWO_GUIS
//Locations::destroyLocations();
return app.exec();
#include "route.h"
#include "routedata.h"
-#include "location.h"
+#include "logic/location.h"
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QXmlStreamReader>
#include <QWidget>
-#include "ytv.h"
+#include "logic/ytv.h"
Route::Route() :
q( new RoutePrivate( this ) ),
#define ROUTE_H
#include "routedata.h"
-#include "location.h"
+#include "logic/location.h"
#include <QObject>
#include <QNetworkReply>
#include "route_p.h"
-#include "location.h"
+#include "logic/location.h"
#include <QXmlStreamReader>
#include <QDebug>
#include "routedata.h"
-#include "location.h"
+#include "logic/location.h"
#include <QObject>
#include "ui.h"
-#include "locations.h"
-#include "ytv.h"
+#include "logic/locations.h"
+#include "logic/ytv.h"
#include <QMainWindow>
#include <QRadioButton>
#include <QMaemo5ValueButton>
#endif
-#include "location.h"
-#include "locationsdisplaywindow.h"
+#include "logic/location.h"
+#include "gui/locationsdisplaywindow.h"
/*class QMainWindow;
class QWidget;
#include "uicontroller.h"
#include "route.h"
#include "ui.h"
-#include "ytv.h"
-#include "location.h"
-#include "locations.h"
+#include "logic/ytv.h"
+#include "logic/location.h"
+#include "logic/locations.h"
#include <QObject>
#include <QPushButton>
m_currentRoute(-1)
{
Locations *locations = Locations::GetInstance();
- if (locations->size() == 0)
+ /*if (locations->size() == 0)
{
locations->addEditLocation(new Location("Home"));
locations->addEditLocation(new Location("Work"));
- }
+ }*/
QObject::connect(m_ui->m_routeButton, SIGNAL(clicked()), this, SLOT(findRoute()));
#ifdef Q_WS_MAEMO_5
#ifdef Q_WS_MAEMO_5
QMaemo5InformationBox::information(this->m_ui->m_mainWindow, "GPS location has not been received yet. Wait a moment.");
#endif
- connect(from, SIGNAL(becomeValid()), this, SLOT(gpsBecameValid()));
+ //connect(from, SIGNAL(becomeValid()), this, SLOT(gpsBecameValid()));
return;
}
}
QMaemo5InformationBox::information(this->m_ui->m_mainWindow, "GPS location received.");
#endif
Location *gps = Locations::GetInstance()->getGpsLocation();
- disconnect(gps, SIGNAL(becomeValid()), this, SLOT(gpsBecameValid()));
+ //disconnect(gps, SIGNAL(becomeValid()), this, SLOT(gpsBecameValid()));
this->changeFrom();
this->changeTo();
}
#ifdef Q_WS_MAEMO_5
QMaemo5InformationBox::information(this->m_ui->m_mainWindow, "GPS location has not been received yet. Wait a moment.");
#endif
- connect(to, SIGNAL(becomeValid()), this, SLOT(gpsBecameValid()));
+ //connect(to, SIGNAL(becomeValid()), this, SLOT(gpsBecameValid()));
return;
}
}
#define UICONTROLLER_H
#include "routedata.h"
-#include "location.h"
+#include "logic/location.h"
#include <QObject>
+++ /dev/null
-#include "ytv.h"
-
-#include <QNetworkReply>
-#include <QNetworkAccessManager>
-#include <QDebug>
-#include <QUrl>
-#include <QString>
-#include <QNetworkRequest>
-
-QNetworkReply* Ytv::searchAddress(const QString &address)
-{
- qDebug() << "Searching for address (" << address << ")";
-
- QUrl fullUrl(Url);
-
- fullUrl.addEncodedQueryItem( "key", address.toAscii().toPercentEncoding() );
- fullUrl.addQueryItem( "user", Username );
- fullUrl.addQueryItem( "pass", Password );
-
- qDebug() << "The query url: " << fullUrl.toString();
-
- return manager->get(QNetworkRequest(fullUrl));
-};
+++ /dev/null
-#ifndef YTV_H
-#define YTV_H
-
-#include <QString>
-#include <QNetworkAccessManager>
-
-class QNetworkReply;
-
-namespace Ytv {
- const QString Url("http://api.reittiopas.fi/public-ytv/fi/api/");
- const QString Username("zouba");
- const QString Password("caf9r3ee");
-
- //const QString Home( QByteArray::fromPercentEncoding( "Taivaanvuohentie%207%2CHelsinki" ) );
- //const QString Work( QByteArray::fromPercentEncoding( "It%E4merenkatu%2011%2CHelsinki" ) );
-
- enum {
- WalkSpeedSlow=1,
- WalkSpeedNormal=2,
- WalkSpeedFast=3,
- WalkSpeedRunning=4,
- WalkSpeedCycling=5,
- NoWalkSpeeds=5
- };
-
- enum {
- ShowOneResult=1,
- ShowThreeResults=3,
- ShowFiveResults=5
- };
-
- enum {
- OptimizeDefault=1,
- OptimizeFastest=2,
- OptimizeLeastTransfers=3,
- OptimizeLeastWalking=4
- };
-
- static QNetworkAccessManager *manager = new QNetworkAccessManager();
-
- QNetworkReply* searchAddress(const QString &address);
-
-};
-
-#endif // YTH_H
TARGET = zouba
SOURCES += \
- main.cpp \
- route.cpp \
- route_p.cpp \
- uicontroller.cpp \
- location.cpp \
- locations.cpp \
- ui.cpp \
- locationbutton.cpp \
- addressdialog.cpp \
- ytv.cpp \
- locationsdisplaywindow.cpp
+ src/main.cpp \
+ src/route.cpp \
+ src/route_p.cpp \
+ src/uicontroller.cpp \
+ src/ui.cpp \
+ src/locationbutton.cpp \
+ src/addressdialog.cpp \
+ src/logic/ytv.cpp \
+ src/logic/routepointgenerator.cpp \
+ src/logic/routepoint.cpp \
+ src/logic/routenew.cpp \
+ src/logic/routeleggenerator.cpp \
+ src/logic/routeleg.cpp \
+ src/logic/routefinder.cpp \
+ src/logic/locations.cpp \
+ src/logic/locationfinder.cpp \
+ src/logic/location.cpp \
+ src/gui/routelegwidget.cpp \
+ src/gui/routeresultwidget.cpp \
+ src/gui/searchdisplay.cpp \
+ src/gui/routeoneitemwidget.cpp \
+ src/gui/locationsdisplaywindow.cpp
HEADERS += \
- route.h \
- route_p.h \
- uicontroller.h \
- location.h \
- locations.h \
- ytv.h \
- ui.h \
- locationbutton.h \
- addressdialog.h \
- locationsdisplaywindow.h
+ src/route.h \
+ src/route_p.h \
+ src/uicontroller.h \
+ src/ui.h \
+ src/locationbutton.h \
+ src/addressdialog.h \
+ src/logic/ytv.h \
+ src/logic/routepointgenerator.h \
+ src/logic/routepoint.h \
+ src/logic/routenew.h \
+ src/logic/routeleggenerator.h \
+ src/logic/routeleg.h \
+ src/logic/routefinder.h \
+ src/logic/locations.h \
+ src/logic/locationfinder.h \
+ src/logic/location.h \
+ src/gui/routelegwidget.h \
+ src/gui/routeresultwidget.h \
+ src/gui/searchdisplay.h \
+ src/gui/routeoneitemwidget.h \
+ src/gui/locationsdisplaywindow.h
FORMS += \
- locationsdisplaywindow.ui
+ src/gui/locationsdisplaywindow.ui \
+ src/gui/routelegwidget.ui \
+ src/gui/routeresultwidget.ui \
+ src/gui/searchdisplay.ui \
+ src/gui/routeoneitemwidget.ui
+
LEXSOURCES += #LEXS#
YACCSOURCES += #YACCS#
QT=core gui network
linux-g++-maemo5 {
-SOURCES += gpscontroller.cpp
-HEADERS += gpscontroller.h
+SOURCES += \
+ gpscontroller.cpp \
+ src/gui/favoriteselectiondialog.cpp
+HEADERS += \
+ gpscontroller.h \
+ src/gui/favoriteselectiondialog.h
+FORMS += \
+ src/gui/favoriteselectiondialog.ui
+
QT += maemo5
LIBS += -lQtBearer -lQtLocation
MOBILITY += location bearer
compiler_clean.commands = -$(DEL_FILE) $(TARGET)
QMAKE_EXTRA_TARGETS += debian-all debian-src debian-bin compiler_clean
+
+OTHER_FILES += \
+ data/TODO.txt
+
+RESOURCES += \
+ ReittiopasImages.qrc