28 #include "canotifierfilter.h" |
29 #include "canotifierfilter.h" |
29 |
30 |
30 #include "hsviewappdetailsstate.h" |
31 #include "hsviewappdetailsstate.h" |
31 #include "hsmenuevent.h" |
32 #include "hsmenuevent.h" |
32 #include "hsmenuitemmodel.h" |
33 #include "hsmenuitemmodel.h" |
33 |
34 #include "hsmenuentryremovedhandler.h" |
|
35 |
|
36 static const char *const HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME= |
|
37 "detailsDialogForJavaApplication"; |
34 |
38 |
35 /*! |
39 /*! |
36 Constructor. |
40 Constructor. |
37 @param parent Parent state. |
41 /param parent Parent state. |
38 */ |
42 */ |
39 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) : |
43 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) : |
40 QState(parent), mDialog(0), mNotifier(0) |
44 QState(parent), mDialog(0) |
41 { |
45 { |
42 construct(); |
46 construct(); |
43 } |
47 } |
44 |
48 |
45 /*! |
49 /*! |
46 Destructor |
50 Destructor |
47 */ |
51 */ |
48 HsViewAppDetailsState::~HsViewAppDetailsState() |
52 HsViewAppDetailsState::~HsViewAppDetailsState() |
49 { |
53 { |
50 if (mDialog) { |
54 delete mDialog; |
51 delete mDialog; |
|
52 } |
|
53 } |
55 } |
54 |
56 |
55 /*! |
57 /*! |
56 Construction |
58 Construction |
57 */ |
59 */ |
58 void HsViewAppDetailsState::construct() |
60 void HsViewAppDetailsState::construct() |
59 { |
61 { |
60 HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct"); |
62 HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct"); |
61 |
63 |
62 setObjectName("/ViewAppDetailsState"); |
64 setObjectName("/ViewAppDetailsState"); |
63 if (this->parent()) { |
65 if (this->parent()) { |
64 setObjectName(this->parent()->objectName() + objectName()); |
66 setObjectName(this->parent()->objectName() + objectName()); |
65 } |
67 } |
66 HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct"); |
68 HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct"); |
73 { |
75 { |
74 HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry"); |
76 HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry"); |
75 QState::onEntry(event); |
77 QState::onEntry(event); |
76 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
78 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
77 QVariantMap data = menuEvent->data(); |
79 QVariantMap data = menuEvent->data(); |
78 |
80 |
79 const int entryId = data.value(itemIdKey()).toInt(); |
81 const int entryId = data.value(itemIdKey()).toInt(); |
80 QSharedPointer<const CaEntry> entry |
82 QSharedPointer<const CaEntry> entry |
81 = CaService::instance()->getEntry(entryId); |
83 = CaService::instance()->getEntry(entryId); |
82 const int componentId = entry->attribute( |
84 const int componentId = entry->attribute( |
83 componentIdAttributeName()).toInt(); |
85 componentIdAttributeName()).toInt(); |
84 |
86 |
85 QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create(); |
87 QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create(); |
86 CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId); |
88 CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId); |
|
89 |
|
90 QString appType = entry->attribute(swTypeKey()); |
|
91 |
|
92 |
|
93 //TODO: Should we display something In that case? |
|
94 if (detailMap.size() < 1){ |
|
95 stateExited(); |
|
96 return; |
|
97 } |
87 |
98 |
88 HbDocumentLoader loader; |
99 HbDocumentLoader loader; |
89 bool loadStatusOk = false; |
100 bool loadStatusOk = false; |
90 mObjectList = loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk); |
101 loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk); |
91 Q_ASSERT_X(loadStatusOk, HS_DETAILS_DIALOG_LAYOUT, |
102 Q_ASSERT_X(loadStatusOk, HS_DETAILS_DIALOG_LAYOUT, |
92 "Error while loading docml file."); |
103 "Error while loading docml file."); |
93 |
104 |
|
105 if (!appType.compare(javaSwType())) { |
|
106 QString section = QString(HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME); |
|
107 loader.load(HS_DETAILS_DIALOG_LAYOUT, |
|
108 section, &loadStatusOk); |
|
109 } |
|
110 |
94 mDialog = qobject_cast<HbDialog*>( |
111 mDialog = qobject_cast<HbDialog*>( |
95 loader.findWidget(HS_DETAILS_DIALOG_NAME)); |
112 loader.findWidget(HS_DETAILS_DIALOG_NAME)); |
96 mDialog->actions()[0]->setParent(mDialog); |
113 |
97 |
|
98 subscribeForMemoryCardRemove(entryId); |
|
99 |
|
100 HbLabel* nameLabel = qobject_cast<HbLabel*>( |
|
101 loader.findWidget(CaSoftwareRegistry::componentNameKey())); |
|
102 HbLabel* versionLabel = qobject_cast<HbLabel*>( |
|
103 loader.findWidget(CaSoftwareRegistry::componentVersionKey())); |
|
104 HbLabel* supplierLabel = qobject_cast<HbLabel*>( |
|
105 loader.findWidget(CaSoftwareRegistry::componentVendorKey())); |
|
106 HbLabel* memoryLabel = qobject_cast<HbLabel*>( |
|
107 loader.findWidget(CaSoftwareRegistry::componentDriveInfoKey())); |
|
108 HbLabel* sizeLabel = qobject_cast<HbLabel*>( |
|
109 loader.findWidget(CaSoftwareRegistry::componentSizeKey())); |
|
110 HbLabel* typeLabel = qobject_cast<HbLabel*>( |
|
111 loader.findWidget(CaSoftwareRegistry::componentTypeKey())); |
|
112 |
|
113 nameLabel->setPlainText( |
|
114 detailMap[CaSoftwareRegistry::componentNameKey()]); |
|
115 versionLabel->setPlainText( |
|
116 detailMap[CaSoftwareRegistry::componentVersionKey()]); |
|
117 supplierLabel->setPlainText( |
|
118 detailMap[CaSoftwareRegistry::componentVendorKey()]); |
|
119 memoryLabel->setPlainText( |
|
120 detailMap[CaSoftwareRegistry::componentDriveInfoKey()]); |
|
121 sizeLabel->setPlainText( |
|
122 detailMap[CaSoftwareRegistry::componentSizeKey()]); |
|
123 |
|
124 typeLabel->setPlainText( |
|
125 detailMap[CaSoftwareRegistry::componentTypeKey()]); |
|
126 |
|
127 if (mDialog != NULL) { |
114 if (mDialog != NULL) { |
128 mDialog->setTimeout(HbPopup::NoTimeout); |
115 mDialog->setTimeout(HbPopup::NoTimeout); |
129 mDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
116 mDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
130 mDialog->open(this, SLOT(stateExited())); |
117 mDialog->actions()[0]->setParent(mDialog); |
131 } |
118 |
132 HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry"); |
119 setFieldPresentation(CaSoftwareRegistry::componentNameKey(), |
|
120 detailMap, loader); |
|
121 setFieldPresentation(CaSoftwareRegistry::componentVersionKey(), |
|
122 detailMap, loader); |
|
123 setFieldPresentation(CaSoftwareRegistry::componentVendorKey(), |
|
124 detailMap, loader); |
|
125 setFieldPresentation(CaSoftwareRegistry::componentDriveInfoKey(), |
|
126 detailMap, loader); |
|
127 setFieldPresentation(CaSoftwareRegistry::componentSizeKey(), |
|
128 detailMap, loader); |
|
129 setFieldPresentation(CaSoftwareRegistry::componentTypeKey(), |
|
130 detailMap, loader); |
|
131 |
|
132 if (!appType.compare(javaSwType())) { |
|
133 setFieldPresentation(CaSoftwareRegistry::componentDescriptionKey(), |
|
134 detailMap, loader); |
|
135 setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(), |
|
136 detailMap, loader); |
|
137 } |
|
138 |
|
139 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
|
140 new HsMenuEntryRemovedHandler(entryId, this, SIGNAL(exit()))); |
|
141 |
|
142 entryObserver.take()->setParent(mDialog); |
|
143 |
|
144 mDialog->open(this, SLOT(stateExited())); |
|
145 } else { |
|
146 stateExited(); |
|
147 } |
|
148 HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry"); |
|
149 } |
|
150 |
|
151 /*! |
|
152 Extracting label from loader and set content of data field. |
|
153 Hide label if the is no data to display. |
|
154 \param key detail key. |
|
155 \param detailMap detail map. |
|
156 \param loader session to document loader |
|
157 \retval void |
|
158 */ |
|
159 void HsViewAppDetailsState::setFieldPresentation(QString key, |
|
160 CaSoftwareRegistry::DetailMap &detailMap, |
|
161 HbDocumentLoader &loader) |
|
162 { |
|
163 HbLabel* dataLabel = qobject_cast<HbLabel*>( |
|
164 loader.findWidget(key)); |
|
165 QString data = detailMap[key]; |
|
166 if (data.isEmpty()) { |
|
167 dataLabel->setVisible(false); |
|
168 dataLabel->setMaximumHeight(0); |
|
169 HbLabel* titleLabel = qobject_cast<HbLabel*>( |
|
170 loader.findWidget(QString("_") + key)); |
|
171 titleLabel->setVisible(false); |
|
172 titleLabel->setMaximumHeight(0); |
|
173 } else { |
|
174 dataLabel->setPlainText(data); |
|
175 } |
133 } |
176 } |
134 |
177 |
135 /*! |
178 /*! |
136 Slot invoked when a state is exited. |
179 Slot invoked when a state is exited. |
137 */ |
180 */ |
138 void HsViewAppDetailsState::stateExited() |
181 void HsViewAppDetailsState::stateExited() |
139 { |
182 { |
140 HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::stateExited"); |
183 HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::stateExited"); |
141 mDialog = NULL; |
|
142 emit exit(); |
184 emit exit(); |
143 HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited"); |
185 HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited"); |
144 qDebug("HsViewAppDetailsState::stateExited()"); |
186 qDebug("HsViewAppDetailsState::stateExited()"); |
145 } |
187 } |
146 |
188 |