messagingappbase/msgavkon/muiu_domain/folderselectiondialog/src/MsgFolderSelectionDialog.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *    Dialog for selecting message folder
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <AknsUtils.h> // CreateIconL
       
    23 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
       
    24 #include <eiktxlbx.h>  // CEikTextListBox
       
    25 #include <eiktxlbm.h>  // CTextListBoxModel
       
    26 #include <avkon.hrh>
       
    27 #include <msvuids.h>
       
    28 #include <msvapi.h>
       
    29 #include <bautils.h>    // BaflUtils
       
    30 #include <gulicon.h>    // CGulIcon
       
    31 #include <aknlists.h>
       
    32 #include <eikclbd.h>
       
    33 #include <AknQueryDialog.h>
       
    34 #include <aknPopupHeadingPane.h>
       
    35 #include <AknIconArray.h> // CAknIconArray
       
    36 #include <muiu.rsg>       // r_muiu_folder_selection_list_query
       
    37 #include <muiu.mbg>
       
    38 #include <avkon.mbg>
       
    39 #include <AknIconUtils.h> // AknIconUtils::AvkonIconFileName()
       
    40 #include "MsgFolderSelectionDialog.h"
       
    41 #include "MsgFolderSelectionListArray.h"
       
    42 
       
    43 
       
    44 
       
    45 // CONSTANTS
       
    46 _LIT(KDirAndResFileName,"muiu.rsc");
       
    47 _LIT(KDirAndMuiuMbmFile,"muiu.mbm");
       
    48 const TInt KMuiuArrayGranularity    = 4;
       
    49 
       
    50 
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =======================
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CMsgFolderSelectionDialog::CMsgFolderSelectionDialog
       
    57 // C++ default constructor can NOT contain any code, that
       
    58 // might leave.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CMsgFolderSelectionDialog::CMsgFolderSelectionDialog( TMsvId& aSelectedFolder, TDesC& aTitle )
       
    62 :
       
    63 iSelectedFolder( aSelectedFolder ),
       
    64 iTitle( aTitle ),
       
    65 iResources( *CCoeEnv::Static() )
       
    66     {
       
    67     }
       
    68 
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CMsgFolderSelectionDialog::ConstructL
       
    72 // Symbian OS default constructor can leave.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CMsgFolderSelectionDialog::ConstructL()
       
    76     {
       
    77     TParse parse;
       
    78     parse.Set(KDirAndMuiuMbmFile, &KDC_APP_BITMAP_DIR, NULL); 
       
    79     TFileName fileName(parse.FullName());
       
    80 
       
    81     iFolderArray = CMsgFolderSelectionListArray::NewL( iSelectedFolder );
       
    82     iIcons = new( ELeave ) CAknIconArray( KMuiuArrayGranularity );
       
    83 
       
    84     CFbsBitmap* bitmap;
       
    85     CFbsBitmap* bitmapMask;
       
    86     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
       
    87 
       
    88     //EMbmMuiuQgn_prop_mce_inbox_small
       
    89     AknsUtils::CreateIconL( skins, KAknsIIDQgnPropMceInboxSmall, bitmap,
       
    90            bitmapMask, fileName, EMbmMuiuQgn_prop_mce_inbox_small,
       
    91            EMbmMuiuQgn_prop_mce_inbox_small + 1 );
       
    92     iIcons->AppendL(CGulIcon::NewL( bitmap, bitmapMask ));
       
    93 
       
    94     //EMbmMuiuQgn_prop_mce_doc_small
       
    95     AknsUtils::CreateIconL( skins, KAknsIIDQgnPropMceDocSmall, bitmap,
       
    96            bitmapMask, fileName, EMbmMuiuQgn_prop_mce_doc_small,
       
    97            EMbmMuiuQgn_prop_mce_doc_small + 1 );
       
    98     iIcons->AppendL(CGulIcon::NewL( bitmap, bitmapMask ));
       
    99 
       
   100     //EMbmAvkonQgn_prop_folder_small
       
   101     fileName = AknIconUtils::AvkonIconFileName();  //avkon.mbm file name and path
       
   102     AknsUtils::CreateIconL( skins, KAknsIIDQgnPropFolderSmall , bitmap,
       
   103            bitmapMask, fileName, EMbmAvkonQgn_prop_folder_small,
       
   104            EMbmAvkonQgn_prop_folder_small + 1 );
       
   105     iIcons->AppendL(CGulIcon::NewL( bitmap, bitmapMask ));
       
   106 
       
   107     parse.Set(KDirAndResFileName, &KDC_RESOURCE_FILES_DIR, NULL);
       
   108     fileName.Copy(parse.FullName());
       
   109     iResources.OpenL( fileName );
       
   110     }
       
   111 
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CMsgFolderSelectionDialog::NewL
       
   116 // Two-phased constructor.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 CMsgFolderSelectionDialog* CMsgFolderSelectionDialog::NewL( TMsvId& aSelectedFolder, 
       
   120                                                             TDesC& aTitle )
       
   121     { // static
       
   122     CMsgFolderSelectionDialog* self = new( ELeave ) CMsgFolderSelectionDialog( aSelectedFolder, 
       
   123                                                                                aTitle );
       
   124     CleanupStack::PushL( self );
       
   125     self->ConstructL();
       
   126     CleanupStack::Pop( self ); // self
       
   127     return self;
       
   128     }
       
   129 
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CMsgFolderSelectionDialog::~CMsgFolderSelectionDialog
       
   133 // Destructor.
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 CMsgFolderSelectionDialog::~CMsgFolderSelectionDialog()
       
   137     {
       
   138     delete iIcons;
       
   139     delete iFolderArray;
       
   140     iResources.Close();
       
   141     }
       
   142 
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CMsgFolderSelectionDialog::ExecutePopupListL
       
   146 // 
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 TBool CMsgFolderSelectionDialog::ExecutePopupListL()
       
   150     {
       
   151     TInt index = 0;
       
   152     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &index );
       
   153     dlg->PrepareLC( R_MUIU_FOLDER_SELECTION_LIST_QUERY );
       
   154     dlg->SetItemTextArray( iFolderArray );
       
   155     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   156     dlg->SetIconArrayL( iIcons ); // takes ownership so must not be deleted
       
   157     iIcons = NULL;
       
   158     CAknPopupHeadingPane* heading = dlg->Heading();
       
   159     heading->SetTextL( iTitle );
       
   160     if( dlg->RunLD( ) )
       
   161         {
       
   162         iSelectedFolder = iFolderArray->ItemId( index );
       
   163         return ETrue;
       
   164         }
       
   165     return EFalse;
       
   166 
       
   167     }
       
   168 
       
   169 
       
   170 // ---------------------------------------------------------
       
   171 // CMsgFolderSelectionDialog::SelectFolderL
       
   172 // ---------------------------------------------------------
       
   173 //
       
   174 EXPORT_C TBool CMsgFolderSelectionDialog::SelectFolderL( TMsvId& aSelectedFolder, TDesC& aTitle )
       
   175     {
       
   176     CMsgFolderSelectionDialog* dlg = CMsgFolderSelectionDialog::NewL( aSelectedFolder, aTitle );
       
   177     CleanupStack::PushL( dlg );
       
   178     TBool button = dlg->ExecutePopupListL();
       
   179     CleanupStack::PopAndDestroy( dlg );
       
   180     return button;
       
   181     }
       
   182 
       
   183 //  End of File
       
   184