hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mydataprovider.cpp
branchGCC_SURGE
changeset 10 c348b9772569
parent 8 15f034b8a3b5
child 17 a10844a9914d
equal deleted inserted replaced
4:463f1934e292 10:c348b9772569
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 *  Version     : %version: 1 %
    16 *  Version     : %version: 7 %
    17 */
    17 */
    18 #include <QList>
    18 #include <QList>
    19 #include "hglogger.h"
    19 #include "hglogger.h"
    20 #include <hbicon.h>
    20 #include <HbIcon>
    21 #include "mydataprovider.h"
    21 #include "mydataprovider.h"
    22 
       
    23 //#include "x:\sf\mw\qt\src\openvg\qpixmapdata_vg_p.h"
       
    24 //typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR);
       
    25 
    22 
    26 const int KItemIdRole = Qt::UserRole+1;
    23 const int KItemIdRole = Qt::UserRole+1;
    27 
    24 
    28 const int KThumbnailsPriority = EPriorityLess; //standard priority
    25 const int KThumbnailsPriority = EPriorityLess; //standard priority
    29 
    26 
    30 
    27 
    31 MyDataProvider::MyDataProvider(QObject *parent) :
    28 MyDataProvider::MyDataProvider(QObject *parent) :
    32 HgDataProviderModel(parent),
    29 HgDataProviderModel(parent),
    33 mDefaultIcon(new HbIcon(QIcon(QPixmap(":/icons/default.png")))),
    30 mDefaultIcon(QIcon(QPixmap(":/icons/default.png"))),
    34 mScheduler(new CActiveSchedulerWait()),
    31 mScheduler(new CActiveSchedulerWait()),
    35 mWrapper( new ThumbnailManager() ),
    32 mWrapper( new ThumbnailManager() ),
    36 mThumbnailRequestPending(false),
    33 mThumbnailRequestPending(false),
    37 mThumbnailRequestIndex(-1),
    34 mThumbnailRequestIndex(-1),
    38 mThumbnailRequestID(-1),
    35 mThumbnailRequestID(-1),
    39 mThumbnailsize(ThumbnailManager::ThumbnailMedium),
    36 mThumbnailsize(ThumbnailManager::ThumbnailMedium),
    40 mMDSLoadInProgress(false)
    37 mMDSLoadInProgress(false),
       
    38 mMode(0)
    41 {
    39 {
    42 //    TX_ENTRY
    40 //    TX_ENTRY
    43     Q_UNUSED(parent);
    41     Q_UNUSED(parent);
       
    42     
    44     mWrapper->setThumbnailSize( mThumbnailsize );
    43     mWrapper->setThumbnailSize( mThumbnailsize );
    45     mWrapper->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
    44     mWrapper->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
    46 
    45 
    47     QObject::connect( mWrapper, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
    46     QObject::connect( mWrapper, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
    48                       this, SLOT( thumbnailReady( QPixmap , void* , int , int )));
    47                       this, SLOT( thumbnailReady( QPixmap , void* , int , int )));
    51 }
    50 }
    52 
    51 
    53 MyDataProvider::~MyDataProvider()
    52 MyDataProvider::~MyDataProvider()
    54 {
    53 {
    55 //    TX_ENTRY
    54 //    TX_ENTRY
    56     delete mDefaultIcon;
       
    57     delete mWrapper;
    55     delete mWrapper;
    58     delete mScheduler;
    56     delete mScheduler;
    59 //    TX_EXIT
    57 //    TX_EXIT
    60 }
    58 }
    61 
    59 
    64 //    TX_ENTRY
    62 //    TX_ENTRY
    65 //	we could  remove all icons from cache and put default ones, but probably that would be waste of time, and it's better just to load new icons with correct sizes.
    63 //	we could  remove all icons from cache and put default ones, but probably that would be waste of time, and it's better just to load new icons with correct sizes.
    66 	mThumbnailsize = aThumbnailsize;
    64 	mThumbnailsize = aThumbnailsize;
    67 	mWrapper->setThumbnailSize( mThumbnailsize );
    65 	mWrapper->setThumbnailSize( mThumbnailsize );
    68 //    TX_EXIT
    66 //    TX_EXIT
       
    67 }
       
    68 
       
    69 void MyDataProvider::changeMode(int mode)
       
    70 {
       
    71     if(mMode!=mode){
       
    72         mMode = mode;
       
    73         resetModel();
       
    74     }
    69 }
    75 }
    70 
    76 
    71 void MyDataProvider::doRequestData(QList<int> list, bool silent)
    77 void MyDataProvider::doRequestData(QList<int> list, bool silent)
    72 {
    78 {
    73     TX_ENTRY
    79     TX_ENTRY
   154     TX_EXIT        
   160     TX_EXIT        
   155 }
   161 }
   156 
   162 
   157 QVariant MyDataProvider::defaultIcon() const
   163 QVariant MyDataProvider::defaultIcon() const
   158 {
   164 {
   159     return *mDefaultIcon;
   165     return mDefaultIcon;
   160 }
   166 }
   161 
   167 
   162 void MyDataProvider::HandleSessionOpened(CMdESession& aSession, TInt aError)
   168 void MyDataProvider::HandleSessionOpened(CMdESession& aSession, TInt aError)
   163 {
   169 {
   164     Q_UNUSED(aSession);
   170     Q_UNUSED(aSession);
   219         CMdESession* session = CMdESession::NewL( *this ); 
   225         CMdESession* session = CMdESession::NewL( *this ); 
   220         mScheduler->Start();
   226         mScheduler->Start();
   221         
   227         
   222         CMdENamespaceDef& namespaceDef = session->GetDefaultNamespaceDefL();
   228         CMdENamespaceDef& namespaceDef = session->GetDefaultNamespaceDefL();
   223                 
   229                 
   224         CMdEObjectDef& objectDef = namespaceDef.GetObjectDefL(_L("Image"));
   230         CMdEObjectQuery* imageQuery;
   225     
   231         if ( mMode == 0){
   226         CMdEObjectQuery* imageQuery = session->NewObjectQueryL( namespaceDef, objectDef, this );
   232             CMdEObjectDef& objectDef = namespaceDef.GetObjectDefL(_L("Image"));
       
   233             imageQuery = session->NewObjectQueryL( namespaceDef, objectDef, this );
       
   234         } else {
       
   235             CMdEObjectDef& objectDef = namespaceDef.GetObjectDefL(_L("Audio"));
       
   236             imageQuery = session->NewObjectQueryL( namespaceDef, objectDef, this );
       
   237         }   
       
   238         
   227         CleanupStack::PushL( imageQuery );
   239         CleanupStack::PushL( imageQuery );
   228         imageQuery->SetResultMode( EQueryResultModeId );
   240         imageQuery->SetResultMode( EQueryResultModeId );
   229         imageQuery->FindL( );
   241         imageQuery->FindL( );
   230         mScheduler->Start();
   242         mScheduler->Start();
   231         CleanupStack::PopAndDestroy( 1 );
   243         CleanupStack::PopAndDestroy( 1 );
   233     );    
   245     );    
   234     
   246     
   235     
   247     
   236     TX_EXIT    
   248     TX_EXIT    
   237 }
   249 }
   238 
   250 void MyDataProvider::testRemoveItem(int pos)
       
   251 {
       
   252     TX_ENTRY
       
   253     removeItem(pos);
       
   254     TX_EXIT  
       
   255 }
       
   256 
       
   257 void MyDataProvider::testInsertItem(int pos, QList< QPair< QVariant, int > >* data)
       
   258 {
       
   259     TX_ENTRY
       
   260     insertItem(pos, data, false);
       
   261     TX_EXIT  
       
   262 }
       
   263