1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
19 #include <thumbnailmanager_qt.h> |
19 #include <thumbnailmanager_qt.h> |
20 |
20 |
21 #include "cxutils.h" |
21 #include "cxutils.h" |
22 #include "cxethumbnailmanagersymbian.h" |
22 #include "cxethumbnailmanagersymbian.h" |
23 |
23 |
24 //#define CXE_USE_THUMBNAIL_MANAGER |
24 |
25 |
25 |
26 |
26 |
27 /*! |
27 /*! |
28 * CxeThumbnailManagerSymbian::CxeThumbnailManagerSymbian |
28 * CxeThumbnailManagerSymbian::CxeThumbnailManagerSymbian |
29 */ |
29 */ |
30 CxeThumbnailManagerSymbian::CxeThumbnailManagerSymbian() |
30 CxeThumbnailManagerSymbian::CxeThumbnailManagerSymbian() |
31 { |
31 { |
32 CX_DEBUG_ENTER_FUNCTION(); |
32 CX_DEBUG_ENTER_FUNCTION(); |
33 |
33 |
34 #ifdef CXE_USE_THUMBNAIL_MANAGER |
|
35 |
|
36 mThumbnailManager = new ThumbnailManager(); |
34 mThumbnailManager = new ThumbnailManager(); |
37 |
35 |
38 // connect thumbnail ready signal from thumbnailmanager |
36 // connect thumbnail ready signal from thumbnailmanager |
39 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), |
37 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), |
40 this, SLOT(thumbnailReady(QPixmap, void *, int, int))); |
38 this, SLOT(thumbnailReady(QPixmap, void *, int, int))); |
41 #endif |
|
42 |
39 |
43 CX_DEBUG_EXIT_FUNCTION(); |
40 CX_DEBUG_EXIT_FUNCTION(); |
44 } |
41 } |
45 |
42 |
46 |
43 |
49 */ |
46 */ |
50 CxeThumbnailManagerSymbian::~CxeThumbnailManagerSymbian() |
47 CxeThumbnailManagerSymbian::~CxeThumbnailManagerSymbian() |
51 { |
48 { |
52 CX_DEBUG_ENTER_FUNCTION(); |
49 CX_DEBUG_ENTER_FUNCTION(); |
53 |
50 |
54 #ifdef CXE_USE_THUMBNAIL_MANAGER |
|
55 mThumbnailRequests.clear(); |
51 mThumbnailRequests.clear(); |
56 delete mThumbnailManager; |
52 delete mThumbnailManager; |
57 #endif |
|
58 |
53 |
59 CX_DEBUG_EXIT_FUNCTION(); |
54 CX_DEBUG_EXIT_FUNCTION(); |
60 } |
55 } |
61 |
56 |
62 |
57 |
64 /*! |
59 /*! |
65 * Creates a thumbnail based on the snapshot data. |
60 * Creates a thumbnail based on the snapshot data. |
66 @param filename - name of the image/video filename |
61 @param filename - name of the image/video filename |
67 @param snapshot - snapshot data from image/video |
62 @param snapshot - snapshot data from image/video |
68 */ |
63 */ |
69 void CxeThumbnailManagerSymbian::createThumbnail(const QString& filename, |
64 void CxeThumbnailManagerSymbian::createThumbnail(const QString &filename, |
70 QPixmap /*snapshot*/) |
65 const QImage &snapshot) |
71 { |
66 { |
72 CX_DEBUG_ENTER_FUNCTION(); |
67 CX_DEBUG_ENTER_FUNCTION(); |
73 |
68 |
74 #ifdef CXE_USE_THUMBNAIL_MANAGER |
|
75 TPtrC16 fName(reinterpret_cast<const TUint16*>(filename.utf16())); |
69 TPtrC16 fName(reinterpret_cast<const TUint16*>(filename.utf16())); |
76 CX_DEBUG(("Create thumbnail! filename = %s", filename.toAscii().constData())); |
70 CX_DEBUG(("Create thumbnail! filename = %s", filename.toAscii().constData())); |
77 |
71 |
78 if (mThumbnailManager) { |
72 if (mThumbnailManager) { |
79 CX_DEBUG(("creating thumbnails")); |
73 CX_DEBUG(("creating thumbnails")); |
80 //!@todo Thumbnail manager interface needs to be changed to use QImage |
74 int thumbnailId = mThumbnailManager->setThumbnail(snapshot, filename); |
81 // instead of QPixmap for setThumbnail. Until then, using qetThumbnail. |
|
82 int thumbnailId = mThumbnailManager->getThumbnail(filename, 0); |
|
83 if (thumbnailId != -1) { |
75 if (thumbnailId != -1) { |
84 CX_DEBUG(("Thumbnail ID = %d", thumbnailId)); |
76 CX_DEBUG(("Thumbnail ID = %d", thumbnailId)); |
85 mThumbnailRequests.insert(filename, thumbnailId); |
77 mThumbnailRequests.insert(filename, thumbnailId); |
86 } else { |
78 } else { |
87 CX_DEBUG(("error initializing data to thumbnail manager")); |
79 CX_DEBUG(("error initializing data to thumbnail manager")); |
88 } |
80 } |
89 } |
81 } |
90 #else |
|
91 Q_UNUSED(filename); |
|
92 #endif |
|
93 |
82 |
94 CX_DEBUG_EXIT_FUNCTION(); |
83 CX_DEBUG_EXIT_FUNCTION(); |
95 } |
84 } |
96 |
85 |
97 |
86 |
101 */ |
90 */ |
102 void CxeThumbnailManagerSymbian::cancelThumbnail(const QString& filename) |
91 void CxeThumbnailManagerSymbian::cancelThumbnail(const QString& filename) |
103 { |
92 { |
104 CX_DEBUG_ENTER_FUNCTION(); |
93 CX_DEBUG_ENTER_FUNCTION(); |
105 |
94 |
106 #ifdef CXE_USE_THUMBNAIL_MANAGER |
|
107 if (mThumbnailRequests.contains(filename)) { |
95 if (mThumbnailRequests.contains(filename)) { |
108 int thumbnailId = mThumbnailRequests.value(filename); |
96 int thumbnailId = mThumbnailRequests.value(filename); |
109 if (mThumbnailManager && |
97 if (mThumbnailManager && |
110 mThumbnailManager->cancelRequest(thumbnailId)) { |
98 mThumbnailManager->cancelRequest(thumbnailId)) { |
111 // thumbnail creation cancelled sucessfully |
99 // thumbnail creation cancelled sucessfully |
112 mThumbnailRequests.remove(filename); |
100 mThumbnailRequests.remove(filename); |
113 } |
101 } |
114 } |
102 } |
115 #else |
103 |
116 Q_UNUSED(filename); |
|
117 #endif |
|
118 CX_DEBUG_EXIT_FUNCTION(); |
104 CX_DEBUG_EXIT_FUNCTION(); |
119 } |
105 } |
120 |
106 |
121 |
107 |
122 /**! |
108 /**! |
129 void CxeThumbnailManagerSymbian::thumbnailReady(QPixmap thumbnail, void * data, int id, int error) |
115 void CxeThumbnailManagerSymbian::thumbnailReady(QPixmap thumbnail, void * data, int id, int error) |
130 { |
116 { |
131 |
117 |
132 CX_DEBUG_ENTER_FUNCTION(); |
118 CX_DEBUG_ENTER_FUNCTION(); |
133 |
119 |
|
120 Q_UNUSED(thumbnail); |
134 Q_UNUSED(data); |
121 Q_UNUSED(data); |
135 #ifdef CXE_USE_THUMBNAIL_MANAGER |
122 |
136 CX_DEBUG(("CxeThumbnailManagerSymbian::thumbnailReady error = %d", error)); |
123 CX_DEBUG(("CxeThumbnailManagerSymbian::thumbnailReady error = %d", error)); |
137 |
124 |
138 QString key; |
125 QString key; |
139 QHash<QString, int>::const_iterator i = mThumbnailRequests.constBegin(); |
126 QHash<QString, int>::const_iterator i = mThumbnailRequests.constBegin(); |
140 |
127 |
147 } |
134 } |
148 |
135 |
149 if (mThumbnailRequests.contains(key)) { |
136 if (mThumbnailRequests.contains(key)) { |
150 CX_DEBUG(("Thumbnail created for filename = %s", key.toAscii().constData())); |
137 CX_DEBUG(("Thumbnail created for filename = %s", key.toAscii().constData())); |
151 mThumbnailRequests.remove(key); |
138 mThumbnailRequests.remove(key); |
152 emit thumbnailReady(thumbnail, error); |
|
153 } |
139 } |
154 #else |
|
155 Q_UNUSED(thumbnail); |
|
156 Q_UNUSED(id); |
|
157 Q_UNUSED(error); |
|
158 #endif |
|
159 |
140 |
160 CX_DEBUG_EXIT_FUNCTION(); |
141 CX_DEBUG_EXIT_FUNCTION(); |
161 } |
142 } |