bluetoothengine/btui/btcpplugin/btcpuimainview.cpp
changeset 40 997690c3397a
parent 33 837dcc42fd6a
child 41 0b2439c3e397
equal deleted inserted replaced
37:91746b151f97 40:997690c3397a
     1 /*
     1 /*
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    31 #include <hbtooltip.h>
    31 #include <hbtooltip.h>
    32 #include <btengconstants.h>
    32 #include <btengconstants.h>
    33 #include <hbmenu.h>
    33 #include <hbmenu.h>
    34 #include <hbaction.h>
    34 #include <hbaction.h>
    35 #include <hbcombobox.h>
    35 #include <hbcombobox.h>
       
    36 #include <hbgroupbox.h>
    36 #include "btcpuisearchview.h"
    37 #include "btcpuisearchview.h"
    37 #include "btcpuideviceview.h"
    38 #include "btcpuideviceview.h"
    38 #include <bluetoothuitrace.h>
    39 #include <bluetoothuitrace.h>
    39 #include <btdelegatefactory.h>
    40 #include <btdelegatefactory.h>
    40 #include <btabstractdelegate.h>
    41 #include <btabstractdelegate.h>
    41 #include "btqtconstants.h"
    42 #include "btqtconstants.h"
    42 
    43 #include "btcpuimainlistviewitem.h"
       
    44 #include "btuidevtypemap.h"
    43 
    45 
    44 // docml to load
    46 // docml to load
    45 const char* BTUI_MAINVIEW_DOCML = ":/docml/bt-main-view.docml";
    47 const char* BTUI_MAINVIEW_DOCML = ":/docml/bt-main-view.docml";
    46 
    48 
    47 /*!
    49 /*!
    55         QGraphicsItem *parent )
    57         QGraphicsItem *parent )
    56     : BtCpUiBaseView( settingModel, deviceModel, parent ),
    58     : BtCpUiBaseView( settingModel, deviceModel, parent ),
    57       mAbstractDelegate(0), mMainFilterModel(0)
    59       mAbstractDelegate(0), mMainFilterModel(0)
    58 {
    60 {
    59     bool ret(false);
    61     bool ret(false);
    60     
    62 
    61     mMainWindow = hbInstance->allMainWindows().first();
    63     mMainWindow = hbInstance->allMainWindows().first();
    62     mMainView = this;
    64     mMainView = this;
    63     
    65     
    64     // Create view for the application.
    66     // Create view for the application.
    65     // Set the name for the view. The name should be same as the view's
    67     // Set the name for the view. The name should be same as the view's
    66     // name in docml.
    68     // name in docml.
    67     setObjectName("view");
    69     setObjectName("view");
    68 
    70 
       
    71     mLoader = new HbDocumentLoader();
       
    72     // Pass the view to documentloader. Document loader uses this view
       
    73     // when docml is parsed, instead of creating new view.
    69     QObjectList objectList;
    74     QObjectList objectList;
    70     objectList.append(this);
    75     objectList.append(this);
    71     // Pass the view to documentloader. Document loader uses this view
       
    72     // when docml is parsed, instead of creating new view.
       
    73     mLoader = new HbDocumentLoader();
       
    74     mLoader->setObjectTree(objectList);
    76     mLoader->setObjectTree(objectList);
    75 
    77 
    76     bool ok = false;
    78     bool ok = false;
    77     mLoader->load( BTUI_MAINVIEW_DOCML, &ok );
    79     mLoader->load( BTUI_MAINVIEW_DOCML, &ok );
    78     // Exit if the file format is invalid
    80     // Exit if the file format is invalid
   101     BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView", "can't connect power button" );
   103     BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView", "can't connect power button" );
   102     
   104     
   103     mVisibilityMode=0;
   105     mVisibilityMode=0;
   104     mVisibilityMode = qobject_cast<HbComboBox *>( mLoader->findWidget( "combobox" ) );
   106     mVisibilityMode = qobject_cast<HbComboBox *>( mLoader->findWidget( "combobox" ) );
   105     BTUI_ASSERT_X( mVisibilityMode != 0, "bt-main-view", "visibility combobox not found" );
   107     BTUI_ASSERT_X( mVisibilityMode != 0, "bt-main-view", "visibility combobox not found" );
       
   108     // add new item for temporary visibility
       
   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
       
   111     // not be shown to the user!
       
   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));  
       
   114     QString tempVis(hbTrId("Visible for 5 min"));  
       
   115     mVisibilityMode->addItem(tempVis, Qt::DisplayRole);
   106         
   116         
   107     mDeviceList=0;
   117     mDeviceList=0;
   108     mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "listView" ) );
   118     mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "listView" ) );
   109     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" );   
   110     
   120     
   118 
   128 
   119     // load tool bar actions
   129     // load tool bar actions
   120     HbAction *discoverAction = static_cast<HbAction*>( mLoader->findObject( "discoverAction" ) );
   130     HbAction *discoverAction = static_cast<HbAction*>( mLoader->findObject( "discoverAction" ) );
   121     BTUI_ASSERT_X( discoverAction, "bt-main-view", "discover action missing" ); 
   131     BTUI_ASSERT_X( discoverAction, "bt-main-view", "discover action missing" ); 
   122     ret = connect(discoverAction, SIGNAL(triggered()), this, SLOT(goToDiscoveryView()));
   132     ret = connect(discoverAction, SIGNAL(triggered()), this, SLOT(goToDiscoveryView()));
   123     BTUI_ASSERT_X( ret, "bt-main-view", "orientation toggle can't connect" ); 
   133     BTUI_ASSERT_X( ret, "bt-main-view", "discover action can't connect" ); 
       
   134 
       
   135     // load tool bar actions
       
   136     mAllAction = static_cast<HbAction*>( mLoader->findObject( "allAction" ) );
       
   137     BTUI_ASSERT_X( mAllAction, "bt-main-view", "All action missing" ); 
       
   138     ret = connect(mAllAction, SIGNAL(triggered()), this, SLOT(allActionTriggered()));
       
   139     BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); 
       
   140 
       
   141     // load tool bar actions
       
   142     mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) );
       
   143     BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); 
       
   144     ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActiontriggered()));
       
   145     BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); 
       
   146 
       
   147     mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox" ) );
       
   148     BTUI_ASSERT_X( mGroupBox != 0, "bt-main-view", "Group Box not found" ); 
   124     
   149     
   125     //*********************Testing device view START****************************//
   150     //*********************Testing device view START****************************//
   126     HbAction *removePairedDevices = static_cast<HbAction*>( mLoader->findObject( "removePairedDevices" ) );
   151     HbAction *removePairedDevices = static_cast<HbAction*>( mLoader->findObject( "removePairedDevices" ) );
   127     BTUI_ASSERT_X( removePairedDevices, "bt-main-view", "remove action missing" ); 
   152     BTUI_ASSERT_X( removePairedDevices, "bt-main-view", "remove action missing" ); 
   128     //ret = connect(removePairedDevices, SIGNAL(triggered()), this, SLOT(goToDeviceView()));
   153     //ret = connect(removePairedDevices, SIGNAL(triggered()), this, SLOT(goToDeviceView()));
   156     mCurrentViewId = MainView;
   181     mCurrentViewId = MainView;
   157     
   182     
   158     mMainFilterModel = new BtuiModelSortFilter(this);
   183     mMainFilterModel = new BtuiModelSortFilter(this);
   159     
   184     
   160     mMainFilterModel->setSourceModel( mDeviceModel );
   185     mMainFilterModel->setSourceModel( mDeviceModel );
   161     // filter to match only InRegistry devices
   186     updateDeviceListFilter(BtuiPaired);
   162     mMainFilterModel->addDeviceMajorFilter(
   187 	    // List view item
   163             BtDeviceModel::InRegistry, 
   188     BtCpUiMainListViewItem *prototype = new BtCpUiMainListViewItem(mDeviceList);
   164             BtuiModelSortFilter::AtLeastMatch);
   189     prototype->setModelSortFilter(mMainFilterModel);
       
   190     mDeviceList->setItemPrototype(prototype);
   165 
   191 
   166     mDeviceList->setModel(mMainFilterModel);
   192     mDeviceList->setModel(mMainFilterModel);
   167 
   193 
   168     
       
   169 }
   194 }
   170 
   195 
   171 /*!
   196 /*!
   172     Destructs the BtCpUiMainView.
   197     Destructs the BtCpUiMainView.
   173  */
   198  */
   174 BtCpUiMainView::~BtCpUiMainView()
   199 BtCpUiMainView::~BtCpUiMainView()
   175 {
   200 {
   176     delete mLoader; // Also deletes all widgets that it constructed.
   201     delete mLoader; // Also deletes all widgets that it constructed.
   177     
       
   178     mMainWindow->removeView(mSearchView);
   202     mMainWindow->removeView(mSearchView);
   179     delete mSearchView;
       
   180     
       
   181     mMainWindow->removeView(mDeviceView);
   203     mMainWindow->removeView(mDeviceView);
   182     delete mDeviceView;
       
   183         
       
   184 	if (mAbstractDelegate) {
   204 	if (mAbstractDelegate) {
   185         delete mAbstractDelegate;
   205         delete mAbstractDelegate;
   186     }
   206     }
   187 }
   207 }
   188 
   208 
   200     From base class. Handle resource before the current view is deactivated.
   220     From base class. Handle resource before the current view is deactivated.
   201  */
   221  */
   202 void BtCpUiMainView::deactivateView()
   222 void BtCpUiMainView::deactivateView()
   203 {
   223 {
   204 
   224 
   205 }
       
   206 
       
   207 void BtCpUiMainView::itemActivated(QModelIndex index)
       
   208 {
       
   209     Q_UNUSED(index);
       
   210 }
   225 }
   211 
   226 
   212 void BtCpUiMainView::goToDiscoveryView()
   227 void BtCpUiMainView::goToDiscoveryView()
   213 {
   228 {
   214     changeView( SearchView, false, 0 );
   229     changeView( SearchView, false, 0 );
   242 }
   257 }
   243 
   258 
   244 void BtCpUiMainView::setPrevBtLocalName()
   259 void BtCpUiMainView::setPrevBtLocalName()
   245 {
   260 {
   246     //Should we notify user this as Error...?
   261     //Should we notify user this as Error...?
   247     HbNotificationDialog::launchDialog(hbTrId("Error"));
   262     HbNotificationDialog::launchDialog(hbTrId("Error"));  // ToDo:  missing text id
   248     QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 );
   263     QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 );
   249     
   264     
   250     mDeviceNameEdit->setText( mSettingModel->data(
   265     mDeviceNameEdit->setText( mSettingModel->data(
   251             index,BtSettingModel::settingDisplayRole).toString() );
   266             index,BtSettingModel::settingDisplayRole).toString() );
   252 }
   267 }
   274 {
   289 {
   275     QList<QVariant> list;
   290     QList<QVariant> list;
   276     
   291     
   277     VisibilityMode mode = indexToVisibilityMode(index);
   292     VisibilityMode mode = indexToVisibilityMode(index);
   278     list.append(QVariant((int)mode));
   293     list.append(QVariant((int)mode));
   279     if(BtTemporary == VisibilityMode(mode)) {
   294     if( BtTemporary == VisibilityMode(mode) ) {
   280         //Right now hardcoded to 5 Mins.
   295         //Right now hardcoded to 5 Mins.
   281         list.append(QVariant(5));
   296         list.append(QVariant(5));
   282     }
   297     }
   283     //Error handling has to be done.    
   298     //Error handling has to be done.    
   284     if (!mAbstractDelegate) {
   299     if ( !mAbstractDelegate ) {
   285         mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Visibility, 
   300         mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Visibility, 
   286                 mSettingModel, mDeviceModel); 
   301                 mSettingModel, mDeviceModel); 
   287         connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(visibilityDelegateCompleted(int)) );
   302         connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(visibilityDelegateCompleted(int)) );
   288         mAbstractDelegate->exec(list);
   303         mAbstractDelegate->exec(list);
   289     }
   304     }
   293 
   308 
   294 }
   309 }
   295 
   310 
   296 void BtCpUiMainView::setPrevVisibilityMode()
   311 void BtCpUiMainView::setPrevVisibilityMode()
   297 {
   312 {
   298     bool ret(false);
   313    
   299     
       
   300     //Should we notify this error to user..?
       
   301     HbNotificationDialog::launchDialog(hbTrId("Error"));
       
   302     QModelIndex index = mSettingModel->index( BtSettingModel::VisibilityRow, 0 );
   314     QModelIndex index = mSettingModel->index( BtSettingModel::VisibilityRow, 0 );
   303     
       
   304     ret = disconnect(mVisibilityMode, SIGNAL(currentIndexChanged (int)), 
       
   305                     this, SLOT(visibilityChanged (int)));
       
   306     BTUI_ASSERT_X( ret, "BtCpUiMainView::setPrevVisibilityMode", "can't disconnect signal" );
       
   307     
   315     
   308     mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode)
   316     mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode)
   309                 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) );
   317                 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) );
   310     
   318     
   311     //Handle Visibility Change User Interaction
   319 }
   312     ret = connect(mVisibilityMode, SIGNAL(currentIndexChanged (int)), 
   320 
   313             this, SLOT(visibilityChanged (int)));
   321 
   314     BTUI_ASSERT_X( ret, "BtCpUiMainView::setPrevVisibilityMode", "can't connect signal" );
   322 void BtCpUiMainView::allActionTriggered()
   315 
   323 {
       
   324     updateDeviceListFilter(BtuiAll);
       
   325 }
       
   326 
       
   327 void BtCpUiMainView::pairActiontriggered()
       
   328 {
       
   329     updateDeviceListFilter(BtuiPaired);
       
   330 }
       
   331 
       
   332 void BtCpUiMainView::updateDeviceListFilter(BtCpUiMainView::filterType filter)
       
   333 {
       
   334     mMainFilterModel->clearDeviceMajorFilters();
       
   335     
       
   336     switch (filter) {
       
   337         case BtuiAll:
       
   338             mGroupBox->setHeading(hbTrId("txt_bt_subhead_bluetooth_all_devices"));
       
   339             mPairAction->setEnabled(true);
       
   340             mAllAction->setEnabled(false);
       
   341             mMainFilterModel->addDeviceMajorFilter(
       
   342                     BtuiDevProperty::InRegistry, 
       
   343                     BtuiModelSortFilter::AtLeastMatch);
       
   344 
       
   345             break;
       
   346         case BtuiPaired:
       
   347             mGroupBox->setHeading(hbTrId("txt_bt_subhead_bluetooth_paired_devices"));
       
   348             mPairAction->setEnabled(false);
       
   349             mAllAction->setEnabled(true);
       
   350             mMainFilterModel->addDeviceMajorFilter(
       
   351                     BtuiDevProperty::InRegistry | BtuiDevProperty::Bonded, 
       
   352                     BtuiModelSortFilter::AtLeastMatch);
       
   353 
       
   354             break;
       
   355     }
   316 }
   356 }
   317 
   357 
   318 
   358 
   319 void BtCpUiMainView::visibilityDelegateCompleted(int status)
   359 void BtCpUiMainView::visibilityDelegateCompleted(int status)
   320 {
   360 {
   349         mLoader->load( BTUI_MAINVIEW_DOCML, "landscape", &ok );
   389         mLoader->load( BTUI_MAINVIEW_DOCML, "landscape", &ok );
   350         BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );
   390         BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );
   351     }
   391     }
   352 }
   392 }
   353 
   393 
   354 void BtCpUiMainView::commandCompleted( int cmdId, int err, const QString &diagnostic )
       
   355 {
       
   356     Q_UNUSED(cmdId);
       
   357     Q_UNUSED(err);
       
   358     Q_UNUSED(diagnostic);
       
   359 
       
   360 }
       
   361 
       
   362 /*!
   394 /*!
   363     Slot for receiving notification of local setting changes from the model.
   395     Slot for receiving notification of local setting changes from the model.
   364     Identify the setting changed and update the corresponding UI item.
   396     Identify the setting changed and update the corresponding UI item.
   365  */
   397  */
   366 void BtCpUiMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight)
   398 void BtCpUiMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight)
   367 {   
   399 {   
   368 
   400     bool val(false);
       
   401     
   369     // update only the part of the view specified by the model's row(s)
   402     // update only the part of the view specified by the model's row(s)
   370     for (int i=topLeft.row(); i <= bottomRight.row(); i++) {
   403     for (int i=topLeft.row(); i <= bottomRight.row(); i++) {
   371         QModelIndex index = mSettingModel->index( i, 0);
   404         QModelIndex index = mSettingModel->index( i, 0);
   372         // Distinguish which setting value is changed.
   405         // Distinguish which setting value is changed.
   373         switch ( i ) {
   406         switch ( i ) {
   374         case BtSettingModel::LocalBtNameRow :
   407         case BtSettingModel::LocalBtNameRow :
   375             mDeviceNameEdit->setText( 
   408             mDeviceNameEdit->setText( 
   376                     mSettingModel->data(index,BtSettingModel::settingDisplayRole).toString() );
   409                     mSettingModel->data(index,BtSettingModel::settingDisplayRole).toString() );
   377             break;
   410             break;
   378         case BtSettingModel::PowerStateRow:
   411         case BtSettingModel::PowerStateRow:
   379             mPowerButton->setText( mSettingModel->data(index,
   412             val = mSettingModel->data(index, BtSettingModel::SettingValueRole).toBool();
   380                     BtSettingModel::settingDisplayRole).toString() );
   413             if (val) {
       
   414                 HbIcon icon("qtg_mono_bluetooth");
       
   415                 icon.setIconName("qtg_mono_bluetooth");
       
   416                 mPowerButton->setIcon(icon);  
       
   417             }
       
   418             else {
       
   419                 HbIcon icon("qtg_mono_bluetooth_off");
       
   420                 icon.setIconName("qtg_mono_bluetooth_off");
       
   421                 mPowerButton->setIcon(icon);
       
   422             }
   381             break;
   423             break;
   382         case BtSettingModel::VisibilityRow:
   424         case BtSettingModel::VisibilityRow:
   383             mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode)
   425             mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode)
   384                     mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) );
   426                     mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) );
   385             break;
   427             break;
   391     Slot for receiving notification for user interaction on power state.
   433     Slot for receiving notification for user interaction on power state.
   392     Manually update model data since HbPushButton is not linked to model directly.
   434     Manually update model data since HbPushButton is not linked to model directly.
   393  */
   435  */
   394 void BtCpUiMainView::changePowerState()
   436 void BtCpUiMainView::changePowerState()
   395 {
   437 {
   396     
       
   397     QModelIndex index = mSettingModel->index(BtSettingModel::PowerStateRow, 0);
   438     QModelIndex index = mSettingModel->index(BtSettingModel::PowerStateRow, 0);
   398     QVariant powerState = mSettingModel->data(index, Qt::EditRole);
   439     PowerStateQtValue powerState = (PowerStateQtValue)mSettingModel->data(index, Qt::EditRole).toInt();
       
   440     BTUI_ASSERT_X(((powerState == BtPowerOn) || (powerState == BtPowerOff)), 
       
   441             "BtCpUiMainView::changePowerState()", "incorrect qt power state");
       
   442 
       
   443     if (powerState == BtPowerOff) {
       
   444         powerState = BtPowerOn;
       
   445     }
       
   446     else {
       
   447         powerState = BtPowerOff;
       
   448     } 
       
   449     
   399     if (!mAbstractDelegate)//if there is no other delegate running
   450     if (!mAbstractDelegate)//if there is no other delegate running
   400     { 
   451     { 
   401         mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
   452         mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
   402                 mSettingModel, mDeviceModel ); 
   453                 mSettingModel, mDeviceModel ); 
   403         connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
   454         connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
   404         mAbstractDelegate->exec(powerState);
   455         mAbstractDelegate->exec(QVariant((int)powerState));
   405     }
   456     }
   406    
   457    
   407 }
   458 }
   408 
   459 
   409 void BtCpUiMainView::powerDelegateCompleted(int status)
   460 void BtCpUiMainView::powerDelegateCompleted(int status)
   422 /*!
   473 /*!
   423  * Mapping from visibility mode UI row to VisibilityMode
   474  * Mapping from visibility mode UI row to VisibilityMode
   424  */
   475  */
   425 VisibilityMode BtCpUiMainView::indexToVisibilityMode(int index)
   476 VisibilityMode BtCpUiMainView::indexToVisibilityMode(int index)
   426 {
   477 {
   427     VisibilityMode mode; 
   478     VisibilityMode mode = BtVisibilityUnknown;
   428     switch(index) {
   479     switch(index) {
   429     case UiRowBtHidden:  
   480     case UiRowBtHidden:  
   430         mode = BtHidden;
   481         mode = BtHidden;
   431         break;
   482         break;
   432     case UiRowBtVisible:  
   483     case UiRowBtVisible:  
   434         break;
   485         break;
   435     case UiRowBtTemporary:  
   486     case UiRowBtTemporary:  
   436         mode = BtTemporary;
   487         mode = BtTemporary;
   437         break;
   488         break;
   438     default:
   489     default:
   439         mode = BtUnknown;
   490         BTUI_ASSERT_X(false, "BtCpUiMainView::indexToVisibilityMode", "invalid mode");
   440     }
   491     }
   441     return mode;
   492     return mode;
   442 }
   493 }
   443 
   494 
   444 /*!
   495 /*!
   445  * Mapping from VisibilityMode to visibility mode UI row  
   496  * Mapping from VisibilityMode to visibility mode UI row  
   446  */
   497  */
   447 int BtCpUiMainView::visibilityModeToIndex(VisibilityMode mode)
   498 int BtCpUiMainView::visibilityModeToIndex(VisibilityMode mode)
   448 {
   499 {
   449     int uiRow;
   500     int uiRow = UiRowBtUnknown;
   450     switch(mode) {
   501     switch(mode) {
   451     case BtHidden:  
   502     case BtHidden:  
   452         uiRow = UiRowBtHidden;
   503         uiRow = UiRowBtHidden;
   453         break;
   504         break;
   454     case BtVisible:  
   505     case BtVisible:  
   456         break;
   507         break;
   457     case BtTemporary:  
   508     case BtTemporary:  
   458         uiRow = UiRowBtTemporary;
   509         uiRow = UiRowBtTemporary;
   459         break;
   510         break;
   460     default:
   511     default:
   461         uiRow = -1;  // error
   512         BTUI_ASSERT_X(false, "BtCpUiMainView::visibilityModeToIndex", "invalid mode");
   462     }
   513     }
   463     return uiRow;
   514     return uiRow;
   464 }
   515 }
   465 //////////////////////
   516 
   466 //
   517 
   467 // from view manager
       
   468 // 
       
   469 //////////////////////
       
   470 
   518 
   471 /*!
   519 /*!
   472     Create views(main view, device view and search view).
   520     Create views(main view, device view and search view).
   473     Add them to MainWindow.  All views are long-lived and are deleted only when exiting the application 
   521     Add them to MainWindow.  All views are long-lived and are deleted only when exiting the application 
   474     (or when main view is deleted).
   522     (or when main view is deleted).
   552         BTUI_ASSERT_X(false, "BtCpUiMainView::idToView", "invalid view id");
   600         BTUI_ASSERT_X(false, "BtCpUiMainView::idToView", "invalid view id");
   553     }
   601     }
   554     return 0;
   602     return 0;
   555 }
   603 }
   556 
   604 
   557 /*
       
   558    Jump to previous view.  This function is used when back button is pressed.
       
   559  */
       
   560 void BtCpUiMainView::switchToPreviousViewReally()
       
   561 {  
       
   562 //    // jump to previous view of current view.
       
   563 //    if( (mCurrentViewId >= 0) && (mCurrentViewId < LastView)) {
       
   564 //        changeView( mPreviousViewIds[mCurrentViewId], true, 0 );
       
   565 //    } 
       
   566 //    else {
       
   567 //        BTUI_ASSERT_X(false, "BtCpUiMainView::switchToPreviousViewReally", "invalid view id");
       
   568 //    }
       
   569 }
       
   570 
       
   571 
       
   572 void BtCpUiMainView::setSoftkeyBack()
   605 void BtCpUiMainView::setSoftkeyBack()
   573 {
   606 {
   574 
   607 
   575 }
   608 }
   576 
   609