1 /* |
|
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QString> |
|
19 #include <thumbnailmanager_qt.h> |
|
20 |
|
21 #include "cxutils.h" |
|
22 #include "cxethumbnailmanagersymbian.h" |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 /*! |
|
28 * CxeThumbnailManagerSymbian::CxeThumbnailManagerSymbian |
|
29 */ |
|
30 CxeThumbnailManagerSymbian::CxeThumbnailManagerSymbian() |
|
31 { |
|
32 CX_DEBUG_ENTER_FUNCTION(); |
|
33 |
|
34 mThumbnailManager = new ThumbnailManager(); |
|
35 |
|
36 // connect thumbnail ready signal from thumbnailmanager |
|
37 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), |
|
38 this, SLOT(thumbnailReady(QPixmap, void *, int, int))); |
|
39 |
|
40 CX_DEBUG_EXIT_FUNCTION(); |
|
41 } |
|
42 |
|
43 |
|
44 /*! |
|
45 * CxeThumbnailManagerSymbian::~CxeThumbnailManagerSymbian |
|
46 */ |
|
47 CxeThumbnailManagerSymbian::~CxeThumbnailManagerSymbian() |
|
48 { |
|
49 CX_DEBUG_ENTER_FUNCTION(); |
|
50 |
|
51 mThumbnailRequests.clear(); |
|
52 delete mThumbnailManager; |
|
53 |
|
54 CX_DEBUG_EXIT_FUNCTION(); |
|
55 } |
|
56 |
|
57 |
|
58 |
|
59 /*! |
|
60 * Creates a thumbnail based on the snapshot data. |
|
61 @param filename - name of the image/video filename |
|
62 @param snapshot - snapshot data from image/video |
|
63 */ |
|
64 void CxeThumbnailManagerSymbian::createThumbnail(const QString &filename, |
|
65 const QImage &snapshot) |
|
66 { |
|
67 CX_DEBUG_ENTER_FUNCTION(); |
|
68 |
|
69 TPtrC16 fName(reinterpret_cast<const TUint16*>(filename.utf16())); |
|
70 CX_DEBUG(("Create thumbnail! filename = %s", filename.toAscii().constData())); |
|
71 |
|
72 if (mThumbnailManager) { |
|
73 CX_DEBUG(("creating thumbnails")); |
|
74 int thumbnailId = mThumbnailManager->setThumbnail(snapshot, filename); |
|
75 if (thumbnailId != -1) { |
|
76 CX_DEBUG(("Thumbnail ID = %d", thumbnailId)); |
|
77 mThumbnailRequests.insert(filename, thumbnailId); |
|
78 } else { |
|
79 CX_DEBUG(("error initializing data to thumbnail manager")); |
|
80 } |
|
81 } |
|
82 |
|
83 CX_DEBUG_EXIT_FUNCTION(); |
|
84 } |
|
85 |
|
86 |
|
87 |
|
88 /*! |
|
89 * start canceling creating thumbnail operation |
|
90 */ |
|
91 void CxeThumbnailManagerSymbian::cancelThumbnail(const QString& filename) |
|
92 { |
|
93 CX_DEBUG_ENTER_FUNCTION(); |
|
94 |
|
95 if (mThumbnailRequests.contains(filename)) { |
|
96 int thumbnailId = mThumbnailRequests.value(filename); |
|
97 if (mThumbnailManager && |
|
98 mThumbnailManager->cancelRequest(thumbnailId)) { |
|
99 // thumbnail creation cancelled sucessfully |
|
100 mThumbnailRequests.remove(filename); |
|
101 } |
|
102 } |
|
103 |
|
104 CX_DEBUG_EXIT_FUNCTION(); |
|
105 } |
|
106 |
|
107 |
|
108 /**! |
|
109 * Slot that notifies when final thumbnail bitmap generation or loading is complete. |
|
110 * @param pixmap An object representing the resulting thumbnail. |
|
111 * @param clientData Client data |
|
112 * @param id Request ID for the operation |
|
113 * @param errorCode error code |
|
114 */ |
|
115 void CxeThumbnailManagerSymbian::thumbnailReady(QPixmap thumbnail, void * data, int id, int error) |
|
116 { |
|
117 |
|
118 CX_DEBUG_ENTER_FUNCTION(); |
|
119 |
|
120 Q_UNUSED(thumbnail); |
|
121 Q_UNUSED(data); |
|
122 |
|
123 CX_DEBUG(("CxeThumbnailManagerSymbian::thumbnailReady error = %d", error)); |
|
124 |
|
125 QString key; |
|
126 QHash<QString, int>::const_iterator i = mThumbnailRequests.constBegin(); |
|
127 |
|
128 while (i != mThumbnailRequests.constEnd()) { |
|
129 if (i.value() == id) { |
|
130 key = i.key(); |
|
131 break; |
|
132 } |
|
133 ++i; |
|
134 } |
|
135 |
|
136 if (mThumbnailRequests.contains(key)) { |
|
137 CX_DEBUG(("Thumbnail created for filename = %s", key.toAscii().constData())); |
|
138 mThumbnailRequests.remove(key); |
|
139 } |
|
140 |
|
141 CX_DEBUG_EXIT_FUNCTION(); |
|
142 } |
|