Believe me, I understand.
Then use a proxy as advised.I agree. But unfortunately, I'm not responsible for agreeing on project requirements, and they are already approved. I have to implement the task.
Not the item - the view. It's like having a combobox with one item...Yes, but to leave the item empty, I need to insert it in the tree in some way at first.![]()
Hmm... I guess we might have misunderstood each other. I thought you meant:Can you please give me a hint on implementing these methods? As I understood, the main function of interest is mapToSource (). So if QDirModel stores indexes for the system logic drives as [0,1,2,...], I will need to shift them by value of 1, and when the model index equals 0, I'll need to perform some custom actions. But I can't understand how to do this
My Documents
+--Drive 1
+--Drive 2
...
but it seems you want:
+My Documents
+Drive 1
+Drive 2
...
So My Documents is not "above" Drive 1 and Drive 2 but "before" them... right?
In that case I suggest you subclass QDirModel as you'll want to provide some data that doesn't exist in the model. Or do you just want to show the contents of some subfolder on one of the disks as children of the added item? If the latter, then you can go with a proxy. You just need to return one more row for an invalid parent, shift row numbers by 1 in mapToSource and mapFromSource for invalid parent and return the model index of the "linked" folder instead of the (0,0, invalid) index. You might have a problem the other way round as a source index of the target folder can be mapped into two indexes of the proxy and you'll have to decide which one to choose.
Bookmarks