The approach looks fine. As for combining two models - you'll have to "delegate" access to one model to the other. So for instance if someone asks your model for data for an index that describes a file in a project, you'll have to translate the index to an index understood by the dir model, call the dir model's method with this crafted index and return the result as a result of your method. A simple sketch of what I mean (look in my earlier post for an extended version):
return internalDirModel->data(dirIndex, ...);
}
QVariant MyModel::data(const QModelIndex &index, ...) const {
QModelIndex dirIndex = translateToDirModel(index);
return internalDirModel->data(dirIndex, ...);
}
To copy to clipboard, switch view to plain text mode
Bookmarks