corkboards.qml Example File
corkboard/corkboards.qml
import QtQuick 2.3
import QtNfc 5.5
Rectangle {
width: 800; height: 480
color: "darkred"
NearField {
property bool requiresManualPolling: false
orderMatch: false
onMessageRecordsChanged: {
var i;
for (i = 0; i < messageRecords.length; ++i) {
var data = "";
if (messageRecords[i].typeNameFormat === NdefRecord.NfcRtd) {
if (messageRecords[i].type === "T") {
data = messageRecords[i].text;
} else if (messageRecords[i].type === "U") {
data = messageRecords[i].uri;
}
}
if (!data)
data = "Unknown content";
list.get(listView.currentIndex).notes.append( {
"noteText":data
})
}
}
onPollingChanged: {
if (!polling && requiresManualPolling)
polling = true;
}
Component.onCompleted: {
if (!polling) {
requiresManualPolling = true;
polling = true;
}
}
}
ListModel {
id: list
ListElement {
name: "Personal"
notes: [
ListElement { noteText: "Near Field Communication" },
ListElement { noteText: "Touch a tag and its contents will appear as a new note" }
]
}
ListElement {
name: "Work"
notes: [
ListElement { noteText: "https://www.qt.io" },
ListElement { noteText: "To write a tag, click the red flag of a note and then touch a tag" }
]
}
}
ListView {
id: listView
anchors.fill: parent
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
model: list
highlightRangeMode: ListView.StrictlyEnforceRange
delegate: Mode {}
}
}