equal
deleted
inserted
replaced
77 iDbView.Close(); |
77 iDbView.Close(); |
78 iKeyArray.Close(); //delete iKeyArray; |
78 iKeyArray.Close(); //delete iKeyArray; |
79 delete iItemArray; |
79 delete iItemArray; |
80 delete iTimeFormat; |
80 delete iTimeFormat; |
81 delete iDateFormat; |
81 delete iDateFormat; |
|
82 if ( iFixedFirstNote ) |
|
83 { |
|
84 delete iFixedFirstNote; |
|
85 } |
82 } |
86 } |
83 |
87 |
84 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
85 // CNotepadModel::AddContentL |
89 // CNotepadModel::AddContentL |
86 // API. CNotepadApi call this. |
90 // API. CNotepadApi call this. |
346 CNotepadCoreModel::ConstructL(rr.ReadInt32()); // LLINK data_file |
350 CNotepadCoreModel::ConstructL(rr.ReadInt32()); // LLINK data_file |
347 iListingStyle |
351 iListingStyle |
348 = rr.ReadInt16(); // WORD listing_style; |
352 = rr.ReadInt16(); // WORD listing_style; |
349 TInt dateResId(rr.ReadInt32()); // LLINK date_format |
353 TInt dateResId(rr.ReadInt32()); // LLINK date_format |
350 TInt timeResId(rr.ReadInt32()); // LLINK time_format |
354 TInt timeResId(rr.ReadInt32()); // LLINK time_format |
|
355 TInt firstNoteResId(rr.ReadInt32()); // LLINK first_note; |
351 CleanupStack::PopAndDestroy(); // rr |
356 CleanupStack::PopAndDestroy(); // rr |
352 if (dateResId) |
357 if (dateResId) |
353 { |
358 { |
354 iDateFormat = iEnv->AllocReadResourceL(dateResId); |
359 iDateFormat = iEnv->AllocReadResourceL(dateResId); |
355 } |
360 } |
356 if (timeResId) |
361 if (timeResId) |
357 { |
362 { |
358 iTimeFormat = iEnv->AllocReadResourceL(timeResId); |
363 iTimeFormat = iEnv->AllocReadResourceL(timeResId); |
359 } |
364 } |
|
365 if ( firstNoteResId ) |
|
366 { |
|
367 iFixedFirstNote = iEnv->AllocReadResourceL( firstNoteResId ); |
|
368 } |
360 iItemArray = new(ELeave) CDesCArrayFlat(KNotepadItemArrayGranularity); |
369 iItemArray = new(ELeave) CDesCArrayFlat(KNotepadItemArrayGranularity); |
361 iDatabaseChangeNotifier = |
370 iDatabaseChangeNotifier = |
362 CNotepadModel::CDatabaseChangeNotifier::NewL(iDatabase, *this); |
371 CNotepadModel::CDatabaseChangeNotifier::NewL(iDatabase, *this); |
363 |
372 |
364 SyncL(ETrue); |
373 SyncL(ETrue); |
612 iModelObserver->HandleNotepadModelEventL( |
621 iModelObserver->HandleNotepadModelEventL( |
613 MNotepadModelObserver::EStartItemArrayChange ); |
622 MNotepadModelObserver::EStartItemArrayChange ); |
614 } |
623 } |
615 iItemArray->Reset(); |
624 iItemArray->Reset(); |
616 iKeyArray.Reset(); |
625 iKeyArray.Reset(); |
|
626 //insert the New note as the firt note |
|
627 if ( iFixedFirstNote != NULL ) |
|
628 { |
|
629 TBuf<256> buf; |
|
630 _LIT( KBlankSpace, " " ); |
|
631 buf.Append( KBlankSpace ); |
|
632 buf.Append( KColumnListSeparator ); |
|
633 buf.Append( *iFixedFirstNote ); |
|
634 iItemArray->AppendL( buf ); |
|
635 //default key for New note, -2 is never used for normal keys. |
|
636 iKeyArray.Append( -2 ); |
|
637 } |
|
638 |
|
639 |
617 TRAPD( err, DoBuildItemArrayL() ); |
640 TRAPD( err, DoBuildItemArrayL() ); |
618 if ( err != KErrNone) |
641 if ( err != KErrNone) |
619 { |
642 { |
620 iItemArray->Reset(); |
643 iItemArray->Reset(); |
621 iKeyArray.Reset(); |
644 iKeyArray.Reset(); |
710 break; |
733 break; |
711 } |
734 } |
712 |
735 |
713 TPtrC thisText = |
736 TPtrC thisText = |
714 aBuf.Mid(textOffset).Left(KNotepadMaxCharactersForSort); |
737 aBuf.Mid(textOffset).Left(KNotepadMaxCharactersForSort); |
715 if ( iItemArray->Count() == 0 || |
738 if ( (iItemArray->Count() == 0 && iFixedFirstNote == NULL) || (iItemArray->Count() == 1 && iFixedFirstNote != NULL) || |
716 dateTime.Day() != prevDateTime.Day() || |
739 dateTime.Day() != prevDateTime.Day() || |
717 dateTime.Month() != prevDateTime.Month() || |
740 dateTime.Month() != prevDateTime.Month() || |
718 dateTime.Year() != prevDateTime.Year() ) |
741 dateTime.Year() != prevDateTime.Year() ) |
719 { |
742 { |
720 // first entry or date of the item has changed |
743 // first entry or date of the item has changed |
721 firstIndexOfTheDay = iItemArray->Count(); |
744 firstIndexOfTheDay = iItemArray->Count(); |
|
745 |
722 textArrayOfTheDay.Reset(); |
746 textArrayOfTheDay.Reset(); |
723 if ( isToday ) |
747 if ( isToday ) |
724 { |
748 { |
725 User::LeaveIfError(minutesArrayOfToday.Append(minutesInToday)); |
749 User::LeaveIfError(minutesArrayOfToday.Append(minutesInToday)); |
726 } |
750 } |