calendarui/controller/src/calenmultidbeditor.cpp
branchRCL_3
changeset 66 bd7edf625bdd
child 67 1539a383d7b6
child 78 356f28cd5ca0
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Include common routine for each note editor.
       
    15  *                For example, handling menu, key event, error handling etc.
       
    16  *
       
    17 */
       
    18 
       
    19 #include <AknColourSelectionGrid.h>
       
    20 #include <eikrted.h>
       
    21 #include <aknnotewrappers.h>
       
    22 #include <bldvariant.hrh>
       
    23 #include <coeaui.h>
       
    24 #include <eikcapc.h>
       
    25 #include <eikedwin.h>
       
    26 #include <StringLoader.h>
       
    27 #include <aknnavi.h>
       
    28 #include <txtrich.h>
       
    29 #include <hlplch.h>
       
    30 #include <calcalendarinfo.h>
       
    31 #include <Calendar.rsg>
       
    32 #include <calencommonui.rsg>
       
    33 #include <sysutil.h>
       
    34 #include <ErrorUI.h>
       
    35 
       
    36 #include "calenmultidbeditor.h"
       
    37 #include "calendarui_debug.h"
       
    38 #include "calendar.hrh"
       
    39 #include "calentitlepane.h"
       
    40 #include "calencontroller.h"
       
    41 #include "calenmultipledbui.h"
       
    42 
       
    43 // Constants.
       
    44 const TUint16 KIllegalChars[] = {
       
    45     '<', '>', '"', '/', '//', '|', ':', '*', '?',
       
    46     0xFF02, // Full width quote
       
    47     0xFF0A, // Full width asterisk
       
    48     0xFF0F, // Full width slash
       
    49     0xFF1A, // Full width colon
       
    50     0xFF1C, // Full width left arrow
       
    51     0xFF1E, // Full width right arrow
       
    52     0xFF1F, // Full width question mark
       
    53     0xFF3C, // Full width back slash
       
    54     0xFF5C, // Full width pipe
       
    55     0x201C, // Left quote
       
    56     0x201D, // Right quote
       
    57     0x201F, // Reversed quote
       
    58     0x21B2, // Downwards arrow with tip leftwards
       
    59     0, // Array terminator
       
    60 };
       
    61 const TInt KCalenMaxELAFTextEditorLength(256);
       
    62 const TInt KOne( 1 );
       
    63 const TInt KBuffLength ( 16 );
       
    64 const TInt KTen( 10 );
       
    65 
       
    66 // Literals.
       
    67 _LIT( KFormatStringTwoDigit, "%02d" );
       
    68 _LIT( KFormatString, "%d" );
       
    69 
       
    70 // ================= MEMBER FUNCTIONS =======================
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // CCalenMultiDBEditor::NewL
       
    74 // Two-phased constructor.
       
    75 // ----------------------------------------------------------------------------
       
    76 // 
       
    77 CCalenMultiDBEditor* CCalenMultiDBEditor::NewL(
       
    78         CCalenMultipleDbUi& aMultipleDbui, CCalCalendarInfo& aCalendarInfo,
       
    79         CCalenController& aController, TBool aEditFlag)
       
    80     {
       
    81     TRACE_ENTRY_POINT;
       
    82 
       
    83     CCalenMultiDBEditor* self = new (ELeave) CCalenMultiDBEditor(
       
    84             aMultipleDbui, aCalendarInfo, aController, aEditFlag);
       
    85     CleanupStack::PushL(self);
       
    86     self->ConstructL();
       
    87     CleanupStack::Pop(self);
       
    88 
       
    89     TRACE_EXIT_POINT;
       
    90     return self;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CCalenMultiDBEditor::~CCalenMultiDBEditor
       
    95 // Destructor.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 CCalenMultiDBEditor::~CCalenMultiDBEditor()
       
    99     {
       
   100     TRACE_ENTRY_POINT; 
       
   101     
       
   102     if(iRgbColors)
       
   103         {
       
   104         iRgbColors->Reset();
       
   105         delete iRgbColors;
       
   106         iRgbColors = NULL;
       
   107         }
       
   108     
       
   109     if(iCalendarName)
       
   110         {
       
   111         delete iCalendarName;
       
   112         iCalendarName = NULL;
       
   113         }
       
   114     
       
   115     if( iNaviContainer )
       
   116         {
       
   117         iNaviContainer->Pop(); // Remove navi pane used by settings view
       
   118         iNaviContainer = NULL; // iNaviContainer is not owned
       
   119         }
       
   120     TRACE_EXIT_POINT;
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CCalenMultiDBEditor::CCalenMultiDBEditor
       
   125 // C++ constructor can NOT contain any code, that might leave.
       
   126 // This overload is used when the repeat type is known.
       
   127 // (other items were commented in a header).
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 CCalenMultiDBEditor::CCalenMultiDBEditor(CCalenMultipleDbUi& aMultipleDbui,
       
   131         CCalCalendarInfo& aCalendarInfo, CCalenController& aController,
       
   132         TBool aEditFlag) :
       
   133             iCalendarInfo(aCalendarInfo), iController(
       
   134             aController), iEditFlag(aEditFlag),
       
   135 			iMultipleDbUi(aMultipleDbui)
       
   136     {
       
   137     TRACE_ENTRY_POINT;
       
   138     
       
   139     iCalendarStatus = ECalenMultiDbVisible;
       
   140 
       
   141     TRACE_EXIT_POINT;
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CCalenMultiDBEditor::ConstructL
       
   146 // Leaving construction common to all editors.
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CCalenMultiDBEditor::ConstructL()
       
   151      {
       
   152     TRACE_ENTRY_POINT;
       
   153     
       
   154     iConflict = CCalenMultiDBEditor::EConflictNone;
       
   155     
       
   156     CAknDialog::ConstructL( R_CALEN_MULTIDB_MENUBAR );  // superclass
       
   157     SetTitlePaneL();
       
   158     iCalendarName = HBufC::NewL(KCalenMaxELAFTextEditorLength); 
       
   159         
       
   160     //Initial color value
       
   161     iColVal = iCalendarInfo.Color().Value();  
       
   162     iChoosenColor = TRgb(iColVal);
       
   163         
       
   164     iPicture = new( ELeave )CDbColorPicture( TSize( 0, 0 ) );
       
   165     iPicture->SetRgbColorsL(iChoosenColor);
       
   166     
       
   167     
       
   168     
       
   169     LoadColorsL();
       
   170     
       
   171     TRACE_EXIT_POINT;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CCalenMultiDBEditor::LoadColorsL
       
   176 // (other items were commented in a header).
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 void CCalenMultiDBEditor::LoadColorsL()
       
   180     {
       
   181     TRACE_ENTRY_POINT
       
   182     
       
   183     if(iRgbColors)
       
   184         {
       
   185         iRgbColors->Reset();
       
   186         delete iRgbColors;
       
   187         iRgbColors = NULL;
       
   188         }
       
   189     
       
   190     iRgbColors = new(ELeave) CArrayFixFlat<TRgb>(2);
       
   191     
       
   192     iRgbColors->AppendL(KCalenDarkBlue);
       
   193     iRgbColors->AppendL(KCalenDarkGreen);
       
   194     iRgbColors->AppendL(KCalenDarkRed);
       
   195     iRgbColors->AppendL(KCalenMegenta);
       
   196     iRgbColors->AppendL(KCalenBlue);
       
   197     iRgbColors->AppendL(KCalenGreen);
       
   198     iRgbColors->AppendL(KCalenOrange);
       
   199     iRgbColors->AppendL(KCalenlightMagenta);
       
   200     iRgbColors->AppendL(KCalenCyan);
       
   201     iRgbColors->AppendL(KCalenlightGreen);
       
   202     iRgbColors->AppendL(KCalenYellow);
       
   203     iRgbColors->AppendL(KCalenlightPink);
       
   204     iRgbColors->AppendL(KCalenlightBlue);
       
   205     iRgbColors->AppendL(KCalenGold);
       
   206     iRgbColors->AppendL(KCalenDarkOrange);
       
   207     iRgbColors->AppendL(KCalenPink);
       
   208     
       
   209     TRACE_EXIT_POINT
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CCalenMultiDBEditor::ProcessCommandL
       
   214 // Process commands from the user.
       
   215 // (other items were commented in a header).
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 void CCalenMultiDBEditor::ProcessCommandL( TInt aCommandId )
       
   219     {
       
   220     TRACE_ENTRY_POINT;
       
   221     
       
   222     HideMenu();
       
   223     
       
   224     switch(aCommandId)
       
   225 	    {
       
   226 	    case ECalenMultiDbHelp:
       
   227 			{
       
   228 			HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   229                                 		(iEikonEnv->AppUi())->AppHelpContextL ());
       
   230 			}
       
   231 			break;
       
   232 		case EAknCmdExit:
       
   233 		case EAknSoftkeyExit:
       
   234 			{
       
   235 			TryExitL( EAknSoftkeyExit );			
       
   236 			}
       
   237 			break;
       
   238 			
       
   239 		case EAknSoftkeyChange:
       
   240 		    {
       
   241 			if( ECalenMultiDbHiddenVisible == IdOfFocusControl() )
       
   242 		        {
       
   243 		        iCalendarStatus = iCalendarInfo.Enabled();
       
   244 
       
   245 		        if( ECalenMultiDbHidden == iCalendarStatus  )
       
   246 		            {
       
   247 		            SetVisiblityFieldL( ECalenMultiDbVisible ); 
       
   248 		            iCalendarStatus = ECalenMultiDbVisible;
       
   249 		            iCalendarInfo.SetEnabled(iCalendarStatus);
       
   250 		            }
       
   251 		        else
       
   252 		            {
       
   253 		            SetVisiblityFieldL( ECalenMultiDbHidden );
       
   254 		            iCalendarStatus = ECalenMultiDbHidden;
       
   255 		            iCalendarInfo.SetEnabled(iCalendarStatus);
       
   256 		            }
       
   257 		        }
       
   258 		    else if ( ECalenMultiDbColor == IdOfFocusControl() )
       
   259 		        {
       
   260 		        GetColorL();
       
   261 		        }
       
   262 		    }
       
   263 		    break; 
       
   264 
       
   265 		case EAknSoftkeyOpen:
       
   266 		    {
       
   267 		    GetColorL();
       
   268 		    } 
       
   269 		    break;
       
   270 			
       
   271 		default:
       
   272 		    {
       
   273 		    // No implementation yet.
       
   274 		    }
       
   275 		    break;
       
   276 		}
       
   277     
       
   278 	TRACE_EXIT_POINT;
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CCalenMultiDBEditor::HandleEditCommandL
       
   283 // Process commands from the user.
       
   284 // (other items were commented in a header).
       
   285 // -----------------------------------------------------------------------------
       
   286 //    
       
   287  void CCalenMultiDBEditor::HandleEditCommandL()
       
   288    {
       
   289    switch(IdOfFocusControl())
       
   290        {
       
   291        case ECalenMultiDbColor:
       
   292           {
       
   293           GetColorL();
       
   294           }
       
   295           break;
       
   296 	  default:
       
   297            {
       
   298            // No implementation yet.
       
   299            }
       
   300           break;
       
   301        }
       
   302    } 
       
   303  
       
   304 
       
   305  // -----------------------------------------------------------------------------
       
   306  // CCalenMultiDBEditor::SetConflict
       
   307  // (other items were commented in a header).
       
   308  // -----------------------------------------------------------------------------
       
   309  // 
       
   310 void CCalenMultiDBEditor::SetConflict(TCalendarConflicts aConflict)
       
   311     {
       
   312     TRACE_ENTRY_POINT
       
   313     iConflict = aConflict;
       
   314     TRACE_EXIT_POINT
       
   315     }
       
   316 
       
   317 // -----------------------------------------------------------------------------
       
   318 // CCalenMultiDBEditor::Conflict
       
   319 // (other items were commented in a header).
       
   320 // -----------------------------------------------------------------------------
       
   321 // 
       
   322 CCalenMultiDBEditor::TCalendarConflicts CCalenMultiDBEditor::Conflict() const
       
   323     {
       
   324     TRACE_ENTRY_POINT
       
   325     TRACE_EXIT_POINT
       
   326     return iConflict;
       
   327     }
       
   328  
       
   329  // -----------------------------------------------------------------------------
       
   330  // CCalenMultiDBEditor::HandleNotification
       
   331  // (other items were commented in a header).
       
   332  // -----------------------------------------------------------------------------
       
   333  // 
       
   334        
       
   335 // -----------------------------------------------------------------------------
       
   336 // CCalenMultiDBEditor::OkToExitL
       
   337 // Handle CBA-key on a form.
       
   338 // (other items were commented in a header).
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 TBool CCalenMultiDBEditor::OkToExitL(TInt aButtonId)
       
   342     {
       
   343     TRACE_ENTRY_POINT;
       
   344     TBool isExitForm(EFalse);
       
   345     
       
   346     switch(aButtonId)
       
   347         {
       
   348         case EAknSoftkeyOpen:
       
   349             {
       
   350             GetColorL();
       
   351             } 
       
   352             break;
       
   353             
       
   354         case EAknSoftkeyOptions:
       
   355             {
       
   356             DisplayMenuL();
       
   357             isExitForm = EFalse;
       
   358             }
       
   359             break;
       
   360             
       
   361         case EAknSoftkeyChange:
       
   362             {
       
   363             isExitForm=EFalse;
       
   364 			if( ECalenMultiDbHiddenVisible == IdOfFocusControl() )
       
   365 				{
       
   366                 iCalendarStatus = iCalendarInfo.Enabled();
       
   367 
       
   368                 if( ECalenMultiDbHidden == iCalendarStatus )
       
   369                     {
       
   370                     SetVisiblityFieldL( ECalenMultiDbVisible ); 
       
   371                     iCalendarStatus = ECalenMultiDbVisible;
       
   372                     iCalendarInfo.SetEnabled(iCalendarStatus);
       
   373                     }
       
   374                 else
       
   375                     {
       
   376                     SetVisiblityFieldL( ECalenMultiDbHidden );
       
   377                     iCalendarStatus = ECalenMultiDbHidden;
       
   378                     iCalendarInfo.SetEnabled(iCalendarStatus);
       
   379                     }
       
   380                 }
       
   381             else if ( ECalenMultiDbColor == IdOfFocusControl() )
       
   382                 {
       
   383                 GetColorL();
       
   384                 }
       
   385             }
       
   386             break;    
       
   387             
       
   388         case EAknSoftkeyDone:
       
   389             {
       
   390             isExitForm = SaveNoteL(aButtonId);
       
   391             if (isExitForm)
       
   392                 {
       
   393                 TInt err = iMultipleDbUi.UpdateOnAddOrEditL(!iEditFlag);
       
   394                 if (err != KErrNone)
       
   395                     {
       
   396                     ShowErrorNoteL(err);
       
   397                     }
       
   398                 }
       
   399             }
       
   400             break;
       
   401         case EAknSoftkeyExit:    
       
   402         case EAknCmdExit:
       
   403             {
       
   404             isExitForm = SaveNoteL(aButtonId);
       
   405             if (isExitForm)
       
   406                 {
       
   407                 TInt err = iMultipleDbUi.UpdateOnAddOrEditL(!iEditFlag);
       
   408                 if (err != KErrNone)
       
   409                     {
       
   410                     ShowErrorNoteL(err);
       
   411                     }
       
   412                 }
       
   413             isExitForm = ETrue;
       
   414             iMultipleDbUi.ExitDialogL();
       
   415             }
       
   416             break;
       
   417         case EAknSoftkeyQuit:
       
   418             {
       
   419             isExitForm = ETrue;
       
   420             }
       
   421             break;
       
   422         default:
       
   423             {
       
   424             isExitForm=CAknForm::OkToExitL(aButtonId);
       
   425             }
       
   426             break;
       
   427         }
       
   428     TRACE_EXIT_POINT;
       
   429     
       
   430     return isExitForm;
       
   431     }
       
   432 
       
   433 // -----------------------------------------------------------------------------
       
   434 // CCalenMultiDBEditor::OfferKeyEventL
       
   435 // Passes key events to MsgEditorView to enable scrolling.
       
   436 // (other items were commented in a header).
       
   437 // -----------------------------------------------------------------------------
       
   438 TKeyResponse CCalenMultiDBEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   439     {
       
   440     TRACE_ENTRY_POINT;
       
   441     TKeyResponse keyResponse(EKeyWasNotConsumed);
       
   442 
       
   443     if (aType == EEventKey)
       
   444        {
       
   445        switch (aKeyEvent.iCode)
       
   446         	{
       
   447         	case EKeyEscape:
       
   448 			    TryExitL( EAknCmdExit );
       
   449         		keyResponse = EKeyWasConsumed;
       
   450         		break;
       
   451           	default:
       
   452            		keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType);    
       
   453               	break;
       
   454             }
       
   455        }
       
   456     else
       
   457         {
       
   458         // Swallow all other keyevents to prevent the active container processing them.
       
   459         keyResponse = EKeyWasConsumed;        
       
   460         }        
       
   461     TRACE_EXIT_POINT;
       
   462     return keyResponse;
       
   463     }
       
   464 
       
   465 // -----------------------------------------------------------------------------
       
   466 // CCalenMultiDBEditor::PreLayoutDynInitL()
       
   467 // Updates fields just before the form is shown.
       
   468 // (other items were commented in a header).
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 void CCalenMultiDBEditor::PreLayoutDynInitL()
       
   472     {
       
   473     TRACE_ENTRY_POINT;
       
   474     
       
   475     
       
   476     
       
   477     // Set data to controls in the editor.
       
   478     SetDataToFormL();
       
   479     
       
   480     TRACE_EXIT_POINT;
       
   481     }
       
   482 	
       
   483 // -----------------------------------------------------------------------------
       
   484 // CCalenMultiDBEditor::SetDataToFormL()
       
   485 // Reads data from the entry and updates the form with the appropriate values.
       
   486 // (other items were commented in a header).
       
   487 // -----------------------------------------------------------------------------
       
   488 //
       
   489 void CCalenMultiDBEditor::SetDataToFormL()
       
   490     {
       
   491     TRACE_ENTRY_POINT;
       
   492     //First filed "Name" of the Form
       
   493     CEikEdwin* edwin =
       
   494         reinterpret_cast<CEikEdwin*>(Control(ECalenMultiDbName));
       
   495    
       
   496     if( edwin )
       
   497         {
       
   498         edwin->SetTextLimit(KCalenMaxELAFTextEditorLength);
       
   499         edwin->SetSelectionL( edwin->TextLength(), 0 );
       
   500         }
       
   501 
       
   502     SetEditableL(ETrue);
       
   503     Line(ECalenMultiDbName)->SetFocus(ETrue);
       
   504     Line(ECalenMultiDbName)->ActivateL();
       
   505     
       
   506     HBufC* calendarName = iCalendarInfo.NameL().AllocLC();
       
   507     
       
   508     // Check for the empty text.
       
   509     if( ( !calendarName->Size() ) )
       
   510         {   
       
   511         CleanupStack::PopAndDestroy(calendarName);
       
   512         TInt index( KOne );
       
   513         calendarName = StringLoader::LoadLC( R_CALE_DB_CALENDAR );
       
   514         TBuf< KBuffLength > numBuf;
       
   515 
       
   516         // Check if name is already there or not.
       
   517         while( IsNameFoundL( *calendarName ) )
       
   518             {
       
   519             CleanupStack::PopAndDestroy( calendarName );
       
   520             numBuf.Zero();
       
   521             if( index < KTen ) 
       
   522                 {
       
   523                 numBuf.Format( KFormatStringTwoDigit, index );
       
   524                 }
       
   525             else
       
   526                 {
       
   527                 numBuf.Format( KFormatString, index );
       
   528                 }
       
   529             AknTextUtils::DisplayTextLanguageSpecificNumberConversion(
       
   530                     numBuf );
       
   531             calendarName = StringLoader::LoadLC(
       
   532                     R_CALE_DB_CALENDAR_DEFAULT_NAME, numBuf );
       
   533 
       
   534             ++index;
       
   535             }
       
   536         }
       
   537     SetEdwinTextL( ECalenMultiDbName, calendarName );
       
   538     CleanupStack::PopAndDestroy(calendarName);
       
   539 	
       
   540     //Second field "Color" of the form
       
   541     // Instantiate CDbColorPicture object 300x300 twips in size
       
   542     CEikRichTextEditor* colorControl = static_cast<CEikRichTextEditor*>(Control(ECalenMultiDbColor));   
       
   543    
       
   544     //Prepare the iPicture header, which will be inserted into the rich text
       
   545     TPictureHeader header;
       
   546     header.iPicture = TSwizzle<CPicture>(iPicture);
       
   547         
       
   548     // Position where we insert iPicture is not valid as it always draws icon depending the rect we provide
       
   549     colorControl->RichText()->InsertL(0, header);   
       
   550     colorControl->AddFlagToUserFlags(CEikEdwin::EAvkonDisableCursor | CEikEdwin::EReadOnly );
       
   551     GetLineByLineAndPageIndex(1,0)->DrawNow(); 	
       
   552 
       
   553     iCalendarStatus = iCalendarInfo.Enabled();
       
   554     
       
   555   
       
   556         
       
   557     if( ECalenMultiDbHidden == iCalendarStatus )
       
   558         {
       
   559         SetVisiblityFieldL( ECalenMultiDbHidden );
       
   560         }
       
   561     else
       
   562         {
       
   563         SetVisiblityFieldL( ECalenMultiDbVisible );
       
   564         }
       
   565 	TRACE_EXIT_POINT;
       
   566     }
       
   567     
       
   568 // ---------------------------------------------------------
       
   569 // CCalenMultiDBEditor::DynInitMenuPaneL
       
   570 // Gets called before form is displayed
       
   571 // (other items were commented in a header).
       
   572 // ---------------------------------------------------------
       
   573 //
       
   574 void CCalenMultiDBEditor::DynInitMenuPaneL( TInt aResourceId,
       
   575 										          CEikMenuPane* aMenuPane )
       
   576 	{
       
   577 	TRACE_ENTRY_POINT;
       
   578 	
       
   579 	if( aResourceId != R_CALEN_MULTIDB_MENUPANE )
       
   580 	    {
       
   581 	    return;
       
   582 	    }
       
   583 
       
   584 	// Execute the following commands if the resource belongs to calendar.
       
   585 	// Display the menu items based on the current focused control.
       
   586 	if( ECalenMultiDbName == IdOfFocusControl() )
       
   587 	    {
       
   588 	    aMenuPane->SetItemDimmed( EAknSoftkeyChange, ETrue );
       
   589 	    }
       
   590 
       
   591 	TRACE_EXIT_POINT;
       
   592 	}
       
   593 	
       
   594 // ---------------------------------------------------------------------------
       
   595 // CCalenMultiDBEditor::GetColorL
       
   596 // From class CAknSettingItem.
       
   597 // GetColorL overridden to launch colour selection grid.
       
   598 // ---------------------------------------------------------------------------
       
   599 //
       
   600 void CCalenMultiDBEditor::GetColorL()
       
   601     {  
       
   602     TRACE_ENTRY_POINT;
       
   603     iNoneChoosen = ETrue;
       
   604     
       
   605     // Construct colour selection grid
       
   606     CAknDialog  *dlg = CAknColourSelectionGrid::NewL(iRgbColors, EFalse,
       
   607             iNoneChoosen,iChoosenColor );
       
   608 
       
   609     dlg->ExecuteLD(R_CALEN_MULTIDB_EDITOR_COLOR_GRID_DLG);
       
   610     
       
   611     TRACE_EXIT_POINT;
       
   612     }
       
   613 
       
   614 // ---------------------------------------------------------------------------
       
   615 // CCalenMultiDBEditor::FocusChanged
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 void CCalenMultiDBEditor::FocusChanged(TDrawNow /*aDrawNow*/)
       
   619     {
       
   620     TRACE_ENTRY_POINT
       
   621     
       
   622     if(IsFocused() && !iNoneChoosen)
       
   623         {
       
   624         iColVal = iChoosenColor.Value();
       
   625         TRAP_IGNORE(iPicture->SetRgbColorsL(iChoosenColor));
       
   626         GetLineByLineAndPageIndex(1, 0)->DrawNow();
       
   627         }
       
   628     
       
   629     TRACE_EXIT_POINT
       
   630     }
       
   631 
       
   632 // ---------------------------------------------------------------------------
       
   633 // CCalenMultiDBEditor::SaveNoteL
       
   634 // Try to save note. Initializes all the member variables of DBInfo.
       
   635 // ---------------------------------------------------------------------------
       
   636 //    
       
   637 TBool CCalenMultiDBEditor::SaveNoteL( TInt aButtonId )
       
   638 	{
       
   639     TRACE_ENTRY_POINT;
       
   640 
       
   641     if (CheckSpaceBelowCriticalLevelL())
       
   642         {
       
   643         TRACE_EXIT_POINT;
       
   644         return EFalse;
       
   645         }
       
   646 
       
   647     if (Conflict() == CCalenMultiDBEditor::EConflictDelete)
       
   648         {
       
   649         CAknNoteDialog *note = new (ELeave) CAknNoteDialog(
       
   650                 CAknNoteDialog::EWarningTone, CAknNoteDialog::ENoTimeout);
       
   651         HBufC* buf = StringLoader::LoadLC(
       
   652                 R_QTN_CALENDAREDITOR_NOTE_DB_CONFLICT_DELETE, iEikonEnv);
       
   653         note->SetTextL(*buf);
       
   654         note->ExecuteLD(R_CALEN_CALENDAREDITOR_CONFLICT_DIALOG);
       
   655         CleanupStack::PopAndDestroy(buf);
       
   656         return ETrue;
       
   657         }
       
   658     else if (Conflict() == CCalenMultiDBEditor::EConflictUpdate)
       
   659         {
       
   660         CAknNoteDialog *note = new (ELeave) CAknNoteDialog(
       
   661                 CAknNoteDialog::EWarningTone, CAknNoteDialog::ENoTimeout);
       
   662         HBufC* buf = StringLoader::LoadLC(
       
   663                 R_QTN_CALENDAREDITOR_NOTE_DB_CONFLICT_UPDATE, iEikonEnv);
       
   664         note->SetTextL(*buf);
       
   665         note->ExecuteLD(R_CALEN_CALENDAREDITOR_CONFLICT_DIALOG);
       
   666         CleanupStack::PopAndDestroy(buf);
       
   667         return ETrue;
       
   668         }
       
   669     else
       
   670         {
       
   671         }
       
   672 
       
   673     TBool retValue = ETrue;
       
   674     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   675     iController.GetAllCalendarInfoL(calendarInfoList);
       
   676     CleanupClosePushL(calendarInfoList);
       
   677     const TBool continueOnError = ETrue;
       
   678     ReadDataFromFormL(continueOnError);
       
   679 
       
   680     iCalendarName->Des().Trim();
       
   681     // Check for the empty text
       
   682     if ((!iCalendarName->Size()))
       
   683         {
       
   684         // If in editing mode, just save the name used before.
       
   685         if (iEditFlag)
       
   686             {
       
   687             iCalendarName->Des().Copy(iCalendarInfo.NameL());
       
   688             SetEdwinTextL(ECalenMultiDbName, iCalendarName);
       
   689             }
       
   690         else
       
   691             {
       
   692             // else use the default name.
       
   693             TInt index(KOne);
       
   694             HBufC* calendarName = StringLoader::LoadLC(R_CALE_DB_CALENDAR);
       
   695             TBuf<KBuffLength> numBuf;
       
   696 
       
   697             // Check if the name is already present.
       
   698             while (IsNameFoundL(*calendarName))
       
   699                 {
       
   700                 CleanupStack::PopAndDestroy(calendarName);
       
   701                 numBuf.Zero();
       
   702                 if (index < KTen)
       
   703                     {
       
   704                     numBuf.Format(KFormatStringTwoDigit, index);
       
   705                     }
       
   706                 else
       
   707                     {
       
   708                     numBuf.Format(KFormatString, index);
       
   709                     }
       
   710                 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(
       
   711                         numBuf);
       
   712                 calendarName = StringLoader::LoadLC(
       
   713                         R_CALE_DB_CALENDAR_DEFAULT_NAME, numBuf);
       
   714 
       
   715                 ++index;
       
   716                 }
       
   717 
       
   718             iCalendarName->Des().Append(calendarName->Des());
       
   719 
       
   720             CleanupStack::PopAndDestroy(calendarName);
       
   721             SetEdwinTextL(ECalenMultiDbName, iCalendarName);
       
   722             }
       
   723 
       
   724         }
       
   725 
       
   726     // Check for the validity of the calendar name.
       
   727     if (IsNameValid(*iCalendarName))
       
   728         {
       
   729         // Name is valid. then check if it already exists or not.
       
   730         if (IsNameEditedL(*iCalendarName))
       
   731             {
       
   732             TInt index = calendarInfoList.Find(*iCalendarName,
       
   733                     CCalenMultiDBEditor::CalenInfoIdentifierL);
       
   734             if (index != KErrNotFound)
       
   735                 {
       
   736                 retValue = EFalse;
       
   737                 if (EAknCmdExit != aButtonId)
       
   738                     {
       
   739                     HBufC* infoText = StringLoader::LoadLC(
       
   740                             R_QTN_CALE_DB_ALREADY_EXISTS_NOTE,
       
   741                             iCalendarName->Des());
       
   742                     CAknInformationNote* dialog =
       
   743                             new (ELeave) CAknInformationNote(ETrue);
       
   744                     dialog->ExecuteLD(*infoText);
       
   745                     CleanupStack::PopAndDestroy(infoText);
       
   746                     }
       
   747                 }
       
   748             else
       
   749                 {
       
   750                 iCalendarInfo.SetNameL(*iCalendarName);
       
   751                 }
       
   752             }
       
   753 
       
   754         }
       
   755     else
       
   756         {
       
   757         if (EAknCmdExit != aButtonId)
       
   758             {
       
   759             retValue = EFalse;
       
   760             HBufC* infoText(NULL);
       
   761             infoText
       
   762                     = AreIllegalChars(*iCalendarName)
       
   763                                                       ? StringLoader::LoadLC(
       
   764                                                              R_CALEN_ILLEGAL_CHARACTERS)
       
   765                                                          : StringLoader::LoadLC(
       
   766                                                                  R_CALEN_BAD_FILE_NAME);
       
   767             CAknInformationNote* dialog = new (ELeave) CAknInformationNote(
       
   768                     ETrue);
       
   769             dialog->ExecuteLD(*infoText);
       
   770             CleanupStack::PopAndDestroy(infoText);
       
   771             }
       
   772         }
       
   773 
       
   774     if (IsColorEditedL(iColVal))
       
   775         {
       
   776         iCalendarInfo.SetColor(iColVal);
       
   777         }
       
   778 
       
   779     if (IsVisiblityFieldEditedL(iCalendarStatus))
       
   780         {
       
   781         iCalendarInfo.SetEnabled(iCalendarStatus);
       
   782         }
       
   783 
       
   784     CleanupStack::PopAndDestroy(&calendarInfoList);
       
   785     TRACE_EXIT_POINT;
       
   786     return retValue;
       
   787     }
       
   788 
       
   789 // ---------------------------------------------------------------------------
       
   790 // CCalenMultiDBEditor::ExecuteLD
       
   791 // Launches the MultiDB Form 
       
   792 // ---------------------------------------------------------------------------
       
   793 //
       
   794 TInt CCalenMultiDBEditor::ExecuteLD()
       
   795 	{
       
   796 	TRACE_ENTRY_POINT; 
       
   797 	TRACE_EXIT_POINT;
       
   798 	return CAknForm::ExecuteLD(R_CALEN_MULTIDB_EDITOR);
       
   799 	}
       
   800 
       
   801 // ---------------------------------------------------------------------------
       
   802 // CCalenMultiDBEditor::ReadDataFromFormL
       
   803 // Read all the data from the form.
       
   804 // ---------------------------------------------------------------------------
       
   805 //
       
   806 void CCalenMultiDBEditor::ReadDataFromFormL( TBool /*aContinueOnError */)
       
   807     {
       
   808     TRACE_ENTRY_POINT;
       
   809     //Initial Name value
       
   810     TPtr summary = iCalendarName->Des();
       
   811 
       
   812     CEikEdwin* edwin = reinterpret_cast<CEikEdwin*> (Control(
       
   813             ECalenMultiDbName));
       
   814     GetEdwinText(summary, ECalenMultiDbName);
       
   815 
       
   816     TRACE_EXIT_POINT;
       
   817     }
       
   818 // ---------------------------------------------------------------------------
       
   819 // CCalenMultiDBEditor::IsNameEditedL
       
   820 // Checks wether Name got edited or not.
       
   821 // ---------------------------------------------------------------------------
       
   822 //    
       
   823 TBool CCalenMultiDBEditor::IsNameEditedL(const TDesC& aName)		
       
   824 	{
       
   825 	TRACE_ENTRY_POINT;	
       
   826 	HBufC* calendarName = iCalendarInfo.NameL().AllocLC();
       
   827 	calendarName->Des().Trim();	
       
   828 	
       
   829 	TBool isEdited = EFalse;
       
   830     if (calendarName->CompareF(aName))
       
   831         {
       
   832         isEdited =  ETrue;
       
   833         }   
       
   834     CleanupStack::PopAndDestroy();
       
   835     TRACE_EXIT_POINT;
       
   836       
       
   837     return isEdited;
       
   838 	}
       
   839 
       
   840 // ---------------------------------------------------------------------------
       
   841 // CCalenMultiDBEditor::IsNameFoundL
       
   842 // Checks wether Name got edited or not.
       
   843 // ---------------------------------------------------------------------------
       
   844 //  
       
   845 TBool CCalenMultiDBEditor::IsNameFoundL(const TDesC& aName)    
       
   846     {
       
   847     TRACE_ENTRY_POINT;
       
   848     
       
   849     TBool retValue = EFalse;
       
   850     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   851     iController.GetAllCalendarInfoL(calendarInfoList);
       
   852     CleanupClosePushL(calendarInfoList);  
       
   853     HBufC *calendarName = aName.AllocLC();
       
   854     
       
   855     TInt index = calendarInfoList.Find( *calendarName, 
       
   856             CCalenMultiDBEditor::CalenInfoIdentifierL );
       
   857 
       
   858     CleanupStack::PopAndDestroy( calendarName );
       
   859     CleanupStack::PopAndDestroy( &calendarInfoList );    
       
   860     
       
   861     // Name is matched.
       
   862     if(index != KErrNotFound)
       
   863         {
       
   864         retValue = ETrue;
       
   865         }
       
   866     
       
   867     TRACE_EXIT_POINT;
       
   868     return retValue;
       
   869     }
       
   870 
       
   871 // ---------------------------------------------------------------------------
       
   872 // CCalenMultiDBEditor::AreIllegalChars
       
   873 // Rest of the details are commented in header.
       
   874 // ---------------------------------------------------------------------------
       
   875 //  
       
   876 TBool CCalenMultiDBEditor::AreIllegalChars( const TDesC& aName )
       
   877     {
       
   878     TRACE_ENTRY_POINT;
       
   879     
       
   880     for ( TInt i( 0 ); KIllegalChars[ i ]; i++ )
       
   881         {
       
   882         if ( aName.Locate( KIllegalChars[ i ] ) != KErrNotFound )
       
   883             {
       
   884             // name is valid.
       
   885             return ETrue;
       
   886             }
       
   887         }
       
   888     TRACE_EXIT_POINT; 
       
   889     
       
   890     return EFalse;
       
   891     }
       
   892 
       
   893 // ---------------------------------------------------------------------------
       
   894 // CCalenMultiDBEditor::IsValidName
       
   895 // Rest of the details are commented in header.
       
   896 // ---------------------------------------------------------------------------
       
   897 // 
       
   898 TBool CCalenMultiDBEditor::IsNameValid( const TDesC& aName )
       
   899     {
       
   900     TRACE_ENTRY_POINT;
       
   901     
       
   902     // Check name for bad chars
       
   903     const TUint16 KMinAllowedChar = 0x0020;
       
   904     const TUint16 KParagraphSeparator = 0x2029;
       
   905     const TUint16 KDot = '.';
       
   906     
       
   907     TInt nameLen( aName.Length() );
       
   908     if ( !nameLen )
       
   909         {
       
   910         return EFalse;
       
   911         }
       
   912     
       
   913     for ( TInt i( 0 ); i < nameLen; i++ )
       
   914         {
       
   915         TUint16 ch( aName[ i ] );
       
   916         if ( ch < KMinAllowedChar || ch == KParagraphSeparator )
       
   917             {
       
   918             return EFalse;
       
   919             }
       
   920         }
       
   921     
       
   922     // File system ignores totally dot in the end of name, so 
       
   923     // we set here as not valid name, so that user gets correctly informed
       
   924     if ( aName[ nameLen - 1 ] == KDot || AreIllegalChars( aName ) )
       
   925         {
       
   926         return EFalse;
       
   927         }
       
   928     return ETrue;
       
   929     }
       
   930 
       
   931 // ---------------------------------------------------------------------------
       
   932 // CCalenMultiDBEditor::IsColorEditedL
       
   933 // Checks wether Color got edited or not.
       
   934 // ---------------------------------------------------------------------------
       
   935 //	
       
   936 TBool CCalenMultiDBEditor::IsColorEditedL(TInt iColVal)
       
   937 	{
       
   938 	TRACE_ENTRY_POINT;
       
   939     TRACE_EXIT_POINT;   
       
   940     return (iCalendarInfo.Color() != iColVal);
       
   941 	}
       
   942 
       
   943 // ---------------------------------------------------------------------------
       
   944 // CCalenMultiDBEditor::IsVisiblityFieldEditedL
       
   945 // Checks the visibility status of the calendar being edited.
       
   946 // ---------------------------------------------------------------------------
       
   947 //
       
   948 TBool CCalenMultiDBEditor::IsVisiblityFieldEditedL( TInt aCalendarStatus )
       
   949     {
       
   950     TRACE_ENTRY_POINT;
       
   951     TRACE_EXIT_POINT;   
       
   952     return (iCalendarInfo.Enabled() != aCalendarStatus );
       
   953     }
       
   954 
       
   955 
       
   956 // ----------------------------------------------------------------------------
       
   957 // CCalenMultiDBEditor::HandleDialogPageEventL
       
   958 // Process pointer event on the dialog.
       
   959 // (other items were commented in a header).
       
   960 // ----------------------------------------------------------------------------
       
   961 void CCalenMultiDBEditor::HandleDialogPageEventL( TInt aEventID )
       
   962     {
       
   963     TRACE_ENTRY_POINT;
       
   964     
       
   965     CAknForm::HandleDialogPageEventL( aEventID );
       
   966     if ( aEventID == MEikDialogPageObserver::EDialogPageTapped )
       
   967         {
       
   968         TInt focusControl( IdOfFocusControl() );
       
   969         
       
   970         switch(focusControl)
       
   971             {
       
   972             case ECalenMultiDbColor:
       
   973                 {
       
   974                 GetColorL();
       
   975                 }
       
   976                 break;
       
   977                     
       
   978 
       
   979                 
       
   980             case ECalenMultiDbHiddenVisible:
       
   981                 {
       
   982                 iCalendarStatus = iCalendarInfo.Enabled();
       
   983                 
       
   984                 if( ECalenMultiDbHidden == iCalendarStatus )
       
   985                     {
       
   986                     SetVisiblityFieldL( ECalenMultiDbVisible ); 
       
   987                     iCalendarStatus = ECalenMultiDbVisible;
       
   988                     iCalendarInfo.SetEnabled(iCalendarStatus);
       
   989                     }
       
   990                 else
       
   991                     {
       
   992                     SetVisiblityFieldL( ECalenMultiDbHidden );
       
   993                     iCalendarStatus = ECalenMultiDbHidden;
       
   994                     iCalendarInfo.SetEnabled(iCalendarStatus);
       
   995                     }
       
   996                 }
       
   997                 break;
       
   998                     
       
   999              default:
       
  1000                  {
       
  1001                  
       
  1002                  }
       
  1003                  break;
       
  1004              }
       
  1005          }
       
  1006     TRACE_EXIT_POINT;
       
  1007     }
       
  1008 
       
  1009 // -----------------------------------------------------------------------------
       
  1010 // CCalenMultiDBEditor::LineChangedL
       
  1011 // This function gets called by the framework each time line is changed in
       
  1012 // the dialog (form). .
       
  1013 // We will use it for MSK label switching.
       
  1014 // (other items were commented in a header).
       
  1015 // -----------------------------------------------------------------------------
       
  1016 //
       
  1017 void CCalenMultiDBEditor::LineChangedL( TInt aControlId )
       
  1018     {
       
  1019     TRACE_ENTRY_POINT;
       
  1020  
       
  1021     CEikButtonGroupContainer&  cba = ButtonGroupContainer ();
       
  1022     TInt resId = 0;
       
  1023     TInt controlId = aControlId;
       
  1024 
       
  1025     switch( controlId )
       
  1026         {
       
  1027         case ECalenMultiDbName:
       
  1028             {
       
  1029             resId = R_CALEN_MULTIDB_MSK_EMPTY_CBA;
       
  1030             }
       
  1031             break;
       
  1032 
       
  1033         case ECalenMultiDbColor:
       
  1034         case ECalenMultiDbHiddenVisible: 
       
  1035             {
       
  1036             resId = R_CALEN_MULTIDB_MSK_CHANGE_CBA;
       
  1037             }
       
  1038             break;
       
  1039             
       
  1040         default:
       
  1041             {
       
  1042             // No implementation yet.
       
  1043             }
       
  1044             break;
       
  1045         }
       
  1046 
       
  1047     // set desired CBA
       
  1048     cba.SetCommandSetL( resId );
       
  1049     cba.DrawNow();
       
  1050 
       
  1051     TRACE_EXIT_POINT;
       
  1052     }
       
  1053 
       
  1054 // -----------------------------------------------------------------------------
       
  1055 // CCalenEditorBase::PostLayoutDynInitL
       
  1056 // This is called in CEikDialog::ExecuteLD() after a form is drawn.
       
  1057 // (other items were commented in a header).
       
  1058 // -----------------------------------------------------------------------------
       
  1059 //
       
  1060 void CCalenMultiDBEditor::PostLayoutDynInitL()
       
  1061     {
       
  1062     TRACE_ENTRY_POINT;    
       
  1063     SetEditableL(ETrue);
       
  1064     
       
  1065     LineChangedL( ECalenMultiDbName );
       
  1066     
       
  1067     CAknForm::PostLayoutDynInitL(); // chain back up to baseclass
       
  1068     TRACE_EXIT_POINT;
       
  1069     }
       
  1070     
       
  1071 // -----------------------------------------------------------------------------
       
  1072 // CCalenMultipleDbUi::CalenInfoIdentifierL
       
  1073 // -----------------------------------------------------------------------------
       
  1074 //
       
  1075 TBool CCalenMultiDBEditor::CalenInfoIdentifierL( const HBufC* aName,
       
  1076                                         const CCalCalendarInfo& aCalendarInfo )
       
  1077     {
       
  1078     TRACE_ENTRY_POINT;
       
  1079     HBufC* calendarName = aCalendarInfo.NameL().AllocLC();
       
  1080     calendarName->Des().Trim();
       
  1081     TBool retVal = EFalse;
       
  1082     retVal = calendarName->Compare(*aName);
       
  1083     CleanupStack::PopAndDestroy();          
       
  1084     TRACE_EXIT_POINT;
       
  1085     return (!retVal);
       
  1086     }
       
  1087 
       
  1088 // -----------------------------------------------------------------------------
       
  1089 // CDbColorPicture::SetVisiblityFieldL
       
  1090 // Rest of the details are commented in header.
       
  1091 // -----------------------------------------------------------------------------
       
  1092 //
       
  1093 void CCalenMultiDBEditor::SetVisiblityFieldL( TBool aStatusVal )
       
  1094     {
       
  1095     TRACE_ENTRY_POINT;
       
  1096     HBufC* statusString( NULL );
       
  1097     CEikEdwin* fieldText =( CEikEdwin* )Control( ECalenMultiDbHiddenVisible );
       
  1098     if( aStatusVal )
       
  1099         {
       
  1100         // load string Visible
       
  1101         statusString = StringLoader::LoadLC( R_CALE_DB_SHOWN_SETTING ,iCoeEnv );
       
  1102         }
       
  1103     else
       
  1104         {
       
  1105         // load string Hidden
       
  1106         statusString = StringLoader::LoadLC( R_CALE_DB_HIDDEN_SETTING ,iCoeEnv );
       
  1107         }
       
  1108     // set status field string
       
  1109     fieldText->SetTextL( statusString );
       
  1110     fieldText->DrawDeferred();
       
  1111     CleanupStack::PopAndDestroy( statusString );    
       
  1112     TRACE_EXIT_POINT;
       
  1113     }
       
  1114 
       
  1115 // -----------------------------------------------------------------------------
       
  1116 // CCalenMultiDBEditor::SetTitlePaneL
       
  1117 // Rest of the details are commented in header.
       
  1118 // -----------------------------------------------------------------------------
       
  1119 //
       
  1120 void CCalenMultiDBEditor::SetTitlePaneL()
       
  1121     {
       
  1122     TRACE_ENTRY_POINT;
       
  1123     
       
  1124     CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
       
  1125 
       
  1126     // Set empty navi pane label
       
  1127     iNaviContainer = static_cast<CAknNavigationControlContainer*>(
       
  1128             sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  1129     iNaviContainer->PushDefaultL();
       
  1130 
       
  1131     // Set title text
       
  1132     CAknTitlePane* tp = static_cast<CAknTitlePane*>(
       
  1133             sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  1134 
       
  1135     HBufC* titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDAR , iCoeEnv );
       
  1136     tp->SetTextL( *titleText );
       
  1137     CleanupStack::PopAndDestroy( titleText );
       
  1138     
       
  1139     TRACE_EXIT_POINT;   
       
  1140     }
       
  1141 
       
  1142 // -----------------------------------------------------------------------------
       
  1143 // CCalenMultiDBEditor::SetSyncFieldL
       
  1144 // Rest of the details are commented in header.
       
  1145 // -----------------------------------------------------------------------------
       
  1146 //
       
  1147 void CCalenMultiDBEditor::SetSyncFieldL( TBool aSyncVal )
       
  1148     {
       
  1149     TRACE_ENTRY_POINT;
       
  1150     
       
  1151     if(!ControlOrNull(ECalenMultiDbSyncStatus))
       
  1152         {
       
  1153         return;
       
  1154         }
       
  1155     
       
  1156     HBufC* syncString( NULL );
       
  1157     CEikEdwin* syncFieldText =( CEikEdwin* )Control( ECalenMultiDbSyncStatus );
       
  1158     if( EFalse == aSyncVal )
       
  1159         {
       
  1160         // load string Off
       
  1161         syncString = StringLoader::LoadLC( R_CALE_SYNC_OFF , iCoeEnv );
       
  1162         }
       
  1163     else
       
  1164         {
       
  1165         // load string On
       
  1166         syncString = StringLoader::LoadLC( R_CALE_SYNC_ON ,iCoeEnv );
       
  1167         }
       
  1168     // set sync field string
       
  1169     syncFieldText->SetTextL( syncString );
       
  1170     syncFieldText->DrawDeferred();
       
  1171     CleanupStack::PopAndDestroy( syncString );    
       
  1172     TRACE_EXIT_POINT;
       
  1173     }
       
  1174 
       
  1175 // -----------------------------------------------------------------------------
       
  1176 // CheckSpaceBelowCriticalLevelL
       
  1177 // Checks if the Flash File System storage will fall below critical level. 
       
  1178 // If there is not enough space, display an error message and return EFalse.
       
  1179 // Return ETrue otherwise.
       
  1180 // (other items were commented in a header).
       
  1181 // -----------------------------------------------------------------------------
       
  1182 //
       
  1183 TBool CCalenMultiDBEditor::CheckSpaceBelowCriticalLevelL()
       
  1184     {
       
  1185     TRACE_ENTRY_POINT;
       
  1186     
       
  1187     TBool retcode(EFalse);
       
  1188     if ( SysUtil::FFSSpaceBelowCriticalLevelL( &( iCoeEnv->FsSession() ) ) )
       
  1189         {
       
  1190         ShowErrorNoteL(KErrDiskFull);
       
  1191         retcode = ETrue;
       
  1192         }
       
  1193     TRACE_EXIT_POINT;
       
  1194     return retcode;
       
  1195     }
       
  1196 
       
  1197 // -----------------------------------------------------------------------------
       
  1198 // CCalenMultiDBEditor::ShowErrorNoteL
       
  1199 // -----------------------------------------------------------------------------
       
  1200 //
       
  1201 void CCalenMultiDBEditor::ShowErrorNoteL(TInt aError)
       
  1202     {
       
  1203     TRACE_ENTRY_POINT
       
  1204     CErrorUI* errorUi = CErrorUI::NewLC();
       
  1205     errorUi->ShowGlobalErrorNoteL( aError );
       
  1206     CleanupStack::PopAndDestroy( errorUi ); 
       
  1207     TRACE_EXIT_POINT
       
  1208     }
       
  1209 
       
  1210 // -----------------------------------------------------------------------------
       
  1211 // CDbColorPicture::CDbColorPicture
       
  1212 // C++ Constructor
       
  1213 // -----------------------------------------------------------------------------
       
  1214 //
       
  1215 CDbColorPicture::CDbColorPicture(TSize aSize) 
       
  1216 : iSize(aSize) 
       
  1217 	{
       
  1218 	TRACE_ENTRY_POINT;
       
  1219 	TRACE_EXIT_POINT;	
       
  1220 	}
       
  1221 
       
  1222 // -----------------------------------------------------------------------------
       
  1223 // CDbColorPicture::ExternalizeL
       
  1224 // Pure virtual from CPicture, intentionally empty.
       
  1225 // -----------------------------------------------------------------------------
       
  1226 //	
       
  1227 void CDbColorPicture::ExternalizeL(RWriteStream& ) const 
       
  1228 	{
       
  1229 	TRACE_ENTRY_POINT;
       
  1230 	TRACE_EXIT_POINT;	
       
  1231 	}
       
  1232 
       
  1233 // -----------------------------------------------------------------------------
       
  1234 // CDbColorPicture::GetOriginalSizeInTwips
       
  1235 // Convert size to twips
       
  1236 // -----------------------------------------------------------------------------
       
  1237 //
       
  1238 void CDbColorPicture::GetOriginalSizeInTwips(TSize& /*aSize*/ ) const 
       
  1239     {
       
  1240     TRACE_ENTRY_POINT;
       
  1241     TRACE_EXIT_POINT;	 
       
  1242     }
       
  1243 
       
  1244 // -----------------------------------------------------------------------------
       
  1245 // CDbColorPicture::SetRgbColorsL
       
  1246 // -----------------------------------------------------------------------------
       
  1247 //
       
  1248 void CDbColorPicture::SetRgbColorsL(TRgb aColors)  
       
  1249     {
       
  1250     TRACE_ENTRY_POINT;
       
  1251     iColors = aColors;
       
  1252     TRACE_EXIT_POINT;    
       
  1253     }
       
  1254 
       
  1255 // -----------------------------------------------------------------------------
       
  1256 // CDbColorPicture::Draw
       
  1257 // Draw funtion to draw the map icon
       
  1258 // -----------------------------------------------------------------------------
       
  1259 //
       
  1260 void CDbColorPicture::Draw(CGraphicsContext& aGc, 
       
  1261                       const TPoint&  aTopLeft ,
       
  1262                       const TRect&  /*aClipRect*/ ,
       
  1263                       MGraphicsDeviceMap* /*aMap*/ ) const
       
  1264     {
       
  1265     TRACE_ENTRY_POINT;
       
  1266     
       
  1267     
       
  1268     //aGc.Reset();
       
  1269      aGc.CancelClippingRect();    
       
  1270     
       
  1271 	TSize pixelsize;
       
  1272     pixelsize.iWidth = 225;
       
  1273     pixelsize.iHeight = 16;
       
  1274     TPoint aPoint;
       
  1275     TRect area = TRect(aTopLeft, pixelsize);
       
  1276     area.Move(0,-11);
       
  1277     // Draw a datbase color rectangle
       
  1278     aGc.SetBrushColor(iColors);
       
  1279     aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1280     
       
  1281     aGc.DrawRect(area);	  
       
  1282     }
       
  1283 
       
  1284 //  End of File