79 uchar *data = (uchar *)aBitmap->DataAddress(); |
81 uchar *data = (uchar *)aBitmap->DataAddress(); |
80 TSize size = aBitmap->SizeInPixels(); |
82 TSize size = aBitmap->SizeInPixels(); |
81 TDisplayMode displayMode = aBitmap->DisplayMode(); |
83 TDisplayMode displayMode = aBitmap->DisplayMode(); |
82 |
84 |
83 // QImage format must match to bitmap format |
85 // QImage format must match to bitmap format |
84 QImage image(data, size.iWidth, size.iHeight, TDisplayMode2Format(displayMode)); |
86 QImage image(data, size.iWidth, size.iHeight, TDisplayMode2Format( |
|
87 displayMode)); |
85 aBitmap->EndDataAccess(); |
88 aBitmap->EndDataAccess(); |
86 |
89 |
87 // No data copying happens because image format matches native OpenVG format. |
90 // No data copying happens because |
|
91 // image format matches native OpenVG format. |
88 // So QPixmap actually points to CFbsBitmap data. |
92 // So QPixmap actually points to CFbsBitmap data. |
89 return QPixmap::fromImage(image); |
93 return QPixmap::fromImage(image); |
90 } |
94 } |
91 |
95 |
92 // ----------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
93 // |
97 // |
94 // ----------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
95 void CaObjectAdapter::convertL(const CaEntry &fromEntry, |
99 void CaObjectAdapter::convertL(const CaEntry &fromEntry, |
96 CCaInnerEntry &toEntry) |
100 CCaInnerEntry &toEntry) |
97 { |
101 { |
98 toEntry.SetId(fromEntry.id()); |
102 toEntry.SetId(fromEntry.id()); |
99 |
103 |
100 toEntry.SetTextL(convertToDescriptor(fromEntry.text())); |
104 toEntry.SetTextL( |
101 |
105 XQConversions::qStringToS60Desc(fromEntry.text())->Des()); |
102 toEntry.SetDescriptionL(convertToDescriptor(fromEntry.description())); |
106 |
|
107 toEntry.SetDescriptionL( |
|
108 XQConversions::qStringToS60Desc(fromEntry.description())->Des()); |
|
109 toEntry.SetDescriptionL( |
|
110 XQConversions::qStringToS60Desc(fromEntry.description())->Des()); |
103 |
111 |
104 toEntry.SetEntryTypeNameL( |
112 toEntry.SetEntryTypeNameL( |
105 convertToDescriptor(fromEntry.entryTypeName())); |
113 XQConversions::qStringToS60Desc(fromEntry.entryTypeName())->Des()); |
106 |
114 |
107 toEntry.SetFlags(static_cast<TUint>(fromEntry.flags())); |
115 toEntry.SetFlags(static_cast<TUint>(fromEntry.flags())); |
108 |
116 |
109 toEntry.SetRole(static_cast<TUint>(fromEntry.role())); |
117 toEntry.SetRole(static_cast<TUint>(fromEntry.role())); |
110 |
118 |
111 const CaIconDescription fromIconDescription = |
119 const CaIconDescription fromIconDescription = |
112 fromEntry.iconDescription(); |
120 fromEntry.iconDescription(); |
113 |
121 |
114 toEntry.SetIconDataL( |
122 toEntry.SetIconDataL( |
115 static_cast<TInt>(fromIconDescription.bitmapId()), |
123 XQConversions::qStringToS60Desc( |
116 static_cast<TInt>(fromIconDescription.maskId()), |
124 fromIconDescription.filename())->Des(), |
117 static_cast<TInt>(fromIconDescription.skinMajorId()), |
125 XQConversions::qStringToS60Desc( |
118 static_cast<TInt>(fromIconDescription.skinMinorId()), |
126 fromIconDescription.skinId())->Des(), |
119 convertToDescriptor(fromIconDescription.filename())); |
127 XQConversions::qStringToS60Desc( |
|
128 fromIconDescription.applicationId())->Des()); |
120 |
129 |
121 const QMap<QString, QString> attributesMap = fromEntry.attributes(); |
130 const QMap<QString, QString> attributesMap = fromEntry.attributes(); |
122 |
131 |
123 foreach(QString key, attributesMap.keys()) { |
132 foreach(QString key, attributesMap.keys()) { |
124 if (key == applicationUidAttributeName()) { |
133 if (key == APPLICATION_UID_ATTRIBUTE_NAME) { |
125 const TInt32 uid = attributesMap.value(key).toInt(); |
134 const TInt32 uid = attributesMap.value(key).toInt(); |
126 toEntry.SetUid(uid); |
135 toEntry.SetUid(uid); |
127 } else { |
136 } else { |
128 toEntry.AddAttributeL( |
137 toEntry.AddAttributeL( |
129 convertToDescriptor(key), |
138 XQConversions::qStringToS60Desc(key)->Des(), |
130 convertToDescriptor(attributesMap.value(key))); |
139 XQConversions::qStringToS60Desc( |
|
140 attributesMap.value(key))->Des()); |
131 } |
141 } |
132 } |
142 } |
133 } |
143 } |
134 |
144 |
135 //---------------------------------------------------------------------------- |
145 //---------------------------------------------------------------------------- |
165 // mapping sort enums |
175 // mapping sort enums |
166 SortAttribute sortAttr; |
176 SortAttribute sortAttr; |
167 Qt::SortOrder sortOrder; |
177 Qt::SortOrder sortOrder; |
168 fromQuery.getSort(sortAttr, sortOrder); |
178 fromQuery.getSort(sortAttr, sortOrder); |
169 toQuery.SetSort(CaObjectAdapter::getSortCode(sortAttr, sortOrder)); |
179 toQuery.SetSort(CaObjectAdapter::getSortCode(sortAttr, sortOrder)); |
170 } |
180 |
171 |
181 const QMap<QString, QString> attributesMap = fromQuery.attributes(); |
172 //---------------------------------------------------------------------------- |
182 |
173 // |
183 foreach(QString key, attributesMap.keys()) { |
174 //---------------------------------------------------------------------------- |
184 toQuery.AddAttributeL( |
175 void CaObjectAdapter::convert(const CCaInnerEntry &fromEntry, |
185 XQConversions::qStringToS60Desc(key)->Des(), |
176 CaEntry &toEntry) |
186 XQConversions::qStringToS60Desc( |
|
187 attributesMap.value(key))->Des()); |
|
188 } |
|
189 } |
|
190 |
|
191 //---------------------------------------------------------------------------- |
|
192 // |
|
193 //---------------------------------------------------------------------------- |
|
194 void CaObjectAdapter::convert( |
|
195 const CCaInnerEntry &fromEntry, CaEntry &toEntry) |
177 { |
196 { |
178 toEntry.setId(fromEntry.GetId()); |
197 toEntry.setId(fromEntry.GetId()); |
179 |
198 |
180 toEntry.setText(convertToString(fromEntry.GetText())); |
199 toEntry.setText(XQConversions::s60DescToQString(fromEntry.GetText())); |
181 |
200 |
182 toEntry.setDescription(convertToString(fromEntry.GetDescription())); |
201 toEntry.setDescription( |
183 toEntry.setEntryTypeName(convertToString(fromEntry.GetEntryTypeName())); |
202 XQConversions::s60DescToQString(fromEntry.GetDescription())); |
|
203 toEntry.setEntryTypeName( |
|
204 XQConversions::s60DescToQString(fromEntry.GetEntryTypeName())); |
184 |
205 |
185 toEntry.setFlags(static_cast<EntryFlag>(fromEntry.GetFlags())); |
206 toEntry.setFlags(static_cast<EntryFlag>(fromEntry.GetFlags())); |
186 |
207 |
187 // take care of converting icon attributes |
208 // take care of converting icon attributes |
188 const CCaInnerEntry::TIconAttributes &icon = fromEntry.GetIcon(); |
209 const CCaInnerEntry::TIconAttributes &icon = fromEntry.GetIcon(); |
189 |
210 |
190 CaIconDescription iconDescription; |
211 CaIconDescription iconDescription; |
191 iconDescription.setId(icon.iId); |
212 iconDescription.setId(icon.iId); |
192 iconDescription.setBitmapId(icon.iBitmapId); |
213 iconDescription.setFilename( |
193 iconDescription.setMaskId(icon.iMaskId); |
214 XQConversions::s60DescToQString(icon.iFileName)); |
194 iconDescription.setSkinMajorId(icon.iSkinMajorId); |
215 iconDescription.setSkinId( |
195 iconDescription.setSkinMinorId(icon.iSkinMinorId); |
216 XQConversions::s60DescToQString(icon.iSkinId)); |
196 iconDescription.setFilename(convertToString(icon.iFileName)); |
217 iconDescription.setApplicationId( |
|
218 XQConversions::s60DescToQString(icon.iApplicationId)); |
197 |
219 |
198 toEntry.setIconDescription(iconDescription); |
220 toEntry.setIconDescription(iconDescription); |
199 |
221 |
200 const RCaEntryAttrArray &attributesArray = fromEntry.GetAttributes(); |
222 const RCaEntryAttrArray &attributesArray = fromEntry.GetAttributes(); |
201 |
223 |
202 if (toEntry.entryTypeName() == applicationEntryName() |
224 if (toEntry.entryTypeName() == APPLICATION_ENTRY_TYPE_NAME |
203 || toEntry.entryTypeName() == widgetEntryName()) { |
225 || toEntry.entryTypeName() == WIDGET_ENTRY_TYPE_NAME) { |
204 toEntry.setAttribute(applicationUidAttributeName(), |
226 toEntry.setAttribute(APPLICATION_UID_ATTRIBUTE_NAME, |
205 QString::number(fromEntry.GetUid())); |
227 QString::number(fromEntry.GetUid())); |
206 } |
228 } |
207 |
229 |
208 const int attributesArrayCount = attributesArray.Count(); |
230 const int attributesArrayCount = attributesArray.Count(); |
209 |
231 |
210 for (int i = 0; i < attributesArrayCount; ++i) { |
232 for (int i = 0; i < attributesArrayCount; ++i) { |
211 const CCaEntryAttribute *const attribute = attributesArray[i]; |
233 const CCaEntryAttribute *const attribute = attributesArray[i]; |
212 toEntry.setAttribute(convertToString(attribute->Name()), |
234 toEntry.setAttribute( |
213 convertToString(attribute->Value())); |
235 XQConversions::s60DescToQString(attribute->Name()), |
214 } |
236 XQConversions::s60DescToQString(attribute->Value())); |
215 } |
237 } |
216 |
|
217 //---------------------------------------------------------------------------- |
|
218 // !!! Warning: returns wrapper to internal QString representation which may |
|
219 // get invalid before returned TPtrC object gets out of scope |
|
220 //---------------------------------------------------------------------------- |
|
221 const TPtrC CaObjectAdapter::convertToDescriptor(const QString &string) |
|
222 { |
|
223 const TPtrC result(reinterpret_cast<const TUint16 *>(string.utf16())); |
|
224 return result; |
|
225 } |
|
226 |
|
227 //---------------------------------------------------------------------------- |
|
228 // |
|
229 //---------------------------------------------------------------------------- |
|
230 QString CaObjectAdapter::convertToString(const TDesC &des) |
|
231 { |
|
232 return QString::fromUtf16(des.Ptr(), des.Length()); |
|
233 } |
238 } |
234 |
239 |
235 //---------------------------------------------------------------------------- |
240 //---------------------------------------------------------------------------- |
236 // |
241 // |
237 //---------------------------------------------------------------------------- |
242 //---------------------------------------------------------------------------- |
351 break; |
355 break; |
352 } |
356 } |
353 return error; |
357 return error; |
354 } |
358 } |
355 |
359 |
356 //---------------------------------------------------------------------------- |
|
357 // |
|
358 //---------------------------------------------------------------------------- |
|
359 const QString &CaObjectAdapter::applicationUidAttributeName() |
|
360 { |
|
361 const static QString name("application:uid"); |
|
362 return name; |
|
363 } |
|
364 |
|
365 //---------------------------------------------------------------------------- |
|
366 // |
|
367 //---------------------------------------------------------------------------- |
|
368 const QString &CaObjectAdapter::applicationEntryName() |
|
369 { |
|
370 const static QString name("application"); |
|
371 return name; |
|
372 } |
|
373 |
|
374 //---------------------------------------------------------------------------- |
|
375 // |
|
376 // ----------------------------------------------------------------------------- |
|
377 const QString &CaObjectAdapter::widgetEntryName() |
|
378 { |
|
379 const static QString name("widget"); |
|
380 return name; |
|
381 } |
|
382 |
360 |
383 // ----------------------------------------------------------------------------- |
361 // ----------------------------------------------------------------------------- |
384 // copying compressed bitmap |
362 // copying compressed bitmap |
385 //---------------------------------------------------------------------------- |
363 //---------------------------------------------------------------------------- |
386 CFbsBitmap *CaObjectAdapter::copyBitmapLC(CFbsBitmap *input) |
364 CFbsBitmap *CaObjectAdapter::copyBitmapLC(CFbsBitmap *input) |
403 // |
381 // |
404 //---------------------------------------------------------------------------- |
382 //---------------------------------------------------------------------------- |
405 HbIcon CaObjectAdapter::makeIconL(const CaEntry &entry, const QSize &size) |
383 HbIcon CaObjectAdapter::makeIconL(const CaEntry &entry, const QSize &size) |
406 { |
384 { |
407 HbIcon icon; |
385 HbIcon icon; |
408 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
386 QString skinId(entry.iconDescription().skinId()); |
409 CaObjectAdapter::convertL(entry, *innerEntry); |
387 if (!skinId.isEmpty()) { |
410 QString filename(entry.iconDescription().filename()); |
388 icon = HbIcon(skinId); |
411 if (!filename.isEmpty()) { |
389 } |
412 icon = HbIcon(filename); |
390 if (icon.isNull() || !(icon.size().isValid())) { |
413 } |
391 QString filename(entry.iconDescription().filename()); |
|
392 if (!filename.isEmpty()) { |
|
393 |
|
394 // TODO: |
|
395 // work-around for HbIcon::size() method locking files if returns |
|
396 // default size, error id: ou1cimx1#279208 Case: mcl06HsDo07 - |
|
397 // "Cannot delete file" when trying to uninstall sisx file |
|
398 |
|
399 if (entry.entryTypeName() == XQConversions::s60DescToQString(KCaTypeWidget)) { |
|
400 icon = QIcon(filename); |
|
401 qWarning("Widget icon created by QIcon, as work-around for HbIcon::size"); |
|
402 } else { |
|
403 icon = HbIcon(filename); |
|
404 } |
|
405 } |
|
406 } |
|
407 |
414 //try to load symbian icon from multi-bitmap (mbm, mbg) |
408 //try to load symbian icon from multi-bitmap (mbm, mbg) |
415 if (icon.isNull() || !(icon.size().isValid())) { |
409 if (icon.isNull() || !(icon.size().isValid())) { |
|
410 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
411 CaObjectAdapter::convertL(entry, *innerEntry); |
|
412 |
416 CAknIcon *aknIcon = CaMenuIconUtility::GetItemIcon(*innerEntry); |
413 CAknIcon *aknIcon = CaMenuIconUtility::GetItemIcon(*innerEntry); |
417 QPixmap pixmap; |
414 QPixmap pixmap; |
418 if (aknIcon) { |
415 if (aknIcon) { |
419 CleanupStack::PushL(aknIcon); |
416 CleanupStack::PushL(aknIcon); |
420 |
417 |
421 //need to disable compression to properly convert the bitmap |
418 //need to disable compression to properly convert the bitmap |
422 AknIconUtils::DisableCompression(aknIcon->Bitmap()); |
419 AknIconUtils::DisableCompression(aknIcon->Bitmap()); |
423 AknIconUtils::SetSize(aknIcon->Bitmap(), TSize(size.width(), |
420 AknIconUtils::SetSize( |
424 size.height()), EAspectRatioPreservedAndUnusedSpaceRemoved); |
421 aknIcon->Bitmap(), TSize(size.width(), size.height()), |
|
422 EAspectRatioPreservedAndUnusedSpaceRemoved); |
425 if (aknIcon->Bitmap()->Header().iCompression |
423 if (aknIcon->Bitmap()->Header().iCompression |
426 == ENoBitmapCompression) { |
424 == ENoBitmapCompression) { |
427 pixmap = fromSymbianCFbsBitmap(aknIcon->Bitmap()); |
425 pixmap = fromSymbianCFbsBitmap(aknIcon->Bitmap()); |
428 QPixmap mask = fromSymbianCFbsBitmap( |
426 QPixmap mask = fromSymbianCFbsBitmap(aknIcon->Mask()); |
429 aknIcon->Mask()); |
|
430 pixmap.setAlphaChannel(mask); |
427 pixmap.setAlphaChannel(mask); |
431 } else { // we need special handling for icons in 9.2 (NGA) |
428 } else { // we need special handling for icons in 9.2 (NGA) |
432 // let's hope that in future it will be in QT code |
429 // let's hope that in future it will be in QT code |
433 CFbsBitmap *temp(NULL); |
430 CFbsBitmap *temp(NULL); |
434 temp = copyBitmapLC(aknIcon->Bitmap()); |
431 temp = copyBitmapLC(aknIcon->Bitmap()); |