13 * |
13 * |
14 * Description: ?Description |
14 * Description: ?Description |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <glxstatemanager.h> |
18 //include |
19 #include <glxviewmanager.h> |
|
20 #include <glxviewids.h> |
|
21 #include <glxmediamodel.h> |
|
22 #include <glxgridstate.h> |
|
23 #include <glxliststate.h> |
|
24 #include <glxfullscreenstate.h> |
|
25 #include <glxdetailstate.h> |
|
26 #include <glxslideshowsettingsstate.h> |
|
27 #include <glxslideshowstate.h> |
|
28 #include <glxtnobserver.h> |
|
29 #include <glxmodelparm.h> |
|
30 #include <glxcollectionpluginall.hrh> |
|
31 #include <glxcollectionplugincamera.hrh> |
|
32 #include <glxcollectionpluginalbums.hrh> |
|
33 #include <glxcollectionpluginimageviewer.hrh> |
|
34 #include <glxexternalutility.h> |
|
35 #include <glxalbummodel.h> |
|
36 #include <glxloggerenabler.h> |
|
37 #include <glxmediaid.h> |
|
38 #include <glxactionhandler.h> |
|
39 #include <glxcommandhandlers.hrh> |
|
40 #include <QApplication> |
19 #include <QApplication> |
41 #include <glxplugincommandid.hrh> |
|
42 #include <QDebug> |
20 #include <QDebug> |
43 #include <QItemSelectionModel> |
21 #include <QItemSelectionModel> |
44 #include <hbnotificationdialog.h> |
22 #include <hbnotificationdialog.h> |
45 #include <QProcess> |
23 #include <QProcess> |
|
24 #include <hbinstance.h> |
|
25 |
|
26 //user includes |
|
27 #include "glxstatemanager.h" |
|
28 #include "glxviewmanager.h" |
|
29 #include "glxviewids.h" |
|
30 #include "glxmediamodel.h" |
|
31 #include "glxgridstate.h" |
|
32 #include "glxliststate.h" |
|
33 #include "glxfullscreenstate.h" |
|
34 #include "glxdetailstate.h" |
|
35 #include "glxslideshowsettingsstate.h" |
|
36 #include "glxslideshowstate.h" |
|
37 #include "glxtnobserver.h" |
|
38 #include "glxmodelparm.h" |
|
39 #include "glxcollectionpluginall.hrh" |
|
40 #include "glxcollectionplugincamera.hrh" |
|
41 #include "glxcollectionpluginalbums.hrh" |
|
42 #include "glxcollectionpluginimageviewer.hrh" |
|
43 #include "glxexternalutility.h" |
|
44 #include "glxalbummodel.h" |
|
45 #include "glxloggerenabler.h" |
|
46 #include "glxmediaid.h" |
|
47 #include "glxactionhandler.h" |
|
48 #include "glxcommandhandlers.hrh" |
|
49 #include "glxplugincommandid.hrh" |
|
50 #include "glxlog.h" |
|
51 #include "glxtracer.h" |
46 |
52 |
47 |
53 |
48 GlxStateManager::GlxStateManager() |
54 GlxStateManager::GlxStateManager() |
49 : mAllMediaModel( NULL ), |
55 : mAllMediaModel( NULL ), |
50 mAlbumGridMediaModel( NULL ), |
56 mAlbumGridMediaModel( NULL ), |
96 } |
102 } |
97 mActionHandler->handleAction(commandId, mCollectionId,indexList); |
103 mActionHandler->handleAction(commandId, mCollectionId,indexList); |
98 return TRUE; |
104 return TRUE; |
99 } |
105 } |
100 |
106 |
|
107 bool GlxStateManager::eventFilter(QObject *obj, QEvent *event) |
|
108 { |
|
109 TRACER("GlxStateManager::eventFilter() "); |
|
110 GLX_LOG_INFO1("GlxStateManager::eventFilter() %d event type", event->type()); |
|
111 |
|
112 if ( event->type() == QEvent::ApplicationActivate ) { |
|
113 mTNObserver->startTNMDaemon(); |
|
114 } |
|
115 if ( event->type() == QEvent::ApplicationDeactivate ) { |
|
116 mTNObserver->stopTNMDaemon(); |
|
117 } |
|
118 return QObject::eventFilter(obj, event); |
|
119 } |
|
120 |
101 void GlxStateManager::launchApplication() |
121 void GlxStateManager::launchApplication() |
102 { |
122 { |
103 qDebug("GlxStateManager::launchApplication"); |
123 qDebug("GlxStateManager::launchApplication"); |
104 |
124 |
105 //To:Do use it in future once performance code is removed nextState(GLX_GRIDVIEW_ID, ALL_ITEM_S) |
125 //To:Do use it in future once performance code is removed nextState(GLX_GRIDVIEW_ID, ALL_ITEM_S) |
106 mCurrentState = createState( GLX_GRIDVIEW_ID ); |
126 mCurrentState = createState( GLX_GRIDVIEW_ID ); |
107 mCurrentState->setState( ALL_ITEM_S ); |
127 mCurrentState->setState( ALL_ITEM_S ); |
108 |
128 |
109 if ( mTNObserver->getTNLeftCount() > 0 ) { |
129 if ( mTNObserver->getTNLeftCount() > 0 ) { |
110 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
130 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
111 mViewManager->launchProgressDialog( mTNObserver->getTNLeftCount() ); |
131 launchProgressDialog(); |
112 isProgressbarRunning = true ; |
|
113 } |
132 } |
114 else { |
133 else { |
115 createModel( GLX_GRIDVIEW_ID ); |
134 createModel( GLX_GRIDVIEW_ID ); |
116 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
135 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
117 } |
136 } |
149 mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID); |
168 mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID); |
150 } |
169 } |
151 |
170 |
152 void GlxStateManager::updateTNProgress( int count) |
171 void GlxStateManager::updateTNProgress( int count) |
153 { |
172 { |
|
173 TRACER("GlxStateManager::updateTNProgress() "); |
154 // this is case when progress bar is not showing |
174 // this is case when progress bar is not showing |
155 // in the case of rename of an image or capture the single item |
175 // in the case of rename of an image or capture the single item |
156 // it is also launching the progress bar, to avoid this scenario add the check of count more than 5 |
176 // it is also launching the progress bar, to avoid this scenario add the check of count more than 5 |
157 if ( mCurrentModel && count > 5 ) { |
177 if ( mCurrentModel && count > 5 ) { |
158 goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ; |
178 goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ; |
159 cleanAllModel(); |
179 cleanAllModel(); |
160 mViewManager->launchProgressDialog ( count ) ; |
180 launchProgressDialog(); |
161 isProgressbarRunning = true ; |
|
162 } |
181 } |
163 |
182 |
164 if ( isProgressbarRunning ){ |
183 if ( isProgressbarRunning ){ |
165 if ( count == 0 ) { |
184 if ( count == 0 ) { |
166 createModel( mCurrentState->id() ); |
185 createModel( mCurrentState->id() ); |
167 mViewManager->setModel( mCurrentModel ); |
186 mViewManager->setModel( mCurrentModel ); |
168 isProgressbarRunning = false; |
187 vanishProgressDialog(); |
169 } |
188 } |
170 |
189 else { |
171 mViewManager->updateProgressDialog( count ); |
190 mViewManager->updateProgressDialog( count ); |
|
191 } |
172 } |
192 } |
173 } |
193 } |
174 |
194 |
175 void GlxStateManager::nextState(qint32 state, int internalState) |
195 void GlxStateManager::nextState(qint32 state, int internalState) |
176 { |
196 { |
280 delete state; |
300 delete state; |
281 } |
301 } |
282 |
302 |
283 void GlxStateManager::removeCurrentModel() |
303 void GlxStateManager::removeCurrentModel() |
284 { |
304 { |
|
305 TRACER("GlxStateManager::removeCurrentModel() "); |
285 if ( mCurrentModel == mAllMediaModel ) { |
306 if ( mCurrentModel == mAllMediaModel ) { |
286 qDebug("GlxStateManager::removeCurrentModel() remove all media model"); |
307 qDebug("GlxStateManager::removeCurrentModel() remove all media model"); |
287 delete mAllMediaModel ; |
308 delete mAllMediaModel ; |
288 mAllMediaModel = NULL ; |
309 mAllMediaModel = NULL ; |
289 mCurrentModel = NULL ; |
310 mCurrentModel = NULL ; |
306 } |
327 } |
307 } |
328 } |
308 |
329 |
309 void GlxStateManager::cleanAllModel() |
330 void GlxStateManager::cleanAllModel() |
310 { |
331 { |
|
332 TRACER("GlxStateManager::cleanAllModel() "); |
311 delete mAllMediaModel ; |
333 delete mAllMediaModel ; |
312 mAllMediaModel = NULL ; |
334 mAllMediaModel = NULL ; |
313 delete mAlbumMediaModel ; |
335 delete mAlbumMediaModel ; |
314 mAlbumMediaModel = NULL ; |
336 mAlbumMediaModel = NULL ; |
315 delete mAlbumGridMediaModel ; |
337 delete mAlbumGridMediaModel ; |
316 mAlbumGridMediaModel = NULL ; |
338 mAlbumGridMediaModel = NULL ; |
317 delete mImageviewerMediaModel ; |
339 delete mImageviewerMediaModel ; |
318 mImageviewerMediaModel = NULL ; |
340 mImageviewerMediaModel = NULL ; |
319 mCurrentModel = NULL ; |
341 mCurrentModel = NULL ; |
|
342 } |
|
343 |
|
344 void GlxStateManager::launchProgressDialog() |
|
345 { |
|
346 TRACER("GlxStateManager::launchProgressDialog() "); |
|
347 //HbMainWindow *window = hbInstance->allMainWindows().first(); |
|
348 //window->setAutomaticOrientationEffectEnabled( true ); |
|
349 |
|
350 QCoreApplication::instance()->installEventFilter( this ); |
|
351 mViewManager->launchProgressDialog( mTNObserver->getTNLeftCount() ); |
|
352 isProgressbarRunning = true ; |
|
353 } |
|
354 |
|
355 void GlxStateManager::vanishProgressDialog() |
|
356 { |
|
357 TRACER("GlxStateManager::vanishProgressDialog() "); |
|
358 //HbMainWindow *window = hbInstance->allMainWindows().first(); |
|
359 //window->setAutomaticOrientationEffectEnabled( false ); |
|
360 |
|
361 QCoreApplication::instance()->removeEventFilter( this ); |
|
362 isProgressbarRunning = false; |
|
363 mViewManager->updateProgressDialog( 0 ); |
320 } |
364 } |
321 |
365 |
322 GlxState * GlxStateManager::createState(qint32 stateId) |
366 GlxState * GlxStateManager::createState(qint32 stateId) |
323 { |
367 { |
324 qDebug("GlxStateManager::createState state id = %d", stateId); |
368 qDebug("GlxStateManager::createState state id = %d", stateId); |