Results 1 to 11 of 11

Thread: QDirModel, Model/View, extend the file onfo

  1. #1
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QDirModel, Model/View, extend the file onfo

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDirModel, Model/View, extend the file onfo

    I think the best and most straightforward way is to subclass QDirModel and extend it with the columns you need.

  3. #3
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel, Model/View, extend the file onfo

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDirModel, Model/View, extend the file onfo

    Reimplement columnCount() and data() (and maybe also index()) to support your additional columns.

  5. #5
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel, Model/View, extend the file onfo

    ColomnCount is easy but the others...
    I solved the problem by using my own FileModel class.
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDirModel, Model/View, extend the file onfo

    Quote Originally Posted by VlJE View Post
    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.

  7. #7
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel, Model/View, extend the file onfo

    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...

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDirModel, Model/View, extend the file onfo

    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.

  9. #9
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel, Model/View, extend the file onfo

    I have 1 container instead of 2 and I don't care to synchronise theese container

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDirModel, Model/View, extend the file onfo

    In what way is it related to the problem?

  11. #11
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel, Model/View, extend the file onfo

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.