34
|
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: VideoDeleteWorker class definition*
|
|
15 |
*/
|
|
16 |
|
|
17 |
#ifndef __VIDEODELETEWORKER_H__
|
|
18 |
#define __VIDEODELETEWORKER_H__
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <QObject>
|
|
23 |
#include <qvariant.h>
|
|
24 |
#include <qset.h>
|
|
25 |
#include <qlist.h>
|
|
26 |
#include <e32const.h>
|
|
27 |
#include <mpxitemid.h>
|
|
28 |
|
|
29 |
// FORWARD DECLARATIONS
|
|
30 |
class QTimer;
|
|
31 |
class VideoListDataModelPrivate;
|
|
32 |
class VideoCollectionClient;
|
|
33 |
|
|
34 |
|
|
35 |
class VideoDeleteWorker : public QObject
|
|
36 |
{
|
|
37 |
/**
|
|
38 |
* define to be able to use signals and slots
|
|
39 |
*/
|
|
40 |
Q_OBJECT
|
|
41 |
|
|
42 |
/**
|
|
43 |
* disable copy-constructor and assignment operator
|
|
44 |
*/
|
|
45 |
Q_DISABLE_COPY(VideoDeleteWorker)
|
|
46 |
|
|
47 |
public:
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Default constructor
|
|
51 |
*/
|
|
52 |
VideoDeleteWorker(VideoCollectionClient &collection, QObject *parent = 0);
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Destructor
|
|
56 |
*/
|
|
57 |
~VideoDeleteWorker();
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Sets items into mRemoveBuffer. And starts deleting of items in
|
|
61 |
* blocks using mRequestWaitTimer interval
|
|
62 |
*
|
|
63 |
* @param itemList items to be deleted
|
|
64 |
*/
|
|
65 |
void requestDelete(const QList<TMPXItemId> &itemList);
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Removes item from the delete and pending buffer
|
|
69 |
*
|
|
70 |
* @param itemId item id to removed
|
|
71 |
*
|
|
72 |
* @returns a coutn of remaining requests
|
|
73 |
*/
|
|
74 |
int removeFromRequest(TMPXItemId &itemId);
|
|
75 |
|
|
76 |
/**
|
|
77 |
* returns true in case there are items at the delete buffer
|
|
78 |
*
|
|
79 |
* @return bool
|
|
80 |
*/
|
|
81 |
bool isDeleting();
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Updates error status
|
|
85 |
*
|
|
86 |
* @param status value to update
|
|
87 |
* @param data data to update
|
|
88 |
*
|
|
89 |
*/
|
|
90 |
void updateStatus(int status, QVariant data);
|
|
91 |
|
|
92 |
/**
|
|
93 |
* returns latest status and data
|
|
94 |
*
|
|
95 |
* @param data to return
|
|
96 |
*
|
|
97 |
* @return status code
|
|
98 |
*/
|
|
99 |
int getLastStatus(QVariant &data);
|
|
100 |
|
|
101 |
/**
|
|
102 |
* method resets status and statusdatas
|
|
103 |
*/
|
|
104 |
void clearStatus();
|
|
105 |
|
|
106 |
public slots:
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Continues deleting in case there are items
|
|
110 |
* yet to be deleted
|
|
111 |
*/
|
|
112 |
void continueSlot();
|
|
113 |
|
|
114 |
private:
|
|
115 |
|
|
116 |
/**
|
|
117 |
* methods dumps all remaining deletes to collection
|
|
118 |
* without caring the result codes.
|
|
119 |
*/
|
|
120 |
void flushAll();
|
|
121 |
|
|
122 |
private slots:
|
|
123 |
|
|
124 |
/**
|
|
125 |
* creates a block of deleted items and calls collection
|
|
126 |
* to startup deletion
|
|
127 |
*/
|
|
128 |
void execDeleteBlockSlot();
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
signals:
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Emitted if some delete startup fails.
|
|
136 |
*
|
|
137 |
* @param list of item ids whose edletion does not start
|
|
138 |
*/
|
|
139 |
void deleteStartupFailed(QList<TMPXItemId>);
|
|
140 |
|
|
141 |
private:
|
|
142 |
|
|
143 |
/**
|
|
144 |
* reference to collection client.
|
|
145 |
* Not own.
|
|
146 |
*/
|
|
147 |
VideoCollectionClient &mCollectionClient;
|
|
148 |
|
|
149 |
/**
|
|
150 |
* buffer for items to be removed
|
|
151 |
*/
|
|
152 |
QSet<TMPXItemId> mRemoveBuffer;
|
|
153 |
|
|
154 |
/**
|
|
155 |
* timer whose interval is used between delete
|
|
156 |
* requests to collection
|
|
157 |
*/
|
|
158 |
QTimer *mRequestWaitTimer;
|
|
159 |
|
|
160 |
/**
|
|
161 |
* last error status
|
|
162 |
*/
|
|
163 |
int mLastStatus;
|
|
164 |
|
|
165 |
/**
|
|
166 |
* last error data
|
|
167 |
*/
|
|
168 |
QVariant mLastStatusData;
|
|
169 |
|
|
170 |
};
|
|
171 |
#endif // __VIDEODELETEWORKER_H__
|
|
172 |
|
|
173 |
// End of file
|
|
174 |
|
|
175 |
|
|
176 |
|