bluetoothengine/btui/btcpplugin/btcpuidevicedetail.cpp
changeset 47 9e2a905b887f
parent 42 b72428996822
child 57 5ebadcda06cb
--- a/bluetoothengine/btui/btcpplugin/btcpuidevicedetail.cpp	Mon Jul 12 19:25:26 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuidevicedetail.cpp	Fri Jul 23 15:57:13 2010 +0300
@@ -23,6 +23,7 @@
 #include <bluetoothuitrace.h>
 #include <HbInstance>
 
+
 BtCpUiDeviceDetail::BtCpUiDeviceDetail(QObject *parent) :
     QObject(parent), mDeviceDetailView(0)
 {
@@ -31,7 +32,6 @@
 
 BtCpUiDeviceDetail::~BtCpUiDeviceDetail()
 {
-    notifyViewStatusToPlugins(AboutToClose);
     clearDeviceDetailList();
     delete mDeviceDetailView;
 }
@@ -57,8 +57,9 @@
         delete interfaces.at(i);
     }
     
+    createDeviceDetailsView(deviceName);
     notifyDeviceDetailStatus();
-    createDeviceDetailsView(deviceName);
+    
 }
 
 void BtCpUiDeviceDetail::appendDeviceToList(BtAbstractDevSetting *devSetting)
@@ -84,6 +85,7 @@
 void BtCpUiDeviceDetail::handleSettingChange(BtAbstractDevSetting *setting, bool available)
 {
     QList<BtDeviceDetails>::iterator i;
+       
     for (i = mDeviceDetailList.begin(); i != mDeviceDetailList.end(); ++i) {
         if((setting == (*i).mSetting) && mDeviceDetailView) {
             (*i).mSettingAvailable = available;
@@ -99,10 +101,9 @@
             else {
                 if((*i).mSettingForm) {
                     //remove widget
-                    //todo: In case if no items are there close this view
-                    //and disable device settings button.
                     mDeviceDetailView->removeItem((*i).mSettingForm);
-                    (*i).mSettingForm = 0; 
+                    (*i).mSettingForm = 0;
+                    checkDeviceDetailSettings();
                 }
             }
             notifyDeviceDetailStatus();
@@ -111,6 +112,25 @@
 }
 
 
+void BtCpUiDeviceDetail::checkDeviceDetailSettings()
+{
+    QList<BtDeviceDetails>::const_iterator i;
+    bool devicedetail = false;
+    
+    for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) {
+        if((*i).mSettingForm) {
+            devicedetail = true;
+            break;
+        }
+    }
+    //If no setting is available and current view is device detail 
+    //view move to previous view.
+    if((!devicedetail) && (mMainWindow->currentView() == mDeviceDetailView)) {
+        mMainWindow->removeView(mDeviceDetailView); 
+        mMainWindow->setCurrentView( mPreviousView );
+    }
+}
+
 void BtCpUiDeviceDetail::notifyDeviceDetailStatus()
 {
     QList<BtDeviceDetails>::const_iterator i;
@@ -156,7 +176,6 @@
             mDeviceDetailView->addItem((*i).mSettingForm);
         }
     }
-
 }
 
 void BtCpUiDeviceDetail::loadDeviceDetailsView()
@@ -203,4 +222,9 @@
 
 }
 
+void BtCpUiDeviceDetail::sendCloseEvent()
+{
+    notifyViewStatusToPlugins(AboutToClose);
+}
 
+