I'm creating a sortable/filterable tree model displaying DBus services/nodes.
My code is based on the code used in qdbusviewer, and everything worked fine, until I started implementing lazy population of items (using hasChildren, canFetchMore and fetchMore).
My base model (DBusModel) works like a charm, but the accompanying proxy model (DBusSortFilterModel) started behaving very strange.
Sorting seems to work fine, Filtering seems to work fine, but when I expand any item, the whole view gets messed up (items just disappear!!).
See attached screenshots...
At the moment my implementation does something like this:
bool DBusSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
// ...
}
bool DBusSortFilterProxyModel::hasChildren(const QModelIndex& parent) const
{
return sourceModel()->hasChildren(mapToSource(parent));
}
bool DBusSortFilterProxyModel::canFetchMore(const QModelIndex& parent) const
{
return sourceModel()->canFetchMore(mapToSource(parent));
}
void DBusSortFilterProxyModel::fetchMore(const QModelIndex& parent)
{
return sourceModel()->fetchMore(mapToSource(parent));
}
bool DBusSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
// ...
}
bool DBusSortFilterProxyModel::hasChildren(const QModelIndex& parent) const
{
return sourceModel()->hasChildren(mapToSource(parent));
}
bool DBusSortFilterProxyModel::canFetchMore(const QModelIndex& parent) const
{
return sourceModel()->canFetchMore(mapToSource(parent));
}
void DBusSortFilterProxyModel::fetchMore(const QModelIndex& parent)
{
return sourceModel()->fetchMore(mapToSource(parent));
}
To copy to clipboard, switch view to plain text mode
Probably I'm just overlooking something, or didn't implement some required functionality for this to work. But what?
Anybody has some experience with this?
Bookmarks