Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
sf18443
Posts: 16
Registered: ‎04-05-2009
My Device: Bold 9930, PlayBook, and Dev Alpha
My Carrier: Verizon Wireless

Sorting RSS entries by pubDate question (Data Source, GroupDataModel, and ListView)

When using a GroupDataModel and Data Source to display RSS entries in a ListView, and when using sortingkeys to sort by pubDate, the entries are grouped based on the the day of the week and then by the date and time... (See image for clarification)

 

GroupDataModel { 
                    id: dataModel
                    sortingKeys: ["pubDate"]
                    grouping: ItemGrouping.None
                    sortedAscending: false
}

 

 

I understand why this happens, but is there a relatively simple way to remedy this issue?

 

Example of the issue described

Please use plain text.
Contributor
sf18443
Posts: 16
Registered: ‎04-05-2009
My Device: Bold 9930, PlayBook, and Dev Alpha
My Carrier: Verizon Wireless

Re: Sorting RSS entries by pubDate question (Data Source, GroupDataModel, and ListView)

*shameless bump* anyone?
Please use plain text.
Contributor
icq782443
Posts: 22
Registered: ‎02-21-2012
My Device: Playbook torch 9800
My Carrier: Telus

Re: Sorting RSS entries by pubDate question (Data Source, GroupDataModel, and ListView)

I have the same question. Hoping someone can reply. Thx.

Please use plain text.
New Contributor
scorpion230154
Posts: 9
Registered: ‎09-08-2011
My Device: developer
My Carrier: developer

Re: Sorting RSS entries by pubDate question (Data Source, GroupDataModel, and ListView)

Hello,
Bad english but if it can help!
---
// Constructeur.
Bb574::Bb574( QObject *parent )
    : QObject( parent ),        
    private_erreur( false ),
    private_groupdatamodel( new GroupDataModel( QStringList() << "id_str", this ) ) {

    // Twitter : id_str : These Tweet IDs are unique 64bit unsigned integers, which,
    // instead of being sequential like the current IDs, are based on time. The full ID
    // is composed of a timestamp, a worker number, and a sequence number.
    QStringList trier_groupdatamodel;
    trier_groupdatamodel << "id_str";    
    // Signature de setSortingKeys ( const QStringList &keys )
    private_groupdatamodel->setSortingKeys( trier_groupdatamodel );    
    private_groupdatamodel->setSortedAscending( false );
    // Les items ne sont pas regroupes.
    private_groupdatamodel->setGrouping( ItemGrouping::None );

---

    Q_PROPERTY
        ( bb::cascades::smileyvery-happy:ataModel* bb_c_dm READ datamodel CONSTANT )

---

      // BEGIN +      
      Container {           
           // background: Color.create( "#ffc0cb" ) // DEBUG - Pink
           layout: AbsoluteLayout { }
           layoutProperties: AbsoluteLayoutProperties {               
               positionX:  5
               positionY: 75
           }
           preferredWidth: 1270
           preferredHeight: 575           
           ListView {               
               layoutProperties: AbsoluteLayoutProperties {                   
                   positionX: 10
                   positionY: 10
               }
               preferredWidth: 1260
               preferredHeight: 565                      
               dataModel: bb574.bb_c_dm // 5 - Q_PROPERTY                      
               listItemComponents: [                                    
                  ListItemComponent {                      
                      type: "item"                          
                      StandardListItem {                          
                          status: ListItemData.created_at
                          description: ListItemData.text
                          imageSpaceReserved: false
                      }
                  }
               ]
           }
           
       } // END +
---

Please use plain text.
New Developer
BrownCode
Posts: 3
Registered: ‎01-16-2013
My Device: Dev Alpha B
My Carrier: Telus

Re: Sorting RSS entries by pubDate question (Data Source, GroupDataModel, and ListView)

Any luck with this?

 

I'm hoping there is any easy way in QML, otherwise I have to break out the C++...

Please use plain text.
Developer
BBornot2B
Posts: 19
Registered: ‎11-11-2012
My Device: Z10, DevAlphaC, Torch 9810, PlayBook
My Carrier: Movistar

Re: Sorting RSS entries by pubDate question (Data Source, GroupDataModel, and ListView)

Hi there

 

QML will allways sort alphabetically, so the only way to solve this is changing the pubDate date format so it starts with the year, then month, and so on... depending on your data source (for instance, SQL does it like this from the beggining)

 

If after building your list you wanna make the date human readable then just use JavaScript... something like this (well, as you're not grouping change Header for Label and title for text)

Header {
    title: ListItemData
    
    onCreationCompleted: {
        var today = new Date();
        today = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0, 0);
        var header = new Date(title.substring(0,4), title.substring(5,7) - 1, title.substring(8,10), 0, 0, 0, 0);
        var hours = (today.getTime() - header.getTime()) / 1000 / 60 / 60;
        var days = (hours - hours % 24) / 24;
        switch (days) {
        case 0:
            title = "Today";
            break;
        case 1:
            title = "Yesterday";
            break;
        default:
            title = header.toDateString();
        }
    }
}

 Good luck!

Please use plain text.