PDA

View Full Version : custom file tree



dinnot
8th May 2010, 18:17
Hello.

I want to do a File Tree (like QTreeView does) but i want it to be custom. First it dont have any file, but when a file or a dir drops on it i want it to be added to root. Also, if the user want to delete one file from one dir that he added, he must be able to (oc without deleting the original file) and keeping the rest of files.

Example:
initialy:

<root>
//add directory "test" which contains file1, file2 and dir1 (which also contains file3)

<root>
- test
file1
file2
- dir1
file3
//add file file4

<root>
- test
file1
file2
- dir1
file3
file4
//delete file1

<root>
- test
file2
- dir1
file3
file4
//delete dir1

<root>
- test
file2
file4


If i use QTreeView Widget i must rewrite ModelIndex to make it custom?
Or any other ideas how to do it?

Thank you! :)

squidge
9th May 2010, 00:26
Just create a normal model. When you want to add or remove items, emit the appropriate signals and all views will automatically update.

dinnot
9th May 2010, 00:38
Well, can you give me more informations? The delete action isnt on the physical address, it's just on my program, so i dont really understand how to do that...

squidge
9th May 2010, 10:43
beginRemoveRows(...)
... remove rows from your data store ...
endRemoveRows()