-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Bus Maps feature to master
- Loading branch information
Showing
24 changed files
with
1,456 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Copyright (C) 2014 Krisztian Olah | ||
email: [email protected] | ||
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 } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
/* | ||
Copyright (C) 2014 Krisztian Olah | ||
email: [email protected] | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/* | ||
Copyright (C) 2014 Krisztian Olah | ||
email: [email protected] | ||
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()} | ||
} |
Oops, something went wrong.