PDA

View Full Version : QDirModel, Model/View, extend the file onfo



VlJE
29th September 2006, 14:05
I need an approach to extend the file information (insert Column?) given in the QDirModel with my own file-specifical information. If I can do it ny subclassing of QDirModel or I should programm my own file model by subclassing the abstract model?
Or it is enough to overwrite columnCount function and add someway the additional information direct to the View (Ex. QTreeView)?
I display the list of files, make an operation on the files and would like to display the status of the operation (Text) and the result near the file. I should have the possibility for the father access of the status information.

wysota
29th September 2006, 15:18
I think the best and most straightforward way is to subclass QDirModel and extend it with the columns you need.

VlJE
13th October 2006, 16:09
The Question is, how to do it.
Use derivered from the abstract item model "insertColumn" or overwrite columnCount or how? I don't understand how the file data is stored in the QDirModel. I suppose the tree based on the QDir Output.

wysota
13th October 2006, 21:50
Reimplement columnCount() and data() (and maybe also index()) to support your additional columns.

VlJE
27th October 2006, 16:19
:confused: ColomnCount is easy but the others...
I solved the problem by using my own FileModel class.

wysota
27th October 2006, 17:06
:confused: ColomnCount is easy but the others...

Others what? If you add columns, you only have to reimplement columnCount() and data(). In data you can call QDirModel::data() for the original columns and return appropriate data for your own columns.

VlJE
31st October 2006, 15:30
My additional columns are the operation result string and the operation result state.
In the case of your solution I have to care about the map FileName/Operation result.
If the processing ramains fast enought by 10000 Files in my directory...

wysota
1st November 2006, 23:00
You have to keep the data somewhere anyway if you can't create the data on the fly. Just access and return it from within data(), just like QDirModel does.

VlJE
30th November 2006, 12:18
I have 1 container instead of 2 and I don't care to synchronise theese container

wysota
30th November 2006, 14:49
In what way is it related to the problem?

VlJE
11th December 2006, 11:56
By using QDirModel "You have to keep the data somewhere anyway if you can't create the data on the fly. Just access and return it from within data(), just like QDirModel does".
Also I have to care about "somewhere" for each processed file. It ist the 1. Container.
QDirModel hat it's own hidden 2. File container (or tree...).
By overwritig of Data() I have to merge the file info of QDirModel and the additional file info in "somewhere".
It was more effectiv in my case to create my own FileModel with 1 File-Container for all the file data, the additional file data inclusive.