|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <hblabel.h> |
|
20 #include <hblistview.h> |
|
21 #include <hbtoolbar.h> |
|
22 #include <hblistwidget.h> |
|
23 #include <qstandarditemmodel.h> |
|
24 #include <hbaction.h> |
|
25 #include "btsenddialogwidget.h" |
|
26 |
|
27 |
|
28 |
|
29 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml"; |
|
30 |
|
31 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap ¶meters) |
|
32 :HbDialog() |
|
33 { |
|
34 // LOG(ELevel1,_L("BTSendDialogWidget::BTSendDialogWidget")); |
|
35 constructDialog(parameters); |
|
36 |
|
37 } |
|
38 |
|
39 BTSendDialogWidget::~BTSendDialogWidget() |
|
40 { |
|
41 if(mLoader) |
|
42 { |
|
43 delete mLoader; |
|
44 mLoader = NULL; |
|
45 } |
|
46 if(mContentItemModel) |
|
47 { |
|
48 delete mContentItemModel; |
|
49 mContentItemModel = NULL; |
|
50 } |
|
51 } |
|
52 |
|
53 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap ¶meters) |
|
54 { |
|
55 // LOG(ELevel1,_L("BTSendDialogWidget::setDeviceDialogParameters ")); |
|
56 |
|
57 if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() ) |
|
58 { |
|
59 mLabel->setTextWrapping(Hb::TextWordWrap); |
|
60 mLabel->setAlignment(Qt::AlignHCenter); |
|
61 //Todo - replace this with the actual text from parameters |
|
62 |
|
63 QString headLabel; |
|
64 headLabel.append(QString("Sending file ")); |
|
65 headLabel.append(parameters.value("currentFileIdx").toString()); |
|
66 headLabel.append('/'); |
|
67 headLabel.append(parameters.value("totalFilesCnt").toString()); |
|
68 headLabel.append(QString(" to ")); |
|
69 headLabel.append(parameters.value("destinationName").toString()); |
|
70 mLabel->setPlainText(headLabel); |
|
71 |
|
72 QStringList info; |
|
73 info.append(parameters.value("fileName").toString()); |
|
74 info.append(parameters.value("fileSzTxt").toString()); |
|
75 |
|
76 QStandardItem* listitem = new QStandardItem(); |
|
77 // parameters. |
|
78 listitem->setData(info, Qt::DisplayRole); |
|
79 |
|
80 //Todo - Insert icons based on the device class |
|
81 QIcon icon(QString(":/icons/qtg_large_bluetooth.svg")); |
|
82 listitem->setIcon(icon); |
|
83 |
|
84 delete mContentItemModel; |
|
85 mContentItemModel = new QStandardItemModel(this); |
|
86 mListView->setModel(mContentItemModel);//, prototype); |
|
87 |
|
88 mContentItemModel->appendRow(listitem); |
|
89 |
|
90 mProgressBar->setMinimum(0); |
|
91 mProgressBar->setProgressValue(0); |
|
92 mProgressBar->setMaximum(parameters.value("fileSz").toInt()); |
|
93 mFileIndex = parameters.value("currentFileIdx").toString().toInt(); |
|
94 } |
|
95 else |
|
96 { |
|
97 mProgressBar->setProgressValue(parameters.value("progressValue").toInt()); |
|
98 } |
|
99 // LOG(ELevel1,_L("BTSendDialogWidget::setDeviceDialogParameters Completed")); |
|
100 return true; |
|
101 } |
|
102 |
|
103 int BTSendDialogWidget::deviceDialogError() const |
|
104 { |
|
105 return 0; |
|
106 } |
|
107 |
|
108 void BTSendDialogWidget::closeDeviceDialog(bool byClient) |
|
109 { |
|
110 Q_UNUSED(byClient); |
|
111 this->close(); |
|
112 } |
|
113 |
|
114 HbPopup* BTSendDialogWidget::deviceDialogWidget() const |
|
115 { |
|
116 return const_cast<BTSendDialogWidget*>(this); |
|
117 } |
|
118 |
|
119 QObject *BTSendDialogWidget::signalSender() const |
|
120 { |
|
121 return const_cast<BTSendDialogWidget*>(this); |
|
122 } |
|
123 |
|
124 bool BTSendDialogWidget::constructDialog(const QVariantMap&/*parameters*/) |
|
125 { |
|
126 // LOG(ELevel1,_L("BTSendDialogWidget::constructDialog ")); |
|
127 mLoader = new HbDocumentLoader(); |
|
128 bool ok = false; |
|
129 |
|
130 mLoader->load(DOCML_BT_SEND_DIALOG, &ok); |
|
131 if(ok) |
|
132 { |
|
133 mLabel = qobject_cast<HbLabel*>(mLoader->findWidget("heading")); |
|
134 this->setHeadingWidget(mLabel); |
|
135 mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView")); |
|
136 if(mListView) |
|
137 { |
|
138 //Todo - replace this with the actual text from parameters |
|
139 mContentItemModel = new QStandardItemModel(this); |
|
140 mListView->setModel(mContentItemModel);//, prototype); |
|
141 } |
|
142 |
|
143 mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar")); |
|
144 |
|
145 HbAction* hide = new HbAction("Hide"); |
|
146 HbAction* cancel = new HbAction("Cancel"); |
|
147 |
|
148 this->addAction(hide); |
|
149 this->addAction(cancel); |
|
150 |
|
151 QGraphicsWidget *widget = mLoader->findWidget(QString("container")); |
|
152 this->setContentWidget(widget); |
|
153 } |
|
154 |
|
155 this->setBackgroundFaded(false); |
|
156 setDismissPolicy(HbPopup::NoDismiss); |
|
157 setTimeout(HbPopup::NoTimeout); |
|
158 |
|
159 this->actions().first()->disconnect(this); |
|
160 connect(this, SIGNAL(finished(HbAction*)), this, SLOT(inputClosed(HbAction*))); |
|
161 |
|
162 return true; |
|
163 } |
|
164 |
|
165 void BTSendDialogWidget::hideEvent(QHideEvent *event) |
|
166 { |
|
167 HbDialog::hideEvent(event); |
|
168 emit deviceDialogClosed(); |
|
169 } |
|
170 |
|
171 void BTSendDialogWidget::showEvent(QShowEvent *event) |
|
172 { |
|
173 HbDialog::showEvent(event); |
|
174 } |
|
175 |
|
176 /*void BTSendDialogWidget::hideClicked() |
|
177 { |
|
178 // TODO |
|
179 this->close(); |
|
180 emit deviceDialogClosed(); |
|
181 } |
|
182 |
|
183 void BTSendDialogWidget::cancelClicked() |
|
184 { |
|
185 // TODO |
|
186 this->close(); |
|
187 emit deviceDialogClosed(); |
|
188 }*/ |
|
189 |
|
190 void BTSendDialogWidget::inputClosed(HbAction* action) |
|
191 { |
|
192 QVariantMap data; |
|
193 |
|
194 HbDialog *dlg=static_cast<HbDialog*>(sender()); |
|
195 if(dlg->actions().first() == action) { |
|
196 } |
|
197 else if(dlg->actions().at(1) == action) { |
|
198 } |
|
199 } |
|
200 |