equal
deleted
inserted
replaced
51 _LIT(KSelectVCardStmt,"SELECT message_id, msg_processingstate, preview_path FROM conversation_messages WHERE message_id = :message_id "); |
51 _LIT(KSelectVCardStmt,"SELECT message_id, msg_processingstate, preview_path FROM conversation_messages WHERE message_id = :message_id "); |
52 |
52 |
53 // preview-cache max cost (items) |
53 // preview-cache max cost (items) |
54 const int CACHE_COST = 50; |
54 const int CACHE_COST = 50; |
55 //Preview thumbnail size |
55 //Preview thumbnail size |
56 const int KWidth = 9.5 * 6.7; |
56 const int KWidth = 24 * 6.7; |
57 const int KHeight = 9.5 * 6.7; |
57 const int KHeight = 24 * 6.7; |
58 //--------------------------------------------------------------- |
58 //--------------------------------------------------------------- |
59 // ConversationsModel::ConversationsModel |
59 // ConversationsModel::ConversationsModel |
60 // Constructor |
60 // Constructor |
61 //--------------------------------------------------------------- |
61 //--------------------------------------------------------------- |
62 ConversationsModel::ConversationsModel(ConversationMsgStoreHandler* msgStoreHandler, |
62 ConversationsModel::ConversationsModel(ConversationMsgStoreHandler* msgStoreHandler, |
509 bytesPerLine, QImage::Format_RGB16)); |
509 bytesPerLine, QImage::Format_RGB16)); |
510 |
510 |
511 setPreviewIcon(pixmap, attachmentPath, msgId, |
511 setPreviewIcon(pixmap, attachmentPath, msgId, |
512 true); |
512 true); |
513 |
513 |
|
514 } |
|
515 else |
|
516 { |
|
517 QPixmap pixmap; |
|
518 setPreviewIcon(pixmap, attachmentPath, msgId, |
|
519 false); |
514 } |
520 } |
515 //remove bitmap |
521 //remove bitmap |
516 delete bitmap; |
522 delete bitmap; |
517 } |
523 } |
518 |
524 |
815 |
821 |
816 // if not found in db, set from file path |
822 // if not found in db, set from file path |
817 if (!inDb) |
823 if (!inDb) |
818 { |
824 { |
819 QPixmap pixmap(filePath); |
825 QPixmap pixmap(filePath); |
820 QPixmap scaledPixmap = pixmap.scaled(KWidth, KHeight, Qt::IgnoreAspectRatio); |
826 QSize originalIconSize = pixmap.size(); |
|
827 QSize scaledIconSize; |
|
828 getScaledSize(originalIconSize,scaledIconSize); |
|
829 |
|
830 QPixmap scaledPixmap = pixmap.scaled(scaledIconSize.width(), |
|
831 scaledIconSize.height(), Qt::KeepAspectRatio); |
821 HbIcon *previewIcon = new HbIcon(scaledPixmap); |
832 HbIcon *previewIcon = new HbIcon(scaledPixmap); |
822 |
833 |
823 previewIconCache.insert(msgId, previewIcon); |
834 previewIconCache.insert(msgId, previewIcon); |
824 |
835 |
825 } |
836 } |
933 |
944 |
934 // if not found in db, set from file path |
945 // if not found in db, set from file path |
935 if (!imagePreviewed) |
946 if (!imagePreviewed) |
936 { |
947 { |
937 QPixmap orgPixmap(filePath); |
948 QPixmap orgPixmap(filePath); |
938 pixmap = orgPixmap.scaled(63.65, 63.65, Qt::IgnoreAspectRatio); |
949 QSize originalIconSize = pixmap.size(); |
|
950 QSize scaledIconSize; |
|
951 getScaledSize(originalIconSize,scaledIconSize); |
|
952 |
|
953 QPixmap scaledPixmap = orgPixmap.scaled(scaledIconSize.width(), |
|
954 scaledIconSize.height(), Qt::KeepAspectRatio); |
939 } |
955 } |
940 HbIcon * previewIcon = new HbIcon(pixmap); |
956 HbIcon * previewIcon = new HbIcon(pixmap); |
941 |
957 |
942 previewIconCache.insert(msgId, previewIcon); |
958 previewIconCache.insert(msgId, previewIcon); |
943 |
959 |
1071 //--------------------------------------------------------------- |
1087 //--------------------------------------------------------------- |
1072 void ConversationsModel:: emitConversationViewEmpty() |
1088 void ConversationsModel:: emitConversationViewEmpty() |
1073 { |
1089 { |
1074 emit conversationViewEmpty(); |
1090 emit conversationViewEmpty(); |
1075 } |
1091 } |
|
1092 |
|
1093 //--------------------------------------------------------------- |
|
1094 // ConversationsModel::getScaledSize() |
|
1095 // @see header |
|
1096 //--------------------------------------------------------------- |
|
1097 void ConversationsModel::getScaledSize(const QSize &originalSize, |
|
1098 QSize &scaledSize) |
|
1099 { |
|
1100 qreal newLength =0; |
|
1101 if(originalSize.width() >= originalSize.height()) |
|
1102 { |
|
1103 if(originalSize.width() < KWidth) |
|
1104 { |
|
1105 scaledSize.setHeight(originalSize.height()); |
|
1106 scaledSize.setWidth(originalSize.width()); |
|
1107 } |
|
1108 else |
|
1109 { |
|
1110 scaledSize.setWidth(KWidth); |
|
1111 newLength = (KWidth * originalSize.height())/ |
|
1112 originalSize.width(); |
|
1113 scaledSize.setHeight(newLength); |
|
1114 } |
|
1115 } |
|
1116 else |
|
1117 { |
|
1118 if(originalSize.height() < KHeight) |
|
1119 { |
|
1120 scaledSize.setHeight(originalSize.height()); |
|
1121 scaledSize.setWidth(originalSize.width()); |
|
1122 } |
|
1123 else |
|
1124 { |
|
1125 scaledSize.setHeight(KHeight); |
|
1126 newLength = (KHeight * originalSize.width())/ |
|
1127 originalSize.height(); |
|
1128 scaledSize.setWidth(newLength); |
|
1129 } |
|
1130 } |
|
1131 } |
|
1132 |
1076 //EOF |
1133 //EOF |