25 |
25 |
26 /*! |
26 /*! |
27 * ThumbnailManager::ThumbnailManager |
27 * ThumbnailManager::ThumbnailManager |
28 */ |
28 */ |
29 ThumbnailManager::ThumbnailManager(QObject* parentPtr) |
29 ThumbnailManager::ThumbnailManager(QObject* parentPtr) |
|
30 : mTimer(this) |
30 { |
31 { |
31 Q_UNUSED(parentPtr); |
32 Q_UNUSED(parentPtr); |
32 |
33 |
33 mCurrentThumbnailId = 0; |
34 mCurrentThumbnailId = 0; |
34 mThumbnailManagerIds.clear(); |
35 mThumbnailManagerIds.clear(); |
|
36 mTimer.setSingleShot(true); |
|
37 connect(&mTimer, SIGNAL(timeout()), |
|
38 this, SLOT(emulateThumbnailReady())); |
35 } |
39 } |
36 |
40 |
37 |
41 |
38 /*! |
42 /*! |
39 * ThumbnailManager::~ThumbnailManager |
43 * ThumbnailManager::~ThumbnailManager |
51 { |
55 { |
52 CX_DEBUG_ENTER_FUNCTION(); |
56 CX_DEBUG_ENTER_FUNCTION(); |
53 |
57 |
54 Q_UNUSED(priority); |
58 Q_UNUSED(priority); |
55 |
59 |
|
60 int id = 0; |
|
61 |
|
62 if (filename.isNull() || filename.isEmpty()) { |
|
63 id = -1; |
|
64 } else { |
|
65 // generate thumbnail id |
|
66 id = mCurrentThumbnailId; |
|
67 mThumbnailManagerIds.append(mCurrentThumbnailId++); |
|
68 } |
|
69 |
|
70 // try emulating thumbnail ready |
|
71 mTimer.start(1000); |
|
72 |
|
73 CX_DEBUG_EXIT_FUNCTION(); |
|
74 |
|
75 return id; |
|
76 } |
|
77 |
|
78 int ThumbnailManager::setThumbnail( const QImage& source, const QString& fileName, |
|
79 void *clientData, int priority) |
|
80 { |
|
81 Q_UNUSED(clientData); |
|
82 Q_UNUSED(priority); |
|
83 |
56 int status = KErrNone; |
84 int status = KErrNone; |
57 |
85 |
58 if (filename.isNull() || filename.isEmpty()) { |
86 if (fileName.isNull() || fileName.isEmpty()) { |
59 status = KErrNotFound; |
87 status = KErrNotFound; |
60 } else { |
88 } else { |
61 // generate thumbnail id |
89 // generate thumbnail id |
62 mThumbnailManagerIds.append(mCurrentThumbnailId); |
90 mThumbnailManagerIds.append(mCurrentThumbnailId); |
63 } |
91 } |
64 |
92 |
65 emit thumbnailReady(QPixmap(), clientData, mCurrentThumbnailId, status); |
93 emit thumbnailReady(QPixmap(), clientData, mCurrentThumbnailId, status); |
66 |
94 |
67 mCurrentThumbnailId++; |
95 mCurrentThumbnailId++; |
68 |
96 |
69 CX_DEBUG_EXIT_FUNCTION(); |
97 CX_DEBUG_EXIT_FUNCTION(); |
70 |
98 |
71 return status; |
99 return mCurrentThumbnailId; |
72 } |
100 } |
73 |
|
74 |
|
75 |
101 |
76 /*! |
102 /*! |
77 * start canceling creating thumbnail operation |
103 * start canceling creating thumbnail operation |
78 */ |
104 */ |
79 bool ThumbnailManager::cancelRequest(int id) |
105 bool ThumbnailManager::cancelRequest(int id) |
80 { |
106 { |
81 return mThumbnailManagerIds.contains(id); |
107 return mThumbnailManagerIds.contains(id); |
82 } |
108 } |
|
109 |
|
110 |
|
111 /*! |
|
112 * slot that emulates thumbnail ready |
|
113 */ |
|
114 void ThumbnailManager::emulateThumbnailReady() |
|
115 { |
|
116 // get the current thumbnail id |
|
117 int id = mCurrentThumbnailId - 1; |
|
118 int status = KErrNone; |
|
119 |
|
120 if (id == -1) { |
|
121 // if there are no valid thumbnails |
|
122 status = KErrNotFound; |
|
123 } |
|
124 emit thumbnailReady(QPixmap(), 0, id, status); |
|
125 } |
|
126 |