messagingapp/msgui/appengine/src/conversationsmodel.cpp
changeset 56 f42d9a78f435
parent 51 3507212d340e
--- a/messagingapp/msgui/appengine/src/conversationsmodel.cpp	Wed Aug 18 00:46:12 2010 +0530
+++ b/messagingapp/msgui/appengine/src/conversationsmodel.cpp	Tue Aug 31 18:53:38 2010 +0530
@@ -53,8 +53,8 @@
 // preview-cache max cost (items)
 const int CACHE_COST =  50;
 //Preview thumbnail size
-const int KWidth = 9.5 * 6.7;
-const int KHeight = 9.5 * 6.7;
+const int KWidth = 24 * 6.7;
+const int KHeight = 24 * 6.7;
 //---------------------------------------------------------------
 // ConversationsModel::ConversationsModel
 // Constructor
@@ -512,6 +512,12 @@
                                     true);
 
                             }
+                        else
+                            {
+                            QPixmap pixmap;
+                            setPreviewIcon(pixmap, attachmentPath, msgId,
+                                    false);
+                            }
                         //remove bitmap
                         delete bitmap;
                         }
@@ -817,7 +823,12 @@
     if (!inDb)
     {
         QPixmap pixmap(filePath);
-        QPixmap scaledPixmap = pixmap.scaled(KWidth, KHeight, Qt::IgnoreAspectRatio);
+        QSize originalIconSize = pixmap.size();
+        QSize scaledIconSize;
+        getScaledSize(originalIconSize,scaledIconSize);
+
+        QPixmap scaledPixmap = pixmap.scaled(scaledIconSize.width(), 
+                scaledIconSize.height(), Qt::KeepAspectRatio);
         HbIcon *previewIcon = new HbIcon(scaledPixmap);
 
         previewIconCache.insert(msgId, previewIcon);
@@ -935,7 +946,12 @@
     if (!imagePreviewed)
     {
         QPixmap orgPixmap(filePath);
-        pixmap = orgPixmap.scaled(63.65, 63.65, Qt::IgnoreAspectRatio);
+        QSize originalIconSize = pixmap.size();
+        QSize scaledIconSize;
+        getScaledSize(originalIconSize,scaledIconSize);
+
+        QPixmap scaledPixmap = orgPixmap.scaled(scaledIconSize.width(), 
+                scaledIconSize.height(), Qt::KeepAspectRatio);
     }
     HbIcon * previewIcon = new HbIcon(pixmap);
 
@@ -1073,4 +1089,45 @@
 {
     emit conversationViewEmpty();
 }
+
+//---------------------------------------------------------------
+// ConversationsModel::getScaledSize()
+// @see header
+//---------------------------------------------------------------
+void ConversationsModel::getScaledSize(const QSize &originalSize,
+        QSize &scaledSize)
+{
+    qreal newLength =0;
+    if(originalSize.width() >= originalSize.height())
+        {
+        if(originalSize.width() < KWidth)
+            {
+            scaledSize.setHeight(originalSize.height());
+            scaledSize.setWidth(originalSize.width());
+            }
+        else
+            {
+            scaledSize.setWidth(KWidth);
+            newLength = (KWidth * originalSize.height())/
+                    originalSize.width();
+            scaledSize.setHeight(newLength);
+            }
+        }
+    else
+        {
+        if(originalSize.height() < KHeight)
+            {
+            scaledSize.setHeight(originalSize.height());
+            scaledSize.setWidth(originalSize.width());
+            }
+        else
+            {
+            scaledSize.setHeight(KHeight);
+            newLength = (KHeight * originalSize.width())/
+                    originalSize.height();
+            scaledSize.setWidth(newLength);
+            }            
+        }
+}
+
 //EOF