Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.0
- import Sailfish.Silica 1.0
- import io.thp.pyotherside 1.3
- Page {
- id: page
- property Item contextMenuPlaces
- onStatusChanged: {
- if (page.status==PageStatus.Active)
- {
- placesModel.clear();
- citiesModel.clear();
- py.call('pyveggiesailor.controller.fav_places', [],function(result) {
- for (var i=0; i<result.length; i++) {
- placesModel.append(result[i]);
- }
- });
- py.call('pyveggiesailor.controller.fav_cities', [],function(result) {
- for (var i=0; i<result.length; i++) {
- citiesModel.append(result[i]);
- }
- });
- }
- }
- SilicaFlickable {
- width: page.width
- height: parent.width
- contentHeight: listView.height
- contentWidth: listView.width
- anchors.fill: parent
- Column {
- PageHeader {
- title: qsTr("Favourites")
- }
- id: listView
- width: page.width
- spacing: Theme.paddingLarge
- Label {
- text: qsTr("Places")
- color: Theme.highlightColor
- font.pixelSize: Theme.fontSizeLarge
- width: parent.width
- x: Theme.paddingLarge
- }
- Repeater {
- id: repPlaces
- model: ListModel {
- id: placesModel
- }
- delegate: EntryBackgroundItem {
- id: bgdPlace
- function openPlace(entryUri) {
- console.log("open place");
- }
- onClicked: openPlace(uri)
- }
- }
- Label {
- text: qsTr("Cities")
- color: Theme.highlightColor
- width: parent.width
- font.pixelSize: Theme.fontSizeLarge
- x: Theme.paddingLarge
- }
- Repeater {
- id: repCities
- // quickScroll : false
- model: ListModel {
- id: citiesModel
- }
- property Item contextMenuCities
- delegate: Item {
- id: myListItemCities
- property bool menuOpen: repCities.contextMenuCities != null && repCities.contextMenuCities.parent === myListItemCities
- // width: ListView.view.width
- height: menuOpen ? repCities.contextMenuCities.height + bgdCity.height : bgdCity.height
- width: Repeater.view.width
- BackgroundItem {
- id: bgdCity
- height: Theme.itemSizeSmall
- width: parent.width
- function openCity(cityUri, cityName) {
- pageStack.push(Qt.resolvedUrl("Entries.qml"),
- {
- "uri": cityUri,
- "mytext":name
- });
- }
- Label {
- text: name
- x: Theme.paddingLarge
- color: bgdCity.highlighted ? Theme.highlightColor : Theme.primaryColor
- }
- onClicked: openCity(uri, name)
- onPressAndHold: {
- console.log("HOLD");
- if (!contextMenuCities)
- contextMenuCities = contextMenuComponentCities.createObject(repCities)
- contextMenuCities.show(myListItemCities)
- }
- }
- }
- Component {
- id: contextMenuComponentCities
- ContextMenu {
- MenuItem {
- text: "Option 1"
- onClicked: console.log("Clicked Option 1")
- }
- MenuItem {
- text: "Option 2"
- onClicked: console.log("Clicked Option 2")
- }
- }
- }
- }
- Python {
- id: py
- Component.onCompleted: {
- addImportPath(Qt.resolvedUrl('.'));
- addImportPath(Qt.resolvedUrl('..'));
- addImportPath(Qt.resolvedUrl('../..'));
- importModule('pyveggiesailor.controller', function () {
- });
- }
- }
- }
- VerticalScrollDecorator {}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement