calendarui/editors/src/calenunifiededitor.cpp
branchRCL_3
changeset 12 38571fd2a704
parent 5 42814f902fe6
child 13 0f07cd1b5772
equal deleted inserted replaced
5:42814f902fe6 12:38571fd2a704
   163     delete iEditorDataHandler;
   163     delete iEditorDataHandler;
   164     delete iEntryUpdater;
   164     delete iEntryUpdater;
   165     delete iUnifiedEditorControl;
   165     delete iUnifiedEditorControl;
   166     
   166     
   167     iCollectionIds.Reset();
   167     iCollectionIds.Reset();
   168 
   168     
       
   169     iAsyncCallback->Cancel();
       
   170     delete iAsyncCallback;
       
   171     
   169     TRACE_EXIT_POINT;
   172     TRACE_EXIT_POINT;
   170     }
   173     }
   171 
   174 
   172 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------
   173 // CCalenUnifiedEditor::CCalenUnifiedEditor
   176 // CCalenUnifiedEditor::CCalenUnifiedEditor
   282     //iServices->EntryViewL(iServices->Context().InstanceId().iColId);
   285     //iServices->EntryViewL(iServices->Context().InstanceId().iColId);
   283 
   286 
   284     iUnifiedEditorControl = CCalenUnifiedEditorControl::NewL( *this,*iServices );
   287     iUnifiedEditorControl = CCalenUnifiedEditorControl::NewL( *this,*iServices );
   285     
   288     
   286     isReplaceLocation = EFalse;
   289     isReplaceLocation = EFalse;
       
   290     
       
   291    
       
   292     TCallBack callback(CCalenUnifiedEditor::AsyncProcessCommandL,this);
       
   293     iAsyncCallback = new(ELeave) CAsyncCallBack(callback,CActive::EPriorityStandard);
       
   294     
   287     
   295     
   288     iIdle = CIdle::NewL( CActive::EPriorityUserInput );
   296     iIdle = CIdle::NewL( CActive::EPriorityUserInput );
   289     iIdle->Start( TCallBack( KeyCallBack, this) );
   297     iIdle->Start( TCallBack( KeyCallBack, this) );
   290     iCoeEnv->AddFepObserverL( *this );
   298     iCoeEnv->AddFepObserverL( *this );
   291     
   299     
  1240                             {
  1248                             {
  1241                                 ProcessCommandL( ECalenCmdAddAttachment );
  1249                                 ProcessCommandL( ECalenCmdAddAttachment );
  1242                             }
  1250                             }
  1243                         break;
  1251                         break;
  1244                         }
  1252                         }
  1245 
  1253                        
       
  1254                     case ECalenEditorDescription:
       
  1255                         {
       
  1256 //                        CEikEdwin* edwin = static_cast<CEikEdwin*>( Control( focusControl ) );  
       
  1257 //                        if ( edwin && edwin->Text()->DocumentLength() == 0 )
       
  1258 //                            {
       
  1259 //                                ProcessCommandL( ECalenCmdAddDescription );
       
  1260 //                            }
       
  1261 //                        else
       
  1262 //                            {
       
  1263 //                                ProcessCommandL( ECalenCmdShowDescription );
       
  1264 //                            }
       
  1265                         iAsyncCallback->CallBack();
       
  1266                         break;
       
  1267                         }
       
  1268                        
  1246                     default:
  1269                     default:
  1247                         {
  1270                         {
  1248                         break;
  1271                         break;
  1249                         }
  1272                         }
  1250                     }
  1273                     }
  1272             iUnifiedEditorControl->CheckAlarmActive( active );
  1295             iUnifiedEditorControl->CheckAlarmActive( active );
  1273             TryChangeFocusToL( ECalenEditorReminder );
  1296             TryChangeFocusToL( ECalenEditorReminder );
  1274             }
  1297             }
  1275         }
  1298         }
  1276     }
  1299     }
       
  1300 
       
  1301 
       
  1302 TInt CCalenUnifiedEditor::AsyncProcessCommandL( TAny* aThisPtr )
       
  1303     {
       
  1304     TInt focusControl( static_cast<CCalenUnifiedEditor*>(aThisPtr)->IdOfFocusControl() );
       
  1305     CEikEdwin* edwin = static_cast<CEikEdwin*>( static_cast<CCalenUnifiedEditor*>(aThisPtr)->Control( focusControl ) );  
       
  1306         if ( edwin && edwin->Text()->DocumentLength() == 0 )
       
  1307             {
       
  1308             static_cast<CCalenUnifiedEditor*>(aThisPtr)->ProcessCommandL(ECalenCmdAddDescription);
       
  1309             }
       
  1310         else
       
  1311             {
       
  1312             static_cast<CCalenUnifiedEditor*>(aThisPtr)->ProcessCommandL(ECalenCmdShowDescription);
       
  1313             }
       
  1314     
       
  1315     return 0;
       
  1316     }
       
  1317 
  1277 
  1318 
  1278 // -----------------------------------------------------------------------------
  1319 // -----------------------------------------------------------------------------
  1279 //  CCalenUnifiedEditor::HandleResourceChange
  1320 //  CCalenUnifiedEditor::HandleResourceChange
  1280 //  Handdles the resource change
  1321 //  Handdles the resource change
  1281 // -----------------------------------------------------------------------------
  1322 // -----------------------------------------------------------------------------
  1523 void CCalenUnifiedEditor::TryInsertSendMenuL( TInt aResourceId, CEikMenuPane* aMenuPane )
  1564 void CCalenUnifiedEditor::TryInsertSendMenuL( TInt aResourceId, CEikMenuPane* aMenuPane )
  1524     {
  1565     {
  1525     TRACE_ENTRY_POINT;
  1566     TRACE_ENTRY_POINT;
  1526 
  1567 
  1527     // Only insert if there is some summary (or location)
  1568     // Only insert if there is some summary (or location)
  1528     if( !EditorDataHandler().AreTextFieldsEmptyL() )
  1569     // Changes done to remove Lunar calendar item from options menu
  1529         {
  1570     if( EditorDataHandler().AreTextFieldsEmptyL() )
  1530         // Insert Send menu item
  1571         {
  1531         iServices->OfferMenuPaneL( aResourceId, aMenuPane );
  1572         // Delete Send Menu item if exists
  1532         }
       
  1533     else
       
  1534         {// Delete Send Menu item if exists
       
  1535         aMenuPane->DeleteMenuItem( ECalenSend );
  1573         aMenuPane->DeleteMenuItem( ECalenSend );
  1536         }    
  1574         }    
  1537 
  1575 
  1538     TRACE_EXIT_POINT;
  1576     TRACE_EXIT_POINT;
  1539     }
  1577     }
  1979         TTime endDate = Edited().EndDateTime();
  2017         TTime endDate = Edited().EndDateTime();
  1980         
  2018         
  1981         if( startDate == CalenDateUtils::BeginningOfDay( startDate ) &&
  2019         if( startDate == CalenDateUtils::BeginningOfDay( startDate ) &&
  1982                 endDate == CalenDateUtils::BeginningOfDay( endDate ) )
  2020                 endDate == CalenDateUtils::BeginningOfDay( endDate ) )
  1983             {
  2021             {
  1984             if( CCalEntry::EAppt == Edited().EntryType() && startDate != endDate )
  2022             TTimeIntervalDays differenceInTime = endDate.DaysFrom(startDate); // fix for AllDayEntry issue
       
  2023             if( CCalEntry::EAppt == Edited().EntryType() && startDate != endDate && differenceInTime.Int() == 1 )
  1985                 {
  2024                 {
  1986                 Edited().SetEntryType( CCalEntry::EEvent );
  2025                 Edited().SetEntryType( CCalEntry::EEvent );
  1987                 }
  2026                 }
  1988             }
  2027             }
  1989         
  2028         
  2236             }
  2275             }
  2237 		}
  2276 		}
  2238     
  2277     
  2239     if(!IsCreatingNewEntry() && !iEditorDataHandler->IsCalendarEditedL())
  2278     if(!IsCreatingNewEntry() && !iEditorDataHandler->IsCalendarEditedL())
  2240         {
  2279         {
       
  2280         iServices->GetAttachmentData()->Reset();
  2241         iServices->EntryViewL(iEditorDataHandler->PreviousDbCollectionId())
  2281         iServices->EntryViewL(iEditorDataHandler->PreviousDbCollectionId())
  2242                                                 ->DeleteL(*iOriginalCalEntry);
  2282                                                 ->DeleteL(*iOriginalCalEntry);
  2243         }
  2283         }
  2244     
  2284     
  2245     TInt saveErr( KErrNone );
  2285     TInt saveErr( KErrNone );
  2266                    newInstanceEndDate,
  2306                    newInstanceEndDate,
  2267                    iUnifiedEditorControl->GetCalendarNameForEntryL() ) );
  2307                    iUnifiedEditorControl->GetCalendarNameForEntryL() ) );
  2268         }
  2308         }
  2269     if(!IsCreatingNewEntry() && iEditorDataHandler->IsCalendarEditedL())
  2309     if(!IsCreatingNewEntry() && iEditorDataHandler->IsCalendarEditedL())
  2270         {
  2310         {
       
  2311         iServices->GetAttachmentData()->Reset();
  2271         iServices->EntryViewL(iEditorDataHandler->PreviousDbCollectionId())
  2312         iServices->EntryViewL(iEditorDataHandler->PreviousDbCollectionId())
  2272                                                 ->DeleteL(*iOriginalCalEntry);
  2313                                                 ->DeleteL(*iOriginalCalEntry);
  2273         }
  2314         }
  2274     iEntryUiOutParams.iSpare = (TUint32) entry->LocalUidL();
  2315     iEntryUiOutParams.iSpare = (TUint32) entry->LocalUidL();
  2275 
  2316 
  3048     TRACE_ENTRY_POINT;
  3089     TRACE_ENTRY_POINT;
  3049     TInt attachmentCount = Edited().AttachmentCount();
  3090     TInt attachmentCount = Edited().AttachmentCount();
  3050     if( attachmentCount )
  3091     if( attachmentCount )
  3051         {
  3092         {
  3052         RPointerArray<HBufC> attachmentNames;
  3093         RPointerArray<HBufC> attachmentNames;
  3053         Edited().AttachmentNamesL(attachmentNames);
  3094         GetAttachmentNamesL(attachmentNames);
  3054         TInt attachmentCount = attachmentNames.Count();
  3095         attachmentCount = attachmentNames.Count();            
  3055         TInt attachmentLength(0);
  3096         TInt attachmentLength(0);        
  3056         for( TInt index =0; index<attachmentCount; index++ )
  3097         for( TInt index =0; index<attachmentCount; index++ )
  3057             {
  3098             {
  3058             if(index>0)
  3099             if(index>0)
  3059                 {
  3100                 {
  3060                 attachmentLength++;
  3101                 attachmentLength++;
  3338     
  3379     
  3339     Control(ECalenEditorPlace)->DrawNow();
  3380     Control(ECalenEditorPlace)->DrawNow();
  3340     
  3381     
  3341     TRACE_EXIT_POINT;   
  3382     TRACE_EXIT_POINT;   
  3342     }
  3383     }
       
  3384 
       
  3385 // -----------------------------------------------------------------------------
       
  3386 // CCalenUnifiedEditor::AttachmentNamesL
       
  3387 // Provides all the attachments names
       
  3388 // -----------------------------------------------------------------------------
       
  3389 // 
       
  3390 void CCalenUnifiedEditor::GetAttachmentNamesL(RPointerArray<HBufC>& aAttachmentNames)
       
  3391     {
       
  3392     TInt attachCount = iServices->GetAttachmentData()->NumberOfItems();
       
  3393     if( attachCount )
       
  3394         {    
       
  3395         RPointerArray<CCalenAttachmentInfo> attachmentInfoList;      
       
  3396         iServices->GetAttachmentData()->GetAttachmentListL(attachmentInfoList);
       
  3397         for( TInt index =0; index<attachCount; index++ )
       
  3398             {
       
  3399             CCalenAttachmentInfo* attachmentInfo = attachmentInfoList[index];
       
  3400             TParsePtrC fileNameParser( attachmentInfo->FileName() );
       
  3401             HBufC* attachmentName = HBufC::NewL(fileNameParser.NameAndExt().Length());
       
  3402             attachmentName->Des().Copy(fileNameParser.NameAndExt());
       
  3403             aAttachmentNames.Append(attachmentName);
       
  3404             }
       
  3405         }
       
  3406     else
       
  3407         {
       
  3408         Edited().AttachmentNamesL(aAttachmentNames);
       
  3409         }
       
  3410     }
  3343 	
  3411 	
  3344 // -----------------------------------------------------------------------------
  3412 // -----------------------------------------------------------------------------
  3345 // CMapsIconPicture::CMapsIconPicture
  3413 // CMapsIconPicture::CMapsIconPicture
  3346 // C++ Constructor
  3414 // C++ Constructor
  3347 // -----------------------------------------------------------------------------
  3415 // -----------------------------------------------------------------------------