|
1 /* |
|
2 * ==================================================== |
|
3 * Name : viewfutedataform.cpp |
|
4 * Part of : fute/listdemo |
|
5 * Description : Settings for listdemo, treedemo, griddemo |
|
6 * Version : %version: 1 % |
|
7 * |
|
8 * Copyright (c) 2009 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ==================================================== |
|
17 */ |
|
18 |
|
19 #include "viewfutedataform.h" |
|
20 #include <hbdataformmodel.h> |
|
21 #include <hbabstractviewitem.h> |
|
22 #include <hblistviewitem.h> |
|
23 #include <hblistview.h> |
|
24 #include <hbtreeview.h> |
|
25 #include <hbgridview.h> |
|
26 #include <hbscrollbar.h> |
|
27 #include <hbframebackground.h> |
|
28 #include <hbaction.h> |
|
29 #include <hbmenu.h> |
|
30 #include <hblineedit.h> |
|
31 #include <hbinputeditorinterface.h> |
|
32 #include <hblistwidgetitem.h> |
|
33 #include <hbabstractitemview.h> |
|
34 #include <hbindexfeedback.h> |
|
35 |
|
36 #include <QStandardItem> |
|
37 #include <QGraphicsScene> |
|
38 #include <QAbstractItemView> |
|
39 |
|
40 Q_DECLARE_METATYPE(QList<int>) |
|
41 |
|
42 // Settings |
|
43 const QStringList TextStyles = (QStringList() << "Primary" << "Secondary"); |
|
44 const QStringList CustomWidgets = (QStringList() << "Empty" << "Zoom slider" << "Volume Slider" << "Progress bar" << "Button" << "Text Editor" ); |
|
45 const QStringList OnOff = (QStringList() << "On" << "Off"); |
|
46 const QStringList LaunchInPopups = (QStringList() << "Launch into popup" << "Launch into view") ; |
|
47 const QStringList SelectionModes = (QStringList() << "Single selection" << "Multiple selection" << "No selection"); |
|
48 const QStringList ScrollModes = (QStringList() << "Pan" << "Pan with follow on"); |
|
49 const QStringList GraphicsSizes = (QStringList() << "Small icon" << "Medium icon" << "Large icon" << "Thumbnail" << "Wide thumbnail"); |
|
50 const QStringList LandscapeModes = (QStringList() << "Normal" << "Stretched"); |
|
51 const QStringList OrientationTypes = (QStringList() << "Portrait" << "Landscape"); |
|
52 const QStringList ScrollHints = (QStringList() << "Just visible" << "At top" << "At bottom" << "At center" ); |
|
53 const QStringList IndexFeedbackPolicies = (QStringList() << "None" << "One Char" << "Three Char" << "String" << "detatch" ); |
|
54 const QStringList IconLoadPolicies = (QStringList() << "Synchronous" << "Asynchronous when scrolling" << "Asynchronous" ); |
|
55 |
|
56 // Add item |
|
57 const QStringList LeftColumnWidgets = (QStringList() << "Empty" << "Icon"); |
|
58 const QStringList RightColumnWidgets = (QStringList() << "Empty" << "Icon"); |
|
59 const QStringList ItemBackgrounds = (QStringList() << "None" << "Red" << "Green" << "Blue" << "Bitmap" << "Frame"); |
|
60 const QStringList ItemTypes = (QStringList() << "Normal" << "Separator"); |
|
61 const QStringList AnimationList = (QStringList() << "Appear" << "Disappear" << "TouchDown"); |
|
62 |
|
63 const QStringList KConvenienceIcons = (QStringList() |
|
64 << ":/demo/list1" |
|
65 ); |
|
66 |
|
67 ViewFuteDataForm::ViewFuteDataForm( HbAbstractItemView &view, |
|
68 QGraphicsItem *parent): |
|
69 HbDataForm(parent), |
|
70 activity(None), |
|
71 view(&view), |
|
72 item(0), |
|
73 mIndexFeedback(0) |
|
74 { |
|
75 settingsFormModel = new HbDataFormModel(); |
|
76 initialise(); |
|
77 } |
|
78 |
|
79 ViewFuteDataForm::~ViewFuteDataForm() |
|
80 { |
|
81 delete settingsFormModel; |
|
82 } |
|
83 |
|
84 void ViewFuteDataForm::populateSettings() |
|
85 { |
|
86 activity = Settings; |
|
87 settingsFormModel->clear(); |
|
88 |
|
89 counter += populateCustomSettingsItem(-1); |
|
90 |
|
91 //populateLaunchInPopup(); |
|
92 //counter += populateCustomSettingsItem(LaunchInPopup); |
|
93 |
|
94 populateSelectionMode(); |
|
95 counter += populateCustomSettingsItem(SelectionMode); |
|
96 |
|
97 populateScrollHint(); |
|
98 counter += populateCustomSettingsItem(ScrollHint); |
|
99 |
|
100 populateRecycling(); |
|
101 counter += populateCustomSettingsItem(Recycling); |
|
102 |
|
103 populateArrangeMode(); |
|
104 counter += populateCustomSettingsItem(ArrangeMode); |
|
105 |
|
106 populateUniformItem(); |
|
107 counter += populateCustomSettingsItem(UniformItem); |
|
108 |
|
109 populateFrame(); |
|
110 counter += populateCustomSettingsItem(Frame); |
|
111 |
|
112 populateRichText(); |
|
113 counter += populateCustomSettingsItem(RichText); |
|
114 |
|
115 populateScrollingStyle(); |
|
116 counter += populateCustomSettingsItem(ScrollingStyle); |
|
117 |
|
118 populateInteractiveScrollBar(); |
|
119 counter += populateCustomSettingsItem(InteractiveScrollBar); |
|
120 |
|
121 populateClampingStyle(); |
|
122 counter += populateCustomSettingsItem(ClampingStyle); |
|
123 |
|
124 populateFrictionEnabled(); |
|
125 counter += populateCustomSettingsItem(FrictionEnabled); |
|
126 |
|
127 populateGraphicsSize(); |
|
128 counter += populateCustomSettingsItem(GraphicsSize); |
|
129 |
|
130 populateStretchingStyle(); |
|
131 counter += populateCustomSettingsItem(StretchingStyle); |
|
132 |
|
133 populateMaximumRowCount(); |
|
134 counter += populateCustomSettingsItem(MaximumRowCount); |
|
135 |
|
136 populateMinimumRowCount(); |
|
137 counter += populateCustomSettingsItem(MinimumRowCount); |
|
138 |
|
139 //populateMirroring(); |
|
140 //counter += populateCustomSettingsItem(Mirroring); |
|
141 |
|
142 populateIndexFeedbackPolicy(); |
|
143 counter += populateCustomSettingsItem(IndexFeedbackPolicy); |
|
144 /* |
|
145 populateEnabledAnimations(); |
|
146 counter += populateCustomSettingsItem(Animations); |
|
147 */ |
|
148 populatePixmapCacheEnabled(); |
|
149 counter += populateCustomSettingsItem(PixmapCache); |
|
150 |
|
151 populateIconLoadPolicy(); |
|
152 counter += populateCustomSettingsItem(IconLoadPolicy); |
|
153 |
|
154 setModel(settingsFormModel); |
|
155 } |
|
156 |
|
157 void ViewFuteDataForm::setInputData( Activity action, |
|
158 int item, |
|
159 QVariant data) |
|
160 { |
|
161 if ( item < 0 |
|
162 || action == None |
|
163 || ( ( action == Settings |
|
164 && item >= SettingsIndexLast) |
|
165 || ( action == AddItem |
|
166 && item >= AddItemIndexLast))) { |
|
167 return; |
|
168 } |
|
169 |
|
170 if (action == Settings) { |
|
171 settingsData[item] = data; |
|
172 data.isValid(); |
|
173 } |
|
174 else if (action == AddItem) { |
|
175 addItemData[item] = data; |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 int ViewFuteDataForm::populateCustomSettingsItem(int previousItem) |
|
181 { |
|
182 Q_UNUSED(previousItem); |
|
183 return 0; |
|
184 } |
|
185 |
|
186 void ViewFuteDataForm::initialise() |
|
187 { |
|
188 settingsFormModel->clear(); |
|
189 counter=0; |
|
190 for (int i=0; i< SettingsIndexLast; i++) { |
|
191 settingsIndexes[i] = -1; |
|
192 } |
|
193 for (int i=0; i< AddItemIndexLast; i++) { |
|
194 addItemIndexes[i] = -1; |
|
195 } |
|
196 for (int i=0; i< SettingsIndexLast; i++) { |
|
197 settingsData[i] = QVariant(); |
|
198 } |
|
199 for (int i=0; i< AddItemIndexLast; i++) { |
|
200 addItemData[i] = QVariant(); |
|
201 } |
|
202 } |
|
203 |
|
204 int ViewFuteDataForm::nextIndex() const |
|
205 { |
|
206 return counter; |
|
207 } |
|
208 |
|
209 ViewFuteDataForm::Activity ViewFuteDataForm::action() const |
|
210 { |
|
211 return activity; |
|
212 } |
|
213 |
|
214 |
|
215 HbDataFormModel *ViewFuteDataForm::dataModel() const |
|
216 { |
|
217 return settingsFormModel; |
|
218 } |
|
219 |
|
220 void ViewFuteDataForm::populateGraphicsSize() |
|
221 { |
|
222 HbListViewItem *prototype = qobject_cast<HbListViewItem *>(view->itemPrototypes().first()); |
|
223 if ( prototype ) { |
|
224 settingsIndexes[GraphicsSize] = counter++; |
|
225 |
|
226 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, |
|
227 QString("Graphics size:")); |
|
228 |
|
229 item->setContentWidgetData("items", GraphicsSizes); |
|
230 |
|
231 HbListViewItem::GraphicsSize graphicsSize = prototype->graphicsSize(); |
|
232 if (graphicsSize == HbListViewItem::SmallIcon) { |
|
233 item->setContentWidgetData("selected", 0); |
|
234 } else if (graphicsSize == HbListViewItem::MediumIcon) { |
|
235 item->setContentWidgetData("selected", 1); |
|
236 } else if (graphicsSize == HbListViewItem::LargeIcon) { |
|
237 item->setContentWidgetData("selected", 2); |
|
238 } else if (graphicsSize == HbListViewItem::Thumbnail) { |
|
239 item->setContentWidgetData("selected", 3); |
|
240 } else { |
|
241 item->setContentWidgetData("selected", 4); |
|
242 } |
|
243 } |
|
244 } |
|
245 |
|
246 void ViewFuteDataForm::populateStretchingStyle() |
|
247 { |
|
248 HbListViewItem *prototype = qobject_cast<HbListViewItem *>(view->itemPrototypes().first()); |
|
249 if ( prototype ) { |
|
250 settingsIndexes[StretchingStyle] = counter++; |
|
251 |
|
252 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, |
|
253 QString("Landscape mode:")); |
|
254 |
|
255 item->setContentWidgetData("items", LandscapeModes); |
|
256 if (prototype->stretchingStyle() == HbListViewItem::StretchLandscape) { |
|
257 item->setContentWidgetData("selected", 1); |
|
258 } else { |
|
259 item->setContentWidgetData("selected", 0); |
|
260 } |
|
261 } |
|
262 } |
|
263 |
|
264 void ViewFuteDataForm::populateMaximumRowCount() |
|
265 { |
|
266 HbListViewItem *prototype = qobject_cast<HbListViewItem *>(view->itemPrototypes().first()); |
|
267 if ( prototype ) { |
|
268 settingsIndexes[MaximumRowCount] = counter++; |
|
269 |
|
270 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem(HbDataFormModelItem::SliderItem, |
|
271 QString("Max secondary text rows:")); |
|
272 |
|
273 int maximum = 0; |
|
274 int minimum = 0; |
|
275 prototype->getSecondaryTextRowCount(minimum, maximum); |
|
276 |
|
277 item->setContentWidgetData("value", maximum); |
|
278 item->setContentWidgetData("maximum", 10); |
|
279 item->setContentWidgetData("minimum", 1); |
|
280 item->setContentWidgetData("tickPosition", Hb::SliderTicksBelow); |
|
281 item->setContentWidgetData("majorTickInterval",1); |
|
282 |
|
283 // does not work |
|
284 /*QStringList values; |
|
285 values << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10"; |
|
286 item->setContentWidgetData("majorTickLabels",values);*/ |
|
287 } |
|
288 } |
|
289 |
|
290 void ViewFuteDataForm::populateMinimumRowCount() |
|
291 { |
|
292 HbListViewItem *prototype = qobject_cast<HbListViewItem *>(view->itemPrototypes().first()); |
|
293 if ( prototype ) { |
|
294 settingsIndexes[MinimumRowCount] = counter++; |
|
295 |
|
296 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem(HbDataFormModelItem::SliderItem, |
|
297 QString("Min secondary text rows:")); |
|
298 |
|
299 int maximum = 0; |
|
300 int minimum = 0; |
|
301 prototype->getSecondaryTextRowCount(minimum, maximum); |
|
302 |
|
303 item->setContentWidgetData("value", minimum); |
|
304 item->setContentWidgetData("maximum", 10); |
|
305 item->setContentWidgetData("minimum", 1); |
|
306 item->setContentWidgetData("tickPosition", Hb::SliderTicksBelow); |
|
307 item->setContentWidgetData("majorTickInterval",1); |
|
308 } |
|
309 } |
|
310 |
|
311 void ViewFuteDataForm::populateFrame() |
|
312 { |
|
313 settingsIndexes[Frame] = counter++; |
|
314 HbAbstractViewItem *prototype = qobject_cast<HbAbstractViewItem *>(view->itemPrototypes().first()); |
|
315 const HbFrameBackground &frameBackground = prototype->defaultFrame(); |
|
316 |
|
317 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
318 HbDataFormModelItem::ToggleValueItem, QString("Default frame:")); |
|
319 if (frameBackground.isNull()) { |
|
320 item->setContentWidgetData("text", "On"); |
|
321 item->setContentWidgetData("additionalText", "Off"); |
|
322 } else { |
|
323 item->setContentWidgetData("text", "Off"); |
|
324 item->setContentWidgetData("additionalText", "On"); |
|
325 } |
|
326 } |
|
327 |
|
328 void ViewFuteDataForm::populateRecycling() |
|
329 { |
|
330 settingsIndexes[Recycling] = counter++; |
|
331 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
332 HbDataFormModelItem::ToggleValueItem, QString("Item recycling:")); |
|
333 if (view->itemRecycling()) { |
|
334 item->setContentWidgetData("text", "On"); |
|
335 item->setContentWidgetData("additionalText", "Off"); |
|
336 } else { |
|
337 item->setContentWidgetData("text", "Off"); |
|
338 item->setContentWidgetData("additionalText", "On"); |
|
339 } |
|
340 } |
|
341 |
|
342 void ViewFuteDataForm::populateUniformItem() |
|
343 { |
|
344 HbListView *listView = qobject_cast<HbListView *>(view); |
|
345 if (listView) { |
|
346 settingsIndexes[UniformItem] = counter++; |
|
347 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
348 HbDataFormModelItem::ToggleValueItem, QString("Uniform Items:")); |
|
349 if (view->uniformItemSizes()) { |
|
350 item->setContentWidgetData("text", "On"); |
|
351 item->setContentWidgetData("additionalText", "Off"); |
|
352 } else { |
|
353 item->setContentWidgetData("text", "Off"); |
|
354 item->setContentWidgetData("additionalText", "On"); |
|
355 } |
|
356 } |
|
357 } |
|
358 |
|
359 void ViewFuteDataForm::populateRichText() |
|
360 { |
|
361 HbListViewItem *prototype = qobject_cast<HbListViewItem *>(view->itemPrototypes().first()); |
|
362 if (prototype) { |
|
363 settingsIndexes[RichText] = counter++; |
|
364 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
365 HbDataFormModelItem::ToggleValueItem, QString("Rich text support:")); |
|
366 if (prototype->textFormat() == Qt::RichText) { |
|
367 item->setContentWidgetData("text", "On"); |
|
368 item->setContentWidgetData("additionalText", "Off"); |
|
369 } else { |
|
370 item->setContentWidgetData("text", "Off"); |
|
371 item->setContentWidgetData("additionalText", "On"); |
|
372 } |
|
373 } |
|
374 } |
|
375 |
|
376 void ViewFuteDataForm::populateSelectionMode() |
|
377 { |
|
378 settingsIndexes[SelectionMode] = counter++; |
|
379 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
380 HbDataFormModelItem::RadioButtonListItem, QString("Selection mode:")); |
|
381 item->setContentWidgetData("items", SelectionModes); |
|
382 if (view->selectionMode() == HbAbstractItemView::SingleSelection) { |
|
383 item->setContentWidgetData("selected", 0); |
|
384 } else if (view->selectionMode() == HbAbstractItemView::MultiSelection) { |
|
385 item->setContentWidgetData("selected", 1); |
|
386 } else { |
|
387 item->setContentWidgetData("selected", 2); |
|
388 } |
|
389 } |
|
390 |
|
391 |
|
392 void ViewFuteDataForm::populateLaunchInPopup() |
|
393 { |
|
394 settingsIndexes[LaunchInPopup] = counter++; |
|
395 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
396 HbDataFormModelItem::RadioButtonListItem, QString("Launch target of next model:")); |
|
397 item->setContentWidgetData("items", LaunchInPopups); |
|
398 if ( settingsData[LaunchInPopup].isValid() |
|
399 && settingsData[LaunchInPopup].canConvert(QVariant::Bool) |
|
400 && settingsData[LaunchInPopup].toBool()) { |
|
401 item->setContentWidgetData("selected", 0); |
|
402 } else { |
|
403 item->setContentWidgetData("selected", 1); |
|
404 } |
|
405 } |
|
406 |
|
407 void ViewFuteDataForm::populateArrangeMode() |
|
408 { |
|
409 HbListView *listView = qobject_cast<HbListView *>(view); |
|
410 if (listView) { |
|
411 settingsIndexes[ArrangeMode] = counter++; |
|
412 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
413 HbDataFormModelItem::ToggleValueItem, QString("Arrange mode:")); |
|
414 if (listView->arrangeMode()) { |
|
415 item->setContentWidgetData("text", "On"); |
|
416 item->setContentWidgetData("additionalText", "Off"); |
|
417 } else { |
|
418 item->setContentWidgetData("text", "Off"); |
|
419 item->setContentWidgetData("additionalText", "On"); |
|
420 } |
|
421 } |
|
422 } |
|
423 |
|
424 void ViewFuteDataForm::populateScrollingStyle() |
|
425 { |
|
426 settingsIndexes[ScrollingStyle] = counter++; |
|
427 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
428 HbDataFormModelItem::RadioButtonListItem, QString("Scroll mode:")); |
|
429 item->setContentWidgetData("items", ScrollModes); |
|
430 if (view->scrollingStyle() == HbScrollArea::Pan) { |
|
431 item->setContentWidgetData("selected", 0); |
|
432 } else { |
|
433 item->setContentWidgetData("selected", 1); |
|
434 } |
|
435 } |
|
436 |
|
437 void ViewFuteDataForm::populateClampingStyle() |
|
438 { |
|
439 settingsIndexes[ClampingStyle] = counter++; |
|
440 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
441 HbDataFormModelItem::ToggleValueItem, QString("List bounce clamping:")); |
|
442 if (view->clampingStyle() == HbScrollArea::BounceBackClamping) { |
|
443 item->setContentWidgetData("text", "On"); |
|
444 item->setContentWidgetData("additionalText", "Off"); |
|
445 } else { |
|
446 item->setContentWidgetData("text", "Off"); |
|
447 item->setContentWidgetData("additionalText", "On"); |
|
448 } |
|
449 } |
|
450 |
|
451 void ViewFuteDataForm::populateInteractiveScrollBar() |
|
452 { |
|
453 settingsIndexes[InteractiveScrollBar] = counter++; |
|
454 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
455 HbDataFormModelItem::ToggleValueItem, QString("Interactive scrollbar:")); |
|
456 if (view->verticalScrollBar()->isInteractive() == true |
|
457 || view->horizontalScrollBar()->isInteractive() == true) { |
|
458 item->setContentWidgetData("text", "On"); |
|
459 item->setContentWidgetData("additionalText", "Off"); |
|
460 } else { |
|
461 item->setContentWidgetData("text", "Off"); |
|
462 item->setContentWidgetData("additionalText", "On"); |
|
463 } |
|
464 } |
|
465 |
|
466 void ViewFuteDataForm::populateFrictionEnabled() |
|
467 { |
|
468 settingsIndexes[FrictionEnabled] = counter++; |
|
469 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
470 HbDataFormModelItem::ToggleValueItem, QString("List scroll inertia:")); |
|
471 if (view->frictionEnabled()) { |
|
472 item->setContentWidgetData("text", "On"); |
|
473 item->setContentWidgetData("additionalText", "Off"); |
|
474 } else { |
|
475 item->setContentWidgetData("text", "Off"); |
|
476 item->setContentWidgetData("additionalText", "On"); |
|
477 } |
|
478 } |
|
479 |
|
480 void ViewFuteDataForm::populateOrientation() |
|
481 { |
|
482 settingsIndexes[Orientation] = counter++; |
|
483 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
484 HbDataFormModelItem::RadioButtonListItem, QString("Orientation:")); |
|
485 item->setContentWidgetData("items", OrientationTypes); |
|
486 if ( settingsData[Orientation].isValid() |
|
487 && settingsData[Orientation].canConvert(QVariant::Int) |
|
488 && ( settingsData[Orientation].toInt() == 0 |
|
489 || settingsData[Orientation].toInt() == 1)) { |
|
490 item->setContentWidgetData("selected", settingsData[Orientation].toInt()); |
|
491 } |
|
492 else { |
|
493 item->setContentWidgetData("selected", 0); |
|
494 } |
|
495 } |
|
496 |
|
497 void ViewFuteDataForm::populateMirroring() |
|
498 { |
|
499 settingsIndexes[Mirroring] = counter++; |
|
500 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
501 HbDataFormModelItem::ToggleValueItem, QString("Layout mirrored:")); |
|
502 if ( settingsData[Mirroring].isValid() |
|
503 && settingsData[Mirroring].canConvert(QVariant::Int)) { |
|
504 if (settingsData[Mirroring].toInt() == Qt::LeftToRight) { |
|
505 item->setContentWidgetData("text", "Off"); |
|
506 item->setContentWidgetData("additionalText", "On"); |
|
507 } |
|
508 else if (settingsData[Mirroring].toInt() == Qt::RightToLeft) { |
|
509 item->setContentWidgetData("text", "On"); |
|
510 item->setContentWidgetData("additionalText", "Off"); |
|
511 } |
|
512 } else { |
|
513 item->setContentWidgetData("text", "Off"); |
|
514 item->setContentWidgetData("additionalText", "On"); |
|
515 } |
|
516 } |
|
517 |
|
518 void ViewFuteDataForm::populateScrollHint() |
|
519 { |
|
520 settingsIndexes[ScrollHint] = counter++; |
|
521 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
522 HbDataFormModelItem::RadioButtonListItem, QString("Scroll-to-target stop position:")); |
|
523 item->setContentWidgetData("items", ScrollHints); |
|
524 int initialValue = 0; |
|
525 if ( settingsData[ScrollHint].isValid() |
|
526 && settingsData[ScrollHint].canConvert(QVariant::Int) |
|
527 && settingsData[ScrollHint].toInt() >= 0 |
|
528 && settingsData[ScrollHint].toInt() <= QAbstractItemView::PositionAtCenter) { |
|
529 initialValue = settingsData[ScrollHint].toInt(); |
|
530 } |
|
531 |
|
532 item->setContentWidgetData("selected", initialValue); |
|
533 } |
|
534 |
|
535 void ViewFuteDataForm::populateIndexFeedbackPolicy() |
|
536 { |
|
537 if (mIndexFeedback) { |
|
538 settingsIndexes[IndexFeedbackPolicy] = counter++; |
|
539 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
540 HbDataFormModelItem::RadioButtonListItem, QString("Index Feedback Policy:")); |
|
541 item->setContentWidgetData("items", IndexFeedbackPolicies); |
|
542 int initialValue = 0; |
|
543 |
|
544 if (! mIndexFeedback->itemView() ) { |
|
545 initialValue = 4; |
|
546 } else { |
|
547 initialValue = (int) mIndexFeedback->indexFeedbackPolicy(); |
|
548 } |
|
549 |
|
550 item->setContentWidgetData("selected", initialValue); |
|
551 } |
|
552 } |
|
553 |
|
554 void ViewFuteDataForm::resolveSettingsResults() |
|
555 { |
|
556 if (!view) { |
|
557 return; |
|
558 } |
|
559 |
|
560 HbListView *listView = qobject_cast<HbListView *>(view); |
|
561 |
|
562 HbAbstractViewItem *prototype = view->itemPrototypes().first(); |
|
563 HbListViewItem *prototypeListView = qobject_cast<HbListViewItem *>(prototype); |
|
564 if (prototypeListView) { |
|
565 prototypeListView->setGraphicsSize(getGraphicsSize()); |
|
566 prototypeListView->setStretchingStyle(getStretchingStyle()); |
|
567 int minBefore = 1; |
|
568 int maxBefore = 1; |
|
569 prototypeListView->getSecondaryTextRowCount(minBefore, maxBefore); |
|
570 if ( minBefore != 1 |
|
571 || maxBefore != 1 |
|
572 || getMinimumRowCount() != 1 |
|
573 || getMaximumRowCount() != 1 ) { |
|
574 prototypeListView->setSecondaryTextRowCount(getMinimumRowCount(), getMaximumRowCount()); |
|
575 } |
|
576 } |
|
577 |
|
578 HbFrameBackground frame; |
|
579 if (getFrame()){ |
|
580 frame.setFrameGraphicsName(QString()); |
|
581 } else { |
|
582 frame.setFrameGraphicsName(QString("")); |
|
583 } |
|
584 prototype->setDefaultFrame(frame); |
|
585 |
|
586 view->setItemRecycling(getRecycling()); |
|
587 view->setUniformItemSizes(getUniformItem()); |
|
588 |
|
589 if (prototypeListView) { |
|
590 prototypeListView->setTextFormat(getRichText()); |
|
591 } |
|
592 view->setSelectionMode(getSelectionMode()); |
|
593 view->setScrollingStyle(getScrollingStyle()); |
|
594 view->setClampingStyle(getClampingStyle()); |
|
595 view->setFrictionEnabled(getFrictionEnabled()); |
|
596 |
|
597 bool interactiveScrollBar = getInteractiveScrollBar(); |
|
598 if (view->scrollDirections() & Qt::Horizontal) |
|
599 { |
|
600 view->horizontalScrollBar()->setInteractive(interactiveScrollBar); |
|
601 } |
|
602 if (view->scrollDirections() & Qt::Vertical) |
|
603 { |
|
604 view->verticalScrollBar()->setInteractive(interactiveScrollBar); |
|
605 } |
|
606 |
|
607 // must be after interactive scrollbar setting |
|
608 if (listView) { |
|
609 listView->setArrangeMode(getArrangeMode()); |
|
610 } |
|
611 |
|
612 if (mIndexFeedback) { |
|
613 int indexFeedbackMode = getIndexFeedbackPolicy(); |
|
614 if (indexFeedbackMode == 4) { |
|
615 mIndexFeedback->setItemView(0); |
|
616 } else { |
|
617 mIndexFeedback->setItemView(view); |
|
618 mIndexFeedback->setIndexFeedbackPolicy((HbIndexFeedback::IndexFeedbackPolicy) indexFeedbackMode); |
|
619 } |
|
620 } |
|
621 |
|
622 view->setItemPixmapCacheEnabled(getPixmapCacheEnaled()); |
|
623 view->setIconLoadPolicy(getIconLoadPolicy()); |
|
624 /* |
|
625 if (listView) { |
|
626 listView->setEnabledAnimations(getEnabledAnimations()); |
|
627 } |
|
628 */ |
|
629 } |
|
630 |
|
631 HbListViewItem::GraphicsSize ViewFuteDataForm::getGraphicsSize() |
|
632 { |
|
633 HbListViewItem::GraphicsSize graphicsSize(HbListViewItem::SmallIcon); |
|
634 |
|
635 if (settingsIndexes[GraphicsSize] != -1) { |
|
636 if (static_cast<HbDataFormViewItem*>(itemByIndex( |
|
637 settingsFormModel->index(settingsIndexes[GraphicsSize],0)))->dataItemContentWidget()->property("selected").toInt() == 1) { |
|
638 graphicsSize = HbListViewItem::MediumIcon; |
|
639 } else if (static_cast<HbDataFormViewItem*>(itemByIndex( |
|
640 settingsFormModel->index(settingsIndexes[GraphicsSize],0)))->dataItemContentWidget()->property("selected").toInt() == 2) { |
|
641 graphicsSize = HbListViewItem::LargeIcon; |
|
642 } else if (static_cast<HbDataFormViewItem*>(itemByIndex( |
|
643 settingsFormModel->index(settingsIndexes[GraphicsSize],0)))->dataItemContentWidget()->property("selected").toInt() == 3) { |
|
644 graphicsSize = HbListViewItem::Thumbnail; |
|
645 } else if (static_cast<HbDataFormViewItem*>(itemByIndex( |
|
646 settingsFormModel->index(settingsIndexes[GraphicsSize],0)))->dataItemContentWidget()->property("selected").toInt() == 4) { |
|
647 graphicsSize = HbListViewItem::WideThumbnail; |
|
648 } |
|
649 } |
|
650 |
|
651 return graphicsSize; |
|
652 } |
|
653 |
|
654 HbListViewItem::StretchingStyle ViewFuteDataForm::getStretchingStyle() |
|
655 { |
|
656 HbListViewItem::StretchingStyle stretchingStyle(HbListViewItem::NoStretching); |
|
657 |
|
658 if (settingsIndexes[StretchingStyle] != -1) { |
|
659 if (static_cast<HbDataFormViewItem*>(itemByIndex( |
|
660 settingsFormModel->index(settingsIndexes[StretchingStyle],0)))->dataItemContentWidget()->property("selected").toInt() == 1) { |
|
661 stretchingStyle = HbListViewItem::StretchLandscape; |
|
662 } |
|
663 } |
|
664 |
|
665 return stretchingStyle; |
|
666 } |
|
667 |
|
668 int ViewFuteDataForm::getMaximumRowCount() |
|
669 { |
|
670 int maximumRowCount = 0; |
|
671 if (settingsIndexes[MaximumRowCount] != -1) { |
|
672 maximumRowCount = static_cast<HbDataFormViewItem*>(itemByIndex( |
|
673 settingsFormModel->index(settingsIndexes[MaximumRowCount],0)))->dataItemContentWidget()->property("value").toInt(); |
|
674 } |
|
675 |
|
676 return maximumRowCount; |
|
677 } |
|
678 |
|
679 int ViewFuteDataForm::getMinimumRowCount() |
|
680 { |
|
681 int minimumRowCount = 0; |
|
682 if (settingsIndexes[MinimumRowCount] != -1) { |
|
683 minimumRowCount = static_cast<HbDataFormViewItem*>(itemByIndex( |
|
684 settingsFormModel->index(settingsIndexes[MinimumRowCount],0)))->dataItemContentWidget()->property("value").toInt(); |
|
685 } |
|
686 |
|
687 return minimumRowCount; |
|
688 } |
|
689 |
|
690 bool ViewFuteDataForm::getFrame() |
|
691 { |
|
692 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[Frame],0)))-> |
|
693 dataItemContentWidget()->property("text").toString() == "On") { |
|
694 return true; |
|
695 } |
|
696 return false; |
|
697 } |
|
698 |
|
699 bool ViewFuteDataForm::getRecycling() |
|
700 { |
|
701 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[Recycling],0)))-> |
|
702 dataItemContentWidget()->property("text").toString() == "On") { |
|
703 return true; |
|
704 } |
|
705 return false; |
|
706 } |
|
707 |
|
708 bool ViewFuteDataForm::getUniformItem() |
|
709 { |
|
710 if (settingsIndexes[UniformItem] != -1) { |
|
711 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[UniformItem],0)))-> |
|
712 dataItemContentWidget()->property("text").toString() == "On") { |
|
713 return true; |
|
714 } |
|
715 } |
|
716 return false; |
|
717 } |
|
718 |
|
719 Qt::TextFormat ViewFuteDataForm::getRichText() |
|
720 { |
|
721 if (settingsIndexes[RichText] != -1) { |
|
722 if (static_cast<HbDataFormViewItem*>(itemByIndex( |
|
723 settingsFormModel->index(settingsIndexes[RichText],0)))-> |
|
724 dataItemContentWidget()->property("text").toString() == "Off") { |
|
725 return Qt::PlainText; |
|
726 } |
|
727 return Qt::RichText; |
|
728 } |
|
729 return Qt::PlainText; |
|
730 } |
|
731 |
|
732 HbAbstractItemView::SelectionMode ViewFuteDataForm::getSelectionMode() |
|
733 { |
|
734 int value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[SelectionMode],0)))-> |
|
735 dataItemContentWidget()->property("selected").toInt(); |
|
736 if (value == 0) { |
|
737 return HbListView::SingleSelection; |
|
738 } else if (value == 1) { |
|
739 return HbListView::MultiSelection; |
|
740 } else { |
|
741 return HbListView::NoSelection; |
|
742 } |
|
743 } |
|
744 |
|
745 bool ViewFuteDataForm::getLaunchInPopup() |
|
746 { |
|
747 int value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[LaunchInPopup],0)))-> |
|
748 dataItemContentWidget()->property("selected").toInt(); |
|
749 if (value == 0) { |
|
750 return true; |
|
751 } else { |
|
752 return false; |
|
753 } |
|
754 } |
|
755 |
|
756 |
|
757 bool ViewFuteDataForm::getArrangeMode() |
|
758 { |
|
759 if (settingsIndexes[ArrangeMode] != -1) { |
|
760 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[ArrangeMode],0)))-> |
|
761 dataItemContentWidget()->property("text").toString() == "On") { |
|
762 return true; |
|
763 } |
|
764 } |
|
765 return false; |
|
766 } |
|
767 |
|
768 HbScrollArea::ScrollingStyle ViewFuteDataForm::getScrollingStyle() |
|
769 { |
|
770 int value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[ScrollingStyle],0)))-> |
|
771 dataItemContentWidget()->property("selected").toInt(); |
|
772 if (value == 0) { |
|
773 return HbScrollArea::Pan; |
|
774 } else { |
|
775 return HbScrollArea::PanWithFollowOn; |
|
776 } |
|
777 } |
|
778 |
|
779 HbScrollArea::ClampingStyle ViewFuteDataForm::getClampingStyle() |
|
780 { |
|
781 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[ClampingStyle],0)))-> |
|
782 dataItemContentWidget()->property("text").toString() == "On") { |
|
783 return HbScrollArea::BounceBackClamping; |
|
784 } |
|
785 return HbScrollArea::StrictClamping; |
|
786 } |
|
787 |
|
788 bool ViewFuteDataForm::getFrictionEnabled() |
|
789 { |
|
790 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[FrictionEnabled],0)))-> |
|
791 dataItemContentWidget()->property("text").toString() == "On") { |
|
792 return true; |
|
793 } |
|
794 return false; |
|
795 } |
|
796 |
|
797 Qt::LayoutDirection ViewFuteDataForm::getMirroring() |
|
798 { |
|
799 int value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[Mirroring],0)))-> |
|
800 dataItemContentWidget()->property("selected").toInt(); |
|
801 if (value == 1) { |
|
802 return Qt::RightToLeft; |
|
803 } |
|
804 return Qt::LeftToRight; |
|
805 } |
|
806 |
|
807 Qt::Orientation ViewFuteDataForm::getOrientation() |
|
808 { |
|
809 int value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[Orientation],0)))-> |
|
810 dataItemContentWidget()->property("selected").toInt(); |
|
811 if (value == 0) { |
|
812 return Qt::Vertical; |
|
813 } else { |
|
814 return Qt::Horizontal; |
|
815 } |
|
816 } |
|
817 |
|
818 HbAbstractItemView::ScrollHint ViewFuteDataForm::getScrollHint() |
|
819 { |
|
820 int value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[ScrollHint],0)))-> |
|
821 dataItemContentWidget()->property("selected").toInt(); |
|
822 return (HbAbstractItemView::ScrollHint)value; |
|
823 } |
|
824 |
|
825 int ViewFuteDataForm::getIndexFeedbackPolicy() |
|
826 { |
|
827 int value = 0; |
|
828 if (mIndexFeedback) { |
|
829 value = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[IndexFeedbackPolicy],0)))-> |
|
830 dataItemContentWidget()->property("selected").toInt(); |
|
831 return value; |
|
832 } |
|
833 return value; |
|
834 } |
|
835 |
|
836 bool ViewFuteDataForm::getInteractiveScrollBar() |
|
837 { |
|
838 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[InteractiveScrollBar],0)))-> |
|
839 dataItemContentWidget()->property("text").toString() == "On") { |
|
840 return true; |
|
841 } |
|
842 return false; |
|
843 } |
|
844 |
|
845 HbAbstractItemView::ItemAnimations ViewFuteDataForm::getEnabledAnimations() |
|
846 { |
|
847 QVariant selectedAsVariant = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[Animations],0)))-> |
|
848 dataItemContentWidget()->property("selectedItems"); |
|
849 |
|
850 QList<QVariant> selected = selectedAsVariant.value< QList<QVariant> >(); |
|
851 |
|
852 HbAbstractItemView::ItemAnimations mask = HbAbstractItemView::None; |
|
853 |
|
854 HbListView *listView = qobject_cast<HbListView *>(view); |
|
855 if (listView) { |
|
856 if (selected.contains(0)) { |
|
857 mask |= HbAbstractItemView::Appear; |
|
858 } |
|
859 if (selected.contains(1)) { |
|
860 mask |= HbAbstractItemView::Disappear; |
|
861 } |
|
862 if (selected.contains(2)) { |
|
863 mask |= HbAbstractItemView::TouchDown; |
|
864 } |
|
865 } else { |
|
866 if (selected.contains(0)) { |
|
867 mask |= HbAbstractItemView::TouchDown; |
|
868 } |
|
869 } |
|
870 return mask; |
|
871 } |
|
872 |
|
873 bool ViewFuteDataForm::getPixmapCacheEnaled() |
|
874 { |
|
875 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[PixmapCache],0)))-> |
|
876 dataItemContentWidget()->property("text").toString() == "On") { |
|
877 return true; |
|
878 } |
|
879 return false; |
|
880 } |
|
881 |
|
882 HbAbstractItemView::IconLoadPolicy ViewFuteDataForm::getIconLoadPolicy() |
|
883 { |
|
884 int selection = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(settingsIndexes[IconLoadPolicy],0)))-> |
|
885 dataItemContentWidget()->property("selected").toInt(); |
|
886 if ( selection == 0) { |
|
887 return HbAbstractItemView::LoadSynchronously; |
|
888 } else if (selection == 2) { |
|
889 return HbAbstractItemView::LoadAsynchronouslyAlways; |
|
890 } else { |
|
891 return HbAbstractItemView::LoadAsynchronouslyWhenScrolling; |
|
892 } |
|
893 } |
|
894 |
|
895 void ViewFuteDataForm::populateAddItem() |
|
896 { |
|
897 activity = AddItem; |
|
898 settingsFormModel->clear(); |
|
899 |
|
900 populatePrimaryText(); |
|
901 populateSecondaryText(); |
|
902 populateThirdText(); |
|
903 populateLeftColumn(); |
|
904 populateRightColumn(); |
|
905 populateType(); |
|
906 populateBackground(); |
|
907 populateAddItemCount(); |
|
908 |
|
909 setModel(settingsFormModel); |
|
910 |
|
911 HbListView *listView = qobject_cast<HbListView *>(view); |
|
912 HbTreeView *treeView = qobject_cast<HbTreeView *>(view); |
|
913 if (listView || treeView) { |
|
914 HbAction *action = new HbAction(tr("Format")); |
|
915 connect(action, SIGNAL(triggered()), this, SLOT(formatTriggered())); |
|
916 |
|
917 if (addItemIndexes[PrimaryText] != -1) { |
|
918 if (qobject_cast<HbLineEdit *>(static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[PrimaryText],0)))->dataItemContentWidget())) { |
|
919 HbLineEdit *editor = qobject_cast<HbLineEdit *>(static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[PrimaryText],0)))->dataItemContentWidget()); |
|
920 HbEditorInterface editInterface(editor); |
|
921 editInterface.addAction(action); |
|
922 } |
|
923 } |
|
924 |
|
925 if (addItemIndexes[SecondaryText] != -1) { |
|
926 if (qobject_cast<HbLineEdit *>(static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[SecondaryText],0)))->dataItemContentWidget())) { |
|
927 HbLineEdit *editor = qobject_cast<HbLineEdit *>(static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[SecondaryText],0)))->dataItemContentWidget()); |
|
928 HbEditorInterface editInterface2(editor); |
|
929 editInterface2.addAction(action); |
|
930 } |
|
931 |
|
932 if (addItemIndexes[ThirdText] != -1) { |
|
933 if (qobject_cast<HbLineEdit *>(static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[ThirdText],0)))->dataItemContentWidget())) { |
|
934 HbLineEdit *editor = qobject_cast<HbLineEdit *>(static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[ThirdText],0)))->dataItemContentWidget()); |
|
935 HbEditorInterface editInterface2(editor); |
|
936 editInterface2.addAction(action); |
|
937 } |
|
938 } |
|
939 } |
|
940 } |
|
941 } |
|
942 |
|
943 void ViewFuteDataForm::populatePrimaryText() |
|
944 { |
|
945 addItemIndexes[PrimaryText] = counter++; |
|
946 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
947 HbDataFormModelItem::TextItem, QString("Primary text:")); |
|
948 if (addItemData[PrimaryText].isValid() && addItemData[PrimaryText].canConvert(QVariant::String)) { |
|
949 item->setContentWidgetData("text", addItemData[PrimaryText].toString()); |
|
950 } |
|
951 } |
|
952 |
|
953 void ViewFuteDataForm::populateSecondaryText() |
|
954 { |
|
955 addItemIndexes[SecondaryText] = counter++; |
|
956 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
957 HbDataFormModelItem::TextItem, QString("Secondary text:")); |
|
958 if (addItemData[SecondaryText].isValid() && addItemData[SecondaryText].canConvert(QVariant::String)) { |
|
959 item->setContentWidgetData("text", addItemData[SecondaryText].toString()); |
|
960 } |
|
961 } |
|
962 |
|
963 void ViewFuteDataForm::populateThirdText() |
|
964 { |
|
965 addItemIndexes[ThirdText] = counter++; |
|
966 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
967 HbDataFormModelItem::TextItem, QString("Third text:")); |
|
968 if (addItemData[ThirdText].isValid() && addItemData[ThirdText].canConvert(QVariant::String)) { |
|
969 item->setContentWidgetData("text", addItemData[ThirdText].toString()); |
|
970 } |
|
971 } |
|
972 |
|
973 |
|
974 void ViewFuteDataForm::populateLeftColumn() |
|
975 { |
|
976 addItemIndexes[LeftColumn] = counter++; |
|
977 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
978 HbDataFormModelItem::RadioButtonListItem, QString("Left column widget:")); |
|
979 item->setContentWidgetData(QString("items"), LeftColumnWidgets); |
|
980 item->setContentWidgetData("selected", 0); |
|
981 } |
|
982 |
|
983 void ViewFuteDataForm::populateRightColumn() |
|
984 { |
|
985 addItemIndexes[RightColumn] = counter++; |
|
986 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
987 HbDataFormModelItem::RadioButtonListItem, QString("Right column widget:")); |
|
988 item->setContentWidgetData(QString("items"), RightColumnWidgets); |
|
989 item->setContentWidgetData("selected", 0); |
|
990 } |
|
991 |
|
992 void ViewFuteDataForm::populateType() |
|
993 { |
|
994 HbListView *listView = qobject_cast<HbListView *>(view); |
|
995 if (listView) { |
|
996 addItemIndexes[Type] = counter++; |
|
997 HbDataFormModelItem *item = settingsFormModel-> |
|
998 appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, QString("Type:")); |
|
999 item->setContentWidgetData("items", ItemTypes); |
|
1000 item->setContentWidgetData("selected", 0); |
|
1001 } |
|
1002 } |
|
1003 |
|
1004 void ViewFuteDataForm::populateBackground() |
|
1005 { |
|
1006 addItemIndexes[Background] = counter++; |
|
1007 HbDataFormModelItem *item = settingsFormModel-> |
|
1008 appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, QString("Background:")); |
|
1009 item->setContentWidgetData("items", ItemBackgrounds); |
|
1010 item->setContentWidgetData("selected", 0); |
|
1011 } |
|
1012 |
|
1013 void ViewFuteDataForm::populateAddItemCount() |
|
1014 { |
|
1015 |
|
1016 addItemIndexes[ItemCount] = counter++; |
|
1017 HbDataFormModelItem *item = settingsFormModel-> |
|
1018 appendDataFormItem(HbDataFormModelItem::TextItem, QString("Item count:")); |
|
1019 if (addItemData[ItemCount].isValid() && addItemData[ItemCount].canConvert(QVariant::Int)) { |
|
1020 item->setContentWidgetData("text", addItemData[ItemCount].toInt()); |
|
1021 } else { |
|
1022 item->setContentWidgetData("text", QString("1")); |
|
1023 } |
|
1024 } |
|
1025 |
|
1026 void ViewFuteDataForm::populateEnabledAnimations() |
|
1027 { |
|
1028 settingsIndexes[Animations] = counter++; |
|
1029 |
|
1030 HbListView *listView = qobject_cast<HbListView *>(view); |
|
1031 |
|
1032 QStringList animations; |
|
1033 if (listView) { |
|
1034 animations << "Appear" << "Disappear"; |
|
1035 } |
|
1036 animations << "TouchDown"; |
|
1037 |
|
1038 QList<QVariant> selected; |
|
1039 if (listView) { |
|
1040 if (view->enabledAnimations() | HbAbstractItemView::Appear) { |
|
1041 selected.append(0); |
|
1042 } |
|
1043 if (view->enabledAnimations() | HbAbstractItemView::Disappear) { |
|
1044 selected.append(1); |
|
1045 } |
|
1046 if (view->enabledAnimations() | HbAbstractItemView::TouchDown) { |
|
1047 selected.append(2); |
|
1048 } |
|
1049 } else { |
|
1050 if (view->enabledAnimations() | HbAbstractItemView::TouchDown) { |
|
1051 selected.append(0); |
|
1052 } |
|
1053 } |
|
1054 |
|
1055 HbDataFormModelItem *item = settingsFormModel-> |
|
1056 appendDataFormItem(HbDataFormModelItem::MultiselectionItem, QString("Enabled animations:")); |
|
1057 item->setContentWidgetData("items", animations); |
|
1058 |
|
1059 item->setContentWidgetData("selectedItems", selected); |
|
1060 } |
|
1061 |
|
1062 void ViewFuteDataForm::populatePixmapCacheEnabled() |
|
1063 { |
|
1064 settingsIndexes[PixmapCache] = counter++; |
|
1065 |
|
1066 HbDataFormModelItem *item = settingsFormModel->appendDataFormItem( |
|
1067 HbDataFormModelItem::ToggleValueItem, QString("Pixmap cache:")); |
|
1068 if (view->itemPixmapCacheEnabled()) { |
|
1069 item->setContentWidgetData("text", "On"); |
|
1070 item->setContentWidgetData("additionalText", "Off"); |
|
1071 } else { |
|
1072 item->setContentWidgetData("text", "Off"); |
|
1073 item->setContentWidgetData("additionalText", "On"); |
|
1074 } |
|
1075 } |
|
1076 |
|
1077 void ViewFuteDataForm::populateIconLoadPolicy() |
|
1078 { |
|
1079 settingsIndexes[IconLoadPolicy] = counter++; |
|
1080 |
|
1081 HbDataFormModelItem *item = settingsFormModel-> |
|
1082 appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, QString("Icon load policy:")); |
|
1083 item->setContentWidgetData("items", IconLoadPolicies); |
|
1084 switch (view->iconLoadPolicy()) { |
|
1085 case HbAbstractItemView::LoadSynchronously: { |
|
1086 item->setContentWidgetData("selected", 0); |
|
1087 break; |
|
1088 } |
|
1089 case HbAbstractItemView::LoadAsynchronouslyWhenScrolling: { |
|
1090 item->setContentWidgetData("selected", 1); |
|
1091 break; |
|
1092 } |
|
1093 case HbAbstractItemView::LoadAsynchronouslyAlways: { |
|
1094 item->setContentWidgetData("selected", 2); |
|
1095 break; |
|
1096 } |
|
1097 default: { |
|
1098 break; |
|
1099 } |
|
1100 } |
|
1101 } |
|
1102 |
|
1103 QList <HbListWidgetItem *> ViewFuteDataForm::getListWidgetItems() |
|
1104 { |
|
1105 QList <HbListWidgetItem *> items; |
|
1106 |
|
1107 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[PrimaryText],0)))-> |
|
1108 dataItemContentWidget()->property("text").toString().isEmpty() |
|
1109 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[SecondaryText],0)))-> |
|
1110 dataItemContentWidget()->property("text").toString().isEmpty() |
|
1111 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[ThirdText],0)))-> |
|
1112 dataItemContentWidget()->property("text").toString().isEmpty() |
|
1113 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[LeftColumn],0)))-> |
|
1114 dataItemContentWidget()->property("selected").toInt() == 0 |
|
1115 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[RightColumn],0)))-> |
|
1116 dataItemContentWidget()->property("selected").toInt() == 0) { |
|
1117 return items; |
|
1118 } |
|
1119 |
|
1120 QVariantList strings; |
|
1121 QVariantList icons; |
|
1122 |
|
1123 QString primaryString = getPrimaryText(); |
|
1124 QString secondaryString = getSecondaryText(); |
|
1125 QString thirdString = getThirdText(); |
|
1126 |
|
1127 |
|
1128 if (!thirdString.isEmpty()) { |
|
1129 if (primaryString.isEmpty()) { |
|
1130 primaryString = " "; |
|
1131 } |
|
1132 strings.append(primaryString); |
|
1133 |
|
1134 if (!secondaryString.isEmpty()) { |
|
1135 strings.append(secondaryString); |
|
1136 } else { |
|
1137 strings.append(QVariant()); |
|
1138 } |
|
1139 strings.append(thirdString); |
|
1140 } else if (!secondaryString.isEmpty()) { |
|
1141 if (primaryString.isEmpty()) { |
|
1142 primaryString = " "; |
|
1143 } |
|
1144 strings.append(primaryString); |
|
1145 strings.append(secondaryString); |
|
1146 } else if (!primaryString.isEmpty()) { |
|
1147 strings.append(primaryString); |
|
1148 } |
|
1149 |
|
1150 QVariant value1 = getLeftColumn(); |
|
1151 QVariant value2 = getRightColumn(); |
|
1152 if (value2.canConvert<HbIcon>()) { |
|
1153 icons.append(value1); |
|
1154 icons.append(value2); |
|
1155 } else if (value1.canConvert<HbIcon>()) { |
|
1156 icons.append(value1); |
|
1157 } |
|
1158 |
|
1159 QVariant background = getBackground(); |
|
1160 |
|
1161 int count = getAddItemCount(); |
|
1162 for (int i = 0; i < count; i++) { |
|
1163 |
|
1164 if (i != 0) { |
|
1165 QString s = QString("%1_%2").arg(primaryString).arg(i); |
|
1166 strings.replace(0, s); |
|
1167 } |
|
1168 |
|
1169 HbListWidgetItem *widgetItem = new HbListWidgetItem(getType()); |
|
1170 |
|
1171 widgetItem->setData(strings, Qt::DisplayRole); |
|
1172 widgetItem->setData(strings.at(0), Hb::IndexFeedbackRole); |
|
1173 widgetItem->setData(icons, Qt::DecorationRole); |
|
1174 |
|
1175 if (background.isValid()) { |
|
1176 widgetItem->setBackground(background); |
|
1177 } |
|
1178 |
|
1179 items.append(widgetItem); |
|
1180 } |
|
1181 |
|
1182 |
|
1183 return items; |
|
1184 } |
|
1185 |
|
1186 QList <QStandardItem *> ViewFuteDataForm::getStandardItems() |
|
1187 { |
|
1188 QList <QStandardItem *> items; |
|
1189 |
|
1190 if (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[PrimaryText],0)))-> |
|
1191 dataItemContentWidget()->property("text").toString().isEmpty() |
|
1192 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[SecondaryText],0)))-> |
|
1193 dataItemContentWidget()->property("text").toString().isEmpty() |
|
1194 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[ThirdText],0)))-> |
|
1195 dataItemContentWidget()->property("text").toString().isEmpty() |
|
1196 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[LeftColumn],0)))-> |
|
1197 dataItemContentWidget()->property("selected").toInt() == 0 |
|
1198 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[RightColumn],0)))-> |
|
1199 dataItemContentWidget()->property("selected").toInt() == 0) { |
|
1200 return items; |
|
1201 } |
|
1202 |
|
1203 QString primaryString = getPrimaryText(); |
|
1204 if (primaryString.isEmpty()) { |
|
1205 primaryString = " "; |
|
1206 } |
|
1207 |
|
1208 QString secondaryString = getSecondaryText(); |
|
1209 |
|
1210 QStringList displayTexts; |
|
1211 displayTexts.append(primaryString); |
|
1212 |
|
1213 if (!secondaryString.isEmpty()) { |
|
1214 displayTexts.append(secondaryString); |
|
1215 } |
|
1216 |
|
1217 QString thirdString = getThirdText(); |
|
1218 |
|
1219 if (!thirdString.isEmpty()) { |
|
1220 displayTexts.append(thirdString); |
|
1221 } |
|
1222 |
|
1223 |
|
1224 QVariant left = getLeftColumn(); |
|
1225 QVariant right = getRightColumn(); |
|
1226 QVariantList decorations; |
|
1227 decorations.append(left); |
|
1228 decorations.append(right); |
|
1229 |
|
1230 QVariant background = getBackground(); |
|
1231 |
|
1232 int count = getAddItemCount(); |
|
1233 for (int i = 0; i < count; i++) { |
|
1234 |
|
1235 if (i != 0) { |
|
1236 QString s = QString("%1_%2").arg(primaryString).arg(i); |
|
1237 displayTexts.replace(0, s); |
|
1238 } |
|
1239 |
|
1240 QStandardItem *item = new QStandardItem(); |
|
1241 item->setData(displayTexts, Qt::DisplayRole); |
|
1242 item->setData(decorations, Qt::DecorationRole); |
|
1243 |
|
1244 if (background.isValid()) { |
|
1245 item->setData(background, Qt::BackgroundRole); |
|
1246 } |
|
1247 |
|
1248 items.append(item); |
|
1249 } |
|
1250 return items; |
|
1251 } |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 QString ViewFuteDataForm::getPrimaryText() |
|
1257 { |
|
1258 return (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[PrimaryText],0)))-> |
|
1259 dataItemContentWidget()->property("text").toString()); |
|
1260 } |
|
1261 |
|
1262 QString ViewFuteDataForm::getSecondaryText() |
|
1263 { |
|
1264 return (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[SecondaryText],0)))-> |
|
1265 dataItemContentWidget()->property("text").toString()); |
|
1266 } |
|
1267 |
|
1268 QString ViewFuteDataForm::getThirdText() |
|
1269 { |
|
1270 return (static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[ThirdText],0)))-> |
|
1271 dataItemContentWidget()->property("text").toString()); |
|
1272 } |
|
1273 |
|
1274 QVariant ViewFuteDataForm::getLeftColumn() |
|
1275 { |
|
1276 HbIcon icon(KConvenienceIcons.at(0)); |
|
1277 int i = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[LeftColumn],0)))-> |
|
1278 dataItemContentWidget()->property("selected").toInt(); |
|
1279 if (i == 1) { |
|
1280 return icon; |
|
1281 } |
|
1282 return QVariant(); |
|
1283 } |
|
1284 |
|
1285 QVariant ViewFuteDataForm::getRightColumn() |
|
1286 { |
|
1287 HbIcon icon(KConvenienceIcons.at(1)); |
|
1288 int i = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[RightColumn],0)))-> |
|
1289 dataItemContentWidget()->property("selected").toInt(); |
|
1290 if (i == 1) { |
|
1291 return icon; |
|
1292 } |
|
1293 return QVariant(); |
|
1294 } |
|
1295 |
|
1296 Hb::ModelItemType ViewFuteDataForm::getType() |
|
1297 { |
|
1298 Hb::ModelItemType type = Hb::StandardItem; |
|
1299 if ( addItemIndexes[Type] != -1 |
|
1300 && static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[Type],0)))-> |
|
1301 dataItemContentWidget()->property("selected").toInt() == 1) { |
|
1302 type = Hb::SeparatorItem; |
|
1303 } |
|
1304 return type; |
|
1305 } |
|
1306 |
|
1307 QVariant ViewFuteDataForm::getBackground() |
|
1308 { |
|
1309 HbIcon icon(KConvenienceIcons.at(2)); |
|
1310 int i = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[Background],0)))-> |
|
1311 dataItemContentWidget()->property("selected").toInt(); |
|
1312 QVariant background; |
|
1313 if (i == 1) { |
|
1314 background = QColor(Qt::red); |
|
1315 } else if (i == 2) { |
|
1316 background = QBrush(Qt::green, Qt::SolidPattern); |
|
1317 } else if (i == 3) { |
|
1318 background = QBrush(Qt::blue, Qt::SolidPattern); |
|
1319 } else if (i == 4) { |
|
1320 background = icon; |
|
1321 } else if (i == 5) { |
|
1322 background = HbFrameBackground(":/demo/qsn_fr_list", HbFrameDrawer::NinePieces); |
|
1323 } |
|
1324 return background; |
|
1325 } |
|
1326 |
|
1327 int ViewFuteDataForm::getAddItemCount() |
|
1328 { |
|
1329 QString result = static_cast<HbDataFormViewItem*>(itemByIndex(settingsFormModel->index(addItemIndexes[ItemCount],0)))-> |
|
1330 dataItemContentWidget()->property("text").toString(); |
|
1331 return result.toInt(); |
|
1332 } |
|
1333 |
|
1334 |
|
1335 void ViewFuteDataForm::formatTriggered() |
|
1336 { |
|
1337 HbMenu *menu = new HbMenu(); |
|
1338 HbAction *action = menu->addAction("Bold"); |
|
1339 action->setData("<b>Bold text </b>"); |
|
1340 connect(action, SIGNAL(triggered()), this, SLOT(addFormating())); |
|
1341 |
|
1342 action = menu->addAction("Italic"); |
|
1343 action->setData("<i>Italic text </i>"); |
|
1344 connect(action, SIGNAL(triggered()), this, SLOT(addFormating())); |
|
1345 |
|
1346 action = menu->addAction("Underline"); |
|
1347 action->setData("<u>Underlined text </u>"); |
|
1348 connect(action, SIGNAL(triggered()), this, SLOT(addFormating())); |
|
1349 |
|
1350 action = menu->addAction("Link"); |
|
1351 action->setData("<a href=\"link\">Link text</a> "); |
|
1352 connect(action, SIGNAL(triggered()), this, SLOT(addFormating())); |
|
1353 |
|
1354 action = menu->addAction("Color"); |
|
1355 action->setData("<font color=red>Colored text </font> "); |
|
1356 connect(action, SIGNAL(triggered()), this, SLOT(addFormating())); |
|
1357 |
|
1358 action = menu->addAction("Font"); |
|
1359 action->setData("<h3>Medium text </h3> "); |
|
1360 connect(action, SIGNAL(triggered()), this, SLOT(addFormating())); |
|
1361 |
|
1362 /*action = menu->addAction("List"); |
|
1363 action->setData("<ul><li><a href=\"link\">Open</a><li><a href=\"link\">Save</a><li><a href=\"link\">Delete</a><li><a href=\"link\">Move</a></ul>"); |
|
1364 connect(action, SIGNAL(triggered()), this, SLOT(addFormating()));*/ |
|
1365 |
|
1366 menu->setPreferredPos(scene()->focusItem()->scenePos()); |
|
1367 menu->open(); |
|
1368 } |
|
1369 |
|
1370 void ViewFuteDataForm::addFormating() |
|
1371 { |
|
1372 HbAction *action = qobject_cast<HbAction *>(sender()); |
|
1373 QGraphicsWidget* focused = focusWidget(); |
|
1374 if (focused) { |
|
1375 HbLineEdit *item = qobject_cast<HbLineEdit*>(focused); |
|
1376 |
|
1377 if (item) { |
|
1378 QString newText = item->text(); |
|
1379 newText.append(action->data().toString()); |
|
1380 item->setText(newText); |
|
1381 } |
|
1382 } |
|
1383 } |
|
1384 |
|
1385 void ViewFuteDataForm::setIndexFeedback(HbIndexFeedback* indexFeedback) |
|
1386 { |
|
1387 mIndexFeedback = indexFeedback; |
|
1388 } |
|
1389 |
|
1390 |