meetingrequest/mrgui/src/cesmrtrackingviewdialog.cpp
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 *  Description : ESMR tracking view dialog
       
    15 *  Version     : %version: e002sa32#15.1.1 %
       
    16 *
       
    17 */
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "cesmrtrackingviewdialog.h"
       
    21 
       
    22 // SYSTEM INCLUDE
       
    23 #include <AknUtils.h>
       
    24 #include <StringLoader.h>
       
    25 #include <calentry.h>
       
    26 #include <MAgnEntryUi.h>
       
    27 //<cmail>
       
    28 #include "cesmrpolicy.h"
       
    29 //</cmail>
       
    30 #include <esmrgui.rsg>
       
    31 
       
    32 #include "esmrgui.hrh"
       
    33 #include "cesmrtrackingview.h"
       
    34 #include "cesmrviewerfieldstorage.h"
       
    35 #include "mesmrcalentry.h"
       
    36 #include "cesmrcontactmenuhandler.h"
       
    37 #include "esmrconfig.hrh"
       
    38 #include "esmrinternaluid.h"
       
    39 
       
    40 #ifdef _DEBUG
       
    41 namespace // codescanner::namespace
       
    42 {
       
    43 // Literal for viewer dialog
       
    44 _LIT( KESMRTrackinglgPanicTxt, "ESMRTrackingDlg" );
       
    45 
       
    46 enum TESMRViewerDlgPanic
       
    47     {
       
    48     EESMRTrackingVieweDlgInvalidCommand
       
    49     };
       
    50 
       
    51 void Panic( TESMRViewerDlgPanic aPanic )
       
    52     {
       
    53     User::Panic( KESMRTrackinglgPanicTxt, aPanic );
       
    54     }
       
    55 }
       
    56 #endif
       
    57 
       
    58 // ======== MEMBER FUNCTIONS ========
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CESMRTrackingViewDialog::NewL
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CESMRTrackingViewDialog* CESMRTrackingViewDialog::NewL(
       
    65 		const CESMRPolicy& aPolicy,
       
    66 		MESMRCalEntry& aEntry,
       
    67 		MAgnEntryUiCallback& aCallback )
       
    68     {
       
    69     FUNC_LOG;
       
    70     CESMRTrackingViewDialog* self =
       
    71 	new (ELeave) CESMRTrackingViewDialog( aPolicy, aEntry, aCallback);
       
    72 	CleanupStack::PushL( self );
       
    73 	self->ConstructL();
       
    74 	CleanupStack::Pop( self );
       
    75 	return self;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CESMRTrackingViewDialog::~CESMRTrackingViewDialog
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 CESMRTrackingViewDialog::~CESMRTrackingViewDialog()
       
    83     {
       
    84     FUNC_LOG;
       
    85     
       
    86     iESMRStatic.Close();
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CESMRTrackingViewDialog::CESMRTrackingViewDialog
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CESMRTrackingViewDialog::CESMRTrackingViewDialog(
       
    94         const CESMRPolicy& aPolicy,
       
    95 		MESMRCalEntry& aEntry,
       
    96 		MAgnEntryUiCallback& aCallback) :
       
    97     iPolicy( aPolicy ),
       
    98 	iEntry( aEntry ),
       
    99     iCallback(aCallback)
       
   100     {
       
   101     FUNC_LOG;
       
   102     // Do nothing
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CESMRTrackingViewDialog::ConstructL
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CESMRTrackingViewDialog::ConstructL()
       
   110     {
       
   111     FUNC_LOG;
       
   112     CAknDialog::ConstructL ( R_TRACKING_DIALOG_MENUBAR );
       
   113     iESMRStatic.ConnectL();
       
   114     iESMRStatic.ContactMenuHandlerL().Reset();
       
   115 
       
   116     TRect clientRect;
       
   117     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, clientRect );
       
   118 
       
   119     // Sort the attendees list so that Req attendeees comes  first
       
   120     // and then opt attendees
       
   121     SortAttendeesL();
       
   122 
       
   123     // Set the index of builder to zero so that
       
   124     // participant field is created from index.
       
   125 
       
   126     iESMRStatic.SetCurrentFieldIndex(0);
       
   127 
       
   128     iView = CESMRTrackingView::NewL( iEntry, clientRect,
       
   129             CountAttendeesL(CCalAttendee::EReqParticipant),
       
   130             CountAttendeesL(CCalAttendee::EOptParticipant));
       
   131     iView->SetParentDialog(this);
       
   132 
       
   133     if ( iEntry.Entry().SummaryL().Length() == 0 )
       
   134 		 {
       
   135 		 // if no title, set unnamed text:
       
   136 		 HBufC* title = StringLoader::LoadLC (R_QTN_MEET_REQ_CONFLICT_UNNAMED);
       
   137 		 iView->SetTitleL( *title );
       
   138 		 CleanupStack::PopAndDestroy( title );
       
   139 		 }
       
   140     else
       
   141          {
       
   142          iView->SetTitleL( iEntry.Entry().SummaryL() );
       
   143          }
       
   144 
       
   145     iMenuBar->SetContextMenuTitleResourceId( R_MR_TRACKING_VIEW_CONTEXT_MENU );
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CESMRTrackingViewDialog::CreateCustomControlL
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 SEikControlInfo
       
   153     CESMRTrackingViewDialog::CreateCustomControlL( TInt aType )
       
   154     {
       
   155     FUNC_LOG;
       
   156     SEikControlInfo controlInfo;
       
   157     controlInfo.iControl = NULL;
       
   158     controlInfo.iFlags = 0;
       
   159     controlInfo.iTrailerTextId = 0;
       
   160 
       
   161     if ( aType == EEsMrTrackingType )
       
   162         {
       
   163         controlInfo.iControl = iView;
       
   164         }
       
   165 
       
   166     return controlInfo;
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CESMRTrackingViewDialog::OfferKeyEventL
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 TKeyResponse CESMRTrackingViewDialog::OfferKeyEventL
       
   174         (const TKeyEvent& aEvent, TEventCode aType)
       
   175     {
       
   176     FUNC_LOG;
       
   177     TKeyResponse response = CAknDialog::OfferKeyEventL( aEvent, aType );
       
   178 
       
   179     if ( ( response == EKeyWasNotConsumed && aEvent.iCode != EKeyEscape)
       
   180 		   && (!MenuShowing()) )
       
   181 		{
       
   182 		response = iView->OfferKeyEventL( aEvent, aType );
       
   183 		}
       
   184 	return response;
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CESMRTrackingViewDialog::OkToExitL
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TBool CESMRTrackingViewDialog::OkToExitL (TInt aButtonId)
       
   192     {
       
   193     FUNC_LOG;
       
   194     TBool res( EFalse );
       
   195     // show options
       
   196     switch ( aButtonId )
       
   197         {
       
   198         case EAknSoftkeyOptions:
       
   199             {
       
   200             CAknDialog::DisplayMenuL();
       
   201             break;
       
   202             }
       
   203         case EESMRCmdBack:
       
   204             {
       
   205             res = ETrue;
       
   206             break;
       
   207             }
       
   208         case EESMRCmdCall:
       
   209             {
       
   210             iESMRStatic.ContactMenuHandlerL().ExecuteOptionsMenuL(
       
   211 												EESMRCmdActionMenuFirst );
       
   212             break;
       
   213             }
       
   214         default:
       
   215             {
       
   216             res = CAknDialog::OkToExitL( aButtonId );
       
   217             break;
       
   218             }
       
   219         }
       
   220 
       
   221     return res;
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CESMRTrackingViewDialog::CountAttendeesL
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 TInt CESMRTrackingViewDialog::CountAttendeesL( // codescanner::intleaves
       
   229         CCalAttendee::TCalRole aRole)
       
   230     {
       
   231     FUNC_LOG;
       
   232     RPointerArray<CCalAttendee>& calAttendeeList = iEntry.Entry().AttendeesL();
       
   233 
       
   234     TInt totalParticipants = calAttendeeList.Count();
       
   235     TInt totalAttendees(0);
       
   236 
       
   237     for (TInt i=0; i< totalParticipants; i++)
       
   238         {
       
   239         CCalAttendee::TCalRole role = CCalAttendee::ENonParticipant;
       
   240         role = calAttendeeList[i]->RoleL();
       
   241         if ( role == aRole )
       
   242         	{
       
   243         	++totalAttendees;
       
   244         	}
       
   245         }
       
   246     return totalAttendees;
       
   247     }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // CESMRTrackingViewDialog::SortAttendeesL
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 void CESMRTrackingViewDialog::SortAttendeesL()
       
   254     {
       
   255     FUNC_LOG;
       
   256     RPointerArray<CCalAttendee>& attendees = iEntry.Entry().AttendeesL();
       
   257     // Sort the attendees so that REqPart come first and then optPart
       
   258     // This is required once only
       
   259      TInt i, j;
       
   260      TBool flag = ETrue;    // set flag to true to begin initial pass
       
   261      TInt arrayLength = attendees.Count();
       
   262      for(i = 1; (i <= arrayLength) && flag; i++)
       
   263          {
       
   264           flag = EFalse;
       
   265           for (j=0; j < (arrayLength -1); j++)
       
   266               {
       
   267               CCalAttendee::TCalRole lhs = CCalAttendee::ENonParticipant;
       
   268               CCalAttendee::TCalRole rhs = CCalAttendee::ENonParticipant;
       
   269               lhs = attendees[j+1]->RoleL();
       
   270               rhs = attendees[j]->RoleL();
       
   271               if ( lhs < rhs )
       
   272                   {
       
   273                   CCalAttendee* tempAttendee = attendees[j];
       
   274                   attendees[j]   = attendees[j+1];
       
   275                   attendees[j+1] = tempAttendee;
       
   276                   flag = ETrue;   // indicates that a swap occurred.
       
   277                   }
       
   278               }// Inner loop (j)
       
   279          } // Outer loop (i)
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------------------------
       
   283 // CESMRTrackingViewDialog::ProcessCommandL
       
   284 // ---------------------------------------------------------------------------
       
   285 //
       
   286 void CESMRTrackingViewDialog::ProcessCommandL( TInt aCommand )
       
   287     {
       
   288     FUNC_LOG;
       
   289     TRAPD( err, DoProcessCommandL( aCommand ) );
       
   290     if ( err != KErrNone &&
       
   291          err != KErrCancel &&
       
   292          err != KErrArgument )
       
   293         {
       
   294         User::Leave(err);
       
   295         }
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------------------------
       
   299 // CESMRTrackingViewDialog::DoProcessCommandL
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 void CESMRTrackingViewDialog::DoProcessCommandL( TInt aCommand )
       
   303     {
       
   304     FUNC_LOG;
       
   305     CAknDialog::ProcessCommandL( aCommand );
       
   306     switch ( aCommand )
       
   307         {
       
   308         case EAknCmdExit:
       
   309         	{
       
   310             TryExitL( aCommand );
       
   311             break;
       
   312         	}
       
   313         case EAknCmdHelp:
       
   314             {
       
   315             iView->LaunchViewerHelpL();
       
   316             break;
       
   317             }
       
   318         default:
       
   319         	{
       
   320             if ( aCommand >= EESMRCmdActionMenuFirst &&
       
   321             	 aCommand <= EESMRCmdActionMenuLast )
       
   322                 {
       
   323                 iESMRStatic.ContactMenuHandlerL().ExecuteOptionsMenuL(
       
   324 																aCommand );
       
   325                 }
       
   326             else
       
   327                 {
       
   328                 __ASSERT_DEBUG( EFalse,
       
   329                 		Panic( EESMRTrackingVieweDlgInvalidCommand ) );
       
   330                 }
       
   331             break;
       
   332         	}
       
   333         }
       
   334     }
       
   335 
       
   336 // ---------------------------------------------------------------------------
       
   337 // CESMRTrackingViewDialog::DynInitMenuPaneL
       
   338 // ---------------------------------------------------------------------------
       
   339 //
       
   340 void CESMRTrackingViewDialog::DynInitMenuPaneL(
       
   341 		TInt aResourceId,
       
   342         CEikMenuPane* aMenuPane )
       
   343     {
       
   344     FUNC_LOG;
       
   345     if ( aResourceId == R_ACTION_MENU )
       
   346         {
       
   347         iESMRStatic.ContactMenuHandlerL().InitOptionsMenuL( aMenuPane );
       
   348         }
       
   349 
       
   350     if ( aResourceId == R_MR_TRACKING_VIEW_MENU )
       
   351         {
       
   352         aMenuPane->SetItemDimmed( EESMRCmdActionMenu,
       
   353         		!iESMRStatic.ContactMenuHandlerL().OptionsMenuAvailable() );
       
   354         }
       
   355     }
       
   356 
       
   357 // ---------------------------------------------------------------------------
       
   358 // CESMRTrackingViewDialog::ActivateL
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 void CESMRTrackingViewDialog::ActivateL()
       
   362     {
       
   363     FUNC_LOG;
       
   364     CAknDialog::ActivateL();
       
   365     iView->InternalizeL();
       
   366     }
       
   367 
       
   368 // ---------------------------------------------------------------------------
       
   369 // CESMRTrackingViewDialog::ExecuteViewLD
       
   370 // ---------------------------------------------------------------------------
       
   371 //
       
   372 TInt CESMRTrackingViewDialog::ExecuteViewLD()
       
   373     {
       
   374     FUNC_LOG;
       
   375     return ExecuteLD( R_MRTRACKING_DIALOG );
       
   376     }
       
   377 
       
   378 // ---------------------------------------------------------------------------
       
   379 // CESMRTrackingViewDialog::HandleFieldEventL
       
   380 // ---------------------------------------------------------------------------
       
   381 
       
   382 void CESMRTrackingViewDialog::HandleListEventL()
       
   383     {
       
   384     FUNC_LOG;
       
   385     iMenuBar->TryDisplayContextMenuBarL();
       
   386     }
       
   387 
       
   388 // End of File
       
   389