qtmobility/src/contacts/engines/qcontactmemorybackend.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
child 15 1f895d8a5b2b
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
   291 }
   291 }
   292 
   292 
   293 /*! \reimp */
   293 /*! \reimp */
   294 bool QContactMemoryEngine::saveContacts(QList<QContact>* contacts, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error)
   294 bool QContactMemoryEngine::saveContacts(QList<QContact>* contacts, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error)
   295 {
   295 {
   296     if(errorMap) {
       
   297         errorMap->clear();
       
   298     }
       
   299 
       
   300     if (!contacts) {
   296     if (!contacts) {
   301         *error = QContactManager::BadArgumentError;
   297         *error = QContactManager::BadArgumentError;
   302         return false;
   298         return false;
   303     }
   299     }
   304 
   300 
   307     QContactManager::Error operationError = QContactManager::NoError;
   303     QContactManager::Error operationError = QContactManager::NoError;
   308     for (int i = 0; i < contacts->count(); i++) {
   304     for (int i = 0; i < contacts->count(); i++) {
   309         current = contacts->at(i);
   305         current = contacts->at(i);
   310         if (!saveContact(&current, changeSet, error)) {
   306         if (!saveContact(&current, changeSet, error)) {
   311             operationError = *error;
   307             operationError = *error;
   312             errorMap->insert(i, operationError);
   308             if (errorMap)
       
   309                 errorMap->insert(i, operationError);
   313         } else {
   310         } else {
   314             (*contacts)[i] = current;
   311             (*contacts)[i] = current;
   315         }
   312         }
   316     }
   313     }
   317 
   314 
   374     QContactManager::Error operationError = QContactManager::NoError;
   371     QContactManager::Error operationError = QContactManager::NoError;
   375     for (int i = 0; i < contactIds.count(); i++) {
   372     for (int i = 0; i < contactIds.count(); i++) {
   376         current = contactIds.at(i);
   373         current = contactIds.at(i);
   377         if (!removeContact(current, changeSet, error)) {
   374         if (!removeContact(current, changeSet, error)) {
   378             operationError = *error;
   375             operationError = *error;
   379             errorMap->insert(i, operationError);
   376             if (errorMap)
       
   377                 errorMap->insert(i, operationError);
   380         }
   378         }
   381     }
   379     }
   382 
   380 
   383     *error = operationError;
   381     *error = operationError;
   384     d->emitSharedSignals(&changeSet);
   382     d->emitSharedSignals(&changeSet);
   688             QContactFetchRequest* r = static_cast<QContactFetchRequest*>(currentRequest);
   686             QContactFetchRequest* r = static_cast<QContactFetchRequest*>(currentRequest);
   689             QContactFilter filter = r->filter();
   687             QContactFilter filter = r->filter();
   690             QList<QContactSortOrder> sorting = r->sorting();
   688             QList<QContactSortOrder> sorting = r->sorting();
   691             QContactFetchHint fetchHint = r->fetchHint();
   689             QContactFetchHint fetchHint = r->fetchHint();
   692 
   690 
   693             QContactManager::Error operationError;
   691             QContactManager::Error operationError = QContactManager::NoError;
   694             QList<QContact> requestedContacts = contacts(filter, sorting, fetchHint, &operationError);
   692             QList<QContact> requestedContacts = contacts(filter, sorting, fetchHint, &operationError);
   695 
   693 
   696             // update the request with the results.
   694             // update the request with the results.
   697             if (!requestedContacts.isEmpty() || operationError != QContactManager::NoError)
   695             if (!requestedContacts.isEmpty() || operationError != QContactManager::NoError)
   698                 updateContactFetchRequest(r, requestedContacts, operationError, QContactAbstractRequest::FinishedState);
   696                 updateContactFetchRequest(r, requestedContacts, operationError, QContactAbstractRequest::FinishedState);