Results 1 to 2 of 2

Thread: Custom Dir View - Folders first, with improved Sort Functions

  1. #1
    Join Date
    May 2010
    Posts
    5
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Question Custom Dir View - Folders first, with improved Sort Functions

    Hi,

    I´m trying to create a Widget that displays the content of a "virtual Folder".
    "Virtual Folder", since the Elements, that need to be displayed later, were delivered by a Server in XML Format.
    The XML File contains all informations, that QDir and QFileInfo would offer.

    If possible, I would like to realise the whole Widget in a single extended subclass of QTreeWidget.


    2 Points need to be considered:

    1.) The Folders should always be displayed on top. While Files can be sorted by Name, Type, Size, ... (Asc & Dsc), the Folders should always be sorted by Name (Asc / Dsc) and stay on top of the list.

    2.) The Columns should contain Human readable data (QStrings), but need to be sorted by sortable values (QStrings, qint64, QDateTime, ...)

    i.e. the Size Columns:

    Text in Item Column : 1,00 Mb (QString) - should be sorted by -
    Data in Item Column : 1048576 (qint64 )


    Basically, you can reduce my post to one single question:

    Is there a way to differ between the displayed Text and the (hidden) sortable value of an Item?

    I would use this as an advantage, to hold the Folders always on Top, by prepending data to the sortable values.


    Thanks in advance for any kind of clue.
    Attached Images Attached Images
    Last edited by Threepwood; 24th June 2010 at 12:07.

  2. #2
    Join Date
    Apr 2010
    Posts
    34
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Dir View - Folders first, with improved Sort Functions

    All you need is to create your own model. Are you acquainted with Model/View architecture? The documentation is exhaustive. Here's online doc.: http://doc.qt.nokia.com/4.6/model-vi...w-architecture

    The Qt class QAbstractItemModel is where to start.

    Keep your data in a separate structure. Derive your own model that will provide the translation of data from the data storage to the view. Then join the view and the data storage through that model. Qt is very friendly in these tasks!

  3. The following user says thank you to Vit Stepanek for this useful post:

    Threepwood (20th March 2011)

Similar Threads

  1. Custom Model? Custom View? Custom Delegate?
    By Doug Broadwell in forum Newbie
    Replies: 4
    Last Post: 11th February 2010, 21:23
  2. dataChanged does not re-sort the view
    By alex9099 in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2008, 21:14
  3. QTreeWidget (Row Check, Custom Sort)
    By AaronMK in forum Qt Programming
    Replies: 3
    Last Post: 8th January 2008, 16:55
  4. Custom sort with QTableWidget
    By nicolas44 in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 01:47
  5. Drag and drop items in view to sort order
    By Big Duck in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2006, 20:43

Tags for this Thread

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.