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: copy of normally used "system" file for thumbnailmanager for qt |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef THUMBNAILMANAGER_QT_H |
|
19 #define THUMBNAILMANAGER_QT_H |
|
20 |
|
21 #include <qobject> |
|
22 #include <QPixmap.h> |
|
23 #include <QStringList> |
|
24 #include <QTimer> |
|
25 |
|
26 |
|
27 class ThumbnailManager : public QObject |
|
28 { |
|
29 Q_OBJECT |
|
30 |
|
31 public: |
|
32 |
|
33 /** |
|
34 * Constructor |
|
35 * |
|
36 * @param parentPtr parent |
|
37 */ |
|
38 ThumbnailManager( QObject* parentPtr = NULL ); |
|
39 |
|
40 /** |
|
41 * Destructor |
|
42 */ |
|
43 virtual ~ThumbnailManager(); |
|
44 |
|
45 /** |
|
46 * Get a thumbnail for an object file. If a thumbnail already exists, it |
|
47 * is loaded and if a thumbnail does not exist, it is created |
|
48 * transparently. If thumbnail loadinf fails thumbnailReady signal is emited |
|
49 * with null pixmap and error code. |
|
50 * |
|
51 * @param fileName Source object or file |
|
52 * @param clientData Pointer to arbitrary client data. |
|
53 * This pointer is not used by the API for |
|
54 * anything other than returning it in the |
|
55 * ThumbnailReady signal. |
|
56 * @param priority Priority for this operation |
|
57 * @return Thumbnail request ID or -1 if request failed. This can be used to |
|
58 * cancel the request or change priority. |
|
59 * The ID is specific to this tnm |
|
60 * instance and may not be shared with other |
|
61 * instances. |
|
62 */ |
|
63 int getThumbnail(const QString& fileName, void * clientData = NULL, |
|
64 int priority = 0); |
|
65 |
|
66 /** |
|
67 * Set a thumbnail for an object file generated from pixmap delivered. |
|
68 * thumbnailReady() signal will be emited when the operation is complete. |
|
69 * |
|
70 * @param source QImage from which the thumbnail will be created |
|
71 * @param fileName file name |
|
72 * @param clientData Pointer to arbitrary client data. |
|
73 * This pointer is not used by the API for |
|
74 * anything other than returning it in the |
|
75 * ThumbnailReady callback. |
|
76 * @param priority Priority for this operation |
|
77 * @return Thumbnail request ID or -1 if request failed. This can be used to |
|
78 * cancel the request or change priority. |
|
79 * |
|
80 */ |
|
81 int setThumbnail( const QImage& source, const QString& fileName, |
|
82 void * clientData = NULL, int priority = 0 ); |
|
83 |
|
84 /** |
|
85 * Cancel a thumbnail operation. |
|
86 * |
|
87 * @param id Request ID for the operation to be cancelled. |
|
88 * @return true if cancelling was successful. |
|
89 */ |
|
90 bool cancelRequest(int id); |
|
91 |
|
92 |
|
93 signals: |
|
94 /** |
|
95 * Final thumbnail bitmap generation or loading is complete. |
|
96 * |
|
97 * @param pixmap An object representing the resulting thumbnail. |
|
98 * @param clientData Client data |
|
99 * @param id Request ID for the operation |
|
100 * @param errorCode error code |
|
101 */ |
|
102 void thumbnailReady( QPixmap , void * , int , int ); |
|
103 |
|
104 private slots: |
|
105 void emulateThumbnailReady(); |
|
106 |
|
107 private: |
|
108 int mCurrentThumbnailId; |
|
109 QList<int> mThumbnailManagerIds; |
|
110 QTimer mTimer; |
|
111 }; |
|
112 |
|
113 #endif // THUMBNAILMANAGER_QT |
|