30 mMainWindow = hbInstance->allMainWindows().first(); |
30 mMainWindow = hbInstance->allMainWindows().first(); |
31 } |
31 } |
32 |
32 |
33 BtCpUiDeviceDetail::~BtCpUiDeviceDetail() |
33 BtCpUiDeviceDetail::~BtCpUiDeviceDetail() |
34 { |
34 { |
|
35 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
35 clearDeviceDetailList(); |
36 clearDeviceDetailList(); |
36 delete mDeviceDetailView; |
37 BOstraceFunctionExit0(DUMMY_DEVLIST); |
37 } |
38 } |
38 |
39 |
39 void BtCpUiDeviceDetail::loadDeviceDetailPlugins(QString deviceAddress, QString deviceName) |
40 void BtCpUiDeviceDetail::loadDeviceDetailPlugins(QString& deviceAddress, QString& deviceName) |
40 { |
41 { |
|
42 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
41 QList<BtDevSettingInterface*> interfaces; |
43 QList<BtDevSettingInterface*> interfaces; |
42 BtAbstractDevSetting *devSetting; |
44 BtAbstractDevSetting *devSetting; |
43 |
45 |
44 clearDeviceDetailList(); |
46 clearDeviceDetailList(); |
45 interfaces = BtDevSettingPluginLoader::loadDevSettingInterfaces(); |
47 interfaces = BtDevSettingPluginLoader::loadDevSettingInterfaces(); |
46 QList<BtDevSettingInterface*>::const_iterator i; |
48 QList<BtDevSettingInterface*>::const_iterator i; |
47 |
49 |
48 for (i = interfaces.constBegin(); i != interfaces.constEnd(); ++i) { |
50 for (i = interfaces.constBegin(); i != interfaces.constEnd(); ++i) { |
49 devSetting = 0; |
51 devSetting = 0; |
50 devSetting = (*i)->createDevSetting( deviceAddress ); |
52 devSetting = (*i)->createDevSetting( deviceAddress ); |
|
53 BtTraceQString1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", deviceAddress); |
51 if(devSetting) { |
54 if(devSetting) { |
|
55 BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Plug-in settings appended"); |
|
56 //If settings are available add to list and connect to plugin signals. |
52 appendDeviceToList(devSetting); |
57 appendDeviceToList(devSetting); |
53 } |
58 } |
54 } |
59 } |
55 |
60 |
56 for (int i = interfaces.count() - 1; i >= 0; --i ) { |
61 for (int i = interfaces.count() - 1; i >= 0; --i ) { |
57 delete interfaces.at(i); |
62 delete interfaces.at(i); |
58 } |
63 } |
59 |
64 |
60 createDeviceDetailsView(deviceName); |
65 createDeviceDetailsView(deviceName); |
|
66 |
|
67 //Notify any changes in settings availability to Device view. |
|
68 //Based on this Device Settings button will be shown. |
61 notifyDeviceDetailStatus(); |
69 notifyDeviceDetailStatus(); |
62 |
70 BOstraceFunctionExit0(DUMMY_DEVLIST); |
63 } |
71 } |
64 |
72 |
65 void BtCpUiDeviceDetail::appendDeviceToList(BtAbstractDevSetting *devSetting) |
73 void BtCpUiDeviceDetail::appendDeviceToList(BtAbstractDevSetting *devSetting) |
66 { |
74 { |
|
75 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
67 bool ret = false; |
76 bool ret = false; |
68 BtDeviceDetails devicedetails; |
77 BtDeviceDetails devicedetails; |
69 devicedetails.mSetting = 0; |
|
70 devicedetails.mSettingForm = 0; |
|
71 devicedetails.mSettingAvailable = false; |
|
72 |
78 |
73 devicedetails.mSetting = devSetting; |
79 devicedetails.mSetting = devSetting; |
74 devicedetails.mSettingAvailable = devSetting->isSettingAvailable(); |
80 devicedetails.mSettingAvailable = devSetting->isSettingAvailable(); |
75 devicedetails.mSettingForm = devSetting->getSettingWidget(); |
81 devicedetails.mSettingForm = 0; |
|
82 |
|
83 if(devicedetails.mSettingAvailable) { |
|
84 devicedetails.mSettingForm = devSetting->getSettingWidget(); |
|
85 } |
76 |
86 |
77 mDeviceDetailList.append(devicedetails); |
87 mDeviceDetailList.append(devicedetails); |
78 |
88 |
79 ret = connect(devicedetails.mSetting, SIGNAL(settingAvailabilityChanged(BtAbstractDevSetting *, bool)), |
89 ret = connect(devicedetails.mSetting, SIGNAL(settingAvailabilityChanged(BtAbstractDevSetting *, bool)), |
80 this, SLOT(handleSettingChange(BtAbstractDevSetting *, bool))); |
90 this, SLOT(handleSettingChange(BtAbstractDevSetting *, bool))); |
81 BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::appendDeviceToList", "connect settingAvailabilityChanged() failed"); |
91 BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::appendDeviceToList", "connect settingAvailabilityChanged() failed"); |
82 |
92 BOstraceFunctionExit0(DUMMY_DEVLIST); |
83 } |
93 } |
84 |
94 |
85 void BtCpUiDeviceDetail::handleSettingChange(BtAbstractDevSetting *setting, bool available) |
95 void BtCpUiDeviceDetail::handleSettingChange(BtAbstractDevSetting *setting, bool available) |
86 { |
96 { |
|
97 BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, available ); |
87 QList<BtDeviceDetails>::iterator i; |
98 QList<BtDeviceDetails>::iterator i; |
88 |
99 |
89 for (i = mDeviceDetailList.begin(); i != mDeviceDetailList.end(); ++i) { |
100 for (i = mDeviceDetailList.begin(); i != mDeviceDetailList.end(); ++i) { |
90 if((setting == (*i).mSetting) && mDeviceDetailView) { |
101 if((setting == (*i).mSetting) && mDeviceDetailView) { |
91 (*i).mSettingAvailable = available; |
102 (*i).mSettingAvailable = available; |
92 if(available) { |
103 if(available) { |
93 if(((*i).mSettingForm)) { |
104 if(((*i).mSettingForm)) { |
94 //If item already exists, remove it first. |
105 //If item already exists, remove it first. |
|
106 BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Setting removed"); |
95 mDeviceDetailView->removeItem((*i).mSettingForm); |
107 mDeviceDetailView->removeItem((*i).mSettingForm); |
96 } |
108 } |
97 (*i).mSettingForm = setting->getSettingWidget(); |
109 (*i).mSettingForm = setting->getSettingWidget(); |
|
110 BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Setting added"); |
98 //add widget |
111 //add widget |
99 mDeviceDetailView->addItem((*i).mSettingForm); |
112 mDeviceDetailView->addItem((*i).mSettingForm); |
100 } |
113 } |
101 else { |
114 else { |
102 if((*i).mSettingForm) { |
115 if((*i).mSettingForm) { |
|
116 BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Setting removed"); |
103 //remove widget |
117 //remove widget |
104 mDeviceDetailView->removeItem((*i).mSettingForm); |
118 mDeviceDetailView->removeItem((*i).mSettingForm); |
105 (*i).mSettingForm = 0; |
119 (*i).mSettingForm = 0; |
106 checkDeviceDetailSettings(); |
120 checkDeviceDetailSettings(); |
107 } |
121 } |
108 } |
122 } |
|
123 //Notify any changes in settings availability to Device view. |
|
124 //Based on this Device Settings button will be shown. |
109 notifyDeviceDetailStatus(); |
125 notifyDeviceDetailStatus(); |
110 } |
126 } |
111 } |
127 } |
|
128 BOstraceFunctionExit0(DUMMY_DEVLIST); |
112 } |
129 } |
113 |
130 |
114 |
131 |
115 void BtCpUiDeviceDetail::checkDeviceDetailSettings() |
132 void BtCpUiDeviceDetail::checkDeviceDetailSettings() |
116 { |
133 { |
|
134 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
117 QList<BtDeviceDetails>::const_iterator i; |
135 QList<BtDeviceDetails>::const_iterator i; |
118 bool devicedetail = false; |
136 bool devicedetail = false; |
119 |
137 |
120 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
138 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
121 if((*i).mSettingForm) { |
139 if((*i).mSettingForm) { |
127 //view move to previous view. |
145 //view move to previous view. |
128 if((!devicedetail) && (mMainWindow->currentView() == mDeviceDetailView)) { |
146 if((!devicedetail) && (mMainWindow->currentView() == mDeviceDetailView)) { |
129 mMainWindow->removeView(mDeviceDetailView); |
147 mMainWindow->removeView(mDeviceDetailView); |
130 mMainWindow->setCurrentView( mPreviousView ); |
148 mMainWindow->setCurrentView( mPreviousView ); |
131 } |
149 } |
|
150 BOstraceFunctionExit0(DUMMY_DEVLIST); |
132 } |
151 } |
133 |
152 |
134 void BtCpUiDeviceDetail::notifyDeviceDetailStatus() |
153 void BtCpUiDeviceDetail::notifyDeviceDetailStatus() |
135 { |
154 { |
|
155 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
136 QList<BtDeviceDetails>::const_iterator i; |
156 QList<BtDeviceDetails>::const_iterator i; |
137 bool devicedetail = false; |
157 bool devicedetail = false; |
138 |
158 |
139 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
159 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
140 if(((*i).mSettingAvailable == true) && ((*i).mSettingForm) ) { |
160 if(((*i).mSettingAvailable == true) && ((*i).mSettingForm) ) { |
141 devicedetail = true; |
161 devicedetail = true; |
142 break; |
162 break; |
143 } |
163 } |
144 } |
164 } |
145 emit deviceSettingsChanged(devicedetail); |
165 emit deviceSettingsChanged(devicedetail); |
|
166 BOstraceFunctionExit0(DUMMY_DEVLIST); |
146 } |
167 } |
147 |
168 |
148 void BtCpUiDeviceDetail::clearDeviceDetailList() |
169 void BtCpUiDeviceDetail::clearDeviceDetailList() |
149 { |
170 { |
|
171 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
150 QList<BtDeviceDetails>::const_iterator i; |
172 QList<BtDeviceDetails>::const_iterator i; |
151 |
173 |
152 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
174 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
153 if((*i).mSetting ) { |
175 if((*i).mSetting ) { |
154 disconnect((*i).mSetting); |
|
155 delete (*i).mSetting; |
176 delete (*i).mSetting; |
156 } |
177 } |
157 } |
178 } |
158 mDeviceDetailList.clear(); |
179 mDeviceDetailList.clear(); |
159 } |
180 |
160 |
181 if(mDeviceDetailView) { |
161 void BtCpUiDeviceDetail::createDeviceDetailsView(QString deviceName) |
182 mDeviceDetailView->removeAllItems(); |
162 { |
183 delete mDeviceDetailView; |
|
184 mDeviceDetailView = 0; |
|
185 } |
|
186 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
187 } |
|
188 |
|
189 void BtCpUiDeviceDetail::createDeviceDetailsView(QString& deviceName) |
|
190 { |
|
191 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
163 bool ret = false; |
192 bool ret = false; |
164 //Launch Device Detail View. |
193 //Launch Device Detail View, this view will be created once device view |
|
194 //is launched and will be deleted when device view is closed. |
165 mDeviceDetailView = new BtCpUiDeviceDetailsView(); |
195 mDeviceDetailView = new BtCpUiDeviceDetailsView(); |
166 mDeviceDetailView->setDeviceName(deviceName); |
196 mDeviceDetailView->setDeviceName(deviceName); |
167 |
197 |
168 ret = connect(mDeviceDetailView, SIGNAL(aboutToClose()), this, |
198 ret = connect(mDeviceDetailView, SIGNAL(aboutToClose()), this, |
169 SLOT(handleDeviceDetailViewClose())); |
199 SLOT(handleDeviceDetailViewClose())); |
170 BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::loadDeviceDetailsView", "connect deviceDetailViewClosed() failed"); |
200 BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::createDeviceDetailsView", "connect deviceDetailViewClosed() failed"); |
171 |
201 |
172 QList<BtDeviceDetails>::const_iterator i; |
202 QList<BtDeviceDetails>::const_iterator i; |
173 |
203 |
174 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
204 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
175 if((*i).mSettingForm) { |
205 if((*i).mSettingForm) { |
176 mDeviceDetailView->addItem((*i).mSettingForm); |
206 mDeviceDetailView->addItem((*i).mSettingForm); |
177 } |
207 } |
178 } |
208 } |
|
209 BOstraceFunctionExit0(DUMMY_DEVLIST); |
179 } |
210 } |
180 |
211 |
181 void BtCpUiDeviceDetail::loadDeviceDetailsView() |
212 void BtCpUiDeviceDetail::loadDeviceDetailsView() |
182 { |
213 { |
183 |
214 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
184 mPreviousView = mMainWindow->currentView(); |
215 mPreviousView = mMainWindow->currentView(); |
185 mMainWindow->addView(mDeviceDetailView); |
216 mMainWindow->addView(mDeviceDetailView); |
186 |
217 |
|
218 //aboutToForeground of plugin is called before launching |
|
219 //device settings view. |
187 notifyViewStatusToPlugins(AboutToShow); |
220 notifyViewStatusToPlugins(AboutToShow); |
188 |
221 |
189 mMainWindow->setCurrentView( mDeviceDetailView ); |
222 mMainWindow->setCurrentView( mDeviceDetailView ); |
|
223 BOstraceFunctionExit0(DUMMY_DEVLIST); |
190 } |
224 } |
191 |
225 |
192 void BtCpUiDeviceDetail::handleDeviceDetailViewClose() |
226 void BtCpUiDeviceDetail::handleDeviceDetailViewClose() |
193 { |
227 { |
|
228 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
229 //aboutToBackground of plugin is called before going |
|
230 //back to device view. |
194 notifyViewStatusToPlugins(AboutToHide); |
231 notifyViewStatusToPlugins(AboutToHide); |
195 |
232 |
196 mMainWindow->removeView(mDeviceDetailView); |
233 mMainWindow->removeView(mDeviceDetailView); |
197 |
234 |
198 mMainWindow->setCurrentView( mPreviousView ); |
235 mMainWindow->setCurrentView( mPreviousView ); |
199 |
236 BOstraceFunctionExit0(DUMMY_DEVLIST); |
200 } |
237 } |
201 |
238 |
202 void BtCpUiDeviceDetail::notifyViewStatusToPlugins(BtCpUiDeviceDetail::NotifyType type) |
239 void BtCpUiDeviceDetail::notifyViewStatusToPlugins(BtCpUiDeviceDetail::NotifyType type) |
203 { |
240 { |
|
241 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
204 QList<BtDeviceDetails>::const_iterator i; |
242 QList<BtDeviceDetails>::const_iterator i; |
205 BtAbstractDevSetting *deviceSetting = 0; |
243 BtAbstractDevSetting *deviceSetting = 0; |
206 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
244 for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) { |
207 deviceSetting = (*i).mSetting; |
245 deviceSetting = (*i).mSetting; |
208 if(deviceSetting) { |
246 if(deviceSetting) { |