messagingapp/msgui/msgaudiofetcher/src/msgaudioselectionengine.cpp
changeset 70 a15d9966050f
parent 52 12db4185673b
--- a/messagingapp/msgui/msgaudiofetcher/src/msgaudioselectionengine.cpp	Thu Sep 02 20:23:03 2010 +0300
+++ b/messagingapp/msgui/msgaudiofetcher/src/msgaudioselectionengine.cpp	Fri Sep 17 08:28:39 2010 +0300
@@ -22,6 +22,7 @@
 #include <bautils.h>
 #include <centralrepository.h>
 #include <ProfileEngineDomainCRKeys.h>
+#include <QMap>
 
 // USER INCLUDES
 #include "msgaudioselectionengine.h"
@@ -135,6 +136,7 @@
         }
     else
         {
+        QMap<QString,QString> nameUriList;
         CMdEObjectQuery* query = static_cast<CMdEObjectQuery*> (&aQuery);
         TInt count = query->Count();
         for (TInt i = 0; i < count; ++i)
@@ -153,11 +155,30 @@
                         property->TextValueL()));
                 QString uriValue(XQConversions::s60DescToQString(
                         object->Uri()));
-                iNameList.append(songName);
-                iUriList.append(uriValue);
+                
+                //insert into the map
+                nameUriList.insertMulti(uriValue, songName);
                 }
             CleanupStack::PopAndDestroy(object);
             }
+        
+        //now get all the song names and sort them
+        iNameList = nameUriList.values();
+        iNameList.sort();
+        
+        // go through the song list and get the associated uri
+        // insert into the uri list
+        int nameListTotal = iNameList.count();
+        for(int nameListCount = 0; 
+                nameListCount<nameListTotal;
+                nameListCount++)
+            {
+            QString key = nameUriList.key(iNameList.at(nameListCount));
+            iUriList.append(key);
+            nameUriList.remove(key);                        
+            }
+        
+        // emit the list to the model
         emit queryComplete(iNameList, iUriList);
         }
     }