harbour-seaprint/qml/pages/JobsPage.qml

87 lines
2.5 KiB
QML
Raw Normal View History

2019-12-08 15:55:56 +03:00
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: page
allowedOrientations: Orientation.All
property var printer
Component.onCompleted: {
printer.getJobs()
console.log(JSON.stringify(printer.jobs))
}
// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
anchors.fill: parent
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
PullDownMenu {
2019-12-12 22:53:46 +03:00
// MenuItem {
// text: qsTr("Remove all")
// onClicked: {
// console.log("todo")
// }
// }
2019-12-08 15:55:56 +03:00
MenuItem {
text: qsTr("Refresh")
onClicked: {
console.log(JSON.stringify(printer.jobs))
printer.getJobs();
}
}
}
SilicaListView {
anchors.fill: parent
id: listView
model: printer.jobs.length
header: PageHeader {
id: pageHeader
title: printer.name
}
delegate: ListItem {
2019-12-12 22:53:46 +03:00
id: jobDelegate
2019-12-08 15:55:56 +03:00
Label {
2019-12-12 22:53:46 +03:00
id: idLabel
2019-12-08 15:55:56 +03:00
leftPadding: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
text: printer.jobs[index]["job-id"].value
Component.onCompleted: console.log(JSON.stringify(printer.jobs))
}
2019-12-12 22:53:46 +03:00
Label {
anchors.left: idLabel.right
anchors.leftMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
text: printer.jobs[index]["job-name"] ? printer.jobs[index]["job-name"].value : qsTr("Untitled job")
Component.onCompleted: console.log(JSON.stringify(printer.jobs))
}
RemorseItem {
id: cancelRemorse
}
menu: ContextMenu {
MenuItem {
text: qsTr("Cancel job")
onClicked: {
cancelRemorse.execute(jobDelegate, qsTr("Cancelling job"),
function() {printer.cancelJob(printer.jobs[index]["job-id"].value) })
}
}
}
2019-12-08 15:55:56 +03:00
}
}
}
}