119 } |
123 } |
120 |
124 |
121 void BTDeviceSearchDialogWidget::closeDeviceDialog(bool byClient) |
125 void BTDeviceSearchDialogWidget::closeDeviceDialog(bool byClient) |
122 { |
126 { |
123 Q_UNUSED(byClient); |
127 Q_UNUSED(byClient); |
124 this->close(); |
128 mSearchDevicesDialog->close(); |
|
129 //@ TODO to check below code is required which is written based on the documentation of closeDeviceDialog API |
|
130 |
|
131 /* QVariantMap val; |
|
132 QVariant index(-1); |
|
133 val.insert("selectedindex",index); |
|
134 emit deviceDialogData(val); |
|
135 emit deviceDialogClosed();*/ |
125 } |
136 } |
126 |
137 |
127 HbPopup* BTDeviceSearchDialogWidget::deviceDialogWidget() const |
138 HbPopup* BTDeviceSearchDialogWidget::deviceDialogWidget() const |
128 { |
139 { |
|
140 return mSearchDevicesDialog; |
|
141 } |
|
142 |
|
143 QObject* BTDeviceSearchDialogWidget::signalSender() const |
|
144 { |
129 return const_cast<BTDeviceSearchDialogWidget*>(this); |
145 return const_cast<BTDeviceSearchDialogWidget*>(this); |
130 } |
146 } |
131 |
147 |
132 bool BTDeviceSearchDialogWidget::constructDialog(const QVariantMap ¶meters) |
148 bool BTDeviceSearchDialogWidget::constructDialog(const QVariantMap ¶meters) |
133 { |
149 { |
134 (void) parameters; |
150 (void) parameters; |
|
151 bool ok = false; |
|
152 |
135 mLoader = new HbDocumentLoader(); |
153 mLoader = new HbDocumentLoader(); |
136 bool ok = false; |
|
137 |
|
138 mLoader->load(DOCML_BTDEV_SEARCH_DIALOG, &ok); |
154 mLoader->load(DOCML_BTDEV_SEARCH_DIALOG, &ok); |
139 if(ok) |
155 if(ok) |
140 { |
156 { |
141 HbLabel* heading = qobject_cast<HbLabel*>(mLoader->findWidget("heading")); |
157 mSearchDevicesDialog = qobject_cast<HbDialog*>(mLoader->findWidget("searchdialog")); |
|
158 |
|
159 /* HbLabel* heading = qobject_cast<HbLabel*>(mLoader->findWidget("heading")); |
142 heading->setTextWrapping(Hb::TextWordWrap); |
160 heading->setTextWrapping(Hb::TextWordWrap); |
143 heading->setAlignment(Qt::AlignHCenter); |
161 heading->setAlignment(Qt::AlignHCenter); |
144 heading->setPlainText("Bluetooth - Found devices"); |
162 heading->setPlainText("Bluetooth - Found devices"); |
145 setHeadingWidget(heading); |
163 setHeadingWidget(heading);*/ |
146 |
164 |
147 mSearchLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchLabel")); |
165 mSearchLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchLabel")); |
148 mSearchLabel->setTextWrapping(Hb::TextWordWrap); |
166 mSearchLabel->setTextWrapping(Hb::TextWordWrap); |
149 mSearchLabel->setAlignment(Qt::AlignHCenter); |
167 mSearchLabel->setAlignment(Qt::AlignHCenter); |
150 mSearchLabel->setPlainText("Searching..."); |
168 mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE); |
151 |
169 |
152 mSearchIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("iconLabel")); |
170 mSearchIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("iconLabel")); |
153 mSearchIconLabel->setIcon(icon()); |
171 mSearchIconLabel->setIcon(icon()); |
154 |
172 |
155 mSearchDoneLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchDoneLabel")); |
173 mSearchDoneLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchDoneLabel")); |
156 mSearchDoneLabel->hide(); |
174 mSearchDoneLabel->hide(); |
157 |
175 |
158 setFrameType(HbDialog::Strong); |
176 |
159 setBackgroundFaded(false); |
177 mSearchDevicesDialog->setFrameType(HbDialog::Strong); |
160 |
178 mSearchDevicesDialog->setBackgroundFaded(false); |
161 mViewByBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("viewby")); |
179 |
162 mStopRetryBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("stop")); |
180 // mViewByBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("viewby")); |
|
181 // mStopRetryBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("stop")); |
163 |
182 |
164 mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView")); |
183 mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView")); |
165 mListView->setSelectionMode(HbAbstractItemView::SingleSelection); |
184 mListView->setSelectionMode(HbAbstractItemView::SingleSelection); |
166 |
185 |
167 mContentItemModel = new QStandardItemModel(this); |
186 mContentItemModel = new QStandardItemModel(this); |
168 mListView->setModel(mContentItemModel);//, prototype); |
187 mListView->setModel(mContentItemModel);//, prototype); |
169 |
188 |
170 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex))); |
189 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex))); |
171 connect(mStopRetryBtn, SIGNAL(clicked()), this, SLOT(stopRetryClicked())); |
190 // connect(mStopRetryBtn, SIGNAL(clicked()), this, SLOT(stopRetryClicked())); |
172 connect(mViewByBtn, SIGNAL(clicked()), this, SLOT(viewByClicked())); |
191 // connect(mViewByBtn, SIGNAL(clicked()), this, SLOT(viewByClicked())); |
173 |
192 |
174 QGraphicsWidget *widget = mLoader->findWidget(QString("container")); |
193 mViewByAction = static_cast<HbAction*>( mLoader->findObject( "viewaction" ) ); |
175 setContentWidget(widget); |
194 mViewByAction->disconnect(mSearchDevicesDialog); |
176 } |
195 |
177 setBackgroundFaded(false); |
196 mStopRetryAction = static_cast<HbAction*>( mLoader->findObject( "stopretryaction" ) ); |
178 setDismissPolicy(HbPopup::TapOutside); |
197 mStopRetryAction->disconnect(mSearchDevicesDialog); |
179 setTimeout(HbPopup::NoTimeout); |
198 |
|
199 connect(mViewByAction, SIGNAL(triggered()), this, SLOT(viewByClicked())); |
|
200 connect(mStopRetryAction, SIGNAL(triggered()), this, SLOT(stopRetryClicked())); |
|
201 |
|
202 connect(mSearchDevicesDialog, SIGNAL(finished(HbAction*)), this, SLOT(searchDialogClosed(HbAction*))); |
|
203 |
|
204 // QGraphicsWidget *widget = mLoader->findWidget(QString("container")); |
|
205 //setContentWidget(widget); |
|
206 } |
|
207 mSearchDevicesDialog->setBackgroundFaded(false); |
|
208 mSearchDevicesDialog->setDismissPolicy(HbPopup::TapOutside); |
|
209 mSearchDevicesDialog->setTimeout(HbPopup::NoTimeout); |
180 |
210 |
181 /* mViewByDialog = new HbDialog(); |
211 /* mViewByDialog = new HbDialog(); |
182 mRbl = new HbRadioButtonList(mViewByDialog); |
212 mRbl = new HbRadioButtonList(mViewByDialog); |
183 connect(mRbl, SIGNAL(itemSelected(int)), this, SLOT(viewByItemSelected(int)));*/ |
213 connect(mRbl, SIGNAL(itemSelected(int)), this, SLOT(viewByItemSelected(int)));*/ |
184 |
214 |
185 return true; |
215 return true; |
186 } |
216 } |
187 |
217 |
188 void BTDeviceSearchDialogWidget::hideEvent(QHideEvent *event) |
218 /*void BTDeviceSearchDialogWidget::hideEvent(QHideEvent *event) |
189 { |
219 { |
190 HbDialog::hideEvent(event); |
220 // HbDialog::hideEvent(event); |
191 QVariantMap val; |
221 QVariantMap val; |
192 QVariant index(-1); |
222 QVariant index(-1); |
193 val.insert("selectedindex",index); |
223 val.insert("selectedindex",index); |
194 emit deviceDialogData(val); |
224 emit deviceDialogData(val); |
195 emit deviceDialogClosed(); |
225 emit deviceDialogClosed(); |
196 } |
226 } |
197 |
227 |
198 void BTDeviceSearchDialogWidget::showEvent(QShowEvent *event) |
228 void BTDeviceSearchDialogWidget::showEvent(QShowEvent *event) |
199 { |
229 { |
200 HbDialog::showEvent(event); |
230 // HbDialog::showEvent(event); |
201 } |
231 }*/ |
202 |
232 |
203 void BTDeviceSearchDialogWidget::stopRetryClicked() |
233 void BTDeviceSearchDialogWidget::stopRetryClicked() |
204 { |
234 { |
205 QVariantMap val; |
235 QVariantMap val; |
206 if(mStopRetryBtn->text().compare("Retry")==0) |
236 if(mStopRetryFlag == 1)//mStopRetryAction->text().compare(LOC_SEARCH_RETRY)==0 |
207 { |
237 { |
|
238 mStopRetryFlag = 0; // Stop |
208 QVariant index("Retry"); |
239 QVariant index("Retry"); |
209 val.insert("Retry",index); |
240 val.insert("Retry",index); |
210 emit deviceDialogData(val); |
241 emit deviceDialogData(val); |
211 delete mContentItemModel; |
242 delete mContentItemModel; |
212 mContentItemModel = new QStandardItemModel(this); |
243 mContentItemModel = new QStandardItemModel(this); |
213 mListView->setModel(mContentItemModel); |
244 mListView->setModel(mContentItemModel); |
214 mStopRetryBtn->setText("Stop"); |
245 mStopRetryAction->setText(LOC_SEARCH_STOP); |
215 |
246 |
216 mSearchLabel->setTextWrapping(Hb::TextWordWrap); |
247 mSearchLabel->setTextWrapping(Hb::TextWordWrap); |
217 mSearchLabel->setAlignment(Qt::AlignHCenter); |
248 mSearchLabel->setAlignment(Qt::AlignHCenter); |
218 mSearchLabel->setPlainText("Searching..."); |
249 mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE); |
219 |
250 |
220 mSearchIconLabel->setIcon(icon()); |
251 mSearchIconLabel->setIcon(icon()); |
221 mSearchLabel->show(); |
252 mSearchLabel->show(); |
222 |
253 |
223 mSearchIconLabel->show(); |
254 mSearchIconLabel->show(); |
224 |
255 |
225 mSearchDoneLabel->hide(); |
256 mSearchDoneLabel->hide(); |
226 } |
257 } |
227 else |
258 else |
228 { |
259 { |
229 mStopRetryBtn->setText("Retry"); |
260 mStopRetryFlag = 1; //Retry |
|
261 mStopRetryAction->setText(LOC_SEARCH_RETRY); |
230 |
262 |
231 mSearchLabel->hide(); |
263 mSearchLabel->hide(); |
232 |
264 |
233 mSearchIconLabel->hide(); |
265 mSearchIconLabel->hide(); |
234 |
266 |
235 mSearchDoneLabel->show(); |
267 mSearchDoneLabel->show(); |
236 mSearchDoneLabel->setTextWrapping(Hb::TextWordWrap); |
268 mSearchDoneLabel->setTextWrapping(Hb::TextWordWrap); |
237 mSearchDoneLabel->setAlignment(Qt::AlignLeft); |
269 mSearchDoneLabel->setAlignment(Qt::AlignLeft); |
238 mSearchDoneLabel->setPlainText("Search Done"); |
270 mSearchDoneLabel->setPlainText(LOC_SEARCH_DONE); |
239 |
271 |
240 QVariantMap val; |
272 QVariantMap val; |
241 QVariant index("Stop"); |
273 QVariant index("Stop"); |
242 val.insert("Stop",index); |
274 val.insert("Stop",index); |
243 emit deviceDialogData(val); |
275 emit deviceDialogData(val); |