phonebookengines/cntlistmodel/inc/cntcache_p.h
changeset 47 7cbcb2896f0e
parent 46 efe85016a067
child 66 554fe4dbbb59
equal deleted inserted replaced
46:efe85016a067 47:7cbcb2896f0e
    54 class CntInfoCacheItem
    54 class CntInfoCacheItem
    55 {
    55 {
    56 public:
    56 public:
    57     int cacheOrder;
    57     int cacheOrder;
    58     int contactId;
    58     int contactId;
       
    59     int latestRow;
    59     QString name;
    60     QString name;
    60     QString text;
    61     QString text;
    61     QString icons[2];
    62     QString icons[2];
    62 };
    63 };
    63 
    64 
    95 public:
    96 public:
    96     CntCacheThread();
    97     CntCacheThread();
    97     ~CntCacheThread();
    98     ~CntCacheThread();
    98 
    99 
    99     void run();
   100     void run();
   100     void scheduleInfoJob(int contactId);
   101     void scheduleInfoJob(int contactId, int priority);
   101     void scheduleIconJob(const QString& iconName);
   102     void scheduleIconJob(const QString& iconName, int priority);
   102     void postponeJobs();
   103     void postponeJobs();
   103     bool event(QEvent *event);
   104     bool event(QEvent *event);
   104 
   105 
   105 signals:
   106 signals:
   106     void infoFieldUpdated(int contactId, ContactInfoField infoField, const QString& infoValue);
   107     void infoFieldUpdated(int contactId, ContactInfoField infoField, const QString& infoValue);
   111     
   112     
   112 private slots:
   113 private slots:
   113     void onInfoFieldReady(CntInfoProvider* sender, int contactId,
   114     void onInfoFieldReady(CntInfoProvider* sender, int contactId,
   114                           ContactInfoField field, const QString& text);
   115                           ContactInfoField field, const QString& text);
   115     void onIconReady(const QPixmap& pixmap, void *data, int id, int error);
   116     void onIconReady(const QPixmap& pixmap, void *data, int id, int error);
   116     void doAllJobs();
   117     void processJobs();
       
   118 
       
   119 private:
       
   120     int infoJobIndex(int contactId);
       
   121     int takeNextInfoJob();
       
   122     int iconJobIndex(QString iconName);
       
   123     QString takeNextIconJob();
   117 
   124 
   118 private:
   125 private:
   119     QContactManager* mContactManager;       // for fetching QContact objects
   126     QContactManager* mContactManager;       // for fetching QContact objects
   120     ThumbnailManager* mThumbnailManager;    // for fetching icons
   127     ThumbnailManager* mThumbnailManager;    // for fetching icons
   121 
   128 
   122     // maps info providers to their responsibilities
   129     // maps info providers to their responsibilities
   123     QMap<CntInfoProvider*, ContactInfoFields> mDataProviders;
   130     QMap<CntInfoProvider*, ContactInfoFields> mDataProviders;
   124 
   131 
   125     QMutex mJobMutex;                       // guards access to the job lists
   132     QMutex mJobMutex;                       // guards access to the job lists
   126     bool mStarted;                          // true when thread has been started
   133     bool mStarted;                          // true when thread has been started
   127     bool mJobLoopRunning;                   // true from when job loop event has been posted until job loop exits
   134     bool mProcessingJobs;                   // true from when job loop event has been posted until job loop exits
   128     int mPostponeJobs;                      // set to true by client if it needs the CPU
   135     int mPostponeJobs;                      // set to true by client if it needs the CPU
   129     QList<int> mInfoJobs;                   // list of all info jobs
   136     QList< QPair<int,int> > mInfoJobs;      // list of all info jobs and their priorities
   130     QList<int> mCancelledInfoJobs;          // list of all cancelled info jobs
   137     QList<int> mCancelledInfoJobs;          // list of all cancelled info jobs
   131     QList<QString> mIconJobs;               // list of all icon jobs
   138     QList< QPair<QString,int> > mIconJobs;  // list of all icon jobs and their priorities
   132     QList<QString> mCancelledIconJobs;      // list of all cancelled icon jobs
   139     QList<QString> mCancelledIconJobs;      // list of all cancelled icon jobs
   133     int mIconRequestId;                     // the id for the last request to thumbnail manager
   140     int mIconRequestId;                     // the id for the last request to thumbnail manager
   134     QString mIconRequestName;               // the name of the icon last requested from thumbnail manager
   141     QString mIconRequestName;               // the name of the icon last requested from thumbnail manager
   135 };
   142 };
   136 
   143