phonebookui/pbkcommonui/src/cntcollectionlistmodelworker.cpp
changeset 59 a642906a277a
parent 47 7cbcb2896f0e
child 66 554fe4dbbb59
equal deleted inserted replaced
47:7cbcb2896f0e 59:a642906a277a
   107 
   107 
   108     return QThread::event(event);
   108     return QThread::event(event);
   109 }
   109 }
   110 
   110 
   111 /*!
   111 /*!
   112     Schedule an asynch job for the given row (model) and contact id.
   112     Schedule an asynch job for the given contact id.
   113 
   113 
   114     \param row the row in the model
   114     \param id the QContactLocalId of the group
   115     \param id the QContactLocalId of the group in the given row
   115 */
   116 */
   116 void CntCollectionListModelWorker::scheduleJob(int id)
   117 void CntCollectionListModelWorker::scheduleJob(int row, int id)
       
   118 {
   117 {
   119     CNT_ENTRY
   118     CNT_ENTRY
   120     
   119     
   121     mMutex.lock();
   120     mMutex.lock();
   122 
   121 
   132         // new job => start processing jobs
   131         // new job => start processing jobs
   133         mProcessingJobs = true;
   132         mProcessingJobs = true;
   134         HbApplication::instance()->postEvent(this, new QEvent(QEvent::User));
   133         HbApplication::instance()->postEvent(this, new QEvent(QEvent::User));
   135     }
   134     }
   136 
   135 
   137     mJobs.append(QPair<int,int>(row, id));
   136     mJobs.append(id);
   138     
   137     
   139     mMutex.unlock();
   138     mMutex.unlock();
   140     
   139     
   141     CNT_EXIT
   140     CNT_EXIT
   142 }
   141 }
   161             break;
   160             break;
   162         }
   161         }
   163         else
   162         else
   164         {
   163         {
   165             // get next job
   164             // get next job
   166             QPair<int,int> pair = mJobs.takeFirst();
   165             int id = mJobs.takeFirst();
   167             int row = pair.first;
       
   168             int id = pair.second;
       
   169 
   166 
   170             mMutex.unlock();
   167             mMutex.unlock();
   171             fetchInformation(row, id);
   168             fetchInformation(id);
   172         }
   169         }
   173 
   170 
   174         HbApplication::processEvents();
   171         HbApplication::processEvents();
   175     }
   172     }
   176     
   173     
   180 /*!
   177 /*!
   181     Fetch the second row text (member names or placeholder text if no members exist)
   178     Fetch the second row text (member names or placeholder text if no members exist)
   182     and the amount of contacts in the group. Emits the result as a signal for
   179     and the amount of contacts in the group. Emits the result as a signal for
   183     CntCollectionListModel to handle.
   180     CntCollectionListModel to handle.
   184 
   181 
   185     \param row the row in the model
       
   186     \param id the QContactLocalId of the group in the given row
   182     \param id the QContactLocalId of the group in the given row
   187 */
   183 */
   188 void CntCollectionListModelWorker::fetchInformation(int row, int id)
   184 void CntCollectionListModelWorker::fetchInformation(int id)
   189 {
   185 {
   190     CNT_ENTRY
   186     CNT_ENTRY
   191     
   187     
   192     if (!mManager)
   188     if (!mManager)
   193     {
   189     {
   236     {
   232     {
   237         QStringList nameList;
   233         QStringList nameList;
   238         for(int i = 0;i < groupMemberIds.count();i++)
   234         for(int i = 0;i < groupMemberIds.count();i++)
   239         {
   235         {
   240             QContactFetchHint nameOnlyFetchHint;
   236             QContactFetchHint nameOnlyFetchHint;
   241             QStringList details;
   237             /*QStringList details;
   242             details << QContactDisplayLabel::DefinitionName;
   238             details << QContactDisplayLabel::DefinitionName;
   243             nameOnlyFetchHint.setDetailDefinitionsHint(details);
   239             nameOnlyFetchHint.setDetailDefinitionsHint(details);*/
   244             nameOnlyFetchHint.setOptimizationHints(QContactFetchHint::NoRelationships);
   240             nameOnlyFetchHint.setOptimizationHints(QContactFetchHint::NoRelationships);
   245 
   241 
   246             QContact contact = mManager->contact(groupMemberIds.at(i), nameOnlyFetchHint);
   242             QContact contact = mManager->contact(groupMemberIds.at(i), nameOnlyFetchHint);
   247             QString memberName = contact.displayLabel();
   243             QString memberName = contact.displayLabel();
   248             if (memberName.isEmpty())
   244             if (memberName.isEmpty())
   273         {
   269         {
   274             secondLineText = mNoMembers;
   270             secondLineText = mNoMembers;
   275         }
   271         }
   276     }
   272     }
   277 
   273 
   278     emit fetchDone(row, secondLineText, memberCount);
   274     emit fetchDone(id, secondLineText, memberCount);
   279     
   275     
   280     CNT_EXIT
   276     CNT_EXIT
   281 }
   277 }
   282 
   278