32 #include <HbAbstractItemView> |
32 #include <HbAbstractItemView> |
33 #include <QGraphicsLinearLayout> |
33 #include <QGraphicsLinearLayout> |
34 #include <QDate> |
34 #include <QDate> |
35 #include <QTime> |
35 #include <QTime> |
36 |
36 |
|
37 //LI related headers |
|
38 #include "qlocationpickeritem.h" |
|
39 #include <xqaiwrequest.h> |
|
40 #include <xqappmgr.h> |
|
41 |
37 // User includes |
42 // User includes |
38 #include "caleneditorcustomitem.h" |
43 #include "caleneditorcustomitem.h" |
39 #include "calendateutils.h" |
44 #include "calendateutils.h" |
40 #include "caleneditorcommon.h" |
45 #include "caleneditorcommon.h" |
|
46 #include "caleneditordocloader.h" |
41 |
47 |
42 /*! |
48 /*! |
43 \class CalenEditorCustomItem |
49 \class CalenEditorCustomItem |
44 This object creats the custom item for the calendar editor dataform. |
50 This object creats the custom item for the calendar editor dataform. |
45 */ |
51 */ |
54 mMinDate = CalenDateUtils::minTime().date(); |
60 mMinDate = CalenDateUtils::minTime().date(); |
55 mMaxDate = CalenDateUtils::maxTime().date(); |
61 mMaxDate = CalenDateUtils::maxTime().date(); |
56 mMinTime.setHMS(0,0,0,0); |
62 mMinTime.setHMS(0,0,0,0); |
57 mMaxTime.setHMS(23,59,59,999); |
63 mMaxTime.setHMS(23,59,59,999); |
58 mLocale = HbExtendedLocale::system(); |
64 mLocale = HbExtendedLocale::system(); |
|
65 mLocationLineEdit = NULL; |
|
66 mLocationPushButton = NULL; |
59 } |
67 } |
60 /*! |
68 /*! |
61 Destructor. |
69 Destructor. |
62 */ |
70 */ |
63 CalenEditorCustomItem::~CalenEditorCustomItem() |
71 CalenEditorCustomItem::~CalenEditorCustomItem() |
117 connect(mPushButtonDate, SIGNAL(clicked()), |
125 connect(mPushButtonDate, SIGNAL(clicked()), |
118 this, SLOT(handleDate())); |
126 this, SLOT(handleDate())); |
119 layoutBottom->addItem(mPushButtonDate); |
127 layoutBottom->addItem(mPushButtonDate); |
120 return widgetBottom; |
128 return widgetBottom; |
121 } |
129 } |
|
130 |
|
131 case CustomWidgetLocation: |
|
132 { |
|
133 CalenEditorDocLoader editorLocationDocLoader; |
|
134 bool loadSuccess = false; |
|
135 |
|
136 editorLocationDocLoader.load(CALEN_EDITOR_LOCATION_XML_FILE, &loadSuccess); |
|
137 Q_ASSERT_X(loadSuccess, "caleneditor.cpp", |
|
138 "Unable to load caleneditor location view XML"); |
|
139 HbWidget* widgetLocation = qobject_cast<HbWidget *> (editorLocationDocLoader.findWidget(CALEN_EDITOR_LOCATION)); |
|
140 |
|
141 mLocationLineEdit = qobject_cast<HbLineEdit *>( editorLocationDocLoader.findWidget(CALEN_EDITOR_LOCATION_LINEEDIT)); |
|
142 mLocationLineEdit->setMinRows(1); |
|
143 mLocationLineEdit->setMaxRows(4); |
|
144 mLocationPushButton = qobject_cast<HbPushButton*>(editorLocationDocLoader.findWidget(CALEN_EDITOR_LOCATION_PUSHBUTTON)); |
|
145 mLocationPushButton->setIcon( HbIcon("qtg_mono_location")); |
|
146 |
|
147 connect(mLocationPushButton, SIGNAL(clicked()), this, SLOT(launchLocationPicker())); |
|
148 connect(mLocationLineEdit, SIGNAL(textChanged(const QString)), |
|
149 this, SLOT(handleLocationTextChange(const QString))); |
|
150 return widgetLocation; |
|
151 } |
122 |
152 |
123 case RepeatUntilOffset: |
153 case RepeatUntilOffset: |
124 { |
154 { |
125 mRepeatUntilWidget = new HbPushButton(this); |
155 mRepeatUntilWidget = new HbPushButton(this); |
126 return mRepeatUntilWidget; |
156 return mRepeatUntilWidget; |
129 |
159 |
130 default: |
160 default: |
131 return 0; |
161 return 0; |
132 } |
162 } |
133 } |
163 } |
134 |
164 /*! |
|
165 launch the location picker application using QT highway with the required service |
|
166 */ |
|
167 |
|
168 void CalenEditorCustomItem::launchLocationPicker() |
|
169 { |
|
170 XQApplicationManager *appManager = new XQApplicationManager(); |
|
171 |
|
172 XQAiwRequest *request = appManager->create("com.nokia.symbian", "ILocationPick", "pick()", true); |
|
173 if( request ) |
|
174 { |
|
175 QVariant retValue; |
|
176 if( request->send( retValue ) ) |
|
177 { |
|
178 setSelectedLocation(retValue); |
|
179 } |
|
180 } |
|
181 } |
|
182 /*! |
|
183 set the selected location from the picker to the line edit widget |
|
184 and notify the other observers. |
|
185 */ |
|
186 void CalenEditorCustomItem::setSelectedLocation( QVariant &aValue ) |
|
187 { |
|
188 QLocationPickerItem selectedLocation = aValue.value<QLocationPickerItem>(); |
|
189 if( selectedLocation.mIsValid ) |
|
190 { |
|
191 QString locationString; |
|
192 if( selectedLocation.mStreet.size() ) |
|
193 { |
|
194 locationString.append(selectedLocation.mStreet); |
|
195 locationString.append(','); |
|
196 } |
|
197 if( selectedLocation.mCity.size() ) |
|
198 { |
|
199 locationString.append(selectedLocation.mCity); |
|
200 locationString.append(','); |
|
201 } |
|
202 locationString.append(selectedLocation.mCountry); |
|
203 emit locationTextChanged(locationString); |
|
204 mLocationLineEdit->setText(locationString ); |
|
205 } |
|
206 } |
135 void CalenEditorCustomItem::populateDateTime(QDateTime defaultDateTime, bool isFromItem) |
207 void CalenEditorCustomItem::populateDateTime(QDateTime defaultDateTime, bool isFromItem) |
136 { |
208 { |
137 // Store the date and time to be shown |
209 // Store the date and time to be shown |
138 mDate = defaultDateTime.date(); |
210 mDate = defaultDateTime.date(); |
139 mTime = defaultDateTime.time(); |
211 mTime = defaultDateTime.time(); |
142 |
214 |
143 mPushButtonDate->setText(mLocale.format(defaultDateTime.date(), |
215 mPushButtonDate->setText(mLocale.format(defaultDateTime.date(), |
144 r_qtn_date_usual_with_zero)); |
216 r_qtn_date_usual_with_zero)); |
145 mPushButtonTime->setText(mLocale.format(defaultDateTime.time(), |
217 mPushButtonTime->setText(mLocale.format(defaultDateTime.time(), |
146 r_qtn_time_usual_with_zero)); |
218 r_qtn_time_usual_with_zero)); |
|
219 } |
|
220 |
|
221 void CalenEditorCustomItem::populateLocation(QString location ) |
|
222 { |
|
223 mLocationLineEdit->setText( location ); |
|
224 |
147 } |
225 } |
148 |
226 |
149 void CalenEditorCustomItem::setDateRange(QDate start, QDate end) |
227 void CalenEditorCustomItem::setDateRange(QDate start, QDate end) |
150 { |
228 { |
151 mMaxDate = end; |
229 mMaxDate = end; |
235 */ |
319 */ |
236 void CalenEditorCustomItem::saveDate() |
320 void CalenEditorCustomItem::saveDate() |
237 { |
321 { |
238 mDate = mDatePicker->date(); |
322 mDate = mDatePicker->date(); |
239 if (mDate.isValid()) { |
323 if (mDate.isValid()) { |
240 mDateTime.setDate(mDate); |
|
241 mDateTime.setTime(mTime); |
|
242 mPushButtonDate->setText(mLocale.format(mDate, |
324 mPushButtonDate->setText(mLocale.format(mDate, |
243 r_qtn_date_usual_with_zero)); |
325 r_qtn_date_usual_with_zero)); |
244 emit dateTimeUpdated(mDateTime); |
326 QDateTime dateTime(mDate,mTime); |
|
327 emit dateTimeUpdated(dateTime); |
245 } |
328 } |
246 } |
329 } |
247 |
330 |
248 /*! |
331 /*! |
249 Save the start time of the event. |
332 Save the start time of the event. |
250 */ |
333 */ |
251 void CalenEditorCustomItem::saveTime() |
334 void CalenEditorCustomItem::saveTime() |
252 { |
335 { |
253 mTime = mTimePicker->time(); |
336 mTime = mTimePicker->time(); |
254 if (mTime.isValid()) { |
337 if (mTime.isValid()) { |
255 mDateTime.setTime(mTime); |
|
256 mPushButtonTime->setText(mLocale.format(mTime, |
338 mPushButtonTime->setText(mLocale.format(mTime, |
257 r_qtn_time_usual_with_zero)); |
339 r_qtn_time_usual_with_zero)); |
258 |
340 |
259 mDateTime.setDate(mDate); |
341 QDateTime dateTime(mDate,mTime); |
260 emit dateTimeUpdated(mDateTime); |
342 emit dateTimeUpdated(dateTime); |
261 } |
343 } |
262 } |
344 } |
263 |
345 |
264 /*! |
346 /*! |
265 Enable/Desable FromTime filed and update time value |
347 Enable/Desable FromTime filed and update time value |
292 { |
374 { |
293 HbDataFormModelItem::DataItemType itemType = |
375 HbDataFormModelItem::DataItemType itemType = |
294 static_cast<HbDataFormModelItem::DataItemType>( |
376 static_cast<HbDataFormModelItem::DataItemType>( |
295 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
377 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
296 |
378 |
297 if(itemType == CustomWidgetFrom || itemType == CustomWidgetTo || itemType == RepeatUntilOffset) { |
379 if(itemType == CustomWidgetFrom || itemType == CustomWidgetTo || itemType == RepeatUntilOffset |
|
380 || itemType == CustomWidgetLocation ) { |
298 return true; |
381 return true; |
299 } else { |
382 } else { |
300 return false; |
383 return false; |
301 } |
384 } |
302 } |
385 } |