bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicesearchdialogwidget.cpp
changeset 57 5ebadcda06cb
parent 47 9e2a905b887f
child 70 f5508c13dfe0
equal deleted inserted replaced
51:625f43ae9362 57:5ebadcda06cb
    36 
    36 
    37 #define LOC_SEARCHING_DEVICE hbTrId("txt_bt_subhead_searching")
    37 #define LOC_SEARCHING_DEVICE hbTrId("txt_bt_subhead_searching")
    38 #define LOC_SEARCH_DONE hbTrId("txt_bt_subhead_search_done")
    38 #define LOC_SEARCH_DONE hbTrId("txt_bt_subhead_search_done")
    39 #define LOC_SEARCH_STOP hbTrId("txt_common_button_stop")
    39 #define LOC_SEARCH_STOP hbTrId("txt_common_button_stop")
    40 #define LOC_SEARCH_RETRY hbTrId("txt_common_button_retry")
    40 #define LOC_SEARCH_RETRY hbTrId("txt_common_button_retry")
       
    41 #define LOC_SHOW_DIALOG_TITLE hbTrId("txt_bt_title_show")
    41 
    42 
    42 
    43 
    43 BTDeviceSearchDialogWidget::BTDeviceSearchDialogWidget(const QVariantMap &parameters)
    44 BTDeviceSearchDialogWidget::BTDeviceSearchDialogWidget(const QVariantMap &parameters)
    44     {
    45 {
    45 //    mDeviceLstIdx = 0;
       
    46 //    mViewByChosen = false;
       
    47     mSelectedDeviceType = 0;
    46     mSelectedDeviceType = 0;
    48  //   mDeviceDialogData = 0;
       
    49     mLoader = 0;
    47     mLoader = 0;
    50     mContentItemModel = 0;
    48     mContentItemModel = 0;
    51     mStopRetryFlag = 0; // Stop 
    49     mStopRetryFlag = 0; // Stop 
    52     mQuery = 0;
    50     mQuery = 0;
    53     mSelectedDeviceType |= (BtuiDevProperty::AVDev | BtuiDevProperty::Computer |
    51     mSelectedDeviceType |= (BtuiDevProperty::AVDev | BtuiDevProperty::Computer |
    54             BtuiDevProperty::Phone | BtuiDevProperty::Peripheral |
    52             BtuiDevProperty::Phone | BtuiDevProperty::Peripheral |
    55             BtuiDevProperty::LANAccessDev | BtuiDevProperty::Toy |
    53             BtuiDevProperty::LANAccessDev | BtuiDevProperty::Toy |
    56             BtuiDevProperty::WearableDev | BtuiDevProperty::ImagingDev |
    54             BtuiDevProperty::WearableDev | BtuiDevProperty::ImagingDev |
    57             BtuiDevProperty::HealthDev | BtuiDevProperty::UncategorizedDev);       
    55             BtuiDevProperty::HealthDev | BtuiDevProperty::UncategorizedDev);       
    58     constructDialog(parameters);
    56     constructDialog(parameters);
    59     }
    57 }
    60 
    58 
    61 BTDeviceSearchDialogWidget::~BTDeviceSearchDialogWidget()
    59 BTDeviceSearchDialogWidget::~BTDeviceSearchDialogWidget()
    62     {
    60 {
    63     delete mLoader;
    61     delete mLoader;
    64     delete mContentItemModel;
    62     delete mContentItemModel;
    65     if ( mQuery ) {
    63     if ( mQuery )
       
    64     {
    66         delete mQuery;
    65         delete mQuery;
    67     }
    66     }
    68     
    67 }
    69  //   delete mRbl;
       
    70  //   delete mViewByDialog;
       
    71     }
       
    72 
    68 
    73 bool BTDeviceSearchDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
    69 bool BTDeviceSearchDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
    74     {
    70 {
    75     if(parameters.keys().at(0).compare("Search Completed")==0)
    71     if(parameters.keys().contains("Search Completed"))
    76         {
    72     {
    77         mStopRetryFlag = 1; // Retry 
    73         mStopRetryFlag = 1; // Retry 
    78         mSearchLabel->hide();
    74         mSearchLabel->hide();
    79         
    75         
    80         mSearchIconLabel->hide();
    76         mSearchIconLabel->hide();
    81         
    77         
    83         mSearchDoneLabel->setTextWrapping(Hb::TextWordWrap);
    79         mSearchDoneLabel->setTextWrapping(Hb::TextWordWrap);
    84         mSearchDoneLabel->setAlignment(Qt::AlignLeft);
    80         mSearchDoneLabel->setAlignment(Qt::AlignLeft);
    85         mSearchDoneLabel->setPlainText(LOC_SEARCH_DONE);
    81         mSearchDoneLabel->setPlainText(LOC_SEARCH_DONE);
    86         
    82         
    87         mStopRetryAction->setText(LOC_SEARCH_RETRY);
    83         mStopRetryAction->setText(LOC_SEARCH_RETRY);
    88         }
    84     }
    89     else
    85     else
    90         {
    86     {
    91         double cod  = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
    87         int cod  = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toInt();
    92         int uiMajorDevice;
    88         int uiMajorDevice;
    93         int uiMinorDevice;
    89         int uiMinorDevice;
    94     
    90     
    95         BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod);
    91         BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod);
    96 
    92 
    97         BtSendDataItem devData;
    93         BtSendDataItem devData;
    98         devData[NameAliasRole] = QVariant(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
    94         //TODO Need to create string constant for Name as enum EDeviceName is not working for this
    99         devData[ReadableBdaddrRole] = QVariant(parameters.value(QString::number(TBluetoothDialogParams::EAddress)).toString());
    95         devData[NameAliasRole] =parameters.value("Name").toString();
   100         devData[CoDRole] = QVariant(cod);
    96         devData[ReadableBdaddrRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EAddress));
       
    97         devData[CoDRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass));
   101         devData[DeviceTypeRole] = QVariant(uiMajorDevice);
    98         devData[DeviceTypeRole] = QVariant(uiMajorDevice);
   102         setMajorProperty(devData,BtuiDevProperty::Bonded,
    99         setMajorProperty(devData,BtuiDevProperty::Bonded,
   103                 parameters.value("Bonded").toBool());
   100                 parameters.value("Bonded").toBool());
   104         setMajorProperty(devData,BtuiDevProperty::Blocked,
   101         setMajorProperty(devData,BtuiDevProperty::Blocked,
   105                 parameters.value("Blocked").toBool());
   102                 parameters.value("Blocked").toBool());
   108         setMajorProperty(devData,BtuiDevProperty::Connected,
   105         setMajorProperty(devData,BtuiDevProperty::Connected,
   109                 parameters.value("Connected").toBool());
   106                 parameters.value("Connected").toBool());
   110         mData.append(devData);
   107         mData.append(devData);
   111         
   108         
   112         if(mSelectedDeviceType & devData[DeviceTypeRole].toInt())
   109         if(mSelectedDeviceType & devData[DeviceTypeRole].toInt())
   113             {
   110         {
   114             QStandardItem* listitem = new QStandardItem();
   111             QStandardItem* listitem = new QStandardItem();
   115             QStringList info;
   112             QStringList info;
   116             info.append(devData[NameAliasRole].toString());
   113             info.append(devData[NameAliasRole].toString());
   117             listitem->setData(info, Qt::DisplayRole);
   114             listitem->setData(info, Qt::DisplayRole);
   118             HbIcon icon =  getBadgedDeviceTypeIcon(devData[CoDRole].toDouble(),
   115             HbIcon icon =  getBadgedDeviceTypeIcon(devData[CoDRole].toInt(),
   119                     devData[MajorPropertyRole].toInt(),
   116                     devData[MajorPropertyRole].toInt(),
   120                     BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
   117                     BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
   121             listitem->setIcon(icon.qicon());
   118             listitem->setIcon(icon.qicon());
   122             mContentItemModel->appendRow(listitem);    
   119             mContentItemModel->appendRow(listitem);    
   123             mSelectedData.append(devData);
   120             mSelectedData.append(devData);
   124             }
       
   125         }
   121         }
       
   122     }
   126                 
   123                 
   127     return true;
   124     return true;
   128     }
   125 }
   129 
   126 
   130 int BTDeviceSearchDialogWidget::deviceDialogError() const
   127 int BTDeviceSearchDialogWidget::deviceDialogError() const
   131     {
   128 {
   132     return 0;
   129     return 0;
   133     }
   130 }
   134 
   131 
   135 void BTDeviceSearchDialogWidget::closeDeviceDialog(bool byClient)
   132 void BTDeviceSearchDialogWidget::closeDeviceDialog(bool byClient)
   136     {
   133 {
   137     Q_UNUSED(byClient);
   134     Q_UNUSED(byClient);
   138     mSearchDevicesDialog->close();
   135     mSearchDevicesDialog->close();
   139     //@ TODO to check below code is required which is written based on the documentation of closeDeviceDialog API
   136     if(!byClient)
   140     
   137         {
   141  /*   QVariantMap val;
   138         QVariantMap val;
   142     QVariant index(-1);
   139         QVariant index(-1);
   143     val.insert("selectedindex",index);
   140         val.insert("selectedindex",index);
   144     emit deviceDialogData(val);    
   141         emit deviceDialogData(val);    
   145     emit deviceDialogClosed();*/
   142         }
   146     }
   143     emit deviceDialogClosed();
       
   144 }
   147 
   145 
   148 HbPopup* BTDeviceSearchDialogWidget::deviceDialogWidget() const
   146 HbPopup* BTDeviceSearchDialogWidget::deviceDialogWidget() const
   149     {
   147 {
   150     return mSearchDevicesDialog;
   148     return mSearchDevicesDialog;
   151     }
   149 }
   152 
   150 
   153 QObject* BTDeviceSearchDialogWidget::signalSender() const
   151 QObject* BTDeviceSearchDialogWidget::signalSender() const
   154     {
   152 {
   155     return const_cast<BTDeviceSearchDialogWidget*>(this);
   153     return const_cast<BTDeviceSearchDialogWidget*>(this);
   156     }
   154 }
   157 
   155 
   158 bool BTDeviceSearchDialogWidget::constructDialog(const QVariantMap &parameters)
   156 bool BTDeviceSearchDialogWidget::constructDialog(const QVariantMap &parameters)
   159     {
   157 {
   160     (void) parameters;
   158     (void) parameters;
   161     bool ok = false;
   159     bool ok = false;
   162     
   160     
   163     mLoader = new HbDocumentLoader();
   161     mLoader = new HbDocumentLoader();
   164     mLoader->load(DOCML_BTDEV_SEARCH_DIALOG, &ok);
   162     mLoader->load(DOCML_BTDEV_SEARCH_DIALOG, &ok);
   165     if(ok)
   163     if(ok)
   166         {
   164     {
   167         mSearchDevicesDialog = qobject_cast<HbDialog*>(mLoader->findWidget("searchdialog"));
   165         mSearchDevicesDialog = qobject_cast<HbDialog*>(mLoader->findWidget("searchDialog"));
   168 
       
   169  /*       HbLabel* heading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
       
   170         heading->setTextWrapping(Hb::TextWordWrap);
       
   171         heading->setAlignment(Qt::AlignHCenter);
       
   172         heading->setPlainText("Bluetooth - Found devices");
       
   173         setHeadingWidget(heading);*/
       
   174         
   166         
   175         mSearchLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchLabel"));
   167         mSearchLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchLabel"));
   176         mSearchLabel->setTextWrapping(Hb::TextWordWrap);
   168         mSearchLabel->setTextWrapping(Hb::TextWordWrap);
   177         mSearchLabel->setAlignment(Qt::AlignHCenter);
   169         mSearchLabel->setAlignment(Qt::AlignHCenter);
   178         mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE);
   170         mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE);
   179  
   171  
   180         mSearchIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("iconLabel"));
   172         mSearchIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchIconLabel"));
   181         mSearchIconLabel->setIcon(QIcon(QString(":/icons/qtg_large_bluetooth.svg")));
   173         mSearchIconLabel->setIcon(HbIcon("qtg_large_bluetooth"));
   182 
   174 
   183         mSearchDoneLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchDoneLabel"));
   175         mSearchDoneLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchDoneLabel"));
   184         mSearchDoneLabel->hide();
   176         mSearchDoneLabel->hide();
   185         
   177         
   186         
   178         mDeviceList = qobject_cast<HbListView*>(mLoader->findWidget("deviceList"));
   187         mSearchDevicesDialog->setFrameType(HbDialog::Strong);
   179         mDeviceList->setSelectionMode(HbAbstractItemView::SingleSelection);
   188         mSearchDevicesDialog->setBackgroundFaded(false);
       
   189 
       
   190  //       mViewByBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("viewby"));
       
   191   //      mStopRetryBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("stop"));
       
   192         
       
   193         mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView"));
       
   194         mListView->setSelectionMode(HbAbstractItemView::SingleSelection);
       
   195 
   180 
   196         mContentItemModel = new QStandardItemModel(this);
   181         mContentItemModel = new QStandardItemModel(this);
   197         mListView->setModel(mContentItemModel);//, prototype);
   182         mDeviceList->setModel(mContentItemModel);//, prototype);
   198 
   183 
   199         connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
   184         connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
   200  //       connect(mStopRetryBtn, SIGNAL(clicked()), this, SLOT(stopRetryClicked()));
   185         
   201  //       connect(mViewByBtn, SIGNAL(clicked()), this, SLOT(viewByClicked()));
   186         mShowAction = static_cast<HbAction*>( mLoader->findObject( "viewByAction" ) );
   202         
   187         //if action is not disconnected the dialog will be closed when action is clicked 
   203         mShowAction = static_cast<HbAction*>( mLoader->findObject( "viewaction" ) );
   188         mShowAction->disconnect(mSearchDevicesDialog); 
   204         mShowAction->disconnect(mSearchDevicesDialog);
   189         
   205         
   190         
   206         mStopRetryAction = static_cast<HbAction*>( mLoader->findObject( "stopretryaction" ) );
   191         mStopRetryAction = static_cast<HbAction*>( mLoader->findObject( "stopRetryAction" ) );
   207         mStopRetryAction->disconnect(mSearchDevicesDialog);
   192         //if action is not disconnected the dialog will be closed when action is clicked         
   208         
   193         mStopRetryAction->disconnect(mSearchDevicesDialog); 
   209 //        mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) );
       
   210 //        mCancelAction->disconnect(mSearchDevicesDialog);
       
   211         
   194         
   212         connect(mShowAction, SIGNAL(triggered()), this, SLOT(viewByClicked()));
   195         connect(mShowAction, SIGNAL(triggered()), this, SLOT(viewByClicked()));
   213         connect(mStopRetryAction, SIGNAL(triggered()), this, SLOT(stopRetryClicked()));
   196         connect(mStopRetryAction, SIGNAL(triggered()), this, SLOT(stopRetryClicked()));
   214 
   197 
   215         connect(mSearchDevicesDialog, SIGNAL(aboutToClose()), this, SLOT(searchDialogClosed()));
   198         connect(mSearchDevicesDialog, SIGNAL(aboutToClose()), this, SLOT(searchDialogClosed()));
   216         
   199     }
   217 //        QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
       
   218         //setContentWidget(widget);
       
   219         }
       
   220     mSearchDevicesDialog->setBackgroundFaded(false);
   200     mSearchDevicesDialog->setBackgroundFaded(false);
   221     mSearchDevicesDialog->setDismissPolicy(HbPopup::NoDismiss);
   201     mSearchDevicesDialog->setDismissPolicy(HbPopup::NoDismiss);
   222     mSearchDevicesDialog->setTimeout(HbPopup::NoTimeout);
   202     mSearchDevicesDialog->setTimeout(HbPopup::NoTimeout);
   223     mSearchDevicesDialog->setAttribute(Qt::WA_DeleteOnClose);
   203     mSearchDevicesDialog->setAttribute(Qt::WA_DeleteOnClose);
   224     
   204     
   226             << hbTrId("txt_bt_list_computers") 
   206             << hbTrId("txt_bt_list_computers") 
   227             << hbTrId("txt_bt_list_input_devices") 
   207             << hbTrId("txt_bt_list_input_devices") 
   228             << hbTrId("txt_bt_list_phones") 
   208             << hbTrId("txt_bt_list_phones") 
   229             << hbTrId("txt_bt_list_other_devices");
   209             << hbTrId("txt_bt_list_other_devices");
   230     
   210     
   231  /*   mViewByDialog = new HbDialog();
       
   232     mRbl = new HbRadioButtonList(mViewByDialog);
       
   233     connect(mRbl, SIGNAL(itemSelected(int)), this, SLOT(viewByItemSelected(int)));*/
       
   234     
       
   235     return true;
   211     return true;
   236     }
   212 }
   237 
   213 
   238 
   214 
   239 void BTDeviceSearchDialogWidget::stopRetryClicked()
   215 void BTDeviceSearchDialogWidget::stopRetryClicked()
   240     {
   216 {
   241     QVariantMap val;
   217     QVariantMap val;
   242     if(mStopRetryFlag == 1)//mStopRetryAction->text().compare(LOC_SEARCH_RETRY)==0
   218     if(mStopRetryFlag == 1)
   243         {
   219     {
   244         mStopRetryFlag = 0; // Stop 
   220         mStopRetryFlag = 0; // Stop 
   245         QVariant index("Retry");
   221         QVariant index("Retry");
   246         val.insert("Retry",index); 
   222         val.insert("Retry",index); 
   247         emit deviceDialogData(val);
   223         emit deviceDialogData(val);
   248         delete mContentItemModel;
   224         delete mContentItemModel;
   249         mContentItemModel = new QStandardItemModel(this);
   225         mContentItemModel = new QStandardItemModel(this);
   250         mListView->setModel(mContentItemModel);
   226         mDeviceList->setModel(mContentItemModel);
   251         mStopRetryAction->setText(LOC_SEARCH_STOP);
   227         mStopRetryAction->setText(LOC_SEARCH_STOP);
   252         
   228         
   253         mSearchLabel->setTextWrapping(Hb::TextWordWrap);
   229         mSearchLabel->setTextWrapping(Hb::TextWordWrap);
   254         mSearchLabel->setAlignment(Qt::AlignHCenter);
   230         mSearchLabel->setAlignment(Qt::AlignHCenter);
   255         mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE);
   231         mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE);
   258         mSearchLabel->show();
   234         mSearchLabel->show();
   259         
   235         
   260         mSearchIconLabel->show();
   236         mSearchIconLabel->show();
   261         
   237         
   262         mSearchDoneLabel->hide();
   238         mSearchDoneLabel->hide();
   263         }
   239     }
   264     else
   240     else
   265         {
   241     {
   266         mStopRetryFlag = 1; //Retry 
   242         mStopRetryFlag = 1; //Retry 
   267         mStopRetryAction->setText(LOC_SEARCH_RETRY);
   243         mStopRetryAction->setText(LOC_SEARCH_RETRY);
   268         
   244         
   269         mSearchLabel->hide();
   245         mSearchLabel->hide();
   270         
   246         
   277         
   253         
   278         QVariantMap val;
   254         QVariantMap val;
   279         QVariant index("Stop");
   255         QVariant index("Stop");
   280         val.insert("Stop",index); 
   256         val.insert("Stop",index); 
   281         emit deviceDialogData(val);    
   257         emit deviceDialogData(val);    
   282         }
   258     }
   283     }
   259 }
   284 
       
   285 void BTDeviceSearchDialogWidget::retryClicked()
       
   286     {
       
   287     QVariantMap val;
       
   288     QVariant index("Retry");
       
   289     val.insert("Retry",index); 
       
   290     emit deviceDialogData(val);
       
   291     delete mContentItemModel;
       
   292     mContentItemModel = new QStandardItemModel(this);
       
   293     mListView->setModel(mContentItemModel);
       
   294     
       
   295 
       
   296     }
       
   297 
   260 
   298 void BTDeviceSearchDialogWidget::viewByClicked()
   261 void BTDeviceSearchDialogWidget::viewByClicked()
   299     {
   262 {
   300     
   263     if ( !mQuery )
   301     if ( !mQuery ) {
   264     {
   302         mQuery = new HbSelectionDialog;
   265         mQuery = new HbSelectionDialog;
   303         mQuery->setStringItems(mDevTypeList, 0);
   266         mQuery->setStringItems(mDevTypeList, 0);
   304         mQuery->setSelectionMode(HbAbstractItemView::MultiSelection);
   267         mQuery->setSelectionMode(HbAbstractItemView::MultiSelection);
   305     
   268     
   306         QList<QVariant> current;
   269         QList<QVariant> current;
   310         //todo need to check whether the dialog is destroyed without setting this flag
   273         //todo need to check whether the dialog is destroyed without setting this flag
   311         //if not destoryed then set this flag in the destructor and then delete it
   274         //if not destoryed then set this flag in the destructor and then delete it
   312         
   275         
   313 //        mQuery->setAttribute(Qt::WA_DeleteOnClose);
   276 //        mQuery->setAttribute(Qt::WA_DeleteOnClose);
   314         // Set the heading for the dialog.
   277         // Set the heading for the dialog.
   315         HbLabel *headingLabel = new HbLabel(hbTrId("txt_bt_title_show"), mQuery);
   278         HbLabel *headingLabel = new HbLabel(LOC_SHOW_DIALOG_TITLE, mQuery);
   316         mQuery->setHeadingWidget(headingLabel);
   279         mQuery->setHeadingWidget(headingLabel);
   317     }
   280     }
   318     mQuery->open(this,SLOT(selectionDialogClosed(HbAction*)));
   281     mQuery->open(this,SLOT(selectionDialogClosed(HbAction*)));
   319 
   282 }
   320      
       
   321     }
       
   322 
   283 
   323 void BTDeviceSearchDialogWidget::searchDialogClosed() 
   284 void BTDeviceSearchDialogWidget::searchDialogClosed() 
   324     {
   285 {
   325     QVariantMap val;
   286     QVariantMap val;
   326     QVariant index(-1);
   287     QVariant index(-1);
   327     val.insert("selectedindex",index);
   288     val.insert("selectedindex",index);
   328     emit deviceDialogData(val);    
   289     emit deviceDialogData(val);    
   329     emit deviceDialogClosed();
   290     emit deviceDialogClosed();
   330     }
   291 }
   331 
   292 
   332 void BTDeviceSearchDialogWidget::selectionDialogClosed(HbAction* action)
   293 void BTDeviceSearchDialogWidget::selectionDialogClosed(HbAction* action)
   333     {
   294 {
   334     Q_UNUSED(action);
   295     disconnect( mQuery, 0, this, 0 ); 
   335     
       
   336     disconnect( mQuery ); 
       
   337     int devTypesWanted = 0;
   296     int devTypesWanted = 0;
   338 
   297 
   339     if (action == mQuery->actions().first()) {  // user pressed "Ok"
   298     if (action == mQuery->actions().first())
       
   299     {  // user pressed "Ok"
   340         // Get selected items.
   300         // Get selected items.
   341         QList<QVariant> selections;
   301         QList<QVariant> selections;
   342         selections = mQuery->selectedItems();
   302         selections = mQuery->selectedItems();
   343         
   303         
   344         for (int i=0; i < selections.count(); i++) {
   304         for (int i=0; i < selections.count(); i++) 
   345             switch (selections.at(i).toInt()) {
   305         {
   346             case BtUiDevAudioDevice:
   306             switch (selections.at(i).toInt()) 
   347                 devTypesWanted |= BtuiDevProperty::AVDev;
   307             {
   348                 break;
   308                 case BtUiDevAudioDevice:
   349             case BtUiDevComputer:
   309                     devTypesWanted |= BtuiDevProperty::AVDev;
   350                 devTypesWanted |= BtuiDevProperty::Computer;
   310                     break;
   351                 break;
   311                 case BtUiDevComputer:
   352             case BtUiDevInputDevice:
   312                     devTypesWanted |= BtuiDevProperty::Computer;
   353                 devTypesWanted |= BtuiDevProperty::Peripheral;
   313                     break;
   354                 break;
   314                 case BtUiDevInputDevice:
   355             case BtUiDevPhone:
   315                     devTypesWanted |= BtuiDevProperty::Peripheral;
   356                 devTypesWanted |= BtuiDevProperty::Phone;
   316                     break;
   357                 break;
   317                 case BtUiDevPhone:
   358             case BtUiDevOtherDevice:
   318                     devTypesWanted |= BtuiDevProperty::Phone;
   359                 devTypesWanted |= (BtuiDevProperty::LANAccessDev |
   319                     break;
   360                         BtuiDevProperty::Toy |
   320                 case BtUiDevOtherDevice:
   361                         BtuiDevProperty::WearableDev |
   321                     devTypesWanted |= (BtuiDevProperty::LANAccessDev |
   362                         BtuiDevProperty::ImagingDev |
   322                             BtuiDevProperty::Toy |
   363                         BtuiDevProperty::HealthDev |
   323                             BtuiDevProperty::WearableDev |
   364                         BtuiDevProperty::UncategorizedDev);
   324                             BtuiDevProperty::ImagingDev |
   365                 break;
   325                             BtuiDevProperty::HealthDev |
   366             default:
   326                             BtuiDevProperty::UncategorizedDev);
   367                 // should never get here
   327                     break;
   368                 break;
   328                 default:
       
   329                     // should never get here
       
   330                     break;
   369             }
   331             }
   370         }
   332         }
   371     }
   333     }
   372     else
   334     else
   373         {
   335     {
   374         devTypesWanted = mSelectedDeviceType;
   336         devTypesWanted = mSelectedDeviceType;
   375         }
   337     }
   376         
   338 
   377     
       
   378 
       
   379  /*   HbSelectionDialog *dlg = (HbSelectionDialog*)(sender());
       
   380     if(dlg->actions().first() == action) {
       
   381 
       
   382      } 
       
   383     else if(dlg->actions().at(1) == action) {
       
   384      }*/
       
   385     
       
   386     if((devTypesWanted != mSelectedDeviceType) &&(devTypesWanted !=0))
   339     if((devTypesWanted != mSelectedDeviceType) &&(devTypesWanted !=0))
   387         {
   340     {
   388         mSelectedDeviceType = devTypesWanted;
   341         mSelectedDeviceType = devTypesWanted;
   389 //        mViewByChosen = true;
       
   390         delete mContentItemModel;
   342         delete mContentItemModel;
   391         mContentItemModel = new QStandardItemModel(this);
   343         mContentItemModel = new QStandardItemModel(this);
   392         mListView->setModel(mContentItemModel);
   344         mDeviceList->setModel(mContentItemModel);
   393         mSelectedData.clear();
   345         mSelectedData.clear();
   394         for(int i=0;i<mData.count();i++)
   346         for(int i=0;i<mData.count();i++)
   395             {
   347         {
   396             const BtSendDataItem& qtdev = mData[i];
   348             const BtSendDataItem& qtdev = mData[i];
   397             if(devTypesWanted & qtdev[DeviceTypeRole].toInt() )
   349             if(devTypesWanted & qtdev[DeviceTypeRole].toInt() )
   398                 {
   350             {
   399                 QStandardItem* listitem = new QStandardItem();
   351                 QStandardItem* listitem = new QStandardItem();
   400                 QStringList info;
   352                 QStringList info;
   401                 info.append(qtdev[NameAliasRole].toString());
   353                 info.append(qtdev[NameAliasRole].toString());
   402     
   354     
   403                 listitem->setData(info, Qt::DisplayRole);
   355                 listitem->setData(info, Qt::DisplayRole);
   405                         qtdev[MajorPropertyRole].toInt(),
   357                         qtdev[MajorPropertyRole].toInt(),
   406                          BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
   358                          BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
   407                 listitem->setIcon(icon.qicon());
   359                 listitem->setIcon(icon.qicon());
   408                 mContentItemModel->appendRow(listitem);        
   360                 mContentItemModel->appendRow(listitem);        
   409                 mSelectedData.append(qtdev);
   361                 mSelectedData.append(qtdev);
   410                 }
       
   411             }
   362             }
   412         }
   363         }
   413     }
   364     }
       
   365 }
   414 
   366 
   415 void BTDeviceSearchDialogWidget::deviceSelected(const QModelIndex& modelIndex)
   367 void BTDeviceSearchDialogWidget::deviceSelected(const QModelIndex& modelIndex)
   416     {
   368 {
   417     int row = 0;
   369     int row = 0;
   418     
       
   419  /*   if(mViewByChosen)
       
   420         {
       
   421         row = mDeviceLstOfType[modelIndex.row()].mDeviceIdx;
       
   422         }
       
   423     
       
   424     else*/
       
   425         {
       
   426         row = modelIndex.row();
       
   427         }
       
   428     
       
   429     QVariantMap val;
   370     QVariantMap val;
   430 //    QVariant index(row);
   371     
   431 //    val.insert("selectedindex",index);
   372     row = modelIndex.row();
   432     
       
   433     const BtSendDataItem& qtdev = mSelectedData.at(row);
   373     const BtSendDataItem& qtdev = mSelectedData.at(row);
   434     val.insert("selectedindex",QVariant(row));
   374     val.insert("selectedindex",QVariant(row));
   435     val.insert("devicename",QVariant(qtdev[NameAliasRole]));
   375     val.insert("devicename",qtdev[NameAliasRole]);
   436     val.insert("deviceaddress",QVariant(qtdev[ReadableBdaddrRole]));
   376     val.insert("deviceaddress",qtdev[ReadableBdaddrRole]);
   437     val.insert("deviceclass",QVariant(qtdev[CoDRole]));
   377     val.insert("deviceclass",qtdev[CoDRole]);
   438 
   378 
   439     emit deviceDialogData(val);
   379     emit deviceDialogData(val);
   440 //    mDeviceDialogData = 1;//flag is to say that device dialog data is emitted required when we cancel the dialog
   380 }
   441     //emit deviceDialogClosed();
   381 
   442   //  this->close();
   382 
   443     }
       
   444 
       
   445