calendarui/controller/src/calenmultidbeditor.cpp
branchRCL_3
changeset 13 1984aceb8774
parent 5 42814f902fe6
child 14 21239b3bcd78
equal deleted inserted replaced
11:0f07cd1b5772 13:1984aceb8774
    27 #include <aknnavi.h>
    27 #include <aknnavi.h>
    28 #include <txtrich.h>
    28 #include <txtrich.h>
    29 #include <hlplch.h>
    29 #include <hlplch.h>
    30 #include <calcalendarinfo.h>
    30 #include <calcalendarinfo.h>
    31 #include <Calendar.rsg>
    31 #include <Calendar.rsg>
       
    32 #include <calencommonui.rsg>
    32 
    33 
    33 #include "calenmultidbeditor.h"
    34 #include "calenmultidbeditor.h"
    34 #include "calendarui_debug.h"
    35 #include "calendarui_debug.h"
    35 #include "calendar.hrh"
    36 #include "calendar.hrh"
    36 #include "calentitlepane.h"
    37 #include "calentitlepane.h"
    37 #include "calencontroller.h"
    38 #include "calencontroller.h"
       
    39 #include "calenmultipledbui.h"
    38 
    40 
    39 // Constants.
    41 // Constants.
    40 const TUint16 KIllegalChars[] = {
    42 const TUint16 KIllegalChars[] = {
    41     '<', '>', '"', '/', '//', '|', ':', '*', '?',
    43     '<', '>', '"', '/', '//', '|', ':', '*', '?',
    42     0xFF02, // Full width quote
    44     0xFF02, // Full width quote
    53     0x201F, // Reversed quote
    55     0x201F, // Reversed quote
    54     0x21B2, // Downwards arrow with tip leftwards
    56     0x21B2, // Downwards arrow with tip leftwards
    55     0, // Array terminator
    57     0, // Array terminator
    56 };
    58 };
    57 const TInt KCalenMaxELAFTextEditorLength(256);
    59 const TInt KCalenMaxELAFTextEditorLength(256);
    58 const TInt KCalenColorPalletteStartColor(35);
       
    59 const TInt KOne( 1 );
    60 const TInt KOne( 1 );
    60 const TInt KBuffLength ( 16 );
    61 const TInt KBuffLength ( 16 );
    61 const TInt KTen( 10 );
    62 const TInt KTen( 10 );
    62 
    63 
    63 // Literals.
    64 // Literals.
    69 // ----------------------------------------------------------------------------
    70 // ----------------------------------------------------------------------------
    70 // CCalenMultiDBEditor::NewL
    71 // CCalenMultiDBEditor::NewL
    71 // Two-phased constructor.
    72 // Two-phased constructor.
    72 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
    73 // 
    74 // 
    74 CCalenMultiDBEditor* CCalenMultiDBEditor::NewL( CCalCalendarInfo& aCalendarInfo, 
    75 CCalenMultiDBEditor* CCalenMultiDBEditor::NewL(
    75                                  CCalenController& aController, TBool aEditFlag)
    76         CCalenMultipleDbUi& aMultipleDbui, CCalCalendarInfo& aCalendarInfo,
    76     {
    77         CCalenController& aController, TBool aEditFlag)
    77     TRACE_ENTRY_POINT;
    78     {
    78 
    79     TRACE_ENTRY_POINT;
    79     CCalenMultiDBEditor* self = 
    80 
    80       new(ELeave) CCalenMultiDBEditor( aCalendarInfo, aController, aEditFlag);
    81     CCalenMultiDBEditor* self = new (ELeave) CCalenMultiDBEditor(
    81     CleanupStack::PushL( self );
    82             aMultipleDbui, aCalendarInfo, aController, aEditFlag);
       
    83     CleanupStack::PushL(self);
    82     self->ConstructL();
    84     self->ConstructL();
    83     CleanupStack::Pop( self );
    85     CleanupStack::Pop(self);
    84 
    86 
    85     TRACE_EXIT_POINT;
    87     TRACE_EXIT_POINT;
    86     return self;
    88     return self;
    87     }
    89     }
    88 
    90 
    91 // Destructor.
    93 // Destructor.
    92 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
    93 //
    95 //
    94 CCalenMultiDBEditor::~CCalenMultiDBEditor()
    96 CCalenMultiDBEditor::~CCalenMultiDBEditor()
    95     {
    97     {
    96     TRACE_ENTRY_POINT;    
    98     TRACE_ENTRY_POINT; 
       
    99     
       
   100     if(iRgbColors)
       
   101         {
       
   102         iRgbColors->Reset();
       
   103         delete iRgbColors;
       
   104         iRgbColors = NULL;
       
   105         }
    97     
   106     
    98     if(iCalendarName)
   107     if(iCalendarName)
    99         {
   108         {
   100         delete iCalendarName;
   109         delete iCalendarName;
   101         iCalendarName = NULL;
   110         iCalendarName = NULL;
   114 // C++ constructor can NOT contain any code, that might leave.
   123 // C++ constructor can NOT contain any code, that might leave.
   115 // This overload is used when the repeat type is known.
   124 // This overload is used when the repeat type is known.
   116 // (other items were commented in a header).
   125 // (other items were commented in a header).
   117 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   118 //
   127 //
   119 CCalenMultiDBEditor::CCalenMultiDBEditor( CCalCalendarInfo&  aCalendarInfo,
   128 CCalenMultiDBEditor::CCalenMultiDBEditor(CCalenMultipleDbUi& aMultipleDbui,
   120         CCalenController& aController, TBool aEditFlag)
   129         CCalCalendarInfo& aCalendarInfo, CCalenController& aController,
   121 	:iCalendarInfo( aCalendarInfo ) , iController( aController ),
   130         TBool aEditFlag) :
   122 	iEditFlag( aEditFlag )
   131             iCalendarInfo(aCalendarInfo), iController(
       
   132             aController), iEditFlag(aEditFlag),
       
   133 			iMultipleDbUi(aMultipleDbui)
   123     {
   134     {
   124     TRACE_ENTRY_POINT;
   135     TRACE_ENTRY_POINT;
   125     
   136     
   126     iCalendarStatus = ECalenMultiDbVisible;
   137     iCalendarStatus = ECalenMultiDbVisible;
   127 
   138 
   144     SetTitlePaneL();
   155     SetTitlePaneL();
   145     iCalendarName = HBufC::NewL(KCalenMaxELAFTextEditorLength); 
   156     iCalendarName = HBufC::NewL(KCalenMaxELAFTextEditorLength); 
   146         
   157         
   147     //Initial color value
   158     //Initial color value
   148     iColVal = iCalendarInfo.Color().Value();  
   159     iColVal = iCalendarInfo.Color().Value();  
   149     iColors = TRgb(iColVal);
   160     iChoosenColor = TRgb(iColVal);
   150         
   161         
   151     iPicture = new( ELeave )CDbColorPicture( TSize( 0, 0 ) );
   162     iPicture = new( ELeave )CDbColorPicture( TSize( 0, 0 ) );
   152     iPicture->SetRgbColorsL(iColors);
   163     iPicture->SetRgbColorsL(iChoosenColor);
   153     
   164     
   154     //set sync value
   165     //set sync value
   155     // ESyncStatus
   166     // ESyncStatus
   156     TBuf8<KBuffLength> keyBuff;    
   167     TBuf8<KBuffLength> keyBuff;    
   157     keyBuff.AppendNum(ESyncStatus);
   168     keyBuff.AppendNum(ESyncStatus);
   159     TRAPD(err,pkgSyncStatus.Set(iCalendarInfo.PropertyValueL(keyBuff)));
   170     TRAPD(err,pkgSyncStatus.Set(iCalendarInfo.PropertyValueL(keyBuff)));
   160     if( KErrNone == err )
   171     if( KErrNone == err )
   161         {
   172         {
   162         iSyncStatus = pkgSyncStatus();
   173         iSyncStatus = pkgSyncStatus();
   163         }
   174         }
   164     TRACE_EXIT_POINT;
   175     
       
   176     LoadColorsL();
       
   177     
       
   178     TRACE_EXIT_POINT;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CCalenMultiDBEditor::LoadColorsL
       
   183 // (other items were commented in a header).
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 void CCalenMultiDBEditor::LoadColorsL()
       
   187     {
       
   188     TRACE_ENTRY_POINT
       
   189     
       
   190     if(iRgbColors)
       
   191         {
       
   192         iRgbColors->Reset();
       
   193         delete iRgbColors;
       
   194         iRgbColors = NULL;
       
   195         }
       
   196     
       
   197     iRgbColors = new(ELeave) CArrayFixFlat<TRgb>(2);
       
   198     
       
   199     iRgbColors->AppendL(KRgbRed);
       
   200     iRgbColors->AppendL(KRgbDarkGray);
       
   201     iRgbColors->AppendL(KRgbDarkRed);
       
   202     iRgbColors->AppendL(KRgbDarkGreen);
       
   203     iRgbColors->AppendL(KRgbDarkYellow);
       
   204     iRgbColors->AppendL(KRgbDarkBlue);
       
   205     iRgbColors->AppendL(KRgbDarkMagenta);
       
   206     iRgbColors->AppendL(KRgbDarkCyan);
       
   207     iRgbColors->AppendL(KRgbBlack);
       
   208     iRgbColors->AppendL(KRgbGreen);
       
   209     iRgbColors->AppendL(KRgbYellow);
       
   210     iRgbColors->AppendL(KRgbBlue);
       
   211     iRgbColors->AppendL(KRgbMagenta);
       
   212     iRgbColors->AppendL(KRgbCyan);
       
   213     iRgbColors->AppendL(KRgbGray);
       
   214     iRgbColors->AppendL(KRgbWhite);
       
   215     
       
   216     TRACE_EXIT_POINT
   165     }
   217     }
   166 
   218 
   167 // -----------------------------------------------------------------------------
   219 // -----------------------------------------------------------------------------
   168 // CCalenMultiDBEditor::ProcessCommandL
   220 // CCalenMultiDBEditor::ProcessCommandL
   169 // Process commands from the user.
   221 // Process commands from the user.
   216 		            }
   268 		            }
   217 		        }
   269 		        }
   218 		    else if ( ECalenMultiDbColor == IdOfFocusControl() )
   270 		    else if ( ECalenMultiDbColor == IdOfFocusControl() )
   219 		        {
   271 		        {
   220 		        GetColorL();
   272 		        GetColorL();
   221 		        iColors = TRgb(iColVal);
       
   222 		        GetLineByLineAndPageIndex(1,0)->DrawNow();
       
   223 		        }
   273 		        }
   224 		    }
   274 		    }
   225 		    break; 
   275 		    break; 
   226 
   276 
   227 		case EAknSoftkeyOpen:
   277 		case EAknSoftkeyOpen:
   228 		    {
   278 		    {
   229 		    GetColorL();
   279 		    GetColorL();
   230 		    iColors = TRgb(iColVal);
       
   231 		    GetLineByLineAndPageIndex(1,0)->DrawNow(); 
       
   232 		    } 
   280 		    } 
   233 		    break;
   281 		    break;
   234 			
   282 			
   235 		default:
   283 		default:
   236 		    {
   284 		    {
   253    switch(IdOfFocusControl())
   301    switch(IdOfFocusControl())
   254        {
   302        {
   255        case ECalenMultiDbColor:
   303        case ECalenMultiDbColor:
   256           {
   304           {
   257           GetColorL();
   305           GetColorL();
   258           iColors = TRgb(iColVal);
       
   259           GetLineByLineAndPageIndex(1,0)->DrawNow(); 
       
   260           }
   306           }
   261           break;
   307           break;
   262 	  default:
   308 	  default:
   263            {
   309            {
   264            // No implementation yet.
   310            // No implementation yet.
   312     switch(aButtonId)
   358     switch(aButtonId)
   313         {
   359         {
   314         case EAknSoftkeyOpen:
   360         case EAknSoftkeyOpen:
   315             {
   361             {
   316             GetColorL();
   362             GetColorL();
   317             iColors = TRgb(iColVal);
       
   318             GetLineByLineAndPageIndex(1,0)->DrawNow(); 
       
   319             } 
   363             } 
   320             break;
   364             break;
   321             
   365             
   322         case EAknSoftkeyOptions:
   366         case EAknSoftkeyOptions:
   323             {
   367             {
   352                     }
   396                     }
   353                 }
   397                 }
   354             else if ( ECalenMultiDbColor == IdOfFocusControl() )
   398             else if ( ECalenMultiDbColor == IdOfFocusControl() )
   355                 {
   399                 {
   356                 GetColorL();
   400                 GetColorL();
   357                 iColors = TRgb(iColVal);
       
   358                 GetLineByLineAndPageIndex(1,0)->DrawNow(); 
       
   359                 }
   401                 }
   360             }
   402             }
   361             break;    
   403             break;    
   362             
   404             
   363         case EAknSoftkeyDone:
   405         case EAknSoftkeyDone:
   364             {
   406             {
   365             isExitForm = SaveNoteL(aButtonId);
   407             isExitForm = SaveNoteL(aButtonId);
       
   408             if(isExitForm)
       
   409                 {
       
   410                 iMultipleDbUi.UpdateOnAddOrEditL(!iEditFlag);
       
   411                 }
   366             }
   412             }
   367             break;
   413             break;
   368         case EAknSoftkeyExit:    
   414         case EAknSoftkeyExit:    
   369         case EAknCmdExit:
   415         case EAknCmdExit:
   370             {
   416             {
   371             SaveNoteL(aButtonId); 
   417             isExitForm  = SaveNoteL(aButtonId); 
   372             isExitForm = ETrue;
   418             if(isExitForm)
   373             }
   419                 {
       
   420                 iMultipleDbUi.UpdateOnAddOrEditL(!iEditFlag);
       
   421                 }
       
   422              iMultipleDbUi.ExitDialogL();           
       
   423 			 }
   374             break;
   424             break;
   375         case EAknSoftkeyQuit:
   425         case EAknSoftkeyQuit:
   376             {
   426             {
   377             isExitForm = ETrue;
   427             isExitForm = ETrue;
   378             }
   428             }
   575 // ---------------------------------------------------------------------------
   625 // ---------------------------------------------------------------------------
   576 //
   626 //
   577 void CCalenMultiDBEditor::GetColorL()
   627 void CCalenMultiDBEditor::GetColorL()
   578     {  
   628     {  
   579     TRACE_ENTRY_POINT;
   629     TRACE_ENTRY_POINT;
   580       
   630     iNoneChoosen = ETrue;
   581     TBool retVal = EFalse;
       
   582     
       
   583     // Array for TRgb colour values
       
   584     CArrayFixFlat<TRgb>* colors = new( ELeave ) CArrayFixFlat<TRgb>( 8 );
       
   585     CleanupStack::PushL( colors );
       
   586     
       
   587     // array of colors.
       
   588     colors->AppendL(KRgbRed);
       
   589     colors->AppendL(KRgbDarkGray);
       
   590     colors->AppendL(KRgbDarkRed);
       
   591     colors->AppendL(KRgbDarkGreen);
       
   592     colors->AppendL(KRgbDarkYellow);
       
   593     colors->AppendL(KRgbDarkBlue);
       
   594     colors->AppendL(KRgbDarkMagenta);
       
   595     colors->AppendL(KRgbDarkCyan);
       
   596     colors->AppendL(KRgbBlack);
       
   597     colors->AppendL(KRgbGreen);
       
   598     colors->AppendL(KRgbYellow);
       
   599     colors->AppendL(KRgbBlue);
       
   600     colors->AppendL(KRgbMagenta);
       
   601     colors->AppendL(KRgbCyan);
       
   602     colors->AppendL(KRgbGray);
       
   603     colors->AppendL(KRgbWhite);
       
   604    
       
   605     // Get current colour
       
   606     TRgb color = KCalenColorPalletteStartColor; //iDbInfo.GetCalendarColor(); 
       
   607     TInt startValue = iColVal;
       
   608     TBool noneChosen = ETrue;
       
   609     
   631     
   610     // Construct colour selection grid
   632     // Construct colour selection grid
   611     CAknColourSelectionGrid *dlg = CAknColourSelectionGrid::NewL(colors, EFalse,
   633     CAknDialog  *dlg = CAknColourSelectionGrid::NewL(iRgbColors, EFalse,
   612             noneChosen,color );
   634             iNoneChoosen,iChoosenColor );
   613 
   635 
   614     retVal = dlg->ExecuteLD();
   636     dlg->ExecuteLD(R_CALEN_MULTIDB_EDITOR_COLOR_GRID_DLG);
   615     
   637     
   616     iColVal = KErrNotFound;
   638     TRACE_EXIT_POINT;
   617     if ( !noneChosen  && retVal )//If something is chosen
   639     }
   618   	    {
   640 
   619 		iColVal = color.Value();
   641 // ---------------------------------------------------------------------------
   620 		}    
   642 // CCalenMultiDBEditor::FocusChanged
   621     else//Else set the previous color.
   643 // ---------------------------------------------------------------------------
   622         {
   644 //
   623         iColVal = startValue;
   645 void CCalenMultiDBEditor::FocusChanged(TDrawNow /*aDrawNow*/)
   624         }
   646     {
   625     iColors = TRgb(iColVal);
   647     TRACE_ENTRY_POINT
   626     iPicture->SetRgbColorsL(iColors);  
   648     
   627     CleanupStack::PopAndDestroy( colors );	
   649     if(IsFocused() && !iNoneChoosen)
   628 	TRACE_EXIT_POINT;
   650         {
       
   651         iColVal = iChoosenColor.Value();
       
   652         iPicture->SetRgbColorsL(iChoosenColor);
       
   653         GetLineByLineAndPageIndex(1, 0)->DrawNow();
       
   654         }
       
   655     
       
   656     TRACE_EXIT_POINT
   629     }
   657     }
   630 
   658 
   631 // ---------------------------------------------------------------------------
   659 // ---------------------------------------------------------------------------
   632 // CCalenMultiDBEditor::SaveNoteL
   660 // CCalenMultiDBEditor::SaveNoteL
   633 // Try to save note. Initializes all the member variables of DBInfo.
   661 // Try to save note. Initializes all the member variables of DBInfo.
   801 //
   829 //
   802 void CCalenMultiDBEditor::ReadDataFromFormL( TBool /*aContinueOnError */)
   830 void CCalenMultiDBEditor::ReadDataFromFormL( TBool /*aContinueOnError */)
   803     {
   831     {
   804     TRACE_ENTRY_POINT;
   832     TRACE_ENTRY_POINT;
   805     //Initial Name value
   833     //Initial Name value
   806      TPtr summary = iCalendarName->Des();    
   834     TPtr summary = iCalendarName->Des();
   807       
   835 
   808      CEikEdwin* edwin =
   836     CEikEdwin* edwin = reinterpret_cast<CEikEdwin*> (Control(
   809               reinterpret_cast<CEikEdwin*>(Control(ECalenMultiDbName));
   837             ECalenMultiDbName));
   810       GetEdwinText(summary, ECalenMultiDbName);
   838     GetEdwinText(summary, ECalenMultiDbName);
   811       
   839 
   812       TRACE_EXIT_POINT;
   840     TRACE_EXIT_POINT;
   813     }
   841     }
   814 // ---------------------------------------------------------------------------
   842 // ---------------------------------------------------------------------------
   815 // CCalenMultiDBEditor::IsNameEditedL
   843 // CCalenMultiDBEditor::IsNameEditedL
   816 // Checks wether Name got edited or not.
   844 // Checks wether Name got edited or not.
   817 // ---------------------------------------------------------------------------
   845 // ---------------------------------------------------------------------------
   966         switch(focusControl)
   994         switch(focusControl)
   967             {
   995             {
   968             case ECalenMultiDbColor:
   996             case ECalenMultiDbColor:
   969                 {
   997                 {
   970                 GetColorL();
   998                 GetColorL();
   971                 iColors = TRgb(iColVal);
       
   972                 GetLineByLineAndPageIndex(1,0)->DrawNow();
       
   973                 }
   999                 }
   974                 break;
  1000                 break;
   975                     
  1001                     
   976             case ECalenMultiDbSyncStatus:
  1002             case ECalenMultiDbSyncStatus:
   977                 {
  1003                 {
  1207     {
  1233     {
  1208     TRACE_ENTRY_POINT;
  1234     TRACE_ENTRY_POINT;
  1209     TRACE_EXIT_POINT;	 
  1235     TRACE_EXIT_POINT;	 
  1210     }
  1236     }
  1211 
  1237 
       
  1238 // -----------------------------------------------------------------------------
       
  1239 // CDbColorPicture::SetRgbColorsL
       
  1240 // -----------------------------------------------------------------------------
       
  1241 //
  1212 void CDbColorPicture::SetRgbColorsL(TRgb aColors)  
  1242 void CDbColorPicture::SetRgbColorsL(TRgb aColors)  
  1213     {
  1243     {
  1214     TRACE_ENTRY_POINT;
  1244     TRACE_ENTRY_POINT;
  1215     iColors = aColors;
  1245     iColors = aColors;
  1216     TRACE_EXIT_POINT;    
  1246     TRACE_EXIT_POINT;