67 qDebug("GlxStateManager::GlxStateManager"); |
67 qDebug("GlxStateManager::GlxStateManager"); |
68 PERFORMANCE_ADV ( d1, "view manager creation time") { |
68 PERFORMANCE_ADV ( d1, "view manager creation time") { |
69 mViewManager = new GlxViewManager(); |
69 mViewManager = new GlxViewManager(); |
70 } |
70 } |
71 mTNObserver = new GlxTNObserver(); |
71 mTNObserver = new GlxTNObserver(); |
72 mSaveActivity.clear(); |
|
73 |
72 |
74 connect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ), Qt::QueuedConnection ); |
73 connect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ), Qt::QueuedConnection ); |
75 connect ( mViewManager, SIGNAL(actionTriggered( qint32 )), this, SLOT(actionTriggered( qint32 )), Qt::QueuedConnection ); |
74 connect ( mViewManager, SIGNAL(actionTriggered( qint32 )), this, SLOT(actionTriggered( qint32 )), Qt::QueuedConnection ); |
76 connect ( mTNObserver, SIGNAL( leftTNCount( int ) ), this, SLOT( updateTNProgress( int ) ) ); |
75 connect ( mTNObserver, SIGNAL( leftTNCount( int ) ), this, SLOT( updateTNProgress( int ) ) ); |
77 connect ( qobject_cast<HbApplication*>(qApp), SIGNAL (aboutToQuit()), this, SLOT(saveData())); |
76 connect ( qobject_cast<HbApplication*>(qApp), SIGNAL (aboutToQuit()), this, SLOT(saveData())); |
132 activitySuccess = launchActivity(); |
131 activitySuccess = launchActivity(); |
133 } |
132 } |
134 if( !activitySuccess ) { |
133 if( !activitySuccess ) { |
135 mCurrentState = createState( GLX_GRIDVIEW_ID ); |
134 mCurrentState = createState( GLX_GRIDVIEW_ID ); |
136 mCurrentState->setState( ALL_ITEM_S ); |
135 mCurrentState->setState( ALL_ITEM_S ); |
137 |
136 |
138 int leftCount = mTNObserver->getTNLeftCount() ; |
137 int leftCount = mTNObserver->getTNLeftCount() ; |
139 if ( leftCount > 0 ) { |
138 if ( leftCount > 0 ) { |
140 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
139 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
141 launchProgressDialog(); |
140 launchProgressDialog(); |
142 } |
141 } |
144 createModel( GLX_GRIDVIEW_ID ); |
143 createModel( GLX_GRIDVIEW_ID ); |
145 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
144 mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel); |
146 } |
145 } |
147 |
146 |
148 mTNObserver->startTNObserving() ; |
147 mTNObserver->startTNObserving() ; |
149 } |
148 } |
150 //Remove the previous activity |
|
151 HbActivityManager* activityManager = app->activityManager(); |
149 HbActivityManager* activityManager = app->activityManager(); |
152 bool ok = activityManager->removeActivity("PhotosMainView"); |
150 bool ok = activityManager->removeActivity("PhotosMainView"); |
153 if ( !ok ) |
151 if ( !ok ) |
154 { |
152 { |
155 qDebug("launchapplication::Remove activity failed" ); |
153 qDebug("launchapplication::Remove activity failed" ); |
160 HbApplication* app = qobject_cast<HbApplication*>(qApp); |
158 HbApplication* app = qobject_cast<HbApplication*>(qApp); |
161 bool ok = app->activityManager()->waitActivity(); |
159 bool ok = app->activityManager()->waitActivity(); |
162 if ( !ok ) |
160 if ( !ok ) |
163 { |
161 { |
164 qDebug("subscribing to activity manager failed" ); |
162 qDebug("subscribing to activity manager failed" ); |
165 //return false; TBD: waitActivity is always returning false. Could be some issue with AM. |
|
166 } |
163 } |
167 QVariant data = app->activityManager()->activityData( "PhotosMainView" ); |
164 QVariant data = app->activityManager()->activityData( "PhotosMainView" ); |
168 QByteArray serializedModel = data.toByteArray(); |
165 QByteArray serializedModel = data.toByteArray(); |
169 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
166 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
|
167 |
170 //Fetch the data from the activity Manager |
168 //Fetch the data from the activity Manager |
171 QMap<QString, qint32> fetchActivity; |
169 stream >> mSaveActivity; |
172 stream >> fetchActivity; |
170 qint32 stateId = mSaveActivity.value("ID"); |
173 qint32 stateId = fetchActivity.value("ID"); |
|
174 mCurrentState = createState(stateId); |
171 mCurrentState = createState(stateId); |
175 mCurrentState->setState( fetchActivity.value("InternalState") ); |
172 mCurrentState->setState( mSaveActivity.value("InternalState") ); |
176 createModel( stateId); |
173 createModel( stateId); |
177 /*Model might not be populated yet to set the visibleWindowIndex right away. |
174 /*Model might not be populated yet to set the visibleWindowIndex right away. |
178 *So, let us store the visible index as a temporary Variable, so that visible Window Index |
175 *So, let us store the visible index as a temporary Variable, so that visible Window Index |
179 *is set once the model is populated. |
176 *is set once the model is populated. |
180 */ |
177 */ |
181 mCurrentModel->setData(QModelIndex(), fetchActivity.value("VisibleIndex") , GlxTempVisualWindowIndex ); |
178 mCurrentModel->setData(QModelIndex(), mSaveActivity.value("VisibleIndex") , GlxTempVisualWindowIndex ); |
182 mViewManager->launchApplication(stateId, mCurrentModel); |
179 mViewManager->launchApplication(stateId, mCurrentModel); |
183 return true; |
180 return true; |
184 } |
181 } |
185 |
182 |
186 void GlxStateManager::launchFromExternal() |
183 void GlxStateManager::launchFromExternal() |
187 { |
184 { |
188 qDebug("GlxStateManager::launchApplication"); |
185 qDebug("GlxStateManager::launchFromExternal"); |
189 mCurrentState = createState(GLX_FULLSCREENVIEW_ID); |
186 mCurrentState = createState(GLX_FULLSCREENVIEW_ID); |
190 mCurrentState->setState(IMAGEVIEWER_S); |
187 mCurrentState->setState(IMAGEVIEWER_S); |
191 |
188 |
192 createModel(GLX_FULLSCREENVIEW_ID); |
189 createModel(GLX_FULLSCREENVIEW_ID); |
193 mCurrentModel->setData( mCurrentModel->index(0,0), 0, GlxFocusIndexRole ); |
190 mCurrentModel->setData( mCurrentModel->index(0,0), 0, GlxFocusIndexRole ); |
208 { |
205 { |
209 qDebug("GlxStateManager::setupItems()"); |
206 qDebug("GlxStateManager::setupItems()"); |
210 mActionHandler = new GlxActionHandler(); |
207 mActionHandler = new GlxActionHandler(); |
211 connect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) ); |
208 connect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) ); |
212 mViewManager->setupItems(); |
209 mViewManager->setupItems(); |
213 mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID); |
210 switch(mSaveActivity.value("ID")){ |
|
211 case GLX_LISTVIEW_ID: |
|
212 mViewManager->updateToolBarIcon(GLX_ALBUM_ACTION_ID); |
|
213 break; |
|
214 case GLX_GRIDVIEW_ID: |
|
215 default: |
|
216 mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID); |
|
217 } |
214 } |
218 } |
215 |
219 |
216 void GlxStateManager::updateTNProgress( int count) |
220 void GlxStateManager::updateTNProgress( int count) |
217 { |
221 { |
218 TRACER("GlxStateManager::updateTNProgress() "); |
222 TRACER("GlxStateManager::updateTNProgress() "); |
219 // mCurrentModel ------------this is case when progress bar is not showing |
223 // this is case when progress bar is not showing |
220 // count > 5 ----------------in the case of rename of an image or capture the single item |
224 // in the case of rename of an image or capture the single item |
221 // it is also launching the progress bar, to avoid this scenario add the check of count more than 5 |
225 // it is also launching the progress bar, to avoid this scenario add the check of count more than 5 |
222 // count == KErrNotReady ----A case when memory card is inserted but it is not harvest so it is given an error |
|
223 // In that case also user should be block to browse the images |
|
224 if ( mCurrentModel && ( count > 5 ) ) { |
226 if ( mCurrentModel && ( count > 5 ) ) { |
225 goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ; |
227 goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ; |
226 cleanAllModel(); |
228 cleanAllModel(); |
227 launchProgressDialog(); |
229 launchProgressDialog(); |
228 } |
230 } |
236 else { |
238 else { |
237 mViewManager->updateProgressDialog( count ); |
239 mViewManager->updateProgressDialog( count ); |
238 } |
240 } |
239 } |
241 } |
240 } |
242 } |
241 |
|
242 void GlxStateManager::saveData() |
243 void GlxStateManager::saveData() |
243 { |
244 { |
244 if( (mCurrentState->id() == GLX_GRIDVIEW_ID && mCurrentState->state() == ALL_ITEM_S) || mCurrentState->id() == GLX_LISTVIEW_ID ) { |
245 if( (mCurrentState->id() == GLX_GRIDVIEW_ID && mCurrentState->state() == ALL_ITEM_S) || mCurrentState->id() == GLX_LISTVIEW_ID ) { |
245 mSaveActivity.insert("ID",mCurrentState->id()); |
246 mSaveActivity.insert("ID",mCurrentState->id()); |
246 mSaveActivity.insert("InternalState",mCurrentState->state()); |
247 mSaveActivity.insert("InternalState",mCurrentState->state()); |
247 |
|
248 //Store the visual Index |
|
249 if(mCurrentModel) |
248 if(mCurrentModel) |
250 { |
249 { |
251 QVariant variant = mCurrentModel->data( mCurrentModel->index(0,0), GlxVisualWindowIndex ); |
250 QVariant variant = mCurrentModel->data( mCurrentModel->index(0,0), GlxVisualWindowIndex ); |
252 if ( variant.isValid() && variant.canConvert<int> () ) { |
251 if ( variant.isValid() && variant.canConvert<int> () ) { |
253 mSaveActivity.insert("VisibleIndex",variant.value<int>()); |
252 mSaveActivity.insert("VisibleIndex",variant.value<int>()); |
254 } |
253 } |
255 } |
254 } |
256 else |
255 else |
257 mSaveActivity.insert("VisibleIndex",0); |
256 mSaveActivity.insert("VisibleIndex",0); |
258 |
|
259 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
257 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
260 |
|
261 //Take a screenshot |
|
262 QVariantHash metadata; |
258 QVariantHash metadata; |
263 HbMainWindow *window = hbInstance->allMainWindows().first(); |
259 HbMainWindow *window = hbInstance->allMainWindows().first(); |
264 metadata.insert("screenshot", QPixmap::grabWidget(window, window->rect())); |
260 metadata.insert("screenshot", QPixmap::grabWidget(window, window->rect())); |
265 |
261 |
266 QByteArray serializedModel; |
262 QByteArray serializedModel; |
267 QDataStream stream(&serializedModel, QIODevice::WriteOnly | QIODevice::Append); |
263 QDataStream stream(&serializedModel, QIODevice::WriteOnly | QIODevice::Append); |
268 stream << mSaveActivity; |
264 stream << mSaveActivity; |
269 //Add the activity |
|
270 bool ok = activityManager->addActivity("PhotosMainView", serializedModel, metadata); |
265 bool ok = activityManager->addActivity("PhotosMainView", serializedModel, metadata); |
271 if ( !ok ) |
266 if ( !ok ) |
272 { |
267 { |
273 qDebug("SaveData::Add activity failed" ); |
268 qDebug("SaveData::Add activity failed" ); |
274 } |
269 } |
275 } |
270 } |
276 } |
271 } |
277 |
|
278 |
272 |
279 void GlxStateManager::nextState(qint32 state, int internalState) |
273 void GlxStateManager::nextState(qint32 state, int internalState) |
280 { |
274 { |
281 qDebug("GlxStateManager::nextState next state = %u", state); |
275 qDebug("GlxStateManager::nextState next state = %u", state); |
282 GlxEffect effect = NO_EFFECT ; |
276 GlxEffect effect = NO_EFFECT ; |
457 |
451 |
458 case GLX_LISTVIEW_ID : |
452 case GLX_LISTVIEW_ID : |
459 return new GlxListState( mCurrentState ); |
453 return new GlxListState( mCurrentState ); |
460 |
454 |
461 case GLX_FULLSCREENVIEW_ID : |
455 case GLX_FULLSCREENVIEW_ID : |
462 return new GlxFullScreenState( mCurrentState ); |
456 return new GlxFullScreenState( this, mCurrentState ); |
463 |
457 |
464 case GLX_DETAILSVIEW_ID: |
458 case GLX_DETAILSVIEW_ID: |
465 return new GlxDetailState( mCurrentState ); |
459 return new GlxDetailState( mCurrentState ); |
466 |
460 |
467 case GLX_SLIDESHOWVIEW_ID : |
461 case GLX_SLIDESHOWVIEW_ID : |
711 |
707 |
712 GlxStateManager::~GlxStateManager() |
708 GlxStateManager::~GlxStateManager() |
713 { |
709 { |
714 qDebug("GlxStateManager::~GlxStateManager"); |
710 qDebug("GlxStateManager::~GlxStateManager"); |
715 cleanAllModel(); |
711 cleanAllModel(); |
|
712 mSaveActivity.clear(); |
716 delete mActionHandler; |
713 delete mActionHandler; |
717 qDebug("GlxStateManager::~GlxStateManager delete Model"); |
714 qDebug("GlxStateManager::~GlxStateManager delete Model"); |
718 |
715 |
719 disconnect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) ); |
716 disconnect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) ); |
720 disconnect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) ); |
717 disconnect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) ); |