Keep a singleton ComputerManager outside of the Models

This commit is contained in:
Cameron Gutman
2018-07-05 22:08:55 -07:00
parent 0d26ef7e5c
commit 1b1ad86271
9 changed files with 72 additions and 24 deletions
+20 -1
View File
@@ -5,6 +5,8 @@ import QtQuick.Layouts 1.11
import ComputerModel 1.0
import ComputerManager 1.0
GridView {
anchors.fill: parent
anchors.leftMargin: 5
@@ -14,7 +16,24 @@ GridView {
cellWidth: 350; cellHeight: 350;
focus: true
model: ComputerModel {}
Component.onCompleted: {
// Start polling when this view is shown
ComputerManager.startPolling()
}
Component.onDestruction: {
// Stop polling when this view is destroyed
ComputerManager.stopPollingAsync()
}
function createModel()
{
var model = Qt.createQmlObject('import ComputerModel 1.0; ComputerModel {}', parent, '')
model.initialize(ComputerManager)
return model
}
model: createModel()
delegate: Item {
width: 300; height: 300;