An example showing how to use this code with QML:
import QtQuick 2.0 import Ubuntu.Components 1.3 import Snapd 1.0
MainView { SnapdClient { id: snapdClient } Page { id: page property var findRequest
TextField { iconName: "input-search" placeholderText: "Search..." onTextChanged: { // Ensure we are connected var connectRequest = snapdClient.connect () connectRequest.runSync ()
// Test code var infoRequest = snapdClient.getSystemInformation () infoRequest.runSync () var info = infoRequest.systemInformation console.log (info.osId + " " + info.osVersion + " " + info.series + " " + info.version)
var listRequest = snapdClient.list () listRequest.runSync () console.log ("Installed:") for (var i = 0; i < listRequest.snapCount; i++) { var snap = listRequest.snap (i) console.log (snap.name, snap.installDate) }
// Cancel existing find if (page.findRequest != undefined) { console.log ("CANCEL " + page.findRequest) page.findRequest.cancel () } page.findRequest = snapdClient.find (SnapdClient.None, text) console.log ("FIND '" + text + "' " + page.findRequest)
function find_complete () { console.log ("COMPLETE " + page.findRequest) if (page.findRequest.error != SnapdRequest.NoError) { console.log (page.findRequest.errorString) return }
console.log (page.findRequest.snapCount + " RESULTS") for (var i = 0; i < page.findRequest.snapCount; i++) { var snap = page.findRequest.snap (i) console.log (snap.name + " " + snap.version) } } page.findRequest.complete.connect (find_complete) page.findRequest.runAsync () console.log ("Waiting...") } } Flickable { ListView { } } } }
« Back to merge proposal
An example showing how to use this code with QML:
import QtQuick 2.0
import Ubuntu.Components 1.3
import Snapd 1.0
MainView {
SnapdClient {
id: snapdClient
}
Page {
id: page
property var findRequest
TextField {
iconName: "input-search"
placeholde rText: "Search..."
onTextChan ged: {
connectReques t.runSync ()
// Ensure we are connected
var connectRequest = snapdClient.connect ()
// Test code getSystemInform ation ()
infoRequest. runSync () systemInformati on
console. log (info.osId + " " + info.osVersion + " " + info.series + " " + info.version)
var infoRequest = snapdClient.
var info = infoRequest.
var listRequest = snapdClient.list ()
listRequest. runSync ()
console. log ("Installed:") snapCount; i++) {
var snap = listRequest.snap (i)
console. log (snap.name, snap.installDate)
for (var i = 0; i < listRequest.
}
// Cancel existing find
console. log ("CANCEL " + page.findRequest)
page. findRequest. cancel ()
page. findRequest = snapdClient.find (SnapdClient.None, text)
console. log ("FIND '" + text + "' " + page.findRequest)
if (page.findRequest != undefined) {
}
{
}
}
}
Flickable {
}
}
}
}