|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "infowidgetlayoutmanager.h" |
|
19 #include <QtGlobal> |
|
20 #include <QObject> |
|
21 #include <QGraphicsWidget> |
|
22 #include <hbdocumentloader.h> |
|
23 #include <hblabel.h> |
|
24 #include <hbaction.h> |
|
25 #include <hbmarqueeitem.h> |
|
26 #include <hbiconitem.h> |
|
27 #include <hbpushbutton.h> |
|
28 #include "infowidgetlogging.h" |
|
29 |
|
30 /*! |
|
31 \class InfoWidgetDocumentLoader |
|
32 \brief Custom document loader for Operator info widget |
|
33 |
|
34 Derived from HbDocumentLoader. |
|
35 |
|
36 */ |
|
37 |
|
38 /*! |
|
39 \class InfoWidgetLayoutManager |
|
40 \brief Layout manager class for Operator info widget. |
|
41 |
|
42 Handles layout document loading and accessing the loaded |
|
43 widgets. |
|
44 |
|
45 */ |
|
46 |
|
47 // Local constants |
|
48 const char INFOWIDGET_DOCML_FILE[] = ":/resource/infowidget.docml"; |
|
49 const char SETTINGS_DIALOG_DOCML_FILE[] = ":/resource/settingsdialog.docml"; |
|
50 |
|
51 const char LAYOUT_PREFIX_INFO_DISPLAY[] = "id:"; |
|
52 const char LAYOUT_PREFIX_SETTINGS_DIALOG[] = "sd:"; |
|
53 const char LAYOUT_NAME_CONTENT[] = "content"; |
|
54 const char LAYOUT_NAME_MCNMARQUEEITEM[] = "mcnMarqueeItem"; |
|
55 const char LAYOUT_NAME_SPNMARQUEEITEM[] = "spnMarqueeItem"; |
|
56 const char LAYOUT_NAME_SATMARQUEEITEM[] = "satMarqueeItem"; |
|
57 const char LAYOUT_NAME_SPNICON[] = "spnIcon"; |
|
58 const char LAYOUT_NAME_MCNICON[] = "mcnIcon"; |
|
59 const char LAYOUT_NAME_SATTEXTICON[] = "satTextIcon"; |
|
60 const char LAYOUT_NAME_SPNCHECKBOX[] = "spnCheckBox"; |
|
61 const char LAYOUT_NAME_MCNCHECKBOX[] = "mcnCheckBox"; |
|
62 const char LAYOUT_NAME_SATTEXTCHECKBOX[] = "satTextCheckBox"; |
|
63 const char LAYOUT_NAME_OKACTION[] = "okAction"; |
|
64 const char LAYOUT_NAME_CANCELACTION[] = "cancelAction"; |
|
65 const char LAYOUT_NAME_SETTINGSDIALOG[] = "settingsDialog"; |
|
66 const char LAYOUT_NAME_SETTINGSCONTAINER[] = "settingsContainer"; |
|
67 const char LAYOUT_NAME_CONTAINER[] = "container"; |
|
68 |
|
69 /*! |
|
70 InfoWidgetDocumentLoader::InfoWidgetDocumentLoader() |
|
71 */ |
|
72 InfoWidgetDocumentLoader::InfoWidgetDocumentLoader() |
|
73 { |
|
74 } |
|
75 |
|
76 /*! |
|
77 InfoWidgetDocumentLoader::createObject() |
|
78 */ |
|
79 QObject *InfoWidgetDocumentLoader::createObject( |
|
80 const QString &type, |
|
81 const QString &name) |
|
82 { |
|
83 DPRINT << ": IN"; |
|
84 |
|
85 DPRINT << ": type: "<< type; |
|
86 DPRINT << ": name: "<< name; |
|
87 |
|
88 if ( type == HbMarqueeItem::staticMetaObject.className() ) { |
|
89 DPRINT << ": HbMarqueeItem"; |
|
90 QObject *object = new HbMarqueeItem; |
|
91 object->setObjectName(name); |
|
92 DPRINT << ": HbMarqueeitem found, OUT"; |
|
93 return object; |
|
94 } |
|
95 |
|
96 DPRINT << ": OUT"; |
|
97 return HbDocumentLoader::createObject(type, name); |
|
98 } |
|
99 |
|
100 /*! |
|
101 InfoWidgetLayoutManager::InfoWidgetLayoutManager() |
|
102 */ |
|
103 InfoWidgetLayoutManager::InfoWidgetLayoutManager(QObject *parent) |
|
104 : QObject(parent), |
|
105 m_documentLoader(NULL), |
|
106 m_displayRole(InfoDisplay), |
|
107 m_layoutRows(0) |
|
108 { |
|
109 DPRINT << ": IN"; |
|
110 |
|
111 // Fill supported layout item roles for info display |
|
112 QList<LayoutItemRole> displayWidgetRoles = widgetRoles(InfoDisplay); |
|
113 |
|
114 // Try to load all widgets in list by widget role |
|
115 bool loadResult = loadWidgets(InfoDisplay, |
|
116 displayWidgetRoles, |
|
117 m_infoDisplayWidgets); |
|
118 DPRINT << ": info display widget load result: " << loadResult; |
|
119 |
|
120 // Fill supported layout item roles for settings display |
|
121 displayWidgetRoles = widgetRoles(SettingsDialog); |
|
122 |
|
123 // Try to load all widgets in list by widget role |
|
124 loadResult = loadWidgets(SettingsDialog, |
|
125 displayWidgetRoles, |
|
126 m_settingsDialogWidgets); |
|
127 DPRINT << ": settings dialog widget load result: " << loadResult; |
|
128 |
|
129 DPRINT << ": OUT"; |
|
130 } |
|
131 |
|
132 /*! |
|
133 InfoWidgetLayoutManager::~InfoWidgetLayoutManager() |
|
134 */ |
|
135 InfoWidgetLayoutManager::~InfoWidgetLayoutManager() |
|
136 { |
|
137 DPRINT << ": IN"; |
|
138 |
|
139 if (m_documentLoader) { |
|
140 delete m_documentLoader; |
|
141 } |
|
142 |
|
143 DPRINT << ": OUT"; |
|
144 } |
|
145 |
|
146 /*! |
|
147 InfoWidgetLayoutManager::destroyWidgets() |
|
148 */ |
|
149 void InfoWidgetLayoutManager::destroyWidgets() |
|
150 { |
|
151 DPRINT << ": IN"; |
|
152 |
|
153 // Destroy parent items |
|
154 removeWidget(RoleContent); |
|
155 removeWidget(RoleSettingsDialog); |
|
156 |
|
157 DPRINT << ": OUT"; |
|
158 } |
|
159 |
|
160 /*! |
|
161 InfoWidgetLayoutManager::currentDisplayRole() |
|
162 */ |
|
163 InfoWidgetLayoutManager::DisplayRole InfoWidgetLayoutManager::currentDisplayRole() |
|
164 { |
|
165 DPRINT; |
|
166 return m_displayRole; |
|
167 } |
|
168 |
|
169 /*! |
|
170 InfoWidgetLayoutManager::currentWidgetRoles() |
|
171 */ |
|
172 QList<InfoWidgetLayoutManager::LayoutItemRole> InfoWidgetLayoutManager::currentWidgetRoles() |
|
173 { |
|
174 DPRINT; |
|
175 return m_widgets.keys(); |
|
176 } |
|
177 |
|
178 /*! |
|
179 InfoWidgetLayoutManager::layoutRows() |
|
180 */ |
|
181 int InfoWidgetLayoutManager::layoutRows() const |
|
182 { |
|
183 DPRINT; |
|
184 return m_layoutRows; |
|
185 } |
|
186 |
|
187 /*! |
|
188 InfoWidgetLayoutManager::setLayoutRows() |
|
189 */ |
|
190 void InfoWidgetLayoutManager::setLayoutRows(int rows) |
|
191 { |
|
192 DPRINT; |
|
193 m_layoutRows = rows; |
|
194 } |
|
195 |
|
196 /*! |
|
197 InfoWidgetLayoutManager::layoutRowHeight() |
|
198 |
|
199 Read size from style, currently graphics icon size used |
|
200 as it defines row height in layout. Real font height |
|
201 and layout spacing could be used instead. |
|
202 */ |
|
203 qreal InfoWidgetLayoutManager::layoutRowHeight() const |
|
204 { |
|
205 DPRINT; |
|
206 HbStyle style; |
|
207 qreal rowHeight; |
|
208 |
|
209 bool ok = style.parameter("hb-param-graphic-size-primary-small", |
|
210 rowHeight); |
|
211 if (!ok) { |
|
212 DWARNING << ": Paremeters reading failed!! Using default"; |
|
213 rowHeight = 26.8; |
|
214 } |
|
215 |
|
216 DPRINT << ": rowHeight: " << rowHeight; |
|
217 return rowHeight; |
|
218 } |
|
219 |
|
220 /*! |
|
221 InfoWidgetLayoutManager::textFitsToRect() |
|
222 |
|
223 Check if text fits to given rect width. Return true also if |
|
224 text width is null, or text width AND rect width is null. |
|
225 */ |
|
226 bool InfoWidgetLayoutManager::textFitsToRect(QString text, |
|
227 QFont font, QRectF rect) |
|
228 { |
|
229 bool fits(true); |
|
230 if (!rect.isEmpty()) { |
|
231 QFontMetricsF metrics(font); |
|
232 qreal width = metrics.boundingRect(text).width(); |
|
233 if (width > rect.width() ) { |
|
234 fits = false; |
|
235 } |
|
236 } |
|
237 |
|
238 DPRINT << ": fits: " << fits; |
|
239 return fits; |
|
240 } |
|
241 |
|
242 /*! |
|
243 InfoWidgetLayoutManager::contentWidget() |
|
244 */ |
|
245 QGraphicsWidget* InfoWidgetLayoutManager::contentWidget() |
|
246 { |
|
247 DPRINT; |
|
248 return getWidget(RoleContent); |
|
249 } |
|
250 |
|
251 /*! |
|
252 InfoWidgetLayoutManager::marqueeItems() |
|
253 */ |
|
254 QList<HbMarqueeItem *> InfoWidgetLayoutManager::marqueeItems() |
|
255 { |
|
256 DPRINT; |
|
257 QList<HbMarqueeItem *> items; |
|
258 |
|
259 QList<LayoutItemRole> marqueeItemRoles; |
|
260 marqueeItemRoles.append(RoleSpnMarqueeItem); |
|
261 marqueeItemRoles.append(RoleMcnMarqueeItem); |
|
262 marqueeItemRoles.append(RoleSatMarqueeItem); |
|
263 |
|
264 LayoutItemRole role; |
|
265 HbMarqueeItem *item(NULL); |
|
266 QGraphicsWidget *widget(NULL); |
|
267 foreach (role, marqueeItemRoles) { |
|
268 widget = getWidget(role); |
|
269 if (widget) { |
|
270 item = qobject_cast<HbMarqueeItem*>(widget); |
|
271 if (item) { |
|
272 items.append(item); |
|
273 item = NULL; |
|
274 } |
|
275 } |
|
276 } |
|
277 DPRINT << ": count of marquee items: " << items.count(); |
|
278 return items; |
|
279 } |
|
280 |
|
281 /*! |
|
282 InfoWidgetLayoutManager::getWidget(); |
|
283 */ |
|
284 QGraphicsWidget* InfoWidgetLayoutManager::getWidget(LayoutItemRole itemRole) |
|
285 { |
|
286 DPRINT << ": item role: " << itemRole; |
|
287 |
|
288 QGraphicsWidget *widget = m_widgets.value(itemRole); |
|
289 if (widget) { |
|
290 DPRINT << ": widget: " << widget; |
|
291 } |
|
292 |
|
293 return widget; |
|
294 } |
|
295 |
|
296 /*! |
|
297 InfoWidgetLayoutManager::getObject(); |
|
298 */ |
|
299 QObject* InfoWidgetLayoutManager::getObject(LayoutItemRole itemRole) |
|
300 { |
|
301 DPRINT << ": item role: " << itemRole; |
|
302 |
|
303 QObject *object = m_objects.value(itemRole); |
|
304 if (object) { |
|
305 DPRINT << ": object: " << object; |
|
306 } |
|
307 |
|
308 return object; |
|
309 } |
|
310 |
|
311 /*! |
|
312 InfoWidgetLayoutManager::removeWidget(); |
|
313 */ |
|
314 void InfoWidgetLayoutManager::removeWidget(LayoutItemRole itemRole, |
|
315 bool deleteLater) |
|
316 { |
|
317 DPRINT << ": item role: " << itemRole; |
|
318 |
|
319 QGraphicsWidget *widget = m_widgets.value(itemRole); |
|
320 if (widget) { |
|
321 DPRINT << ": removing widget: " << widget; |
|
322 m_widgets.remove(itemRole); |
|
323 if (!deleteLater) { |
|
324 delete widget; |
|
325 } else { |
|
326 widget->deleteLater(); |
|
327 } |
|
328 } |
|
329 |
|
330 widget = m_infoDisplayWidgets.value(itemRole); |
|
331 if (widget) { |
|
332 DPRINT << ": removing widget from m_infoDisplayWidgets"; |
|
333 m_infoDisplayWidgets.remove(itemRole); |
|
334 } |
|
335 |
|
336 widget = m_settingsDialogWidgets.value(itemRole); |
|
337 if (widget) { |
|
338 DPRINT << ": removing widget from m_settingsDialogWidgets"; |
|
339 m_settingsDialogWidgets.remove(itemRole); |
|
340 } |
|
341 } |
|
342 |
|
343 /*! |
|
344 InfoWidgetLayoutManager::layoutInfoDisplay() |
|
345 */ |
|
346 QGraphicsLayout* InfoWidgetLayoutManager::layoutInfoDisplay() |
|
347 { |
|
348 DPRINT << ": IN"; |
|
349 |
|
350 m_displayRole = InfoDisplay; |
|
351 m_widgets = m_infoDisplayWidgets; |
|
352 |
|
353 QGraphicsLayout *activeLayout(NULL); |
|
354 DPRINT << ": getting content item and using its layout for activeLayout"; |
|
355 QGraphicsWidget *content = getWidget(RoleContent); |
|
356 if (content) { |
|
357 DPRINT << ": content found, getting layout"; |
|
358 activeLayout = content->layout(); |
|
359 } |
|
360 |
|
361 DPRINT << ": OUT"; |
|
362 return activeLayout; |
|
363 } |
|
364 |
|
365 /*! |
|
366 InfoWidgetLayoutManager::layoutSettingsDialog() |
|
367 */ |
|
368 QGraphicsLayout* InfoWidgetLayoutManager::layoutSettingsDialog() |
|
369 { |
|
370 DPRINT << ": IN"; |
|
371 |
|
372 m_displayRole = SettingsDialog; |
|
373 m_widgets = m_settingsDialogWidgets; |
|
374 |
|
375 QGraphicsLayout *activeLayout(NULL); |
|
376 DPRINT << ": getting settingsDialog item"; |
|
377 QGraphicsWidget *dialog = getWidget(RoleSettingsDialog); |
|
378 if (dialog) { |
|
379 DPRINT << ": dialog found, getting layout"; |
|
380 activeLayout = dialog->layout(); |
|
381 |
|
382 HbAction *okAction = qobject_cast<HbAction *>(getObject(RoleOkAction)); |
|
383 if (okAction) { |
|
384 dialog->addAction(okAction); |
|
385 } |
|
386 |
|
387 HbAction *cancelAction = qobject_cast<HbAction *>(getObject(RoleCancelAction)); |
|
388 if (cancelAction) { |
|
389 dialog->addAction(cancelAction); |
|
390 } |
|
391 } |
|
392 |
|
393 DPRINT << ": OUT"; |
|
394 return activeLayout; |
|
395 } |
|
396 |
|
397 /*! |
|
398 InfoWidgetLayoutManager::loadWidgets() |
|
399 */ |
|
400 bool InfoWidgetLayoutManager::loadWidgets(const DisplayRole displayRole, |
|
401 const QList<LayoutItemRole> &displayWidgets, |
|
402 QMap<LayoutItemRole, QGraphicsWidget *> &widgetMap) |
|
403 { |
|
404 DPRINT << ": IN"; |
|
405 bool loadResult(true); |
|
406 |
|
407 // Cleanup previously loaded content in case of any data |
|
408 widgetMap.clear(); |
|
409 |
|
410 if (!m_documentLoader) { |
|
411 m_documentLoader = new InfoWidgetDocumentLoader; |
|
412 } |
|
413 |
|
414 Q_ASSERT(m_documentLoader); |
|
415 |
|
416 bool loaded = true; |
|
417 if (displayRole != SettingsDialog) { |
|
418 m_documentLoader->load(INFOWIDGET_DOCML_FILE, &loaded); |
|
419 } else { |
|
420 m_documentLoader->load(SETTINGS_DIALOG_DOCML_FILE, &loaded); |
|
421 } |
|
422 |
|
423 Q_ASSERT_X(loaded, |
|
424 "InfoWidgetLayoutManager", |
|
425 "Invalid docml file"); |
|
426 |
|
427 QGraphicsWidget *widget(NULL); |
|
428 LayoutItemRole currentWidgetRole; |
|
429 bool allWidgetsLoaded(true); |
|
430 |
|
431 foreach (currentWidgetRole, displayWidgets) { |
|
432 widget = loadWidget(*m_documentLoader, displayRole, currentWidgetRole); |
|
433 if (widget) { |
|
434 widgetMap.insert(currentWidgetRole, widget); |
|
435 widget = NULL; |
|
436 } else { |
|
437 allWidgetsLoaded = false; |
|
438 DWARNING << ": widget not found!"; |
|
439 } |
|
440 } |
|
441 |
|
442 DPRINT << ": allWidgetsLoaded: " << allWidgetsLoaded; |
|
443 |
|
444 int widgetCount = widgetMap.count(); |
|
445 if (widgetCount == displayWidgets.count()) { |
|
446 loadResult = true; |
|
447 } else { |
|
448 DWARNING << ": all widgets were not loaded!"; |
|
449 loadResult = false; |
|
450 } |
|
451 |
|
452 if (displayRole == SettingsDialog) { |
|
453 m_objects.clear(); |
|
454 QObject *okAction = |
|
455 loadObject(*m_documentLoader, |
|
456 displayRole, |
|
457 RoleOkAction); |
|
458 m_objects.insert(RoleOkAction, okAction); |
|
459 QObject *cancelAction = |
|
460 loadObject(*m_documentLoader, |
|
461 displayRole, |
|
462 RoleCancelAction); |
|
463 m_objects.insert(RoleCancelAction, cancelAction); |
|
464 } |
|
465 |
|
466 DPRINT << ": OUT"; |
|
467 return loadResult; |
|
468 } |
|
469 |
|
470 /*! |
|
471 InfoWidgetLayoutManager::reloadWidgets() |
|
472 */ |
|
473 bool InfoWidgetLayoutManager::reloadWidgets(const DisplayRole displayRole) |
|
474 { |
|
475 QList<LayoutItemRole> displayWidgetRoles = widgetRoles(displayRole); |
|
476 bool loadResult(false); |
|
477 |
|
478 switch (displayRole) { |
|
479 case InfoDisplay: |
|
480 loadResult = loadWidgets(displayRole, |
|
481 displayWidgetRoles, |
|
482 m_infoDisplayWidgets); |
|
483 break; |
|
484 case SettingsDialog: |
|
485 loadResult = loadWidgets(displayRole, |
|
486 displayWidgetRoles, |
|
487 m_settingsDialogWidgets); |
|
488 break; |
|
489 default: |
|
490 break; |
|
491 } |
|
492 return loadResult; |
|
493 } |
|
494 |
|
495 /*! |
|
496 InfoWidgetLayoutManager::loadWidget() |
|
497 |
|
498 Initialize loader with corresponding document file |
|
499 before calling this single widget loader utility |
|
500 */ |
|
501 QGraphicsWidget* InfoWidgetLayoutManager::loadWidget(InfoWidgetDocumentLoader &loader, |
|
502 DisplayRole displayRole, |
|
503 LayoutItemRole widgetRole) |
|
504 { |
|
505 DPRINT << ": IN"; |
|
506 |
|
507 QString widgetPrefix; |
|
508 if (displayRole == InfoDisplay) { |
|
509 widgetPrefix = LAYOUT_PREFIX_INFO_DISPLAY; |
|
510 } else if (displayRole == SettingsDialog) { |
|
511 widgetPrefix = LAYOUT_PREFIX_SETTINGS_DIALOG; |
|
512 } |
|
513 |
|
514 QGraphicsWidget *widget(NULL); |
|
515 QString widgetName = widgetPrefix; |
|
516 |
|
517 switch (widgetRole) |
|
518 { |
|
519 case RoleContent: |
|
520 widgetName.append(LAYOUT_NAME_CONTENT); |
|
521 break; |
|
522 case RoleMcnMarqueeItem: |
|
523 widgetName.append(LAYOUT_NAME_MCNMARQUEEITEM); |
|
524 break; |
|
525 case RoleSpnMarqueeItem: |
|
526 widgetName.append(LAYOUT_NAME_SPNMARQUEEITEM); |
|
527 break; |
|
528 case RoleSatMarqueeItem: |
|
529 widgetName.append(LAYOUT_NAME_SATMARQUEEITEM); |
|
530 break; |
|
531 case RoleSpnIcon: |
|
532 widgetName.append(LAYOUT_NAME_SPNICON); |
|
533 break; |
|
534 case RoleMcnIcon: |
|
535 widgetName.append(LAYOUT_NAME_MCNICON); |
|
536 break; |
|
537 case RoleSatTextIcon: |
|
538 widgetName.append(LAYOUT_NAME_SATTEXTICON); |
|
539 break; |
|
540 case RoleSpnCheckBox: |
|
541 widgetName.append(LAYOUT_NAME_SPNCHECKBOX); |
|
542 break; |
|
543 case RoleMcnCheckBox: |
|
544 widgetName.append(LAYOUT_NAME_MCNCHECKBOX); |
|
545 break; |
|
546 case RoleSatTextCheckBox: |
|
547 widgetName.append(LAYOUT_NAME_SATTEXTCHECKBOX); |
|
548 break; |
|
549 case RoleSettingsDialog: |
|
550 widgetName.append(LAYOUT_NAME_SETTINGSDIALOG); |
|
551 break; |
|
552 case RoleContainer: |
|
553 widgetName.append(LAYOUT_NAME_CONTAINER); |
|
554 break; |
|
555 case RoleSettingsContainer: |
|
556 widgetName.append(LAYOUT_NAME_SETTINGSCONTAINER); |
|
557 break; |
|
558 |
|
559 case RoleUndefined: // Fall through |
|
560 default: |
|
561 break; |
|
562 } |
|
563 |
|
564 DPRINT << ": widget name: " << widgetName; |
|
565 widget = qobject_cast<QGraphicsWidget *>(loader.findWidget(widgetName)); |
|
566 |
|
567 if (widget) { |
|
568 DPRINT << ": widget found: " << widgetName; |
|
569 } else { |
|
570 DPRINT << ": ERROR, widget not found!"; |
|
571 } |
|
572 |
|
573 DPRINT << ": OUT"; |
|
574 return widget; |
|
575 } |
|
576 |
|
577 /*! |
|
578 InfoWidgetLayoutManager::loadObject() |
|
579 |
|
580 Initialize loader with corresponding document |
|
581 file before calling this single object loader utility |
|
582 */ |
|
583 QObject* InfoWidgetLayoutManager::loadObject(InfoWidgetDocumentLoader &loader, |
|
584 DisplayRole displayRole, |
|
585 LayoutItemRole objectRole) |
|
586 { |
|
587 DPRINT << ": IN"; |
|
588 |
|
589 QString objectPrefix; |
|
590 if (displayRole == InfoDisplay) { |
|
591 objectPrefix = LAYOUT_PREFIX_INFO_DISPLAY; |
|
592 } else if (displayRole == SettingsDialog) { |
|
593 objectPrefix = LAYOUT_PREFIX_SETTINGS_DIALOG; |
|
594 } |
|
595 |
|
596 QObject *object(NULL); |
|
597 QString objectName = objectPrefix; |
|
598 |
|
599 switch (objectRole) |
|
600 { |
|
601 case RoleOkAction: |
|
602 objectName.append(LAYOUT_NAME_OKACTION); |
|
603 break; |
|
604 case RoleCancelAction: |
|
605 objectName.append(LAYOUT_NAME_CANCELACTION); |
|
606 break; |
|
607 |
|
608 case RoleUndefined: // Fall through |
|
609 default: |
|
610 break; |
|
611 } |
|
612 |
|
613 DPRINT << ": object name: " << objectName; |
|
614 object = qobject_cast<QObject *>(loader.findObject(objectName)); |
|
615 |
|
616 if (object) { |
|
617 DPRINT << ": object found: " << objectName; |
|
618 } else { |
|
619 DPRINT << ": ERROR, object not found!"; |
|
620 } |
|
621 |
|
622 DPRINT << ": OUT"; |
|
623 return object; |
|
624 } |
|
625 |
|
626 |
|
627 /*! |
|
628 InfoWidgetLayoutManager::widgetRoles() |
|
629 |
|
630 Returns supported widget roles for specific display |
|
631 */ |
|
632 const QList<InfoWidgetLayoutManager::LayoutItemRole> InfoWidgetLayoutManager::widgetRoles( |
|
633 DisplayRole displayRole) const |
|
634 { |
|
635 QList<LayoutItemRole> widgetRoles; |
|
636 switch (displayRole) { |
|
637 case InfoDisplay: |
|
638 // Fill supported layout item roles for info display |
|
639 widgetRoles.append(RoleContent); |
|
640 widgetRoles.append(RoleSpnIcon); |
|
641 widgetRoles.append(RoleSpnMarqueeItem); |
|
642 widgetRoles.append(RoleMcnIcon); |
|
643 widgetRoles.append(RoleMcnMarqueeItem); |
|
644 widgetRoles.append(RoleSatTextIcon); |
|
645 widgetRoles.append(RoleSatMarqueeItem); |
|
646 break; |
|
647 case SettingsDialog: |
|
648 // Fill supported layout item roles for settings display |
|
649 widgetRoles.append(RoleSettingsDialog); |
|
650 widgetRoles.append(RoleSettingsContainer); |
|
651 widgetRoles.append(RoleSpnCheckBox); |
|
652 widgetRoles.append(RoleMcnCheckBox); |
|
653 widgetRoles.append(RoleSatTextCheckBox); |
|
654 break; |
|
655 |
|
656 default: |
|
657 break; |
|
658 } |
|
659 |
|
660 DPRINT << ": widgetRoles.count() : " << widgetRoles.count(); |
|
661 return widgetRoles; |
|
662 } |
|
663 |
|
664 // End of File. |
|
665 |
|
666 |