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