bluetoothengine/btui/btcpplugin/btcpuimainview.cpp
changeset 41 0b2439c3e397
parent 40 997690c3397a
child 52 4545c04e61e1
equal deleted inserted replaced
40:997690c3397a 41:0b2439c3e397
   108     // add new item for temporary visibility
   108     // add new item for temporary visibility
   109     // NOTE:  translation (at least default english) gives string "(p)Visible for 5 min", 
   109     // NOTE:  translation (at least default english) gives string "(p)Visible for 5 min", 
   110     // if setting 1 min --> "(s)Visible for 1 min", ie p=plural, s=singular, but these should
   110     // if setting 1 min --> "(s)Visible for 1 min", ie p=plural, s=singular, but these should
   111     // not be shown to the user!
   111     // not be shown to the user!
   112     // ToDo:  change this to use translation once it starts working
   112     // ToDo:  change this to use translation once it starts working
   113 //    QString tempVis(hbTrId("txt_bt_setlabel_visibility_val_visible_for_l1_min", TEMP_VISIBILITY_DEFAULT));  
   113     QString tempVis(hbTrId("txt_bt_setlabel_visibility_val_visible_for_l1_min", 5));  
   114     QString tempVis(hbTrId("Visible for 5 min"));  
   114     //QString tempVis(hbTrId("Visible for 5 min"));  
   115     mVisibilityMode->addItem(tempVis, Qt::DisplayRole);
   115     mVisibilityMode->addItem(tempVis, Qt::DisplayRole);
   116         
   116         
   117     mDeviceList=0;
   117     mDeviceList=0;
   118     mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "listView" ) );
   118     mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "listView" ) );
   119     BTUI_ASSERT_X( mDeviceList != 0, "bt-main-view", "Device List (grid view) not found" );   
   119     BTUI_ASSERT_X( mDeviceList != 0, "bt-main-view", "Device List (grid view) not found" );   
   139     BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); 
   139     BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); 
   140 
   140 
   141     // load tool bar actions
   141     // load tool bar actions
   142     mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) );
   142     mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) );
   143     BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); 
   143     BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); 
   144     ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActiontriggered()));
   144     ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActionTriggered()));
   145     BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); 
   145     BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); 
   146 
   146 
   147     mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox" ) );
   147     mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox" ) );
   148     BTUI_ASSERT_X( mGroupBox != 0, "bt-main-view", "Group Box not found" ); 
   148     BTUI_ASSERT_X( mGroupBox != 0, "bt-main-view", "Group Box not found" ); 
   149     
   149     
   207 }
   207 }
   208 
   208 
   209 /*! 
   209 /*! 
   210     from base class, initialize the view
   210     from base class, initialize the view
   211  */
   211  */
   212 void BtCpUiMainView::activateView(const QVariant& value, int cmdId )
   212 void BtCpUiMainView::activateView(const QVariant& value, bool fromBackButton )
   213 {
   213 {
   214     Q_UNUSED(value);
   214     Q_UNUSED(value);
   215     Q_UNUSED(cmdId);
   215     Q_UNUSED(fromBackButton);
   216     
   216     
   217 }
   217 }
   218 
   218 
   219 /*! 
   219 /*! 
   220     From base class. Handle resource before the current view is deactivated.
   220     From base class. Handle resource before the current view is deactivated.
   224 
   224 
   225 }
   225 }
   226 
   226 
   227 void BtCpUiMainView::goToDiscoveryView()
   227 void BtCpUiMainView::goToDiscoveryView()
   228 {
   228 {
   229     changeView( SearchView, false, 0 );
   229     changeView( SearchView, false );
   230 }
   230 }
   231 
   231 
   232 void BtCpUiMainView::goToDeviceView(const QModelIndex& modelIndex)
   232 void BtCpUiMainView::goToDeviceView(const QModelIndex& modelIndex)
   233 {
   233 {
   234     //the QModelIndex of the selected device should be given as parameter here 
   234     //the QModelIndex of the selected device should be given as parameter here 
   235     QVariant params;
   235     QVariant params;
   236     params.setValue(modelIndex);
   236     params.setValue(modelIndex);
   237     changeView( DeviceView, false, 0, params );
   237     changeView( DeviceView, false, params );
   238 }
   238 }
   239 
   239 
   240 Qt::Orientation BtCpUiMainView::orientation()
   240 Qt::Orientation BtCpUiMainView::orientation()
   241 {
   241 {
   242     return mOrientation;
   242     return mOrientation;
   256     }
   256     }
   257 }
   257 }
   258 
   258 
   259 void BtCpUiMainView::setPrevBtLocalName()
   259 void BtCpUiMainView::setPrevBtLocalName()
   260 {
   260 {
   261     //Should we notify user this as Error...?
   261     //ToDo: Should we notify user this as Error...?
   262     HbNotificationDialog::launchDialog(hbTrId("Error"));  // ToDo:  missing text id
   262     //HbNotificationDialog::launchDialog(hbTrId("Error"));
   263     QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 );
   263     QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 );
   264     
   264     
   265     mDeviceNameEdit->setText( mSettingModel->data(
   265     mDeviceNameEdit->setText( mSettingModel->data(
   266             index,BtSettingModel::settingDisplayRole).toString() );
   266             index,BtSettingModel::settingDisplayRole).toString() );
   267 }
   267 }
   322 void BtCpUiMainView::allActionTriggered()
   322 void BtCpUiMainView::allActionTriggered()
   323 {
   323 {
   324     updateDeviceListFilter(BtuiAll);
   324     updateDeviceListFilter(BtuiAll);
   325 }
   325 }
   326 
   326 
   327 void BtCpUiMainView::pairActiontriggered()
   327 void BtCpUiMainView::pairActionTriggered()
   328 {
   328 {
   329     updateDeviceListFilter(BtuiPaired);
   329     updateDeviceListFilter(BtuiPaired);
   330 }
   330 }
   331 
   331 
   332 void BtCpUiMainView::updateDeviceListFilter(BtCpUiMainView::filterType filter)
   332 void BtCpUiMainView::updateDeviceListFilter(BtCpUiMainView::filterType filter)
   541     }
   541     }
   542 }
   542 }
   543 
   543 
   544 /*!
   544 /*!
   545     Switch between the views.  
   545     Switch between the views.  
   546     Parameter cmdId is used for automatically executing command.
       
   547     Parameter "value" is optional except for GadgetView, 
   546     Parameter "value" is optional except for GadgetView, 
   548     which needs the BT address (QString)
   547     which needs the QModelIndex of device
   549  */
   548  */
   550 void BtCpUiMainView::changeView(int targetViewId, bool fromBackButton, 
   549 void BtCpUiMainView::changeView(int targetViewId, bool fromBackButton, 
   551         int cmdId, const QVariant& value )
   550         const QVariant& value )
   552 {
   551 {
   553     mCurrentView->deactivateView();
   552     mCurrentView->deactivateView();
   554 
   553 
   555     // update the previous view Id in QList<int> 
   554     // update the previous view Id in QList<int> 
   556     // If launching the target view from back softkey, 
   555     // If launching the target view from back softkey, 
   557     // the previous viewId of target view should not be changed. 
   556     // the previous viewId of target view should not be changed. 
   558     // Otherwise, loop happens between two views.
   557     // Otherwise, loop happens between two views.
   559     if(!fromBackButton) {
   558     if(!fromBackButton) {
   560         if ((targetViewId == DeviceView) && (mCurrentViewId == SearchView)) {
   559         // normal case:  return to previous view
   561             // we don't want to return to search view after e.g. pairing a new device
   560         mPreviousViewIds[ targetViewId ] = mCurrentViewId;
   562             mPreviousViewIds[ targetViewId ] = MainView;  
       
   563         } 
       
   564         else {
       
   565             // normal case:  return to previous view
       
   566             mPreviousViewIds[ targetViewId ] = mCurrentViewId;
       
   567         }
       
   568     }
   561     }
   569 
   562 
   570     // set the new current view 
   563     // set the new current view 
   571     mCurrentView = idToView(targetViewId);
   564     mCurrentView = idToView(targetViewId);
   572     mCurrentViewId = targetViewId;
   565     mCurrentViewId = targetViewId;
   573     mMainWindow->setCurrentView( mCurrentView );
   566     mMainWindow->setCurrentView( mCurrentView );
   574 
   567 
   575     // do preparation or some actions when new view is activated 
   568     // do preparation or some actions when new view is activated 
   576     mCurrentView->activateView( value, cmdId );
   569     mCurrentView->activateView( value, fromBackButton );
   577 }
   570 }
   578  
   571  
   579 
   572 
   580 void BtCpUiMainView::deviceSelected(const QModelIndex& modelIndex)
   573 void BtCpUiMainView::deviceSelected(const QModelIndex& modelIndex)
   581 {
   574 {
   582     QModelIndex index = mMainFilterModel->mapToSource(modelIndex);
   575     QModelIndex index = mMainFilterModel->mapToSource(modelIndex);
   583     
   576     
   584     QVariant params;
   577     QVariant params;
   585     params.setValue(index);
   578     params.setValue(index);
   586     
   579     
   587     changeView( DeviceView, false, 0, params );
   580     changeView( DeviceView, false, params );
   588 }
   581 }
   589 
   582 
   590 BtCpUiBaseView * BtCpUiMainView::idToView(int targetViewId)
   583 BtCpUiBaseView * BtCpUiMainView::idToView(int targetViewId)
   591 {
   584 {
   592     switch (targetViewId) {
   585     switch (targetViewId) {
   602     return 0;
   595     return 0;
   603 }
   596 }
   604 
   597 
   605 void BtCpUiMainView::setSoftkeyBack()
   598 void BtCpUiMainView::setSoftkeyBack()
   606 {
   599 {
   607 
   600     // not needed in main view
   608 }
   601 }
   609 
   602 
   610 /*!
   603 /*!
   611    Jump to previous view.  This function is used when back button is pressed.
   604    Jump to previous view.  This function is used when back button is pressed.
   612    semantics slightly different than in other views, since this is called by other
   605    semantics slightly different than in other views, since this is called by other
   613    views when a view switch is needed
   606    views when a view switch is needed
   614  */
   607  */
   615 void BtCpUiMainView::switchToPreviousView()
   608 void BtCpUiMainView::switchToPreviousView()
   616 {
   609 {
   617     // jump to previous view of current view.
   610     BTUI_ASSERT_X( (mCurrentViewId >= 0) && (mCurrentViewId < LastView), 
   618     if( (mCurrentViewId >= 0) && (mCurrentViewId < LastView)) {
   611             "BtCpUiMainView::switchToPreviousView", "invalid view id");
   619         changeView( mPreviousViewIds[mCurrentViewId], true, 0 );
   612     changeView( mPreviousViewIds[mCurrentViewId], true );
   620     } 
   613 }
   621     else {
   614 
   622         BTUI_ASSERT_X(false, "BtCpUiMainView::switchToPreviousView", "invalid view id");
       
   623     }      
       
   624 }
       
   625