498 { |
498 { |
499 if( aSqlQuery[i]->Type() == CCaSqlQuery::EIconTable ) |
499 if( aSqlQuery[i]->Type() == CCaSqlQuery::EIconTable ) |
500 { |
500 { |
501 //check if icon exists - just update |
501 //check if icon exists - just update |
502 CCaSqlQuery* query = CCaSqlQuery::NewLC( iSqlDb ); |
502 CCaSqlQuery* query = CCaSqlQuery::NewLC( iSqlDb ); |
503 query->SetQueryL( KSQLGetIconId ); |
503 CaSqlQueryCreator::CreateFindIconQueryL(aEntry, query); |
504 query->SetTableType( CCaSqlQuery::EIconTable ); |
504 query->SetTableType( CCaSqlQuery::EIconTable ); |
505 query->PrepareL(); |
505 query->PrepareL(); |
506 query->BindValuesForGetIconL( aEntry ); |
506 query->BindValuesForGetIconL( aEntry ); |
507 CCaInnerEntry::TIconAttributes iconAttributes; |
507 TInt idIcon( 0 ); |
508 TInt countIcons = query->ExecuteL( iconAttributes ); |
508 query->ExecuteL( idIcon ); |
509 CleanupStack::PopAndDestroy( query ); |
509 CleanupStack::PopAndDestroy( query ); |
510 |
510 |
511 aSqlQuery[i]->PrepareL(); |
511 aSqlQuery[i]->PrepareL(); |
512 aSqlQuery[i]->BindValuesForAddL( aEntry ); |
512 aSqlQuery[i]->BindValuesForAddL( aEntry ); |
513 TInt tmpId( 0 ); |
513 TInt tmpId( 0 ); |
514 TRAPD( err, tmpId = aSqlQuery[i]->ExecuteL() ); |
514 TRAPD( err, tmpId = aSqlQuery[i]->ExecuteL() ); |
515 aSqlQuery[i]->CloseStatement(); |
515 aSqlQuery[i]->CloseStatement(); |
516 if( !countIcons && !aEntry->GetIconId() ) |
516 if( !idIcon && !aEntry->GetIconId() ) |
517 { // new icon added |
517 { // new icon added |
518 aEntry->SetIconId( tmpId ); |
518 aEntry->SetIconId( tmpId ); |
519 } |
519 } |
520 |
|
521 if( err == KSqlErrConstraint ) |
520 if( err == KSqlErrConstraint ) |
522 { |
521 { |
523 // ignore, this means that the icon cannot be removed |
522 // ignore, this means that the icon cannot be removed |
524 // because some other entry has the same icon. |
523 // because some other entry has the same icon. |
525 } |
524 } |