Hello,
i want to create a list based on a model c++ , this model is contains a different data type , and i want to display just one type , so i used DelegateModelGroup.
i want to know the index of the items in the list in the filtred Model and his index in the origin model , i tried DelegateModel.itemsIndex and DelegateModel.persistedItemsIndex properties , itemsIndex return the index in the groupedmodel but persistedItemsIndex return always 0.
DelegateModel {
id: displayDelegateModelFavoris
delegate: Item {
id: resultDelegateMainItem
MouseArea {
anchors.fill: parent;
onClicked:{
console.log("**************visualindex*********",resultDelegateMainItem.DelegateModel.itemsIndex)
console.log("**************firstIndex*********",resultDelegateMainItem.DelegateModel.persistedItemsIndex)
}
}
}
}
model: docModel
groups: [
DelegateModelGroup {
includeByDefault: false
name: "favoris"
}
]
filterOnGroup: "favoris"
Component.onCompleted: {
var rowCount = docModel.size();
items.remove(0,rowCount);
for( var i = 0;i < rowCount;i++ ) {
var entry = docModel.get(i);
if(entry.BookDocumentType === BookDocumentType.Bookmark) {
items.insert(entry, "favoris");
}
}
}
}
ListView {
id: favorisList
clip: true
width: settings.width;
height: 600
model: displayDelegateModelFavoris
}
DelegateModel {
id: displayDelegateModelFavoris
delegate: Item {
id: resultDelegateMainItem
MouseArea {
anchors.fill: parent;
onClicked:{
console.log("**************visualindex*********",resultDelegateMainItem.DelegateModel.itemsIndex)
console.log("**************firstIndex*********",resultDelegateMainItem.DelegateModel.persistedItemsIndex)
}
}
}
}
model: docModel
groups: [
DelegateModelGroup {
includeByDefault: false
name: "favoris"
}
]
filterOnGroup: "favoris"
Component.onCompleted: {
var rowCount = docModel.size();
items.remove(0,rowCount);
for( var i = 0;i < rowCount;i++ ) {
var entry = docModel.get(i);
if(entry.BookDocumentType === BookDocumentType.Bookmark) {
items.insert(entry, "favoris");
}
}
}
}
ListView {
id: favorisList
clip: true
width: settings.width;
height: 600
model: displayDelegateModelFavoris
}
To copy to clipboard, switch view to plain text mode
Can any one help me please ?
Bookmarks