photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerdelete.cpp
changeset 0 4e91876724a2
child 3 9a9c174934f5
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-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:    Delete command handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxcommandhandlerdelete.h"
       
    22 
       
    23 #include <AknUtils.h>
       
    24 #include <bautils.h>
       
    25 #include <data_caging_path_literals.hrh>
       
    26 #include <glxcommandhandlers.hrh>
       
    27 #include <glxuiutility.h>
       
    28 #include <glxuistd.h>
       
    29 #include <glxuiutilities.rsg>
       
    30 #include <mglxmedialist.h>
       
    31 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
       
    32 #include <glxscreenfurniture.h>
       
    33 #include <mpxcollectionpath.h>
       
    34 #include <StringLoader.h>
       
    35 
       
    36 #include <glxicons.mbg>
       
    37 #include <glxtracer.h>
       
    38 #include <glxnavigationalstate.h>
       
    39 #include <mpxcollectionpath.h>
       
    40 #include <glxcollectionpluginimageviewer.hrh>
       
    41 #include "glxcommandfactory.h"
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // Two-phased constructor.
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CGlxCommandHandlerDelete* CGlxCommandHandlerDelete::NewL(
       
    48         MGlxMediaListProvider* aMediaListProvider, TBool aContainerList, TBool aHasToolbarItem)
       
    49     {
       
    50     /// @todo Minor: Rowland Cook 06/06/07 no use of glx logging
       
    51     CGlxCommandHandlerDelete* self = new (ELeave) CGlxCommandHandlerDelete(aMediaListProvider, aHasToolbarItem);
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL(aContainerList);
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // C++ default constructor can NOT contain any code, that
       
    60 // might leave.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CGlxCommandHandlerDelete::CGlxCommandHandlerDelete(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem)
       
    64         : CGlxMpxCommandCommandHandler( aMediaListProvider, aHasToolbarItem )
       
    65     {
       
    66     // Don't do anything.
       
    67     }
       
    68  
       
    69 // ---------------------------------------------------------------------------
       
    70 // Symbian 2nd phase constructor can leave.
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CGlxCommandHandlerDelete::ConstructL(TBool aIsContainerList)
       
    74     {
       
    75     iIsContainerList = aIsContainerList;
       
    76     iUiUtility = CGlxUiUtility::UtilityL();
       
    77     
       
    78     // Load resource file
       
    79 	TParse parse;
       
    80     parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL);
       
    81     TFileName resourceFile;
       
    82     resourceFile.Append(parse.FullName());
       
    83     CGlxResourceUtilities::GetResourceFilenameL(resourceFile);  
       
    84    	iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile);
       
    85 
       
    86    	// Add supported command
       
    87    	TCommandInfo info( EGlxCmdDelete );
       
    88    	// Filter out static items
       
    89     info.iMinSelectionLength = 1;
       
    90     info.iDisallowSystemItems = aIsContainerList;
       
    91    	AddCommandL(info);
       
    92 	}
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Destructor
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 EXPORT_C CGlxCommandHandlerDelete::~CGlxCommandHandlerDelete()
       
    99     {
       
   100     if (iResourceOffset)
       
   101         {
       
   102         CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
       
   103         }
       
   104     if(iUiUtility)
       
   105         {
       
   106         iUiUtility->Close();
       
   107         }
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // Create an add to container command
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 CMPXCommand* CGlxCommandHandlerDelete::CreateCommandL(TInt /*aCommandId*/, 
       
   115         MGlxMediaList& aMediaList, TBool& /*aConsume*/) const
       
   116     {
       
   117     CMPXCollectionPath* path = aMediaList.PathLC( NGlxListDefs::EPathFocusOrSelection );
       
   118     CMPXCommand* command = TGlxCommandFactory::DeleteCommandLC(*path);
       
   119     CleanupStack::Pop(command);
       
   120     CleanupStack::PopAndDestroy(path);
       
   121     return command;
       
   122     } 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // Return default progress string
       
   126 // -----------------------------------------------------------------------------
       
   127 //	
       
   128 HBufC* CGlxCommandHandlerDelete::ProgressTextL(TInt /*aCommandId*/) const
       
   129     {
       
   130     return StringLoader::LoadL(R_QTN_FLDR_DELETING_WAIT_NOTE);
       
   131     }
       
   132     
       
   133 // -----------------------------------------------------------------------------
       
   134 // Return confirmation string
       
   135 // -----------------------------------------------------------------------------
       
   136 //	
       
   137 HBufC* CGlxCommandHandlerDelete::ConfirmationTextL(TInt /*aCommandId*/, 
       
   138         TBool aMultiSelection) const
       
   139     {
       
   140     // Return appropriate confirmation note
       
   141     HBufC* text = NULL;
       
   142     if (aMultiSelection)    
       
   143         {
       
   144         if (iIsContainerList) 
       
   145             {
       
   146             // Delete multiple containers string
       
   147             text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_CONTAINER_MULTIPLE);
       
   148             }
       
   149         else 
       
   150             {
       
   151             // Delete multiple items string
       
   152             text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_MULTIPLE);
       
   153             }
       
   154         }
       
   155     else 
       
   156     	{
       
   157 	    if (iIsContainerList) 
       
   158 	          {
       
   159 	          // Delete one container string
       
   160 	          text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_CONTAINER_SINGLE);
       
   161 	          }
       
   162 	        else 
       
   163 	          {
       
   164 	          // Delete one item string
       
   165 	          text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_SINGLE);
       
   166 	          }
       
   167     	}
       
   168     return text; 
       
   169     }
       
   170     
       
   171 // ----------------------------------------------------------------------------
       
   172 // DoActivateL
       
   173 // ----------------------------------------------------------------------------
       
   174 void CGlxCommandHandlerDelete::DoActivateL(TInt /*aViewId*/)
       
   175 	{
       
   176 
       
   177 	}
       
   178 
       
   179 // ----------------------------------------------------------------------------
       
   180 // OfferKeyEventL
       
   181 // ----------------------------------------------------------------------------
       
   182 TKeyResponse CGlxCommandHandlerDelete::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   183 															TEventCode aType)
       
   184 	{
       
   185     TKeyResponse response = EKeyWasNotConsumed;
       
   186     // Is the key event from the Cancel (Backspace) key
       
   187 	if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey)
       
   188 		{
       
   189 		// try to execute the delete command
       
   190 		if(ExecuteL( EGlxCmdDelete ))
       
   191 		    {
       
   192     		response = EKeyWasConsumed;
       
   193 		    }
       
   194 		}
       
   195 	return response;	
       
   196 	}
       
   197 
       
   198 // ----------------------------------------------------------------------------
       
   199 // PopulateToolbar
       
   200 // ----------------------------------------------------------------------------
       
   201 //
       
   202 void CGlxCommandHandlerDelete::PopulateToolbarL()
       
   203 	{
       
   204 	TRACER( "CGlxCommandHandlerRename::PopulateToolbar" );
       
   205 	
       
   206 	iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdDelete, CAknButton::EPositionLeft );
       
   207 	}
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // DoIsDisabled
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 TBool CGlxCommandHandlerDelete::DoIsDisabled(TInt aCommandId, 
       
   214         MGlxMediaList& aList) const 
       
   215         {
       
   216         TRACER( "CGlxCommandHandlerDelete::DoIsDisabled" );
       
   217         TBool fullscreenViewingMode = EFalse;
       
   218         CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL();
       
   219         CMPXCollectionPath* naviState = aNavigationalState->StateLC();
       
   220         
       
   221         if ( naviState->Levels() >= 1)
       
   222             {
       
   223             if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) 
       
   224                 {
       
   225                 // For image viewer collection, goto view mode
       
   226                 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
       
   227                     {
       
   228                     //it means we are in img viewer.
       
   229                     fullscreenViewingMode = ETrue;
       
   230                     }
       
   231                 else
       
   232                     {
       
   233                      //it means we are in grid view.
       
   234                     fullscreenViewingMode = EFalse;
       
   235                     }
       
   236                 } 
       
   237             else 
       
   238                 {
       
   239                 //it means we are in Fullscreen.
       
   240                 fullscreenViewingMode = ETrue;
       
   241                 }                
       
   242             }
       
   243         CleanupStack::PopAndDestroy( naviState );
       
   244         aNavigationalState->Close();
       
   245         if(EGlxCmdDelete==aCommandId && (0 == aList.Count() ) && !fullscreenViewingMode)
       
   246             {   
       
   247             return ETrue;
       
   248             }
       
   249         return EFalse;
       
   250         }
       
   251 //end of file
       
   252