17 |
17 |
18 |
18 |
19 |
19 |
20 #include <glxviewmanager.h> |
20 #include <glxviewmanager.h> |
21 #include <glxview.h> |
21 #include <glxview.h> |
|
22 #include "glxicondefs.h" //Contains the icon names/Ids |
22 #include <glxviewsfactory.h> |
23 #include <glxviewsfactory.h> |
23 #include <glxeffectengine.h> |
24 #include <glxeffectengine.h> |
24 #include <hbmainwindow.h> |
25 #include <hbmainwindow.h> |
25 #include <glxexternalutility.h> |
26 #include <glxexternalutility.h> |
26 #include <glxloggerenabler.h> |
27 #include <glxloggerenabler.h> |
30 |
31 |
31 #include <hbaction.h> |
32 #include <hbaction.h> |
32 #include <hbtoolbar.h> |
33 #include <hbtoolbar.h> |
33 #include <hbmenu.h> |
34 #include <hbmenu.h> |
34 #include <QDebug> |
35 #include <QDebug> |
35 |
36 #include <hbstyleloader.h> |
36 |
37 |
37 GlxViewManager::GlxViewManager() : mBackAction( NULL ), mMenuManager( NULL ), mEffectEngine( NULL ), |
38 |
38 mViewToolBar( NULL ), mMarkingToolBar( NULL ), mMenu( NULL ) |
39 GlxViewManager::GlxViewManager() |
|
40 : mBackAction( NULL ), |
|
41 mMenuManager( NULL ), |
|
42 mEffectEngine( NULL ), |
|
43 mViewToolBar( NULL ), |
|
44 mMarkingToolBar( NULL ), |
|
45 mMenu( NULL ) |
39 { |
46 { |
40 qDebug("GlxViewManager::GlxViewManager() "); |
47 qDebug("GlxViewManager::GlxViewManager() "); |
41 PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { |
48 PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { |
42 //check the case when application launch through some other application (view plugin) |
49 //check the case when application launch through some other application (view plugin) |
43 mMainWindow = GlxExternalUtility::instance()->getMainWindow(); |
50 mMainWindow = GlxExternalUtility::instance()->getMainWindow(); |
44 if(mMainWindow == NULL) { |
51 if(mMainWindow == NULL) { |
45 mMainWindow = new HbMainWindow(); |
52 mMainWindow = new HbMainWindow(); |
46 } |
53 } |
47 } //end PERFORMANCE_ADV |
54 //Without this Zoom Does not work |
48 |
55 mMainWindow->viewport()->grabGesture(Qt::PinchGesture); |
49 //mMainWindow->setOptimizationFlag(QGraphicsView::DontSavePainterState); |
56 } |
|
57 HbStyleLoader::registerFilePath(":/data/photos.css"); |
50 } |
58 } |
51 |
59 |
52 void GlxViewManager::setupItems(int subState) |
60 void GlxViewManager::setupItems(int subState) |
53 { |
61 { |
54 mMenuManager = new GlxMenuManager(); |
62 mMenuManager = new GlxMenuManager(mMainWindow); |
55 addBackSoftKeyAction(); |
63 addBackSoftKeyAction(); |
56 createToolBar(); |
64 createToolBar(); |
57 addConnection(); |
65 addConnection(); |
58 mView->addToolBar(mViewToolBar); |
66 mView->addToolBar(mViewToolBar); |
59 mMenuManager->CreateViewMenu( mView->viewId(), mView->menu(), ( 0 == mModel->rowCount() ),subState); |
67 mMenuManager->addMenu( mView->viewId(), mView->menu() ); |
|
68 mMenuManager->setModel( mModel ); |
60 } |
69 } |
61 |
70 |
62 void GlxViewManager::launchApplication(qint32 id, QAbstractItemModel *model) |
71 void GlxViewManager::launchApplication(qint32 id, QAbstractItemModel *model) |
63 { |
72 { |
64 mModel = model; |
73 mModel = model; |
65 PERFORMANCE_ADV ( viewMgrD1, "View Creation time" ) { |
74 PERFORMANCE_ADV ( viewMgrD1, "View Creation time" ) { |
66 mView = resolveView(id); |
75 mView = resolveView(id); |
67 } |
76 } |
68 mView->activate(); |
77 mView->activate(); |
69 //mView->show(); |
|
70 |
78 |
71 PERFORMANCE_ADV ( viewMgrD3, "Set Model time") |
79 PERFORMANCE_ADV ( viewMgrD3, "Set Model time") |
72 mView->setModel(mModel); |
80 mView->setModel(mModel); |
73 |
81 |
74 PERFORMANCE_ADV( viewMgrD4, "View Display time") { |
82 PERFORMANCE_ADV( viewMgrD4, "View Display time") { |
91 |
99 |
92 void GlxViewManager::addBackSoftKeyAction ( ) |
100 void GlxViewManager::addBackSoftKeyAction ( ) |
93 { |
101 { |
94 qDebug("GlxViewManager::addBackSoftKeyAction "); |
102 qDebug("GlxViewManager::addBackSoftKeyAction "); |
95 //create the back soft key action and set the data |
103 //create the back soft key action and set the data |
96 mBackAction = new HbAction(Hb::BackAction, this); |
104 mBackAction = new HbAction(Hb::BackNaviAction, this); |
97 mBackAction->setData(EGlxCmdBack); |
105 mBackAction->setData(EGlxCmdBack); |
98 |
106 mView->setNavigationAction(mBackAction); |
99 //remove the current secondary soft key for main window and set the new created one |
|
100 HbAction *action = mMainWindow->softKeyAction(Hb::SecondarySoftKey); |
|
101 mMainWindow->removeSoftKeyAction(Hb::SecondarySoftKey,action); |
|
102 mMainWindow->addSoftKeyAction(Hb::SecondarySoftKey, mBackAction); |
|
103 } |
107 } |
104 |
108 |
105 Qt::Orientation GlxViewManager::orientation() const |
109 Qt::Orientation GlxViewManager::orientation() const |
106 { |
110 { |
107 return mMainWindow->orientation(); |
111 return mMainWindow->orientation(); |
108 } |
112 } |
109 |
|
110 |
113 |
111 void GlxViewManager::launchView(qint32 id, QAbstractItemModel *model) |
114 void GlxViewManager::launchView(qint32 id, QAbstractItemModel *model) |
112 { |
115 { |
113 qDebug("GlxViewManager::launchView Id = %d ", id); |
116 qDebug("GlxViewManager::launchView Id = %d ", id); |
114 mModel = model; |
117 mModel = model; |
195 int toolBarActionId = (int) GLX_ALL_ACTION_ID; |
198 int toolBarActionId = (int) GLX_ALL_ACTION_ID; |
196 int count = mActionList.count(); |
199 int count = mActionList.count(); |
197 |
200 |
198 qDebug("GlxViewManager::updateToolBarIcon() action ID list %d count %d", id, count); |
201 qDebug("GlxViewManager::updateToolBarIcon() action ID list %d count %d", id, count); |
199 |
202 |
200 for ( int i = 0; i < count ; i++ ) { |
203 for ( int i = 0; i < count ; i++ ) |
|
204 { |
201 qDebug("GlxViewManager::updateToolBarIcon() toolBarActionId %d value %d", toolBarActionId, ( id & toolBarActionId ) ); |
205 qDebug("GlxViewManager::updateToolBarIcon() toolBarActionId %d value %d", toolBarActionId, ( id & toolBarActionId ) ); |
202 //check and get the icon path |
206 //check and get the icon path |
203 if ( ( id & toolBarActionId ) == toolBarActionId ) { |
207 if ( ( id & toolBarActionId ) == toolBarActionId ) |
204 path = mSelIconPathList.at(i); |
208 { |
205 } |
209 mActionList[i]->setCheckable(TRUE); |
206 else { |
210 mActionList[i]->setChecked(TRUE); |
207 path = mDefaultIconPathList.at(i); |
211 } |
208 } |
212 else |
|
213 { |
|
214 mActionList[i]->setChecked(FALSE); |
|
215 } |
209 //to get it the next action id to verify it is selecter or not |
216 //to get it the next action id to verify it is selecter or not |
210 toolBarActionId = toolBarActionId << 1; |
217 toolBarActionId = toolBarActionId << 1; |
211 HbIcon icon(path); |
218 } |
212 mActionList[i]->setIcon(icon) ; |
|
213 } |
|
214 } |
219 } |
215 |
220 |
216 void GlxViewManager::enterMarkingMode(qint32 viewId) |
221 void GlxViewManager::enterMarkingMode(qint32 viewId) |
217 { |
222 { |
218 GlxView *view = findView ( viewId ); |
223 GlxView *view = findView ( viewId ); |
242 void GlxViewManager::exitMarkingMode(qint32 viewId) |
247 void GlxViewManager::exitMarkingMode(qint32 viewId) |
243 { |
248 { |
244 GlxView *view = findView ( viewId ); |
249 GlxView *view = findView ( viewId ); |
245 qDebug("GlxViewManager::exitMarkingMode view ID %d", viewId); |
250 qDebug("GlxViewManager::exitMarkingMode view ID %d", viewId); |
246 if ( view ) { |
251 if ( view ) { |
247 //createToolBar(); //Marking mode tool bar is different from normal mode tool bar |
|
248 view->disableMarking(); |
252 view->disableMarking(); |
249 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
253 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
250 view->setMenu(mMenu); //Set the view menu option |
254 view->setMenu(mMenu); //Set the view menu option |
251 mMenu = menu; |
255 mMenu = menu; |
252 view->takeToolBar(); |
256 view->takeToolBar(); |
281 return view ; |
285 return view ; |
282 } |
286 } |
283 |
287 |
284 view = GlxViewsFactory::createView(id, mMainWindow); |
288 view = GlxViewsFactory::createView(id, mMainWindow); |
285 if ( view ) { |
289 if ( view ) { |
286 //view->addToolBar(mViewToolBar); |
|
287 connect ( view, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionProcess(qint32 )), Qt::QueuedConnection ); |
290 connect ( view, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionProcess(qint32 )), Qt::QueuedConnection ); |
288 connect ( view, SIGNAL(itemSpecificMenuTriggered(qint32,QPointF ) ), this, SLOT( itemSpecificMenuTriggered(qint32,QPointF ) )); |
291 connect ( view, SIGNAL(itemSpecificMenuTriggered(qint32,QPointF ) ), this, SLOT( itemSpecificMenuTriggered(qint32,QPointF ) ), Qt::QueuedConnection ); |
289 mViewList.append(view); |
292 mViewList.append(view); |
290 mMainWindow->addView(view); |
293 mMainWindow->addView(view); |
|
294 if ( mMenuManager ) { |
|
295 mMenuManager->addMenu( id, view->menu()); |
|
296 } |
|
297 view->setNavigationAction(mBackAction); |
291 } |
298 } |
292 return view; |
299 return view; |
293 } |
300 } |
294 |
301 |
295 void GlxViewManager::itemSpecificMenuTriggered(qint32 viewId,QPointF pos) |
302 void GlxViewManager::itemSpecificMenuTriggered(qint32 viewId,QPointF pos) |
318 for ( int i = 0 ; i < count; i++) { |
325 for ( int i = 0 ; i < count; i++) { |
319 if ( mViewList.at(i)->compare(id) ) { |
326 if ( mViewList.at(i)->compare(id) ) { |
320 return mViewList.at(i); |
327 return mViewList.at(i); |
321 } |
328 } |
322 } |
329 } |
323 //qDebug("GlxViewManager::findView view = %u ", view); |
|
324 return NULL; |
330 return NULL; |
325 } |
331 } |
326 |
332 |
327 void GlxViewManager::deActivateView() |
333 void GlxViewManager::deActivateView() |
328 { |
334 { |
329 qDebug("GlxViewManager::deActivateCurrentView()"); |
335 qDebug("GlxViewManager::deActivateCurrentView()"); |
330 |
336 |
331 GlxView *view = (GlxView *) mMainWindow->currentView(); |
337 GlxView *view = (GlxView *) mMainWindow->currentView(); |
332 if ( view ){ |
338 if ( view ){ |
333 view->deActivate() ; |
339 view->deActivate() ; |
334 //view->hide(); //To:do is it required |
|
335 } |
340 } |
336 if (mView && view) { |
341 if (mView && view) { |
337 mView->setZValue(view->zValue()); |
342 mView->setZValue(view->zValue()); |
338 } |
343 } |
339 } |
344 } |
344 |
349 |
345 PERFORMANCE_ADV ( viewMgrD2, "View Activation time") { |
350 PERFORMANCE_ADV ( viewMgrD2, "View Activation time") { |
346 mView->addToolBar(mViewToolBar); |
351 mView->addToolBar(mViewToolBar); |
347 mView->activate(); |
352 mView->activate(); |
348 mView->show(); |
353 mView->show(); |
349 //check and create the view menu |
354 mMenuManager->setModel( mModel ); //set the model to get the item type info and row count info |
350 if ( mView->menu()->isEmpty() ) { |
|
351 mMenuManager->CreateViewMenu( mView->viewId(), mView->menu(), ( 0 == mModel->rowCount() )); |
|
352 } |
|
353 } |
355 } |
354 |
356 |
355 PERFORMANCE_ADV ( viewMgrD3, "Set Model time") |
357 PERFORMANCE_ADV ( viewMgrD3, "Set Model time") |
356 mView->setModel(mModel); |
358 mView->setModel(mModel); |
357 |
359 |
362 } |
364 } |
363 |
365 |
364 void GlxViewManager::createActions() |
366 void GlxViewManager::createActions() |
365 { |
367 { |
366 qDebug("GlxViewManager::createActions() " ); |
368 qDebug("GlxViewManager::createActions() " ); |
367 mActionList.clear(); |
369 mActionList.clear(); |
368 mSelIconPathList.clear(); |
|
369 mDefaultIconPathList.clear(); |
|
370 |
370 |
371 //create the All tool bar button action |
371 //create the All tool bar button action |
372 HbAction* allAction = new HbAction(this); |
372 HbAction* allAction = new HbAction(this); |
373 allAction->setData(EGlxCmdAllGridOpen); |
373 allAction->setData(EGlxCmdAllGridOpen); |
374 mActionList.append(allAction); |
374 mActionList.append(allAction); |
375 mSelIconPathList.append(QString(":/data/All_selected.png")); |
375 allAction->setIcon(HbIcon(GLXICON_ALL)) ; |
376 mDefaultIconPathList.append(QString(":/data/All_default.png")); |
376 |
377 |
|
378 //create the Album tool bar button action |
377 //create the Album tool bar button action |
379 HbAction* albumAction = new HbAction(this); |
378 HbAction* albumAction = new HbAction(this); |
380 albumAction->setData(EGlxCmdAlbumListOpen); |
379 albumAction->setData(EGlxCmdAlbumListOpen); |
381 mActionList.append(albumAction); |
380 mActionList.append(albumAction); |
382 mSelIconPathList.append(QString(":/data/Albums_selected.png")); |
381 albumAction->setIcon(HbIcon(GLXICON_ALBUMS)) ; |
383 mDefaultIconPathList.append(QString(":/data/Albums_default.png")); |
382 |
384 |
|
385 //create the album tool bar button action |
383 //create the album tool bar button action |
386 HbAction* cameraAction = new HbAction(this); |
384 HbAction* cameraAction = new HbAction(this); |
387 cameraAction->setData(EGlxCmdCameraOpen); |
385 cameraAction->setData(EGlxCmdCameraOpen); |
388 mActionList.append(cameraAction); |
386 mActionList.append(cameraAction); |
389 mSelIconPathList.append(QString(":/data/camera_selected.png")); |
387 cameraAction->setIcon(HbIcon(GLXICON_CAMERA)) ; |
390 mDefaultIconPathList.append(QString(":/data/camera_default.png")); |
388 |
391 |
389 |
392 //create the ovi tool bar button action |
390 //create the ovi tool bar button action |
393 HbAction* oviAction = new HbAction(this); |
391 HbAction* oviAction = new HbAction(this); |
394 oviAction->setData(EGlxCmdOviOpen); |
392 oviAction->setData(EGlxCmdOviOpen); |
395 mActionList.append(oviAction); |
393 mActionList.append(oviAction); |
396 mSelIconPathList.append(QString(":/data/ovi_selected.png")); |
394 oviAction->setIcon(HbIcon(GLXICON_OVI)) ; |
397 mDefaultIconPathList.append(QString(":/data/ovi_default.png")); |
395 |
398 } |
396 } |
399 |
397 |
400 void GlxViewManager::createMarkingModeActions() |
398 void GlxViewManager::createMarkingModeActions() |
401 { |
399 { |
402 mMarkingActionList.clear(); |
400 mMarkingActionList.clear(); |
441 { |
439 { |
442 qDebug("GlxViewManager::createMarkingModeToolBar() " ); |
440 qDebug("GlxViewManager::createMarkingModeToolBar() " ); |
443 mMarkingToolBar = new HbToolBar(); |
441 mMarkingToolBar = new HbToolBar(); |
444 mMarkingToolBar->setOrientation( Qt::Horizontal ); |
442 mMarkingToolBar->setOrientation( Qt::Horizontal ); |
445 mMarkingToolBar->setVisible(true); |
443 mMarkingToolBar->setVisible(true); |
446 mMarkingToolBar->clearActions(); |
444 mMarkingToolBar->clearActions(); |
447 |
|
448 createMarkingModeActions(); |
445 createMarkingModeActions(); |
449 } |
446 } |
450 |
447 |
451 void GlxViewManager::addConnection() |
448 void GlxViewManager::addConnection() |
452 { |
449 { |
474 |
471 |
475 count = mViewList.count(); |
472 count = mViewList.count(); |
476 for ( int i = 0; i < count; i++ ) { |
473 for ( int i = 0; i < count; i++ ) { |
477 disconnect ( mViewList.at(i), SIGNAL(actionTriggered(qint32 )), this, SLOT(actionProcess(qint32 )) ); |
474 disconnect ( mViewList.at(i), SIGNAL(actionTriggered(qint32 )), this, SLOT(actionProcess(qint32 )) ); |
478 disconnect ( mViewList.at(i), SIGNAL(itemSpecificMenuTriggered(qint32, QPointF ) ), this, SLOT( itemSpecificMenuTriggered(qint32, QPointF ) )); |
475 disconnect ( mViewList.at(i), SIGNAL(itemSpecificMenuTriggered(qint32, QPointF ) ), this, SLOT( itemSpecificMenuTriggered(qint32, QPointF ) )); |
|
476 mMenuManager->removeMenu( mViewList.at(i)->viewId(), mViewList.at(i)->menu() ) ; |
479 } |
477 } |
480 |
478 |
481 if ( mMenuManager ) |
479 if ( mMenuManager ) |
482 disconnect(mMenuManager, SIGNAL( commandTriggered(qint32 ) ), this, SLOT( handleMenuAction(qint32 ) )); |
480 disconnect(mMenuManager, SIGNAL( commandTriggered(qint32 ) ), this, SLOT( handleMenuAction(qint32 ) )); |
|
481 |
483 if ( mBackAction ) |
482 if ( mBackAction ) |
484 disconnect(mBackAction, SIGNAL( triggered() ), this, SLOT( handleAction() )); |
483 disconnect(mBackAction, SIGNAL( triggered() ), this, SLOT( handleAction() )); |
485 |
484 |
486 if ( mEffectEngine ) { |
485 if ( mEffectEngine ) { |
487 disconnect( mEffectEngine, SIGNAL( effectFinished() ), this, SLOT( effectFinished() ) ); |
486 disconnect( mEffectEngine, SIGNAL( effectFinished() ), this, SLOT( effectFinished() ) ); |
503 } |
502 } |
504 |
503 |
505 GlxViewManager::~GlxViewManager() |
504 GlxViewManager::~GlxViewManager() |
506 { |
505 { |
507 qDebug("GlxViewManager::~GlxViewManager"); |
506 qDebug("GlxViewManager::~GlxViewManager"); |
|
507 HbStyleLoader::unregisterFilePath(":/data/photos.css"); |
508 |
508 |
509 removeConnection(); |
509 removeConnection(); |
510 delete mMenuManager; |
510 delete mMenuManager; |
511 qDebug("GlxViewManager::~GlxViewManager deleted menu manager"); |
511 qDebug("GlxViewManager::~GlxViewManager deleted menu manager"); |
512 |
512 |
513 while( mViewList.isEmpty( ) == FALSE){ |
513 while( mViewList.isEmpty( ) == FALSE){ |
514 delete mViewList.takeLast() ; |
514 delete mViewList.takeLast() ; |
515 } |
515 } |
516 qDebug("GlxViewManager::~GlxViewManager view deleted"); |
516 qDebug("GlxViewManager::~GlxViewManager view deleted"); |
517 |
517 |
518 while( mActionList.isEmpty() == FALSE) { |
518 |
519 delete mActionList.takeLast(); |
|
520 } |
|
521 |
|
522 while ( mMarkingActionList.isEmpty() == FALSE ) { |
|
523 delete mMarkingActionList.takeLast(); |
|
524 } |
|
525 qDebug("GlxViewManager::~GlxViewManager delete action list"); |
|
526 |
|
527 delete mBackAction; |
519 delete mBackAction; |
528 delete mViewToolBar; |
520 delete mViewToolBar; |
529 delete mMarkingToolBar; |
521 delete mMarkingToolBar; |
530 delete mMenu; |
522 delete mMenu; |
531 qDebug("GlxViewManager::~GlxViewManager delete toolbar"); |
523 |
532 |
|
533 mSelIconPathList.clear(); |
|
534 mDefaultIconPathList.clear(); |
|
535 qDebug("GlxViewManager::~GlxViewManager clear path list"); |
|
536 |
|
537 if ( mEffectEngine ) { |
524 if ( mEffectEngine ) { |
538 mEffectEngine->deregistertransitionEffect(); |
525 mEffectEngine->deregistertransitionEffect(); |
539 delete mEffectEngine; |
526 delete mEffectEngine; |
540 } |
527 } |
541 |
528 |