Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
Adds Bus Maps feature to master
  • Loading branch information
KrisztianOlah committed Oct 15, 2014
2 parents 59b8dfe + c2bdc36 commit f819200
Show file tree
Hide file tree
Showing 24 changed files with 1,456 additions and 12 deletions.
20 changes: 17 additions & 3 deletions harbour-london-sail.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ SOURCES += src/harbour-london-sail.cpp \
src/logic/coverlogic.cpp \
src/logic/database/databasemanager.cpp \
src/logic/database/database.cpp \
src/logic/arrivals/stopsquerymodel.cpp
src/logic/arrivals/stopsquerymodel.cpp \
src/logic/maplogic.cpp \
src/logic/maps/mapsmodel.cpp \
src/logic/maps/busmap.cpp \
src/logic/maps/busmapdownloader.cpp \
src/logic/maps/mapfilesmodel.cpp

OTHER_FILES += qml/harbour-london-sail.qml \
qml/cover/CoverPage.qml \
Expand Down Expand Up @@ -74,7 +79,11 @@ OTHER_FILES += qml/harbour-london-sail.qml \
qml/pages/JourneyProgressPage.qml \
qml/cover/JourneyProgressCover.qml \
qml/gui/StopIcon.qml \
qml/gui/RunningText.qml
qml/gui/RunningText.qml \
qml/pages/MapsPage.qml \
qml/pages/BusMapsPage.qml \
qml/pages/MyMapsPage.qml \
qml/gui/NotificationWidget.qml

HEADERS += \
src/logic/servicestatuslogic.h \
Expand Down Expand Up @@ -103,7 +112,12 @@ HEADERS += \
src/logic/coverlogic.h \
src/logic/database/databasemanager.h \
src/logic/database/database.h \
src/logic/arrivals/stopsquerymodel.h
src/logic/arrivals/stopsquerymodel.h \
src/logic/maplogic.h \
src/logic/maps/mapsmodel.h \
src/logic/maps/busmap.h \
src/logic/maps/busmapdownloader.h \
src/logic/maps/mapfilesmodel.h

RESOURCES += \
images.qrc
Expand Down
95 changes: 95 additions & 0 deletions qml/gui/NotificationWidget.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
Copyright (C) 2014 Krisztian Olah
email: fasza2mobile@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import QtQuick 2.0
import Sailfish.Silica 1.0

