12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: VideoDeleteWorker class implementation |
14 * Description: VideoDeleteWorker class implementation |
15 * |
15 * |
16 */ |
16 */ |
|
17 |
|
18 // Version : %version: % |
|
19 |
17 // INCLUDE FILES |
20 // INCLUDE FILES |
18 |
|
19 #include <qtimer.h> |
21 #include <qtimer.h> |
|
22 |
20 #include "videocollectioncommon.h" |
23 #include "videocollectioncommon.h" |
21 #include "videocollectionclient.h" |
24 #include "videocollectionclient.h" |
22 #include "videodeleteworker.h" |
25 #include "videodeleteworker.h" |
23 |
26 #include "videocollectiontrace.h" |
24 |
|
25 |
27 |
26 // ================= MEMBER FUNCTIONS ======================= |
28 // ================= MEMBER FUNCTIONS ======================= |
27 // |
29 // |
28 |
30 |
29 /** |
31 /** |
45 mCollectionClient(collection), |
47 mCollectionClient(collection), |
46 mRequestWaitTimer(0), |
48 mRequestWaitTimer(0), |
47 mLastStatus(0), |
49 mLastStatus(0), |
48 mLastStatusData(QVariant()) |
50 mLastStatusData(QVariant()) |
49 { |
51 { |
|
52 FUNC_LOG; |
50 |
53 |
51 } |
54 } |
52 |
55 |
53 // ----------------------------------------------------------------------------- |
56 // ----------------------------------------------------------------------------- |
54 // ~VideoDeleteWorker() |
57 // ~VideoDeleteWorker() |
55 // ----------------------------------------------------------------------------- |
58 // ----------------------------------------------------------------------------- |
56 // |
59 // |
57 VideoDeleteWorker::~VideoDeleteWorker() |
60 VideoDeleteWorker::~VideoDeleteWorker() |
58 { |
61 { |
|
62 FUNC_LOG; |
59 if(mRequestWaitTimer && mRequestWaitTimer->isActive()) |
63 if(mRequestWaitTimer && mRequestWaitTimer->isActive()) |
60 { |
64 { |
61 mRequestWaitTimer->stop(); |
65 mRequestWaitTimer->stop(); |
62 } |
66 } |
63 // if we're still doing some background deletion, |
67 // if we're still doing some background deletion, |
69 // requestDelete() |
73 // requestDelete() |
70 // ----------------------------------------------------------------------------- |
74 // ----------------------------------------------------------------------------- |
71 // |
75 // |
72 void VideoDeleteWorker::requestDelete(const QList<TMPXItemId> &indexList) |
76 void VideoDeleteWorker::requestDelete(const QList<TMPXItemId> &indexList) |
73 { |
77 { |
|
78 FUNC_LOG; |
74 if(!mRequestWaitTimer) |
79 if(!mRequestWaitTimer) |
75 { |
80 { |
76 mRequestWaitTimer = new QTimer(); |
81 mRequestWaitTimer = new QTimer(); |
77 connect(mRequestWaitTimer, SIGNAL(timeout()), this, SLOT(execDeleteBlockSlot())); |
82 connect(mRequestWaitTimer, SIGNAL(timeout()), this, SLOT(execDeleteBlockSlot())); |
78 } |
83 } |
93 // removeFromRequest() |
98 // removeFromRequest() |
94 // ----------------------------------------------------------------------------- |
99 // ----------------------------------------------------------------------------- |
95 // |
100 // |
96 int VideoDeleteWorker::removeFromRequest(TMPXItemId &itemId) |
101 int VideoDeleteWorker::removeFromRequest(TMPXItemId &itemId) |
97 { |
102 { |
|
103 FUNC_LOG; |
98 mRemoveBuffer.remove(itemId); |
104 mRemoveBuffer.remove(itemId); |
99 return mRemoveBuffer.count(); |
105 return mRemoveBuffer.count(); |
100 } |
106 } |
101 |
107 |
102 // ----------------------------------------------------------------------------- |
108 // ----------------------------------------------------------------------------- |
103 // isDeleting() |
109 // isDeleting() |
104 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
105 // |
111 // |
106 bool VideoDeleteWorker::isDeleting() |
112 bool VideoDeleteWorker::isDeleting() |
107 { |
113 { |
|
114 FUNC_LOG; |
108 return mRemoveBuffer.count() ? true : false; |
115 return mRemoveBuffer.count() ? true : false; |
109 } |
116 } |
110 |
117 |
111 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
112 // updateStatus() |
119 // updateStatus() |
113 // ----------------------------------------------------------------------------- |
120 // ----------------------------------------------------------------------------- |
114 // |
121 // |
115 void VideoDeleteWorker::updateStatus(int status, QVariant data) |
122 void VideoDeleteWorker::updateStatus(int status, QVariant data) |
116 { |
123 { |
|
124 FUNC_LOG; |
|
125 INFO_1("VideoDeleteWorker::updateStatus() status: %d", status); |
|
126 |
117 // do not update invalid status |
127 // do not update invalid status |
118 if(status != VideoCollectionCommon::statusDeleteSucceed && |
128 if(status != VideoCollectionCommon::statusDeleteSucceed && |
119 status != VideoCollectionCommon::statusSingleDeleteFail && |
129 status != VideoCollectionCommon::statusSingleDeleteFail && |
120 status != VideoCollectionCommon::statusMultipleDeleteFail) |
130 status != VideoCollectionCommon::statusMultipleDeleteFail) |
121 { |
131 { |
157 // getStatus() |
167 // getStatus() |
158 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
159 // |
169 // |
160 int VideoDeleteWorker::getLastStatus(QVariant &data) |
170 int VideoDeleteWorker::getLastStatus(QVariant &data) |
161 { |
171 { |
|
172 FUNC_LOG; |
162 data = mLastStatusData; |
173 data = mLastStatusData; |
163 return mLastStatus; |
174 return mLastStatus; |
164 } |
175 } |
165 |
176 |
166 // ----------------------------------------------------------------------------- |
177 // ----------------------------------------------------------------------------- |
167 // clearStatus() |
178 // clearStatus() |
168 // ----------------------------------------------------------------------------- |
179 // ----------------------------------------------------------------------------- |
169 // |
180 // |
170 void VideoDeleteWorker::clearStatus() |
181 void VideoDeleteWorker::clearStatus() |
171 { |
182 { |
|
183 FUNC_LOG; |
172 mLastStatus = 0; |
184 mLastStatus = 0; |
173 mLastStatusData = QVariant(); |
185 mLastStatusData = QVariant(); |
174 } |
186 } |
175 |
187 |
176 // ----------------------------------------------------------------------------- |
188 // ----------------------------------------------------------------------------- |
177 // continueSlot() |
189 // continueSlot() |
178 // ----------------------------------------------------------------------------- |
190 // ----------------------------------------------------------------------------- |
179 // |
191 // |
180 void VideoDeleteWorker::continueSlot() |
192 void VideoDeleteWorker::continueSlot() |
181 { |
193 { |
182 if(!mRequestWaitTimer || !mRemoveBuffer.count()) |
194 FUNC_LOG; |
183 { |
195 if(!mRequestWaitTimer || !mRemoveBuffer.count()) |
184 return; |
196 { |
185 } |
197 return; |
186 if(!mRequestWaitTimer->isActive()) |
198 } |
187 { |
199 if(!mRequestWaitTimer->isActive()) |
188 mRequestWaitTimer->setSingleShot(true); |
200 { |
189 mRequestWaitTimer->start(0); |
201 mRequestWaitTimer->setSingleShot(true); |
190 } |
202 mRequestWaitTimer->start(0); |
|
203 } |
191 } |
204 } |
192 |
205 |
193 // ----------------------------------------------------------------------------- |
206 // ----------------------------------------------------------------------------- |
194 // doBackgroundDeleteSlot() |
207 // doBackgroundDeleteSlot() |
195 // ----------------------------------------------------------------------------- |
208 // ----------------------------------------------------------------------------- |
196 // |
209 // |
197 void VideoDeleteWorker::execDeleteBlockSlot() |
210 void VideoDeleteWorker::execDeleteBlockSlot() |
198 { |
211 { |
|
212 FUNC_LOG; |
199 if(!mRemoveBuffer.count()) |
213 if(!mRemoveBuffer.count()) |
200 { |
214 { |
201 return; |
215 return; |
202 } |
216 } |
203 QList<TMPXItemId> deleteBlock; |
217 QList<TMPXItemId> deleteBlock; |
224 // flushAll() |
238 // flushAll() |
225 // ----------------------------------------------------------------------------- |
239 // ----------------------------------------------------------------------------- |
226 // |
240 // |
227 void VideoDeleteWorker::flushAll() |
241 void VideoDeleteWorker::flushAll() |
228 { |
242 { |
|
243 FUNC_LOG; |
229 if(!mRemoveBuffer.count()) |
244 if(!mRemoveBuffer.count()) |
230 { |
245 { |
231 return; |
246 return; |
232 } |
247 } |
233 QList<TMPXItemId> ids = mRemoveBuffer.toList(); |
248 QList<TMPXItemId> ids = mRemoveBuffer.toList(); |
234 mCollectionClient.deleteVideos(&ids); |
249 mCollectionClient.deleteVideos(&ids); |
235 mRemoveBuffer.clear(); |
250 mRemoveBuffer.clear(); |
236 } |
251 } |
237 |
|
238 |
|
239 |
252 |
240 // End of file |
253 // End of file |