i cant think of implementing this from beginning. it seems to be beyond my level as am getting into this. i request you to give complete code for similar application if you have any.
thanks
i cant think of implementing this from beginning. it seems to be beyond my level as am getting into this. i request you to give complete code for similar application if you have any.
thanks
If I had and I could give it to you, I already would have.
It's not that hard to implement what you want using the dir model, you should really try it. You only have to come up with a nice way to bind "virtual" and "real" paths. It is possible that it is enough to store a file path of the root of the project within the list storing projects.
Hi,
could you varify my approch and give answers for my questions?
i am using the concept of SimpleTreeModel(example program) to list the top level structure i, e,
+ projects
+ Qt Project
+ d:\qt
+ Qtopia
+ c:\qtopia
now, from "d:\qt" or "c:\qtopia" i would like to use the QDirModel to list the directory structure.
is this valid aproach?
if yes, how to integrate QDirModel with the SimpleTreeModel?
is it possible to use the two model? how?
any low level design details would be great
Thanks
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):
Qt Code:
return internalDirModel->data(dirIndex, ...); }To copy to clipboard, switch view to plain text mode
Thanks Wysota,
I am finding difficult in "mapping the index (of my model) to index of dir model" and also finding the depth of an index. Somehow i managed to code for finding the depth of an index. I have attached the source code. Please verify the depth function and some more hints on mapping the index(i would request the complete code).
As I said earliar, i am using the simpletreemodel code. currently am hardcoded the values in setupModelData.
Thanks
Finding depth is easy. Just iterate to parent() index and count how many iterations it takes until you reach the top.
Qt Code:
QModelIndex iter = index; int depth = 0; while(!iter.isNull()){ iter = iter.parent(); ++depth; }To copy to clipboard, switch view to plain text mode
Bookmarks