Rectangle {
id: self
property string text: ""
property int timeOut: 0
property bool active: false

anchors {
top: parent.top
left: parent.left
right: parent.right
}
state: "invisible"
height: label.paintedHeight + Theme.paddingSmall * 2
color: Theme.highlightColor
z: 3
Label {
id: label
text: self.text
textFormat: Text.RichText
truncationMode: TruncationMode.Fade
font.pixelSize: Theme.fontSizeSmall
z: 4
anchors {
left: parent.left
leftMargin: Theme.paddingLarge
right: parent.right
rightMargin: Theme.paddingLarge
verticalCenter: parent.verticalCenter
}
color: Theme.highlightDimmerColor
}
onActiveChanged: self.state = self.active ? "visible" : "invisible"
Timer {
interval: self.timeOut
running: self.active
onTriggered: {
self.active = false
}
}
states: [
State {
name: "visible"
PropertyChanges {
target: self
opacity: 100
}
},
State {
name: "invisible"
PropertyChanges {
target: self
opacity: 0
}
}
]
transitions: [
Transition {
from: "visible"
to: "invisible"
NumberAnimation { target: self; property: "opacity"; duration: 1000; easing.type: Easing.OutSine }
},
Transition {
from: "invisible"
to: "visible"
NumberAnimation { target: self; property: "opacity"; duration: 1000; easing.type: Easing.InSine }
}
]
}
24 changes: 24 additions & 0 deletions qml/gui/RunningText.qml
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
Copyright (C) 2014 Krisztian Olah
email: fasza2mobile@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.london.sail.utilities 1.0
Expand Down
5 changes: 3 additions & 2 deletions qml/gui/StopInfoWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Rectangle {
signal clicked

id: self
height: 80 + towardLabel.lineCount * 20
height: nameLabel.paintedHeight + towardLabel.paintedHeight + Theme.paddingMedium * 2
radius: 10
color: Theme.secondaryHighlightColor
anchors {
Expand Down Expand Up @@ -66,10 +66,11 @@ Rectangle {
Label {
id: nameLabel
text: "Name of Stop"
wrapMode: Text.WordWrap
font.pixelSize: Theme.fontSizeMedium
anchors {
top: parent.top
topMargin: (towards === "") ? 30 : 10 //no need to leave space when there is nothing to display
topMargin: (towards === "") ? (parent.height - nameLabel.paintedHeight) / 2 : Theme.paddingMedium //no need to leave space when there is nothing to display
left: icon.right
leftMargin: Theme.paddingMedium
right: iconButton.left
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/AboutPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Page {
right: parent.right
rightMargin: Theme.paddingLarge
}
text: "Version: 0.4.2"
text: "Version: 0.4.3"
}
Label {
id: descriptionLabel
Expand Down
201 changes: 201 additions & 0 deletions qml/pages/BusMapsPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/*
Copyright (C) 2014 Krisztian Olah
email: fasza2mobile@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.london.sail.utilities 1.0

import "../gui"

Page {
property string headertitle: ""
id: page
allowedOrientations: Orientation.All

NotificationWidget {
id: notification
timeOut: 2000
}

SilicaListView {
id: view
property string currentName: ""
property string currentLink: ""
property int cIndex: 0
property bool isDownloadingList: !view.count && mapData.isDownloading()
signal deleteRequested (int index)

anchors.fill: parent
model: mapData.getMapsModel()
header: PageHeader {
title: headertitle
}
footer: Item {
height: Theme.paddingLarge
width: 1
}

delegate: Item {
id: itemDelegate
objectName: "mapDelegate"

width: ListView.view.width
height: loader.height + contentItem.height

function refreshItem() {
loader.item.isLocalFile = mapData.isThereLocalFile(nameData)
label.color = mapData.isThereLocalFile(nameData) ?
Theme.primaryColor : Theme.secondaryColor }
function deleteMap() {
remorseItem.execute( itemDelegate ,"Deleting",
function () { mapData.deleteMap(nameData)} )
}

function deleteMapByIndex (ix) {
if (ix === index) { deleteMap() }
}

BackgroundItem {
id: contentItem

width: parent.width
height: label.paintedHeight + Theme.paddingMedium * 2 < 80 ? 80 : label.paintedHeight + Theme.paddingMedium * 2

Separator {
color: Theme.secondaryHighlightColor
anchors {
top: parent.bottom
left: parent.left
right: parent.right
}
}

Label {
id: label
text: nameData
color: mapData.isThereLocalFile(nameData) ? Theme.primaryColor : Theme.secondaryColor
wrapMode: Text.WordWrap
textFormat: Text.RichText
anchors {
left: parent.left
leftMargin: Theme.paddingLarge
right: parent.right
rightMargin: Theme.paddingLarge
verticalCenter: parent.verticalCenter
}
}
Connections {
target: mapData
onMapDownloaded: {
refreshItem()
}
onMapDeleted: {
refreshItem()
}
}
Loader {
id: loader
sourceComponent: contextMenuComponent
height: children.height
anchors {
left: parent.left
right: parent.right
}
}
RemorseItem { id: remorseItem }

onClicked: {
if (mapData.isThereLocalFile(nameData)) {
notification.text = "Opening " + nameData + "..."
notification.active = true
mapData.openMap(nameData)
}
}

onPressAndHold: {
view.currentName = nameData
view.currentLink = linkData
view.cIndex = index
loader.item.show(itemDelegate)
}
}
}

Component {
id: contextMenuComponent
ContextMenu {
id: contextMenu
property bool isLocalFile: mapData.isThereLocalFile(view.currentName)


MenuItem {
text: contextMenu.isLocalFile ? "delete" : "download"
onClicked: {
if (contextMenu.isLocalFile) {
view.deleteRequested(view.cIndex)
}
else {
mapData.downloadMap(view.currentName, view.currentLink)
}
}
}
}
}
VerticalScrollDecorator {
flickable: view
}
onDeleteRequested: {
for (var i = 0; i !== view.contentItem.children.length; ++i) {
if (view.contentItem.children[i].objectName === "mapDelegate") {
view.contentItem.children[i].deleteMapByIndex(index)
}
}
}
BusyIndicator {
id: busyIndicator
running: view.isDownloadingList
anchors.centerIn: parent
size: BusyIndicatorSize.Large
}
}
Connections {
target: mapData
onDownloadingChanged: {
refreshWidget.active = view.count ? mapData.isDownloading() : false
view.isDownloadingList = !view.count && mapData.isDownloading()
}
}

RefreshWidget {
id: refreshWidget
title: "Downloading"
}
onOrientationChanged: {
//BUG: its seems to be reverted for some reason
refreshWidget.isPortrait = !isPortrait
}

Component.onCompleted: { mapData.downloadListOfMapsFor(headertitle) }
Component.onDestruction: { mapData.clearMapList()}
}
Loading

0 comments on commit f819200

Please sign in to comment.