26 #include <glxexternalutility.h> |
26 #include <glxexternalutility.h> |
27 #include <glxloggerenabler.h> |
27 #include <glxloggerenabler.h> |
28 #include <glxmenumanager.h> |
28 #include <glxmenumanager.h> |
29 #include <glxcommandhandlers.hrh> |
29 #include <glxcommandhandlers.hrh> |
30 #include <glxplugincommandid.hrh> |
30 #include <glxplugincommandid.hrh> |
|
31 #include "glxlocalisationstrings.h" |
31 |
32 |
32 #include <hbaction.h> |
33 #include <hbaction.h> |
33 #include <hbtoolbar.h> |
34 #include <hbtoolbar.h> |
34 #include <hbmenu.h> |
35 #include <hbmenu.h> |
35 #include <QDebug> |
36 #include <QDebug> |
39 GlxViewManager::GlxViewManager() |
40 GlxViewManager::GlxViewManager() |
40 : mBackAction( NULL ), |
41 : mBackAction( NULL ), |
41 mMenuManager( NULL ), |
42 mMenuManager( NULL ), |
42 mEffectEngine( NULL ), |
43 mEffectEngine( NULL ), |
43 mViewToolBar( NULL ), |
44 mViewToolBar( NULL ), |
44 mMarkingToolBar( NULL ), |
45 mMarkingToolBar( NULL ), |
45 mMenu( NULL ) |
46 mMenu( NULL ), |
|
47 mSelectionModel ( NULL ) |
46 { |
48 { |
47 qDebug("GlxViewManager::GlxViewManager() "); |
49 qDebug("GlxViewManager::GlxViewManager() "); |
48 PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { |
50 PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { |
49 //check the case when application launch through some other application (view plugin) |
51 //check the case when application launch through some other application (view plugin) |
50 mMainWindow = GlxExternalUtility::instance()->getMainWindow(); |
52 mMainWindow = GlxExternalUtility::instance()->getMainWindow(); |
216 //to get it the next action id to verify it is selecter or not |
218 //to get it the next action id to verify it is selecter or not |
217 toolBarActionId = toolBarActionId << 1; |
219 toolBarActionId = toolBarActionId << 1; |
218 } |
220 } |
219 } |
221 } |
220 |
222 |
|
223 void GlxViewManager::checkMarked() |
|
224 { |
|
225 qDebug("GlxViewManager::checkMarked"); |
|
226 QModelIndexList selectedModelIndex = mSelectionModel->selectedIndexes(); |
|
227 for ( int i = 0 ; i < mMarkingActionList.count(); i++) { |
|
228 if( mMarkingActionList.at(i)->data()==EGlxCmdSelect) { |
|
229 bool noSelection=selectedModelIndex.empty(); |
|
230 mMarkingActionList.at(i)->setDisabled(noSelection); |
|
231 mMenuManager->disableAction(mView->menu(),noSelection); |
|
232 break; |
|
233 } |
|
234 } |
|
235 } |
221 void GlxViewManager::enterMarkingMode(qint32 viewId) |
236 void GlxViewManager::enterMarkingMode(qint32 viewId) |
222 { |
237 { |
223 GlxView *view = findView ( viewId ); |
238 GlxView *view = findView ( viewId ); |
224 qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId); |
239 qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId); |
225 |
240 |
238 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
253 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
239 view->setMenu(mMenu); //Set the marking mode menu |
254 view->setMenu(mMenu); //Set the marking mode menu |
240 mMenu = menu; |
255 mMenu = menu; |
241 view->takeToolBar(); |
256 view->takeToolBar(); |
242 view->addToolBar(mMarkingToolBar); |
257 view->addToolBar(mMarkingToolBar); |
|
258 mSelectionModel = view->getSelectionModel(); |
|
259 if(mSelectionModel) |
|
260 { |
|
261 connect(mSelectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT(checkMarked())); |
|
262 checkMarked(); |
|
263 } |
243 } |
264 } |
244 qDebug("GlxViewManager::enterMarkingMode view ID %d exit", viewId); |
265 qDebug("GlxViewManager::enterMarkingMode view ID %d exit", viewId); |
245 } |
266 } |
246 |
267 |
247 void GlxViewManager::exitMarkingMode(qint32 viewId) |
268 void GlxViewManager::exitMarkingMode(qint32 viewId) |
253 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
274 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
254 view->setMenu(mMenu); //Set the view menu option |
275 view->setMenu(mMenu); //Set the view menu option |
255 mMenu = menu; |
276 mMenu = menu; |
256 view->takeToolBar(); |
277 view->takeToolBar(); |
257 view->addToolBar(mViewToolBar); |
278 view->addToolBar(mViewToolBar); |
|
279 if(mSelectionModel) |
|
280 { |
|
281 disconnect(mSelectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT(checkMarked())); |
|
282 } |
258 } |
283 } |
259 qDebug("GlxViewManager::exitMarkingMode view ID %d exit", viewId); |
284 qDebug("GlxViewManager::exitMarkingMode view ID %d exit", viewId); |
260 } |
285 } |
261 |
286 |
262 void GlxViewManager::handleUserAction(qint32 viewId, qint32 commandId) |
287 void GlxViewManager::handleUserAction(qint32 viewId, qint32 commandId) |
398 void GlxViewManager::createMarkingModeActions() |
423 void GlxViewManager::createMarkingModeActions() |
399 { |
424 { |
400 mMarkingActionList.clear(); |
425 mMarkingActionList.clear(); |
401 |
426 |
402 //create the ok tool bar button action |
427 //create the ok tool bar button action |
403 HbAction* selectAction = new HbAction("Ok", this); |
428 HbAction* selectAction = new HbAction(GLX_BUTTON_OK, this); |
404 selectAction->setData(EGlxCmdSelect); |
429 selectAction->setData(EGlxCmdSelect); |
405 mMarkingActionList.append(selectAction); |
430 mMarkingActionList.append(selectAction); |
406 connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
431 connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
407 mMarkingToolBar->addAction( selectAction ); |
432 mMarkingToolBar->addAction( selectAction ); |
408 |
433 |
409 //create the cancel tool bar button action |
434 //create the cancel tool bar button action |
410 HbAction* cancelAction = new HbAction("Cancel", this); |
435 HbAction* cancelAction = new HbAction(GLX_BUTTON_CANCEL, this); |
411 cancelAction->setData(EGlxCmdCancel); |
436 cancelAction->setData(EGlxCmdCancel); |
412 mMarkingActionList.append(cancelAction); |
437 mMarkingActionList.append(cancelAction); |
413 connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
438 connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
414 mMarkingToolBar->addAction( cancelAction ); |
439 mMarkingToolBar->addAction( cancelAction ); |
415 } |
440 } |