|
1 /* |
|
2 * Copyright (c) 2009 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 <qsize.h> |
|
19 #include "thumbnailmanager_qt.h" |
|
20 #include <QMap> |
|
21 |
|
22 QMap<int, ThumbnailManager::TnRequest> ThumbnailManager::mRequests = QMap<int, ThumbnailManager::TnRequest>(); |
|
23 |
|
24 bool ThumbnailManager::mGetThumbFails = false; |
|
25 int ThumbnailManager::mThumbnailReadyError = 0; |
|
26 |
|
27 ThumbnailManager::ThumbnailManager( QObject* parentPtr ) : |
|
28 QObject( parentPtr ) |
|
29 { |
|
30 mMode = Default; |
|
31 } |
|
32 |
|
33 ThumbnailManager::~ThumbnailManager() |
|
34 { |
|
35 |
|
36 } |
|
37 |
|
38 ThumbnailManager::QualityPreference ThumbnailManager::qualityPreference() const |
|
39 { |
|
40 return mQuality; |
|
41 } |
|
42 |
|
43 bool ThumbnailManager::setQualityPreference( QualityPreference |
|
44 qualityPreference ) |
|
45 { |
|
46 mQuality = qualityPreference; |
|
47 return true; |
|
48 } |
|
49 |
|
50 ThumbnailManager::DisplayMode ThumbnailManager::displayMode() const |
|
51 { |
|
52 return Color16MAP; |
|
53 } |
|
54 |
|
55 bool ThumbnailManager::setDisplayMode( ThumbnailManager::DisplayMode displayMode ) |
|
56 { |
|
57 Q_UNUSED(displayMode); |
|
58 return true; |
|
59 } |
|
60 |
|
61 QSize ThumbnailManager::thumbnailSize() const |
|
62 { |
|
63 return QSize(128, 128); // ThumbnailMedium? |
|
64 } |
|
65 |
|
66 bool ThumbnailManager::setThumbnailSize( const QSize& thumbnailSize ) |
|
67 { |
|
68 Q_UNUSED(thumbnailSize); |
|
69 return true; |
|
70 } |
|
71 |
|
72 bool ThumbnailManager::setThumbnailSize( ThumbnailSize thumbnailSize ) |
|
73 { |
|
74 mThumbSize = thumbnailSize; |
|
75 return true; |
|
76 } |
|
77 |
|
78 ThumbnailManager::ThumbnailMode ThumbnailManager::mode() const |
|
79 { |
|
80 return mMode; |
|
81 } |
|
82 |
|
83 bool ThumbnailManager::setMode( ThumbnailMode mode ) |
|
84 { |
|
85 mMode = mode; |
|
86 return true; |
|
87 } |
|
88 |
|
89 int ThumbnailManager::getThumbnail( const QString& fileName, void * clientData, |
|
90 int priority ) |
|
91 { |
|
92 if(mGetThumbFails) return -1; |
|
93 |
|
94 int id = mRequests.count(); |
|
95 mRequests[id] = TnRequest(fileName, clientData, priority, false); |
|
96 return id; |
|
97 } |
|
98 |
|
99 int ThumbnailManager::getThumbnail( unsigned long int thumbnailId, void * clientData, |
|
100 int priority ) |
|
101 { |
|
102 Q_UNUSED(thumbnailId); |
|
103 Q_UNUSED(clientData); |
|
104 Q_UNUSED(priority); |
|
105 return 0; |
|
106 } |
|
107 |
|
108 int ThumbnailManager::setThumbnail( const QPixmap& source, const QString& filename, |
|
109 void * clientData , int priority ) |
|
110 { |
|
111 Q_UNUSED(source); |
|
112 Q_UNUSED(filename); |
|
113 Q_UNUSED(clientData); |
|
114 Q_UNUSED(priority); |
|
115 return 0; |
|
116 } |
|
117 |
|
118 void ThumbnailManager::deleteThumbnails( const QString& fileName ) |
|
119 { |
|
120 Q_UNUSED(fileName); |
|
121 } |
|
122 |
|
123 void ThumbnailManager::deleteThumbnails( unsigned long int thumbnailId ) |
|
124 { |
|
125 Q_UNUSED(thumbnailId); |
|
126 } |
|
127 |
|
128 bool ThumbnailManager::cancelRequest( int id ) |
|
129 { |
|
130 if(mRequests.contains(id)) { |
|
131 mRequests[id].cancelled = true; |
|
132 } |
|
133 return true; |
|
134 } |
|
135 |
|
136 bool ThumbnailManager::changePriority( int id, int newPriority ) |
|
137 { |
|
138 if(mRequests.contains(id)) { |
|
139 mRequests[id].priority = newPriority; |
|
140 } |
|
141 return true; |
|
142 } |
|
143 |
|
144 void ThumbnailManager::emitThumbnailReady(int tnId, bool emitNullThumb) |
|
145 { |
|
146 if(emitNullThumb) |
|
147 { |
|
148 QPixmap pixmap; |
|
149 int* internal = new int(0); |
|
150 emit thumbnailReady(pixmap, internal, tnId, mThumbnailReadyError); |
|
151 } |
|
152 else |
|
153 { |
|
154 QPixmap pixmap(100,100); |
|
155 pixmap.fill(Qt::white); |
|
156 void* internal = 0; |
|
157 |
|
158 if(mRequests.contains(tnId)) { |
|
159 internal = mRequests[tnId].id; |
|
160 mRequests.remove(tnId); |
|
161 } |
|
162 emit thumbnailReady(pixmap, internal, tnId, mThumbnailReadyError); |
|
163 } |
|
164 } |
|
165 |
|
166 void ThumbnailManager::emitThumbnailReady(QPixmap pixmap, void *internal, int id, int errorCode) |
|
167 { |
|
168 emit thumbnailReady(pixmap, internal, id, errorCode); |
|
169 } |
|
170 |