Skip to content

Commit

Permalink
Refs #2, trying to use GenericItemDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
doumdi committed Mar 7, 2024
1 parent 171e3c8 commit 33a32b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
33 changes: 29 additions & 4 deletions Frontend/DashboardsViewer/content/widgets/ListViewWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BaseWidget {
//Set model and delegate properties externally
property alias model: myListView.model
property alias delegate: myListView.delegate
property var dataSource: Object()


// Define a ListView to display the items
Expand All @@ -19,11 +20,35 @@ BaseWidget {

onModelChanged: function()
{
console.log("ListViewWidget.onModelChanged");
delegate.fieldIdName = model.fieldIdName
delegate.fieldDisplayName = model.fieldDisplayName;
delegate.iconPath = model.iconPath;
//At this stage the model is empty
}

onCountChanged: function()
{
//Something added to the model
//Update all delegate to model items
for (var i = 0; i < myListView.count; ++i) {
var element = model.get(i); // Access the ListElement at index i
var item = myListView.itemAtIndex(i);

// Data Source will determine field names
var fieldIdName = dataSource.fieldIdName;
var fieldDisplayName = dataSource.fieldDisplayName;
var iconPath = dataSource.iconPath;


//TODO not working yet.
/*
item[fieldIdName] = element[fieldIdName];
item[fieldDisplayName] = element[fieldDisplayName];
item[iconPath] = element[iconPath];
*/

console.log("Item at index", i, ":", item, element);
}

}

}


Expand Down
4 changes: 2 additions & 2 deletions Frontend/DashboardsViewer/resources/json/TestDashboardv2.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"id": "participantList",
"properties": {
"Layout.alignment": {"type": "raw", "value": "Qt.AlignVCenter | Qt.AlignHCenter"},
"model": {"type": "raw", "value": "participantListData.model"},
"dataSource": {"type": "raw", "value": "participantListData"},
"delegate": {"type": "delegate", "value": "GenericItemDelegate"}
}
},
Expand All @@ -75,7 +75,7 @@
"id": "participantSessionList",
"properties": {
"Layout.alignment": {"type": "raw", "value": "Qt.AlignVCenter | Qt.AlignHCenter"},
"model": {"type": "raw", "value": "participantSessionListData.model"},
"dataSource": {"type": "raw", "value": "participantSessionListData"},
"delegate": {"type": "delegate", "value": "SessionDelegate"}
}
}
Expand Down

0 comments on commit 33a32b4

Please sign in to comment.