author | hgs |
Thu, 17 Jun 2010 15:34:52 +0300 | |
changeset 30 | d8e625c87f33 |
parent 29 | 1c71b77fbc93 |
child 31 | e7a04a6385be |
permissions | -rw-r--r-- |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <hbmessagebox.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <hblabel.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <hbaction.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <hbpopup.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <hblineedit.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include <hbvalidator.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include <hbabstractitemview.h> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include <hbprogressdialog.h> |
27 | 27 |
#include <hbdatetimepicker.h> |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include <QString> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include <QDate> |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include <QRegExp> |
27 | 32 |
#include <QList> |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
#include "notifications.h" |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
|
25 | 36 |
// --------------------------------------------------------------------------- |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
|
25 | 38 |
void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ) |
39 |
{ |
|
40 |
HbMessageBox *messageBox = new HbMessageBox(type); |
|
41 |
messageBox->setText(text); |
|
42 |
if(label.length()) |
|
43 |
{ |
|
44 |
HbLabel *header = new HbLabel(label, messageBox); |
|
45 |
messageBox->setHeadingWidget(header); |
|
46 |
} |
|
47 |
messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
48 |
messageBox->setTimeout(timeout); |
|
49 |
messageBox->open(); |
|
50 |
} |
|
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
// --------------------------------------------------------------------------- |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
void Notifications::about() |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
{ |
25 | 56 |
showMessageBox(HbMessageBox::MessageTypeInformation, |
29 | 57 |
"Version 6.0.1 - June 4th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", |
25 | 58 |
"About Creator", |
59 |
HbPopup::NoTimeout |
|
60 |
); |
|
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
} |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
// --------------------------------------------------------------------------- |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
void Notifications::error(const QString& errorMessage) |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
{ |
25 | 67 |
showMessageBox(HbMessageBox::MessageTypeWarning, errorMessage, QString("Error"), 3000); |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
} |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
// --------------------------------------------------------------------------- |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
HbProgressDialog* Notifications::showProgressBar(const QString& text, int max) |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
{ |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::ProgressDialog); |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
note->setText(text); |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
note->setMaximum(max); |
28 | 78 |
note->setAutoClose(false); |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
note->show(); |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
return note; |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
} |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
// --------------------------------------------------------------------------- |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
|
25 | 86 |
void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout timeout) |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
{ |
25 | 88 |
showMessageBox(type, text, QString("Creator"), timeout); |
17
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
} |
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
4f2773374eff
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
// --------------------------------------------------------------------------- |
27 | 93 |
|
94 |
CreatorYesNoDialog::CreatorYesNoDialog(MUIObserver* observer, int userData) : |
|
95 |
HbMessageBox(HbMessageBox::MessageTypeQuestion, NULL), |
|
96 |
CreatorDialog(observer, userData) |
|
97 |
{ |
|
98 |
} |
|
99 |
||
100 |
void CreatorYesNoDialog::launch(const QString& text, const QString& label, MUIObserver* observer, int userData) throw(std::exception) |
|
101 |
{ |
|
102 |
CreatorYesNoDialog* dlg = new CreatorYesNoDialog(observer, userData); |
|
103 |
dlg->setText(text); |
|
104 |
if(label.length()) |
|
105 |
dlg->setHeadingWidget(new HbLabel(label, dlg)); |
|
106 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
107 |
dlg->setTimeout(HbPopup::NoTimeout); |
|
108 |
dlg->open(dlg, SLOT(DialogClosed(HbAction*))); |
|
109 |
} |
|
110 |
||
111 |
void CreatorYesNoDialog::DialogClosed(HbAction *action) |
|
112 |
{ |
|
113 |
TBool PositiveAction(EFalse); |
|
114 |
if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("yes", Qt::CaseInsensitive))){ |
|
115 |
PositiveAction = ETrue; |
|
116 |
} |
|
117 |
NotifyObserver(PositiveAction); |
|
118 |
} |
|
119 |
||
120 |
CreatorInputDialog::CreatorInputDialog(int* value, MUIObserver* module, int userData) : |
|
121 |
HbInputDialog(NULL), |
|
122 |
CreatorDialog(module, userData), |
|
28 | 123 |
mIntValue(value), |
124 |
mStrValue(mDummy)// will not be used |
|
27 | 125 |
{ |
126 |
if(!value) |
|
127 |
throw std::invalid_argument("value cannot be the null!"); |
|
128 |
} |
|
129 |
||
28 | 130 |
CreatorInputDialog::CreatorInputDialog(TDes& value, MUIObserver* module, int userData) : |
131 |
HbInputDialog(NULL), |
|
132 |
CreatorDialog(module, userData), |
|
133 |
mIntValue(NULL), |
|
134 |
mStrValue(value) |
|
135 |
{ |
|
136 |
} |
|
137 |
||
27 | 138 |
void CreatorInputDialog::launch(const QString& label, int* value, bool acceptsZero, MUIObserver* observer, int userData) throw( std::exception ) |
139 |
{ |
|
140 |
CreatorInputDialog* dlg = new CreatorInputDialog(value, observer, userData); |
|
141 |
dlg->setPromptText(label); |
|
142 |
dlg->setInputMode(IntInput); |
|
143 |
HbValidator *validator = new HbValidator(dlg); |
|
144 |
QString tmp; |
|
145 |
if (acceptsZero == false) { |
|
146 |
tmp.append("[1-9]{1}\\d{1,4}"); |
|
147 |
} |
|
148 |
else { |
|
149 |
tmp.append("^[0-9]{5}"); |
|
150 |
} |
|
151 |
||
152 |
QRegExp rxBasic(tmp); |
|
153 |
validator->addField(new QRegExpValidator(rxBasic, 0), ""); |
|
154 |
dlg->setValidator(validator); |
|
155 |
dlg->setValue(QVariant(*value)); |
|
156 |
dlg->lineEdit()->setSelection(0, dlg->value().toString().length()); |
|
157 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
158 |
dlg->open(dlg, SLOT(DialogClosed(HbAction*))); |
|
159 |
} |
|
160 |
||
28 | 161 |
void CreatorInputDialog::launch(const QString& label, TDes& value, MUIObserver* observer, int userData) throw( std::exception ) |
162 |
{ |
|
163 |
CreatorInputDialog* dlg = new CreatorInputDialog(value, observer, userData); |
|
164 |
dlg->setPromptText(label); |
|
165 |
dlg->lineEdit()->setMaxLength(value.MaxLength()); |
|
166 |
dlg->setValue(QString::fromUtf16(value.Ptr(), value.Length())); |
|
167 |
dlg->lineEdit()->setSelection(0, dlg->value().toString().length()); |
|
168 |
dlg->setInputMode(TextInput); |
|
169 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
170 |
dlg->open(dlg, SLOT(DialogClosed(HbAction*))); |
|
171 |
} |
|
172 |
||
27 | 173 |
void CreatorInputDialog::DialogClosed(HbAction *action) |
174 |
{ |
|
175 |
TBool PositiveAction(EFalse); |
|
176 |
if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("ok", Qt::CaseInsensitive))){ |
|
28 | 177 |
bool ok = true; |
178 |
if( inputMode() == IntInput ) |
|
179 |
*mIntValue = value().toInt(&ok); |
|
180 |
else if( inputMode() == TextInput && mStrValue.MaxLength() >= value().toString().length() ) |
|
181 |
mStrValue.Copy(value().toString().utf16()); |
|
182 |
else |
|
183 |
ok = false; |
|
27 | 184 |
PositiveAction = ok ? ETrue : EFalse; |
185 |
} |
|
186 |
NotifyObserver(PositiveAction); |
|
187 |
} |
|
188 |
||
189 |
CreatorSelectionDialog::CreatorSelectionDialog(int* selectedItem, MUIObserver* observer, int userData) throw(std::exception) : |
|
190 |
HbSelectionDialog(NULL), |
|
191 |
CreatorDialog(observer, userData), |
|
192 |
mSelectedItem(selectedItem), |
|
193 |
mSelectedItems(NULL) |
|
194 |
{ |
|
195 |
if(!mSelectedItem) |
|
196 |
throw std::invalid_argument("selectedItem cannot be null!"); |
|
197 |
} |
|
198 |
||
199 |
CreatorSelectionDialog::CreatorSelectionDialog(CArrayFixFlat<TInt>* selectedItems, MUIObserver* observer, int userData) throw(std::exception) : |
|
200 |
HbSelectionDialog(NULL), |
|
201 |
CreatorDialog(observer, userData), |
|
202 |
mSelectedItem(NULL), |
|
203 |
mSelectedItems(selectedItems) |
|
204 |
{ |
|
205 |
if(!mSelectedItems) |
|
206 |
throw std::invalid_argument("selectedItems cannot be null!"); |
|
207 |
} |
|
208 |
||
209 |
void CreatorSelectionDialog::launch(const QString& label, const QStringList& items, int* selectedItem, MUIObserver* observer, int userData) throw(std::exception) |
|
210 |
{ |
|
211 |
CreatorSelectionDialog* dlg = new CreatorSelectionDialog(selectedItem, observer, userData); |
|
212 |
if(label.length()) |
|
213 |
dlg->setHeadingWidget(new HbLabel(label, dlg)); |
|
214 |
dlg->setStringItems(items); |
|
215 |
dlg->setSelectionMode(HbAbstractItemView::SingleSelection); |
|
216 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
217 |
dlg->open(dlg, SLOT(DialogClosed(HbAction*))); |
|
218 |
} |
|
219 |
||
220 |
void CreatorSelectionDialog::launch(const QString& label, const QStringList& items, CArrayFixFlat<TInt>* selectedItems, MUIObserver* observer, int userData) throw(std::exception) |
|
221 |
{ |
|
222 |
CreatorSelectionDialog* dlg = new CreatorSelectionDialog(selectedItems, observer, userData); |
|
223 |
if(label.length()) |
|
224 |
dlg->setHeadingWidget(new HbLabel(label, dlg)); |
|
225 |
dlg->setStringItems(items); |
|
226 |
dlg->setSelectionMode(HbAbstractItemView::MultiSelection); |
|
227 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
228 |
dlg->open(dlg, SLOT(DialogClosed(HbAction*))); |
|
229 |
} |
|
230 |
||
231 |
void CreatorSelectionDialog::DialogClosed(HbAction *action) |
|
232 |
{ |
|
233 |
TBool PositiveAction(EFalse); |
|
234 |
//CreatorSelectionDialog* dlg = qobject_cast<CreatorSelectionDialog*>(sender()); |
|
235 |
if(!action || (action && action->softKeyRole()==QAction::SelectSoftKey) || (action && !action->text().compare("ok", Qt::CaseInsensitive))){ |
|
236 |
if(selectedItems().count()){ |
|
237 |
try{ |
|
238 |
if( selectionMode() == HbAbstractItemView::SingleSelection && mSelectedItem){ |
|
239 |
bool ok(false); |
|
240 |
*mSelectedItem = selectedItems().at(0).toInt(&ok); |
|
241 |
if(!ok) |
|
242 |
throw std::invalid_argument("cannot obtain selected item!"); |
|
243 |
} |
|
244 |
if( selectionMode() == HbAbstractItemView::MultiSelection && mSelectedItems){ |
|
245 |
QList<QVariant> items = selectedItems(); |
|
246 |
foreach( QVariant item, items){ |
|
247 |
QT_TRAP_THROWING( mSelectedItems->AppendL( item.toInt() ) ); |
|
248 |
} |
|
249 |
} |
|
250 |
PositiveAction = ETrue; |
|
251 |
} |
|
252 |
catch (std::exception& e){ |
|
253 |
Notifications::error( QString("exception: ")+e.what() ); |
|
254 |
} |
|
255 |
} |
|
256 |
} |
|
257 |
NotifyObserver(PositiveAction); |
|
258 |
} |
|
259 |
||
260 |
CreatorDateTimeDialog::CreatorDateTimeDialog(TTime* value, MUIObserver* observer, int userData) : |
|
261 |
HbDialog(NULL), |
|
262 |
CreatorDialog(observer, userData), |
|
263 |
mValue(value) |
|
264 |
{ |
|
265 |
} |
|
266 |
||
267 |
void CreatorDateTimeDialog::launch(const QString& label, TTime* value, MUIObserver* observer, int userData) throw( std::exception ) |
|
268 |
{ |
|
269 |
CreatorDateTimeDialog* dlg = new CreatorDateTimeDialog(value, observer, userData); |
|
270 |
if(!value) |
|
271 |
throw std::invalid_argument("value cannot be the null!"); |
|
272 |
if(label.length()) |
|
273 |
dlg->setHeadingWidget( new HbLabel(label, dlg) ); |
|
274 |
||
275 |
// TTime to QDate |
|
276 |
TBuf<20> timeString; |
|
277 |
_LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); |
|
278 |
TRAP_IGNORE( value->FormatL(timeString, KDateString) ); |
|
279 |
QString temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); |
|
280 |
temp.replace(QChar('/'), QChar('-')); |
|
281 |
QDate date = QDate::fromString(temp, "dd-MM-yyyy"); |
|
282 |
HbDateTimePicker* widget = new HbDateTimePicker( date, dlg ); |
|
283 |
dlg->setContentWidget( widget ); |
|
284 |
dlg->addAction(new HbAction("Ok", dlg)); |
|
285 |
dlg->addAction(new HbAction("Cancel", dlg)); |
|
286 |
dlg->setModal(true); // Dialog is modal |
|
287 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
288 |
dlg->setTimeout(HbPopup::NoTimeout); |
|
289 |
dlg->open(dlg, SLOT(DialogClosed(HbAction*))); |
|
290 |
} |
|
291 |
||
292 |
void CreatorDateTimeDialog::DialogClosed(HbAction *action) |
|
293 |
{ |
|
294 |
TBool PositiveAction(EFalse); |
|
295 |
if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("ok", Qt::CaseInsensitive))){ |
|
296 |
QString str = qobject_cast<HbDateTimePicker*>(contentWidget())->date().toString(Qt::ISODate); |
|
297 |
str.remove('-'); |
|
298 |
str += ":000000";// 0h 0m 0s |
|
299 |
TBuf<30> dateTimeString(str.utf16()); |
|
300 |
mValue->Set(dateTimeString); |
|
301 |
PositiveAction = ETrue; |
|
302 |
} |
|
303 |
NotifyObserver(PositiveAction); |
|
304 |
} |
|
305 |
//End of File |