notepad/notepad1/LibSrc/NpdEditorDialog.cpp
branchRCL_3
changeset 21 9711e452b5e9
parent 0 f979ecb2b13e
child 36 9c5b1510919f
equal deleted inserted replaced
20:21239b3bcd78 21:9711e452b5e9
   213             savedNextKey : iKey;
   213             savedNextKey : iKey;
   214         }
   214         }
   215     if ( aNeedListRefresh )
   215     if ( aNeedListRefresh )
   216         {
   216         {
   217         iListDialog->HandleEditorExitL( statOfSave, returnKey,
   217         iListDialog->HandleEditorExitL( statOfSave, returnKey,
   218             statOfSave == CNotepadModel::ENotepadModelRowNop || 
   218             statOfSave != CNotepadModel::ENotepadModelRowNop || 
   219             iFlags & ENotepadCatchSaveOnExitCallback );
   219             iFlags & ENotepadCatchSaveOnExitCallback );
   220         }
   220         }
   221     return statOfSave;
   221     return statOfSave;
   222     }
   222     }
   223 
   223 
   386 				aMenuPane->DeleteMenuItem(EAknCmdHelp);
   386 				aMenuPane->DeleteMenuItem(EAknCmdHelp);
   387 					}
   387 					}
   388 				}
   388 				}
   389             else
   389             else
   390                 {
   390                 {
   391                 if ( IsSequenceAtLast() )
   391                 if ( IsSequenceAtLast() || iSequence->Count() == 1 )
   392                     {
   392                     {
   393                     aMenuPane->DeleteMenuItem(ENotepadCmdNextMemo);
   393                     aMenuPane->DeleteMenuItem(ENotepadCmdNextMemo);
   394                     }
   394                     }
   395                 if ( IsSequenceAtFirst() )
   395                 if ( IsSequenceAtFirst() )
   396                     {
   396                     {
   529 
   529 
   530 	switch (aCommandId)
   530 	switch (aCommandId)
   531         {
   531         {
   532 		case EAknSoftkeyExit:
   532 		case EAknSoftkeyExit:
   533 		case EAknCmdExit:
   533 		case EAknCmdExit:
   534             if ( iListDialog )
       
   535                 {
       
   536                 iListDialog->MakeVisible( EFalse );
       
   537                 } 
       
   538             TryExitL(EAknSoftkeyExit);
   534             TryExitL(EAknSoftkeyExit);
   539             iAvkonAppUi->ProcessCommandL(EAknCmdExit);
   535             iAvkonAppUi->ProcessCommandL(EAknCmdExit);
   540             break;
   536             break;
   541         case ENotepadCmdAdd:
   537         case ENotepadCmdAdd:
   542             OnCmdAddL();
   538             OnCmdAddL();
   875     else
   871     else
   876         {
   872         {
   877         if ( wasModeAdding && 
   873         if ( wasModeAdding && 
   878             rowResult == CNotepadModel::ENotepadModelRowAdded )
   874             rowResult == CNotepadModel::ENotepadModelRowAdded )
   879             {
   875             {
   880             iSequence->InsertL(0, iKey); // *never leave* because reserved
   876             if ( IsNotepad() )
       
   877             	{
       
   878                 iSequence->InsertL(1, iKey); // *never leave* because reserved
       
   879             	}
       
   880             else
       
   881             	{
       
   882                 iSequence->InsertL(0, iKey); // *never leave* because reserved
       
   883             	}
       
   884             
   881             }
   885             }
   882         else if ( savedCurrentSequence != KNotepadInvalidSequenceIndex &&
   886         else if ( savedCurrentSequence != KNotepadInvalidSequenceIndex &&
   883             ( rowResult == CNotepadModel::ENotepadModelRowAdded ||
   887             ( rowResult == CNotepadModel::ENotepadModelRowAdded ||
   884             rowResult == CNotepadModel::ENotepadModelRowUpdated ) )
   888             rowResult == CNotepadModel::ENotepadModelRowUpdated ) )
   885             {
   889             {
   922 // Of course, we must check the nextIndex so as not to exceed the total count.
   926 // Of course, we must check the nextIndex so as not to exceed the total count.
   923 // -----------------------------------------------------------------------------
   927 // -----------------------------------------------------------------------------
   924 //
   928 //
   925 void CNotepadEditorDialog::OnCmdNextMemoL()
   929 void CNotepadEditorDialog::OnCmdNextMemoL()
   926     {
   930     {
   927     TInt nextIndex(0);
   931     TInt nextIndex(1);
   928     const TBool wasModeAdding( IsModeAdding() );
   932     const TBool wasModeAdding( IsModeAdding() );
   929     if ( !wasModeAdding )
   933     if ( !wasModeAdding )
   930         {
   934         {
   931         nextIndex = CurrentSequence(); // oldIndex
   935         nextIndex = CurrentSequence(); // oldIndex
   932         }
   936         }
  1087 
  1091 
  1088     // Add entries which is newly added after previous Create/SyncSequenceL
  1092     // Add entries which is newly added after previous Create/SyncSequenceL
  1089     //
  1093     //
  1090     TInt index( 0 );
  1094     TInt index( 0 );
  1091     TKeyArrayFix cmpKeyArray(0, ECmpTInt);
  1095     TKeyArrayFix cmpKeyArray(0, ECmpTInt);
  1092     for (i = keyArray.Count() - 1; i >= 0; --i)
  1096     for (i = keyArray.Count() - 1; i >= 1; --i)
  1093         {
  1097         {
  1094         if (iSequence->Find(keyArray[i], cmpKeyArray, index) != 0)
  1098         if (iSequence->Find(keyArray[i], cmpKeyArray, index) != 0)
  1095             {
  1099             {
  1096             iSequence->InsertL(0, keyArray[i]);
  1100             iSequence->InsertL(1, keyArray[i]);
  1097             }
  1101             }
  1098         }
  1102         }
  1099     if (iKey != KNotepadPseudoKeyIdForNewNote 
  1103     if (iKey != KNotepadPseudoKeyIdForNewNote 
  1100         && iSequence->Find(iKey, cmpKeyArray, index) != 0) // not found
  1104         && iSequence->Find(iKey, cmpKeyArray, index) != 0) // not found
  1101         {
  1105         {
  1110 //
  1114 //
  1111 TBool CNotepadEditorDialog::IsSequenceAtLast() const
  1115 TBool CNotepadEditorDialog::IsSequenceAtLast() const
  1112     {
  1116     {
  1113     __ASSERT_DEBUG( iSequence, 
  1117     __ASSERT_DEBUG( iSequence, 
  1114         Panic(ENotepadLibraryPanicNullSequenceInEditor) );
  1118         Panic(ENotepadLibraryPanicNullSequenceInEditor) );
  1115     return ( IsModeAdding() ? iSequence->Count() == 0 :
  1119     return ( IsModeAdding() ? iSequence->Count() == 1 :
  1116         CurrentSequence() == iSequence->Count() - 1 );
  1120         CurrentSequence() == iSequence->Count() - 1 );
  1117     }
  1121     }
  1118 
  1122 
  1119 // -----------------------------------------------------------------------------
  1123 // -----------------------------------------------------------------------------
  1120 // CNotepadEditorDialog::IsSequenceAtFirst
  1124 // CNotepadEditorDialog::IsSequenceAtFirst
  1122 //
  1126 //
  1123 TBool CNotepadEditorDialog::IsSequenceAtFirst() const
  1127 TBool CNotepadEditorDialog::IsSequenceAtFirst() const
  1124     {
  1128     {
  1125     __ASSERT_DEBUG( iSequence, 
  1129     __ASSERT_DEBUG( iSequence, 
  1126         Panic(ENotepadLibraryPanicNullSequenceInEditor) );
  1130         Panic(ENotepadLibraryPanicNullSequenceInEditor) );
  1127     return ( IsModeAdding() || CurrentSequence() == 0);
  1131     return ( IsModeAdding() ||  CurrentSequence() == 1);
  1128     }
  1132     }
  1129 
  1133 
  1130 // -----------------------------------------------------------------------------
  1134 // -----------------------------------------------------------------------------
  1131 // CNotepadEditorDialog::CurrentSequence
  1135 // CNotepadEditorDialog::CurrentSequence
  1132 // -----------------------------------------------------------------------------
  1136 // -----------------------------------------------------------------------------
  1150     __ASSERT_DEBUG( iSequence, 
  1154     __ASSERT_DEBUG( iSequence, 
  1151         Panic(ENotepadLibraryPanicNullSequenceInEditor) );
  1155         Panic(ENotepadLibraryPanicNullSequenceInEditor) );
  1152     TInt nextKey(iKey);
  1156     TInt nextKey(iKey);
  1153     if ( iKey == KNotepadPseudoKeyIdForNewNote ) // IsModeAdding
  1157     if ( iKey == KNotepadPseudoKeyIdForNewNote ) // IsModeAdding
  1154         {
  1158         {
  1155         if ( iSequence->Count() > 0 )
  1159         if ( iSequence->Count() > 1 )
  1156             {
  1160             {
       
  1161             nextKey = (*iSequence)[1];
       
  1162             }
       
  1163         else if ( iSequence->Count() == 1 )
       
  1164         	{
  1157             nextKey = (*iSequence)[0];
  1165             nextKey = (*iSequence)[0];
  1158             }
  1166         	}
  1159         }
  1167         }
  1160     else
  1168     else
  1161         {
  1169         {
  1162         TInt index ( CurrentSequence() );
  1170         TInt index ( CurrentSequence() );
  1163         if ( index < iSequence->Count() - 1 )
  1171         if ( index < iSequence->Count() - 1 )