|
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 "irdocumentloader.h" |
|
19 #include "irbannerlabel.h" |
|
20 #include "ircombobox.h" |
|
21 #include "irlineeditor.h" |
|
22 |
|
23 IRDocumentLoader::IRDocumentLoader(QObject *aParent) : iParent(aParent) |
|
24 { |
|
25 |
|
26 } |
|
27 |
|
28 QObjectList IRDocumentLoader::load(const QString &aFileName, const QString &aSection, QObject *aParent) |
|
29 { |
|
30 bool ok = false; |
|
31 QObjectList list = HbDocumentLoader::load(aFileName, aSection, &ok); |
|
32 Q_ASSERT_X(ok, "void IRDocumentLoader::load(const QString &aFileName, const QString &aSection)", "load failed"); |
|
33 |
|
34 int size = list.count(); |
|
35 QObject *parent = aParent ? aParent : iParent; |
|
36 for (int i = 0; i < size; i++) |
|
37 { |
|
38 QObject *obj = list[i]; |
|
39 if (obj != parent) |
|
40 { |
|
41 obj->setParent(parent); |
|
42 } |
|
43 } |
|
44 |
|
45 return list; |
|
46 } |
|
47 |
|
48 QObjectList IRDocumentLoader::load(const QString &aFileName, QObject *aParent) |
|
49 { |
|
50 bool ok = false; |
|
51 QObjectList list = HbDocumentLoader::load(aFileName, &ok); |
|
52 Q_ASSERT_X(ok, "void IRDocumentLoader::load(const QString &aFileName)", "load failed"); |
|
53 |
|
54 int size = list.count(); |
|
55 QObject *parent = aParent ? aParent : iParent; |
|
56 for (int i = 0; i < size; i++) |
|
57 { |
|
58 QObject *obj = list[i]; |
|
59 if (obj != parent) |
|
60 { |
|
61 obj->setParent(parent); |
|
62 } |
|
63 } |
|
64 |
|
65 return list; |
|
66 } |
|
67 |
|
68 QObject *IRDocumentLoader::createObject(const QString& aType, const QString &aName) |
|
69 { |
|
70 if (aType == IrViewBannerLabel::staticMetaObject.className()) |
|
71 { |
|
72 QObject *object = new IrViewBannerLabel(); |
|
73 object->setObjectName(aName); |
|
74 return object; |
|
75 } |
|
76 else if(aType == IrNowPlayingBannerLabel::staticMetaObject.className()) |
|
77 { |
|
78 QObject *object = new IrNowPlayingBannerLabel(); |
|
79 object->setObjectName(aName); |
|
80 return object; |
|
81 } |
|
82 else if(aType == IrComboBox::staticMetaObject.className()) |
|
83 { |
|
84 QObject *object = new IrComboBox(); |
|
85 object->setObjectName(aName); |
|
86 return object; |
|
87 } |
|
88 else if(aType == IrLineEditor::staticMetaObject.className()) |
|
89 { |
|
90 QObject *object = new IrLineEditor(); |
|
91 object->setObjectName(aName); |
|
92 return object; |
|
93 } |
|
94 else if (aType == HbTextItem::staticMetaObject.className()) |
|
95 { |
|
96 QObject *object = new HbTextItem; |
|
97 object->setObjectName(aName); |
|
98 return object; |
|
99 } |
|
100 else if (aType == HbMarqueeItem::staticMetaObject.className()) |
|
101 { |
|
102 QObject *object = new HbMarqueeItem; |
|
103 object->setObjectName(aName); |
|
104 return object; |
|
105 } |
|
106 |
|
107 return HbDocumentLoader::createObject(aType, aName); |
|
108 } |