21 |
21 |
22 #include <btdevsettingpluginloader.h> |
22 #include <btdevsettingpluginloader.h> |
23 #include <bluetoothuitrace.h> |
23 #include <bluetoothuitrace.h> |
24 #include <HbInstance> |
24 #include <HbInstance> |
25 |
25 |
|
26 |
26 BtCpUiDeviceDetail::BtCpUiDeviceDetail(QObject *parent) : |
27 BtCpUiDeviceDetail::BtCpUiDeviceDetail(QObject *parent) : |
27 QObject(parent), mDeviceDetailView(0) |
28 QObject(parent), mDeviceDetailView(0) |
28 { |
29 { |
29 mMainWindow = hbInstance->allMainWindows().first(); |
30 mMainWindow = hbInstance->allMainWindows().first(); |
30 } |
31 } |
31 |
32 |
32 BtCpUiDeviceDetail::~BtCpUiDeviceDetail() |
33 BtCpUiDeviceDetail::~BtCpUiDeviceDetail() |
33 { |
34 { |
34 notifyViewStatusToPlugins(AboutToClose); |
|
35 clearDeviceDetailList(); |
35 clearDeviceDetailList(); |
36 delete mDeviceDetailView; |
36 delete mDeviceDetailView; |
37 } |
37 } |
38 |
38 |
39 void BtCpUiDeviceDetail::loadDeviceDetailPlugins(QString deviceAddress, QString deviceName) |
39 void BtCpUiDeviceDetail::loadDeviceDetailPlugins(QString deviceAddress, QString deviceName) |
55 |
55 |
56 for (int i = interfaces.count() - 1; i >= 0; --i ) { |
56 for (int i = interfaces.count() - 1; i >= 0; --i ) { |
57 delete interfaces.at(i); |
57 delete interfaces.at(i); |
58 } |
58 } |
59 |
59 |
|
60 createDeviceDetailsView(deviceName); |
60 notifyDeviceDetailStatus(); |
61 notifyDeviceDetailStatus(); |
61 createDeviceDetailsView(deviceName); |
62 |
62 } |
63 } |
63 |
64 |
64 void BtCpUiDeviceDetail::appendDeviceToList(BtAbstractDevSetting *devSetting) |
65 void BtCpUiDeviceDetail::appendDeviceToList(BtAbstractDevSetting *devSetting) |
65 { |
66 { |
66 bool ret = false; |
67 bool ret = false; |
82 } |
83 } |
83 |
84 |
84 void BtCpUiDeviceDetail::handleSettingChange(BtAbstractDevSetting *setting, bool available) |
85 void BtCpUiDeviceDetail::handleSettingChange(BtAbstractDevSetting *setting, bool available) |
85 { |
86 { |
86 QList<BtDeviceDetails>::iterator i; |
87 QList<BtDeviceDetails>::iterator i; |
|
88 |
87 for (i = mDeviceDetailList.begin(); i != mDeviceDetailList.end(); ++i) { |
89 for (i = mDeviceDetailList.begin(); i != mDeviceDetailList.end(); ++i) { |
88 if((setting == (*i).mSetting) && mDeviceDetailView) { |
90 if((setting == (*i).mSetting) && mDeviceDetailView) { |
89 (*i).mSettingAvailable = available; |
91 (*i).mSettingAvailable = available; |
90 if(available) { |
92 if(available) { |
91 if(((*i).mSettingForm)) { |
93 if(((*i).mSettingForm)) { |
97 mDeviceDetailView->addItem((*i).mSettingForm); |
99 mDeviceDetailView->addItem((*i).mSettingForm); |
98 } |
100 } |
99 else { |
101 else { |
100 if((*i).mSettingForm) { |
102 if((*i).mSettingForm) { |
101 //remove widget |
103 //remove widget |
102 //todo: In case if no items are there close this view |
|
103 //and disable device settings button. |
|
104 mDeviceDetailView->removeItem((*i).mSettingForm); |
104 mDeviceDetailView->removeItem((*i).mSettingForm); |
105 (*i).mSettingForm = 0; |
105 (*i).mSettingForm = 0; |
|
106 checkDeviceDetailSettings(); |
106 } |
107 } |
107 } |
108 } |
108 notifyDeviceDetailStatus(); |
109 notifyDeviceDetailStatus(); |
109 } |
110 } |
110 } |
111 } |
111 } |
112 } |
112 |
113 |
|
114 |
|
115 void BtCpUiDeviceDetail::checkDeviceDetailSettings() |
|
116 { |
|
117 QList<BtDeviceDetails>::const_iterator i; |
|
118 bool devicedetail = false; |
|
119 |
|
120 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
|
121 if((*i).mSettingForm) { |
|
122 devicedetail = true; |
|
123 break; |
|
124 } |
|
125 } |
|
126 //If no setting is available and current view is device detail |
|
127 //view move to previous view. |
|
128 if((!devicedetail) && (mMainWindow->currentView() == mDeviceDetailView)) { |
|
129 mMainWindow->removeView(mDeviceDetailView); |
|
130 mMainWindow->setCurrentView( mPreviousView ); |
|
131 } |
|
132 } |
113 |
133 |
114 void BtCpUiDeviceDetail::notifyDeviceDetailStatus() |
134 void BtCpUiDeviceDetail::notifyDeviceDetailStatus() |
115 { |
135 { |
116 QList<BtDeviceDetails>::const_iterator i; |
136 QList<BtDeviceDetails>::const_iterator i; |
117 bool devicedetail = false; |
137 bool devicedetail = false; |