23 #include <qstandarditemmodel.h> |
23 #include <qstandarditemmodel.h> |
24 #include <hbaction.h> |
24 #include <hbaction.h> |
25 #include "btsenddialogwidget.h" |
25 #include "btsenddialogwidget.h" |
26 |
26 |
27 |
27 |
|
28 #define LOC_SENDING_FILES_TO_DEVICE hbTrId("txt_bt_title_sending_file_l1l2_to_3") |
28 |
29 |
29 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml"; |
30 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml"; |
30 |
31 |
31 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap ¶meters) |
32 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap ¶meters) |
32 :HbDialog() |
33 { |
33 { |
34 mLoader = 0; |
34 // LOG(ELevel1,_L("BTSendDialogWidget::BTSendDialogWidget")); |
|
35 constructDialog(parameters); |
35 constructDialog(parameters); |
36 |
|
37 } |
36 } |
38 |
37 |
39 BTSendDialogWidget::~BTSendDialogWidget() |
38 BTSendDialogWidget::~BTSendDialogWidget() |
40 { |
39 { |
41 if(mLoader) |
40 delete mLoader; |
42 { |
41 /* if(mContentItemModel) |
43 delete mLoader; |
|
44 mLoader = NULL; |
|
45 } |
|
46 if(mContentItemModel) |
|
47 { |
42 { |
48 delete mContentItemModel; |
43 delete mContentItemModel; |
49 mContentItemModel = NULL; |
44 mContentItemModel = NULL; |
50 } |
45 }*/ |
51 } |
46 } |
52 |
47 |
53 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap ¶meters) |
48 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap ¶meters) |
54 { |
49 { |
55 // LOG(ELevel1,_L("BTSendDialogWidget::setDeviceDialogParameters ")); |
|
56 |
|
57 if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() ) |
50 if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() ) |
58 { |
51 { |
59 mLabel->setTextWrapping(Hb::TextWordWrap); |
52 mDialogHeading->setTextWrapping(Hb::TextWordWrap); |
60 mLabel->setAlignment(Qt::AlignHCenter); |
53 mDialogHeading->setAlignment(Qt::AlignHCenter); |
61 //Todo - replace this with the actual text from parameters |
54 //Todo - replace this with the actual text from parameters |
62 |
55 |
63 QString headLabel; |
56 QString headLabel = QString(LOC_SENDING_FILES_TO_DEVICE).arg(parameters.value("currentFileIdx").toInt()) |
64 headLabel.append(QString("Sending file ")); |
57 .arg(parameters.value("totalFilesCnt").toInt()) |
|
58 .arg(parameters.value("destinationName").toString()); |
|
59 /* headLabel.append(QString("Sending file ")); |
65 headLabel.append(parameters.value("currentFileIdx").toString()); |
60 headLabel.append(parameters.value("currentFileIdx").toString()); |
66 headLabel.append('/'); |
61 headLabel.append('/'); |
67 headLabel.append(parameters.value("totalFilesCnt").toString()); |
62 headLabel.append(parameters.value("totalFilesCnt").toString()); |
68 headLabel.append(QString(" to ")); |
63 headLabel.append(QString(" to ")); |
69 headLabel.append(parameters.value("destinationName").toString()); |
64 headLabel.append(parameters.value("destinationName").toString());*/ |
70 mLabel->setPlainText(headLabel); |
65 mDialogHeading->setPlainText(headLabel); |
71 |
66 |
72 QStringList info; |
67 /* QStringList info; |
73 info.append(parameters.value("fileName").toString()); |
68 info.append(parameters.value("fileName").toString()); |
74 info.append(parameters.value("fileSzTxt").toString()); |
69 info.append(parameters.value("fileSzTxt").toString()); |
75 |
70 |
76 QStandardItem* listitem = new QStandardItem(); |
71 QStandardItem* listitem = new QStandardItem(); |
77 // parameters. |
72 // parameters. |
78 listitem->setData(info, Qt::DisplayRole); |
73 listitem->setData(info, Qt::DisplayRole); |
79 |
74 |
80 //Todo - Insert icons based on the device class |
75 //Todo - Insert file icons here thumbnail icon |
81 QIcon icon(QString(":/icons/qtg_large_bluetooth.svg")); |
76 QIcon icon(QString(":/icons/qtg_large_bluetooth.svg")); |
82 listitem->setIcon(icon); |
77 listitem->setIcon(icon); |
83 |
78 |
84 delete mContentItemModel; |
79 delete mContentItemModel; |
85 mContentItemModel = new QStandardItemModel(this); |
80 mContentItemModel = new QStandardItemModel(this); |
86 mListView->setModel(mContentItemModel);//, prototype); |
81 mListView->setModel(mContentItemModel);//, prototype); |
87 |
82 |
88 mContentItemModel->appendRow(listitem); |
83 mContentItemModel->appendRow(listitem);*/ |
89 |
84 //Todo - Insert file icons here thumbnail icon |
|
85 QIcon icon(QString(":/icons/qtg_large_bluetooth.svg")); |
|
86 mFileIconLabel->setIcon(icon); |
|
87 mFileNameLabel->setPlainText(parameters.value("fileName").toString()); |
|
88 mFileSizeLabel->setPlainText(parameters.value("fileSzTxt").toString()); |
90 mProgressBar->setMinimum(0); |
89 mProgressBar->setMinimum(0); |
91 mProgressBar->setProgressValue(0); |
90 mProgressBar->setProgressValue(0); |
92 mProgressBar->setMaximum(parameters.value("fileSz").toInt()); |
91 mProgressBar->setMaximum(parameters.value("fileSz").toInt()); |
93 mFileIndex = parameters.value("currentFileIdx").toString().toInt(); |
92 mFileIndex = parameters.value("currentFileIdx").toString().toInt(); |
94 } |
93 } |
95 else |
94 else |
96 { |
95 { |
97 mProgressBar->setProgressValue(parameters.value("progressValue").toInt()); |
96 mProgressBar->setProgressValue(parameters.value("progressValue").toInt()); |
98 } |
97 } |
99 // LOG(ELevel1,_L("BTSendDialogWidget::setDeviceDialogParameters Completed")); |
|
100 return true; |
98 return true; |
101 } |
99 } |
102 |
100 |
103 int BTSendDialogWidget::deviceDialogError() const |
101 int BTSendDialogWidget::deviceDialogError() const |
104 { |
102 { |
106 } |
104 } |
107 |
105 |
108 void BTSendDialogWidget::closeDeviceDialog(bool byClient) |
106 void BTSendDialogWidget::closeDeviceDialog(bool byClient) |
109 { |
107 { |
110 Q_UNUSED(byClient); |
108 Q_UNUSED(byClient); |
111 this->close(); |
109 mSendDialog->close(); |
|
110 // below redundant call is required because of the api documentation. |
|
111 emit deviceDialogClosed(); |
112 } |
112 } |
113 |
113 |
114 HbPopup* BTSendDialogWidget::deviceDialogWidget() const |
114 HbPopup* BTSendDialogWidget::deviceDialogWidget() const |
115 { |
115 { |
116 return const_cast<BTSendDialogWidget*>(this); |
116 return mSendDialog; |
117 } |
117 } |
118 |
118 |
119 QObject *BTSendDialogWidget::signalSender() const |
119 QObject *BTSendDialogWidget::signalSender() const |
120 { |
120 { |
121 return const_cast<BTSendDialogWidget*>(this); |
121 return const_cast<BTSendDialogWidget*>(this); |
122 } |
122 } |
123 |
123 |
124 bool BTSendDialogWidget::constructDialog(const QVariantMap&/*parameters*/) |
124 bool BTSendDialogWidget::constructDialog(const QVariantMap&/*parameters*/) |
125 { |
125 { |
126 // LOG(ELevel1,_L("BTSendDialogWidget::constructDialog ")); |
|
127 mLoader = new HbDocumentLoader(); |
126 mLoader = new HbDocumentLoader(); |
128 bool ok = false; |
127 bool ok = false; |
129 |
128 |
130 mLoader->load(DOCML_BT_SEND_DIALOG, &ok); |
129 mLoader->load(DOCML_BT_SEND_DIALOG, &ok); |
131 if(ok) |
130 if(ok) |
132 { |
131 { |
133 mLabel = qobject_cast<HbLabel*>(mLoader->findWidget("heading")); |
132 mSendDialog = qobject_cast<HbDialog*>(mLoader->findWidget("senddialog")); |
134 this->setHeadingWidget(mLabel); |
133 mDialogHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading")); |
135 mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView")); |
134 mFileIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileiconlabel")); |
|
135 mFileNameLabel = qobject_cast<HbLabel*>(mLoader->findWidget("filenamelabel")); |
|
136 mFileSizeLabel = qobject_cast<HbLabel*>(mLoader->findWidget("filesizelabel")); |
|
137 // mSendDialog->setHeadingWidget(mLabel); |
|
138 /* mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView")); |
136 if(mListView) |
139 if(mListView) |
137 { |
140 { |
138 //Todo - replace this with the actual text from parameters |
|
139 mContentItemModel = new QStandardItemModel(this); |
141 mContentItemModel = new QStandardItemModel(this); |
140 mListView->setModel(mContentItemModel);//, prototype); |
142 mListView->setModel(mContentItemModel);//, prototype); |
141 } |
143 }*/ |
142 |
144 |
143 mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar")); |
145 mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar")); |
144 |
146 |
145 HbAction* hide = new HbAction("Hide"); |
147 // HbAction* hide = new HbAction("Hide"); |
146 HbAction* cancel = new HbAction("Cancel"); |
148 // HbAction* cancel = new HbAction("Cancel"); |
147 |
149 |
148 this->addAction(hide); |
150 // this->addAction(hide); |
149 this->addAction(cancel); |
151 // this->addAction(cancel); |
150 |
152 |
151 QGraphicsWidget *widget = mLoader->findWidget(QString("container")); |
153 // QGraphicsWidget *widget = mLoader->findWidget(QString("container")); |
152 this->setContentWidget(widget); |
154 // this->setContentWidget(widget); |
153 } |
155 } |
154 |
156 |
155 this->setBackgroundFaded(false); |
157 mSendDialog->setBackgroundFaded(false); |
156 setDismissPolicy(HbPopup::NoDismiss); |
158 mSendDialog->setDismissPolicy(HbPopup::NoDismiss); |
157 setTimeout(HbPopup::NoTimeout); |
159 mSendDialog->setTimeout(HbPopup::NoTimeout); |
158 |
160 |
159 this->actions().first()->disconnect(this); |
161 mHideAction = static_cast<HbAction*>( mLoader->findObject( "hideaction" ) ); |
160 connect(this, SIGNAL(finished(HbAction*)), this, SLOT(inputClosed(HbAction*))); |
162 mHideAction->disconnect(mSendDialog); |
161 |
163 |
|
164 mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) ); |
|
165 mCancelAction->disconnect(mSendDialog); |
|
166 |
|
167 connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked())); |
|
168 |
162 return true; |
169 return true; |
163 } |
170 } |
164 |
171 |
165 void BTSendDialogWidget::hideEvent(QHideEvent *event) |
172 /*void BTSendDialogWidget::hideEvent(QHideEvent *event) |
166 { |
173 { |
167 HbDialog::hideEvent(event); |
174 HbDialog::hideEvent(event); |
168 emit deviceDialogClosed(); |
175 emit deviceDialogClosed(); |
169 } |
176 } |
170 |
177 |
171 void BTSendDialogWidget::showEvent(QShowEvent *event) |
178 void BTSendDialogWidget::showEvent(QShowEvent *event) |
172 { |
179 { |
173 HbDialog::showEvent(event); |
180 HbDialog::showEvent(event); |
174 } |
181 }*/ |
175 |
182 |
176 /*void BTSendDialogWidget::hideClicked() |
183 /*void BTSendDialogWidget::hideClicked() |
177 { |
184 { |
178 // TODO |
185 // TODO |
179 this->close(); |
186 this->close(); |
180 emit deviceDialogClosed(); |
187 emit deviceDialogClosed(); |
181 } |
188 }*/ |
182 |
189 |
183 void BTSendDialogWidget::cancelClicked() |
190 void BTSendDialogWidget::cancelClicked() |
184 { |
191 { |
185 // TODO |
192 mSendDialog->close(); |
186 this->close(); |
193 emit deviceDialogClosed(); |
187 emit deviceDialogClosed(); |
194 } |
188 }*/ |
195 |
189 |
196 /*void BTSendDialogWidget::inputClosed(HbAction* action) |
190 void BTSendDialogWidget::inputClosed(HbAction* action) |
|
191 { |
197 { |
192 QVariantMap data; |
198 QVariantMap data; |
193 |
199 |
194 HbDialog *dlg=static_cast<HbDialog*>(sender()); |
200 HbDialog *dlg=static_cast<HbDialog*>(sender()); |
195 if(dlg->actions().first() == action) { |
201 if(dlg->actions().first() == action) { |
196 } |
202 } |
197 else if(dlg->actions().at(1) == action) { |
203 else if(dlg->actions().at(1) == action) { |
198 } |
204 } |
199 } |
205 }*/ |
200 |
206 |