
Originally Posted by
Urvin
I can't imagine what to write in canFetchMore and fetchMore
Back in your first post, you had code like this:
if (*condition*)
node->children.last()->children.append(new treeNodeClient(-1, tr("Loading..."), node->children.last() ));
if (*condition*)
node->children.last()->children.append(new treeNodeClient(-1, tr("Loading..."), node->children.last() ));
To copy to clipboard, switch view to plain text mode
which I presume now reads:
node->children.last()->hasChildren = *condition*;
node->children.last()->hasChildren = *condition*;
To copy to clipboard, switch view to plain text mode
instead. You’ll then want something like this:
bool modelClients::canFetchMore(const QModelIndex& parent) const {
if (!parent.isValid()) return false;
treeNodeClient *node = static_cast<treeNodeClient*>(parent.internalPointer());
return parentNode->hasChildren && !parentNode->children.count();
}
void modelClients::fetchMore (const QModelIndex& parent) {
if (!canFetchMore(parent)) return;
treeNodeClient *node = static_cast<treeNodeClient*>(parent.internalPointer());
//
// get the information you need to populate node
//
beginInsertRows(node, 0, mm_IDs.count()-1);
setLists(node, mm_IDs, mm_Names);
endInsertRows();
}
bool modelClients::canFetchMore(const QModelIndex& parent) const {
if (!parent.isValid()) return false;
treeNodeClient *node = static_cast<treeNodeClient*>(parent.internalPointer());
return parentNode->hasChildren && !parentNode->children.count();
}
void modelClients::fetchMore (const QModelIndex& parent) {
if (!canFetchMore(parent)) return;
treeNodeClient *node = static_cast<treeNodeClient*>(parent.internalPointer());
//
// get the information you need to populate node
//
beginInsertRows(node, 0, mm_IDs.count()-1);
setLists(node, mm_IDs, mm_Names);
endInsertRows();
}
To copy to clipboard, switch view to plain text mode
for canFetchMore and fetchMore.
Bookmarks