--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btmoredevicesdialogwidget.cpp Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btmoredevicesdialogwidget.cpp Fri Sep 03 16:17:59 2010 +0300
@@ -32,8 +32,7 @@
BTMoreDevicesDialogWidget::BTMoreDevicesDialogWidget(const QVariantMap ¶meters)
- {
- mDeviceDialogData = 0;
+{
mLoader = 0;
mContentItemModel = 0;
constructDialog(parameters);
@@ -48,27 +47,28 @@
Q_UNUSED(badAlloc);
// = UnknownDeviceDialogError;
}*/
- }
+}
BTMoreDevicesDialogWidget::~BTMoreDevicesDialogWidget()
- {
+{
delete mLoader;
delete mContentItemModel;
- }
+}
bool BTMoreDevicesDialogWidget::setDeviceDialogParameters(const QVariantMap ¶meters)
- {
- double cod = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
+{
+ int cod = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toInt();
int uiMajorDevice;
int uiMinorDevice;
BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod);
if ((uiMajorDevice & BtuiDevProperty::Phone)||(uiMajorDevice & BtuiDevProperty::Computer) )
- {
+ {
BtSendDataItem devData;
- devData[NameAliasRole] = QVariant(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
- devData[ReadableBdaddrRole] = QVariant(parameters.value(QString::number(TBluetoothDialogParams::EAddress)).toString());
- devData[CoDRole] = QVariant(cod);
+ //todo Need to create string constant for name as enum EDeviceName has an issue
+ devData[NameAliasRole] = parameters.value("Name");
+ devData[ReadableBdaddrRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EAddress));
+ devData[CoDRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass));
setMajorProperty(devData,BtuiDevProperty::Bonded,
parameters.value("Bonded").toBool());
@@ -85,212 +85,111 @@
info.append(devData[NameAliasRole].toString());
listitem->setData(info, Qt::DisplayRole);
- HbIcon icon = getBadgedDeviceTypeIcon(devData[CoDRole].toDouble(),
+ HbIcon icon = getBadgedDeviceTypeIcon(devData[CoDRole].toInt(),
devData[MajorPropertyRole].toInt(),
- BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
+ BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
listitem->setIcon(icon.qicon());
- // listitem->setIcon(icon(parameters.value("deviceType").toString()));
mContentItemModel->appendRow(listitem);
- }
+ }
return true;
- }
+}
int BTMoreDevicesDialogWidget::deviceDialogError() const
- {
+{
return 0;
- }
+}
void BTMoreDevicesDialogWidget::closeDeviceDialog(bool byClient)
- {
- Q_UNUSED(byClient);
- // below code is required and written based on the documentation of closeDeviceDialog API
- mMoreDeviceDialog->close();
- QVariantMap val;
- QVariant index(-1);
- val.insert("selectedindex",index);
- emit deviceDialogData(val);
- //below signal is emitted to make dialog server aware that our dialog is closed
+{
+ mLastUsedDeviceDialog->close();
+ if(!byClient)
+ {
+ QVariantMap val;
+ QVariant index(-1);
+ val.insert("selectedindex",index);
+ emit deviceDialogData(val);
+ }
emit deviceDialogClosed();
- }
+}
HbPopup* BTMoreDevicesDialogWidget::deviceDialogWidget() const
- {
- return mMoreDeviceDialog;
- }
+{
+ return mLastUsedDeviceDialog;
+}
QObject* BTMoreDevicesDialogWidget::signalSender() const
- {
+{
return const_cast<BTMoreDevicesDialogWidget*>(this);
- }
+}
-bool BTMoreDevicesDialogWidget::constructDialog(const QVariantMap &/*parameters*/)
- {
+bool BTMoreDevicesDialogWidget::constructDialog(const QVariantMap ¶meters)
+{
+ Q_UNUSED(parameters);
mLoader = new HbDocumentLoader();
bool ok = false;
mLoader->load(DOCML_BT_MORE_DEV_DIALOG, &ok);
if(ok)
- {
- mMoreDeviceDialog = qobject_cast<HbDialog*>(mLoader->findWidget("lastuseddialog"));
- mMoreDeviceDialog->setFrameType(HbDialog::Strong);
- mMoreDeviceDialog->setBackgroundFaded(false);
-/* HbLabel* label = qobject_cast<HbLabel*>(mLoader->findWidget("label"));
- if(label)
- {
- label->setTextWrapping(Hb::TextWordWrap);
- label->setPlainText("Send to:");
- }
- this->setHeadingWidget(label);*/
- // HbPushButton* moreDevices = qobject_cast<HbPushButton*>(mLoader->findWidget("moreDevices"));
- // HbPushButton* cancel = qobject_cast<HbPushButton*>(mLoader->findWidget("cancel"));
+ {
+ mLastUsedDeviceDialog = qobject_cast<HbDialog*>(mLoader->findWidget("lastUsedDevicesDialog"));
+
- HbListView* listView = qobject_cast<HbListView*>(mLoader->findWidget("listView"));
- listView->setSelectionMode(HbAbstractItemView::SingleSelection);
+ HbListView* deviceList = qobject_cast<HbListView*>(mLoader->findWidget("deviceList"));
+ deviceList->setSelectionMode(HbAbstractItemView::SingleSelection);
mContentItemModel = new QStandardItemModel(this);
- listView->setModel(mContentItemModel);//, prototype);
+ deviceList->setModel(mContentItemModel);
- // QList<QVariant> values = parameters.values();
+ connect(deviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
- /* for(int i=0;i < values.count();i++)
- {
- QStandardItem* listitem = new QStandardItem();
- // parameters.
- // QString string = values.at(i).toString();
-
- listitem->setData(values.at(i).toString(), Qt::DisplayRole);
- // listitem->setData(QString("search"), Qt::DisplayRole);
- //Todo - Insert icons based on the device class
- QIcon icon(QString(":/qgn_prop_sml_bt.svg"));
- listitem->setIcon(icon);
+ mMoreAction = static_cast<HbAction*>( mLoader->findObject( "moreAction" ) );
+
+ mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelAction" ) );
- mContentItemModel->appendRow(listitem);
- }*/
-
- connect(listView, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
- // connect(moreDevices, SIGNAL(clicked()), this, SLOT(moreDevicesClicked()));
- // connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
- mMoreAction = static_cast<HbAction*>( mLoader->findObject( "moreaction" ) );
- mMoreAction->disconnect(mMoreDeviceDialog);
-
- mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) );
- mCancelAction->disconnect(mMoreDeviceDialog);
-// QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
- // mMoreDeviceDialog->setContentWidget(widget);
-
- connect(mMoreAction, SIGNAL(triggered()), this, SLOT(moreDevicesClicked()));
- connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
+ connect(mMoreAction, SIGNAL(triggered()), this, SLOT(moreDevicesClicked()));
+ connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
- }
+ }
+ mLastUsedDeviceDialog->setBackgroundFaded(false);
+ mLastUsedDeviceDialog->setDismissPolicy(HbPopup::NoDismiss);
+ mLastUsedDeviceDialog->setTimeout(HbPopup::NoTimeout);
+ mLastUsedDeviceDialog->setAttribute(Qt::WA_DeleteOnClose);
+ return true;
+}
- mMoreDeviceDialog->setBackgroundFaded(false);
- mMoreDeviceDialog->setDismissPolicy(HbPopup::NoDismiss);
- mMoreDeviceDialog->setTimeout(HbPopup::NoTimeout);
- mMoreDeviceDialog->setAttribute(Qt::WA_DeleteOnClose);
- return true;
- }
-
-/*void BTMoreDevicesDialogWidget::hideEvent(QHideEvent *event)
- {
- //HbDialog::hideEvent(event);
- mMoreDeviceDialog->hideEvent(event);
-// if(mDeviceDialogData == 0)
- {
- QVariantMap val;
- QVariant index(-1);
- val.insert("selectedindex",index);
- emit deviceDialogData(val);
- emit deviceDialogClosed();
- }*/
- //
- // }
-
-/*void BTMoreDevicesDialogWidget::showEvent(QShowEvent *event)
- {
- //HbDialog::showEvent(event);
- }*/
-
void BTMoreDevicesDialogWidget::moreDevicesClicked()
- {
+{
QVariantMap val;
QVariant index("MoreDevices");
val.insert("MoreDevices",index);
emit deviceDialogData(val);
- // mDeviceDialogData = 1;//flag is to say that device dialog data is emitted required when we cancel the dialog
- // this->close();
- // TODO
- }
+ emit deviceDialogClosed();
+}
void BTMoreDevicesDialogWidget::cancelClicked()
- {
- // TODO
- mMoreDeviceDialog->close();
+{
+ mLastUsedDeviceDialog->close();
QVariantMap val;
QVariant index(-1);
val.insert("selectedindex",index);
emit deviceDialogData(val);
emit deviceDialogClosed();
- }
+}
void BTMoreDevicesDialogWidget::deviceSelected(const QModelIndex& modelIndex)
- {
+{
int row = modelIndex.row();
QVariantMap val;
-// QVariant index(row);
const BtSendDataItem& qtdev = mData.at(row);
val.insert("selectedindex",QVariant(row));
val.insert("devicename",QVariant(qtdev[NameAliasRole]));
val.insert("deviceaddress",QVariant(qtdev[ReadableBdaddrRole]));
val.insert("deviceclass",QVariant(qtdev[CoDRole]));
emit deviceDialogData(val);
- // mDeviceDialogData = 1;//flag is to say that device dialog data is emitted required when we cancel the dialog
- // this->close();
-
- }
-
-QIcon BTMoreDevicesDialogWidget::icon(/*QString deviceType*/)
- {
- /* if(deviceType == "Audio")
- {
- return (QIcon(QString(":/qgn_prop_bt_audio.svg")));
- }
- else if(deviceType == "Car-kit")
- {
- return (QIcon(QString(":/qgn_prop_bt_car_kit.svg")));
- }
- else if(deviceType == "Computer")
- {
- return (QIcon(QString(":/qgn_prop_bt_computer.svg")));
- }
- else if(deviceType == "Headset")
- {
- return (QIcon(QString(":/qgn_prop_bt_headset.svg")));
- }
- else if(deviceType == "Keyboard")
- {
- return (QIcon(QString(":/qgn_prop_bt_keyboard.svg")));
- }
- else if(deviceType == "Mouse")
- {
- return (QIcon(QString(":/qgn_prop_bt_mouse.svg")));
- }
- else if(deviceType == "Phone")
- {
- return (QIcon(QString(":/qgn_prop_bt_phone.svg")));
- }
- else if(deviceType == "Printer")
- {
- return (QIcon(QString(":/qgn_prop_bt_printer.svg")));
- }
- else
- {
- return (QIcon(QString(":/qgn_prop_bt_unknown.svg")));
- }*/
- return QIcon(QString(":/icons/qtg_large_bluetooth.svg"));
- }
-
+}
+