contentstorage/caclient/s60/src/caobjectadapter.cpp
changeset 86 e492551a0d54
parent 85 7feec50967db
child 87 9d806967057c
equal deleted inserted replaced
85:7feec50967db 86:e492551a0d54
    16  */
    16  */
    17 
    17 
    18 #include <e32std.h>
    18 #include <e32std.h>
    19 #include <exception>
    19 #include <exception>
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 #include <BADESCA.H>
    21 #include <badesca.h>
    22 #include <AknIconUtils.h>
    22 #include <AknIconUtils.h>
    23 #include <fbs.h>
    23 #include <fbs.h>
    24 #include <BITDEV.H>
    24 #include <bitdev.h>
    25 #include <QPixmap>
    25 #include <QPixmap>
       
    26 #include <HbIcon>
    26 #include <QBitmap>
    27 #include <QBitmap>
    27 #include <QDebug>
    28 #include <QDebug>
    28 
    29 
    29 #include "cadef.h"
    30 #include "cadef.h"
    30 #include "caobjectadapter.h"
    31 #include "caobjectadapter.h"
   313 }
   314 }
   314 
   315 
   315 //----------------------------------------------------------------------------
   316 //----------------------------------------------------------------------------
   316 //
   317 //
   317 //----------------------------------------------------------------------------
   318 //----------------------------------------------------------------------------
   318 QPixmap CaObjectAdapter::makeIcon(const CaEntry &entry, const QSize &size)
   319 HbIcon CaObjectAdapter::makeIcon(const CaEntry &entry, const QSize &size)
   319 {
   320 {
   320     QPixmap pixmap;
   321     HbIcon icon;
   321     TRAPD(leaveCode, pixmap = makeIconL(entry, size));
   322     TRAPD(leaveCode, icon = makeIconL(entry, size));
   322 
   323 
   323     USE_QDEBUG_IF(leaveCode) << "CaObjectAdapter::makeIcon leaveCode:"
   324     USE_QDEBUG_IF(leaveCode) << "CaObjectAdapter::makeIcon leaveCode:"
   324         << leaveCode;
   325         << leaveCode;
   325 
   326 
   326     return pixmap;
   327     return icon;
   327 }
   328 }
   328 
   329 
   329 //----------------------------------------------------------------------------
   330 //----------------------------------------------------------------------------
   330 //
   331 //
   331 //----------------------------------------------------------------------------
   332 //----------------------------------------------------------------------------
   399 }
   400 }
   400 
   401 
   401 //----------------------------------------------------------------------------
   402 //----------------------------------------------------------------------------
   402 //
   403 //
   403 //----------------------------------------------------------------------------
   404 //----------------------------------------------------------------------------
   404 QPixmap CaObjectAdapter::makeIconL(const CaEntry &entry, const QSize &size)
   405 HbIcon CaObjectAdapter::makeIconL(const CaEntry &entry, const QSize &size)
   405 {
   406 {
   406     QPixmap pixmap;
   407     HbIcon icon;
   407     CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
   408     CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
   408     CaObjectAdapter::convertL(entry, *innerEntry);
   409     CaObjectAdapter::convertL(entry, *innerEntry);
   409     //get the icon (jpg, png, gif ...)
   410     QString filename(entry.iconDescription().filename());
   410     if (entry.iconDescription().filename() != "") {
   411     if (!filename.isEmpty()) {
   411         pixmap = QPixmap(entry.iconDescription().filename()).
   412         icon = HbIcon(filename);
   412         scaled(size, Qt::KeepAspectRatioByExpanding);
       
   413     }
   413     }
   414     //try to load symbian icon from multi-bitmap (mbm, mbg)
   414     //try to load symbian icon from multi-bitmap (mbm, mbg)
   415     if (pixmap.isNull()) {
   415     if (icon.isNull() || !(icon.size().isValid())) {
   416         CAknIcon *aknIcon = CaMenuIconUtility::GetItemIcon(*innerEntry);
   416         CAknIcon *aknIcon = CaMenuIconUtility::GetItemIcon(*innerEntry);
       
   417         QPixmap pixmap;
   417         if (aknIcon) {
   418         if (aknIcon) {
   418             CleanupStack::PushL(aknIcon);
   419             CleanupStack::PushL(aknIcon);
   419 
   420 
   420             //need to disable compression to properly convert the bitmap
   421             //need to disable compression to properly convert the bitmap
   421             AknIconUtils::DisableCompression(aknIcon->Bitmap());
   422             AknIconUtils::DisableCompression(aknIcon->Bitmap());
   439                 CleanupStack::PopAndDestroy();
   440                 CleanupStack::PopAndDestroy();
   440                 pixmap.setAlphaChannel(mask);
   441                 pixmap.setAlphaChannel(mask);
   441             }
   442             }
   442             pixmap = pixmap.scaled(size, Qt::KeepAspectRatioByExpanding);
   443             pixmap = pixmap.scaled(size, Qt::KeepAspectRatioByExpanding);
   443             CleanupStack::PopAndDestroy(aknIcon);
   444             CleanupStack::PopAndDestroy(aknIcon);
       
   445             icon = HbIcon(QIcon(pixmap));
   444         }
   446         }
   445     }
   447     }
   446 
       
   447     CleanupStack::PopAndDestroy(innerEntry);
   448     CleanupStack::PopAndDestroy(innerEntry);
   448     return pixmap;
   449     return icon;
   449 }
   450 }
   450 
   451 
   451 //----------------------------------------------------------------------------
   452 //----------------------------------------------------------------------------
   452 //
   453 //
   453 //----------------------------------------------------------------------------
   454 //----------------------------------------------------------------------------