messagingapp/shareui/src/shareuiprivate.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 70 a15d9966050f
--- a/messagingapp/shareui/src/shareuiprivate.cpp	Tue Jul 06 14:12:40 2010 +0300
+++ b/messagingapp/shareui/src/shareuiprivate.cpp	Wed Aug 18 09:45:25 2010 +0300
@@ -31,7 +31,7 @@
 #include <HbNotificationDialog>
 #include <HbIconItem>
 #include <HbTextItem>
-
+#include <HbColorScheme>
 #include <xqserviceglobal.h>
 #include <xqaiwrequest.h>
 #include <xqaiwinterfacedescriptor.h>
@@ -54,6 +54,8 @@
 #define LOC_SERVICE_ERROR       hbTrId("Service error.")
 #define LOC_PROTECTED_CONTENT   hbTrId("Protected content.")
 
+const QString LIST_ITEM_TITLE("qtc_list_item_title_normal");
+
 /**
  * Constructor.
  */
@@ -84,7 +86,6 @@
         delete request;
     }
     mAiwRequestList.clear();
-
     }
 
 /**
@@ -95,106 +96,103 @@
  * 
  */
 bool ShareUiPrivate::init(QStringList& fileList, bool embedded)
-    {    
+    {
     reset();
     mIsEmbedded = embedded;
     // No input files
-    if ( fileList.count() == 0 )
-        {
+    if (fileList.count() == 0) {
         showNote(LOC_NO_FILES);
-        return true;       
-        }
+        return true;
+    }
 
 #ifdef __SHAREUI_MIME_HANDLING__   
     // Get the file attributes (MIME and forward lock)
     QStringList mimeTypeList;
     QStringList forwardStatusList;
     getFileAttributes(fileList, mimeTypeList, forwardStatusList);
-    
+
     // Ignore protected files
     QStringList filteredFileList;
     QStringList filteredMimeList;
-    for ( int i = 0; i < forwardStatusList.count(); i++ )
-        {
-        if ( forwardStatusList[i].toInt() )
-            {
+    for (int i = 0; i < forwardStatusList.count(); i++) {
+        if (forwardStatusList[i].toInt()) {
             filteredFileList << fileList[i];
             filteredMimeList << mimeTypeList[i];
-            }
         }
-    filteredMimeList.removeDuplicates();    
-    
+    }
+    filteredMimeList.removeDuplicates();
+
     // Some protected content
-    if ( fileList.count() != filteredFileList.count() )
-        {
-        showNote(LOC_PROTECTED_CONTENT);      
+    if (fileList.count() != filteredFileList.count()) {
+        showNote(LOC_PROTECTED_CONTENT);
         return true;
-        }
-    
+    }
+
     // Only protected content
-    if ( filteredFileList.count() == 0 )
-        {
+    if (filteredFileList.count() == 0) {
         showNote(LOC_NO_FILES);
-        return true;       
-        }
+        return true;
+    }
 #endif
 
 #ifdef __SHAREUI_MIME_HANDLING__ 
-    for ( int i = 0; i < filteredFileList.count(); i++ )
-        {     
+    for (int i = 0; i < filteredFileList.count(); i++) {
         mFileList.append(QDir::toNativeSeparators(filteredFileList[i]));
-        }
+    }
 #else
     for ( int i = 0; i < fileList.count(); i++ )
-        {     
+    {
         mFileList.append(QDir::toNativeSeparators(fileList[i]));
-        }
+    }
 #endif
-    
-    QList<XQAiwInterfaceDescriptor> serviceDescriptorList = 
-            mAppManager.list(SERVICE_INTERFACE, SHARE_OP);
-    if ( serviceDescriptorList.size() > 0 )
-        {          
+
+    QList<XQAiwInterfaceDescriptor> serviceDescriptorList = mAppManager.list(SERVICE_INTERFACE,
+        SHARE_OP);
+
+    if (serviceDescriptorList.size() > 0) {
         initializeUi();
-
-        for ( int i = 0; i < serviceDescriptorList.count() ; i++ )
-            { 
+        //sorting the services based on service names,
+        QMap<QString,XQAiwInterfaceDescriptor > serviceInterfaceMap;
+        for (int i = 0; i < serviceDescriptorList.count(); i++) {
+            serviceInterfaceMap.insert(serviceDescriptorList[i].serviceName(),
+                serviceDescriptorList[i]);
+        }
+        QStringList serviceNames = serviceInterfaceMap.keys();
+        serviceDescriptorList.clear();
+        
+        for (int i = 0; i < serviceNames.count(); i++) {
 #ifdef __SHAREUI_MIME_HANDLING__          
             // Filter services based on content type
-            QString allowedTypes = serviceDescriptorList[i].customProperty
-                    (QString("allowed_mime_types"));              
-            QString blockedTypes = serviceDescriptorList[i].customProperty
-                    (QString("blocked_mime_types"));
-            
+            QString allowedTypes = serviceInterfaceMap[serviceNames.at(i)].customProperty(QString(
+                "allowed_mime_types"));
+            QString blockedTypes = serviceInterfaceMap[serviceNames.at(i)].customProperty(QString(
+                "blocked_mime_types"));
+
             // Check against MIME filters
-            if ( ! isContentAllowed( filteredMimeList, allowedTypes ) )
+            if (!isContentAllowed(filteredMimeList, allowedTypes))
                 continue;
-            
-            if ( isContentBlocked( filteredMimeList, blockedTypes ) )
-                continue;                     
+
+            if (isContentBlocked(filteredMimeList, blockedTypes))
+                continue;
 #endif            
-            HbAction* action = fetchServiceAction(serviceDescriptorList[i]);
-            QString iconName = serviceDescriptorList[i].customProperty
-                    (QString("aiw_action_icon"));
-            if ( action )
-                {
+            HbAction* action = fetchServiceAction(serviceInterfaceMap[serviceNames.at(i)]);
+            QString iconName = serviceInterfaceMap[serviceNames.at(i)].customProperty(QString("aiw_action_icon"));
+            if (action) {
                 updateShareUiDialogList(action, iconName);
-                }
             }
-        
-        if ( mContentItemModel->rowCount() == 0 )
-            {
+        }
+        serviceInterfaceMap.clear();
+        if (mContentItemModel->rowCount() == 0) {
             showNote(LOC_NO_SERVICES);
             return true;
-            }
+        }
 
         mSharePopup->show();
-        }
-    else
-        {
+    }
+    else {
         showNote(LOC_NO_SERVICES);
-        }
-    
+    }
+
     return true;
     }
 
@@ -208,6 +206,8 @@
     // make it delete itself on close
     mSharePopup->setAttribute( Qt::WA_DeleteOnClose, true );
     HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup);
+    QColor color = HbColorScheme::color( LIST_ITEM_TITLE );
+    heading->setTextColor( color );
     heading->setAlignment(Qt::AlignCenter);
     mSharePopup->setDismissPolicy(HbDialog::TapAnywhere);
     mSharePopup->setHeadingWidget(heading);
@@ -486,7 +486,7 @@
     HbNotificationDialog* dlg = new HbNotificationDialog();
     dlg->setFocusPolicy(Qt::NoFocus);
     dlg->setAttribute(Qt::WA_DeleteOnClose, true);
-    dlg->setText(text);
+    dlg->setTitle(text);
     dlg->show();
     }