photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerremovefrom.cpp
changeset 1 9ba538e329bd
parent 0 4e91876724a2
child 3 9a9c174934f5
equal deleted inserted replaced
0:4e91876724a2 1:9ba538e329bd
    35 #include <StringLoader.h>
    35 #include <StringLoader.h>
    36 
    36 
    37 #include "glxcommandfactory.h"
    37 #include "glxcommandfactory.h"
    38 
    38 
    39 // ---------------------------------------------------------------------------
    39 // ---------------------------------------------------------------------------
    40 // Return add (to) tags command handler
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CGlxCommandHandlerRemoveFrom* 
       
    44     CGlxCommandHandlerRemoveFrom::NewRemFromFavCommandHandlerL(
       
    45         MGlxMediaListProvider* aMediaListProvider) 
       
    46     {
       
    47     return CGlxCommandHandlerRemoveFrom::NewL(aMediaListProvider, 
       
    48                                 EMPXAlbum, EGlxCmdRemoveFromFavourites);
       
    49     }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Two-phased constructor.
    40 // Two-phased constructor.
    54 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    55 //
    42 //
    56 EXPORT_C CGlxCommandHandlerRemoveFrom* CGlxCommandHandlerRemoveFrom::NewL(
    43 EXPORT_C CGlxCommandHandlerRemoveFrom* CGlxCommandHandlerRemoveFrom::NewL(
    57         MGlxMediaListProvider* aMediaListProvider, TMPXGeneralCategory aContainerType, 
    44         MGlxMediaListProvider* aMediaListProvider, TMPXGeneralCategory aContainerType)
    58                 TInt aCommandId)
       
    59     {
    45     {
    60     CGlxCommandHandlerRemoveFrom* self = new (ELeave) CGlxCommandHandlerRemoveFrom(
    46     CGlxCommandHandlerRemoveFrom* self = new (ELeave) CGlxCommandHandlerRemoveFrom(aMediaListProvider, aContainerType);
    61             aMediaListProvider, aContainerType);
       
    62     CleanupStack::PushL(self);
    47     CleanupStack::PushL(self);
    63     self->ConstructL(aCommandId);
    48     self->ConstructL();
    64     CleanupStack::Pop(self);
    49     CleanupStack::Pop(self);
    65     return self;
    50     return self;
    66     }
    51     }
    67 
    52 
    68 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    69 // C++ default constructor can NOT contain any code, that
    54 // C++ default constructor can NOT contain any code, that
    70 // might leave.
    55 // might leave.
    71 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    72 //
    57 //
    73 CGlxCommandHandlerRemoveFrom::CGlxCommandHandlerRemoveFrom(MGlxMediaListProvider* 
    58 CGlxCommandHandlerRemoveFrom::CGlxCommandHandlerRemoveFrom(MGlxMediaListProvider* aMediaListProvider, TMPXGeneralCategory aContainerType)
    74         aMediaListProvider, TMPXGeneralCategory aContainerType): 
    59         : CGlxMpxCommandCommandHandler(aMediaListProvider), iContainerType(aContainerType)
    75         CGlxMpxCommandCommandHandler(aMediaListProvider), iContainerType(aContainerType)
       
    76     {
    60     {
    77     // Do nothing
    61     // Do nothing
    78     }
    62     }
    79 
    63 
    80 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    81 // Symbian 2nd phase constructor can leave.
    65 // Symbian 2nd phase constructor can leave.
    82 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    83 //
    67 //
    84 void CGlxCommandHandlerRemoveFrom::ConstructL(TInt aCommandId)
    68 void CGlxCommandHandlerRemoveFrom::ConstructL()
    85     {
    69     {
    86     // Load resource file
    70     // Load resource file
    87 	TParse parse;
    71 	TParse parse;
    88     parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL);
    72     parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL);
    89     TFileName resourceFile;
    73     TFileName resourceFile;
    95    	TCommandInfo info(EGlxCmdRemoveFrom);
    79    	TCommandInfo info(EGlxCmdRemoveFrom);
    96    	// Filter out static items
    80    	// Filter out static items
    97     info.iMinSelectionLength = 1;
    81     info.iMinSelectionLength = 1;
    98     info.iMaxSelectionLength = KMaxTInt;
    82     info.iMaxSelectionLength = KMaxTInt;
    99    	AddCommandL(info);
    83    	AddCommandL(info);
   100 
       
   101     // Add Remove From Favourites Command
       
   102     TCommandInfo removeFav(EGlxCmdRemoveFromFavourites);
       
   103     removeFav.iMinSelectionLength = 1;
       
   104     removeFav.iMaxSelectionLength = 1;
       
   105     AddCommandL(removeFav);
       
   106 
       
   107     // Store this value to show the correct Text
       
   108    	iCommandId = aCommandId;
       
   109 	}
    84 	}
   110 
    85 
   111 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
   112 // Destructor
    87 // Destructor
   113 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
   131 
   106 
   132 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   133 // Create an add to container command
   108 // Create an add to container command
   134 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   135 //
   110 //
   136 CMPXCommand* CGlxCommandHandlerRemoveFrom::CreateCommandL(TInt aCommandId, 
   111 CMPXCommand* CGlxCommandHandlerRemoveFrom::CreateCommandL(TInt /*aCommandId*/, 
   137         MGlxMediaList& aMediaList, TBool& /*aConsume*/) const
   112         MGlxMediaList& aMediaList, TBool& /*aConsume*/) const
   138     {
   113     {
   139     CMPXCollectionPath* path = aMediaList.PathLC();
   114     CMPXCollectionPath* path = aMediaList.PathLC();
       
   115     
   140     CMPXCommand* command = NULL;
   116     CMPXCommand* command = NULL;
   141     if (aCommandId == EGlxCmdRemoveFromFavourites)
   117     if (iRemoveFromContainerId == KGlxIdNone)
   142         {
   118     	{
   143         // Hardcoding this to the favourites
   119     	command = TGlxCommandFactory::RemoveFromContainerCommandLC(*path);
   144         TGlxMediaId favId(1);
   120     	}
   145 
       
   146         command = TGlxCommandFactory::RemoveFromContainerCommandLC(favId, *path);
       
   147         }
       
   148     else
   121     else
   149         {
   122     	{
   150         if (iRemoveFromContainerId == KGlxIdNone)
   123     	command = TGlxCommandFactory::RemoveFromContainerCommandLC(iRemoveFromContainerId, *path);
   151             {
   124     	}
   152             command = TGlxCommandFactory::RemoveFromContainerCommandLC(*path);
       
   153             }
       
   154         else
       
   155             {
       
   156             command = TGlxCommandFactory::RemoveFromContainerCommandLC(iRemoveFromContainerId, *path);
       
   157             }
       
   158         }
       
   159     CleanupStack::Pop(command);
   125     CleanupStack::Pop(command);
   160     CleanupStack::PopAndDestroy(path);
   126     CleanupStack::PopAndDestroy(path);
   161     return command;
   127     return command;
   162     } 
   128     } 
   163     
   129     
   164 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   165 // CGlxCommandHandlerAddToFavourites::CompletionTextL
       
   166 // -----------------------------------------------------------------------------
       
   167 //  
       
   168 HBufC* CGlxCommandHandlerRemoveFrom::CompletionTextL() const
       
   169     {
       
   170     HBufC* text = NULL;
       
   171     if (iCommandId == EGlxCmdRemoveFromFavourites)
       
   172         {
       
   173         text = StringLoader::LoadL(R_GLX_COMPLETION_REM_FROM_FAVOURITES);            
       
   174         }
       
   175     return text;
       
   176     }
       
   177     
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // Return confirmation string
   131 // Return confirmation string
   181 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   182 //	
   133 //	
   183 HBufC* CGlxCommandHandlerRemoveFrom::ConfirmationTextL(TInt aCommandId, 
   134 HBufC* CGlxCommandHandlerRemoveFrom::ConfirmationTextL(TInt /*aCommandId*/, 
   184         TBool aMultiSelection) const
   135         TBool aMultiSelection) const
   185     {
   136     {
   186     HBufC* text = NULL;
   137 	HBufC* text = NULL;
   187     if (EGlxCmdRemoveFromFavourites != aCommandId)
   138     switch (iContainerType)
   188         {
   139     	{
   189         switch (iContainerType)
   140 /// @todo Rowland Cook 08/06/07 Check the indenting is correct here
   190             {
   141     	case EMPXAlbum:
   191             case EMPXAlbum:
       
   192     	if (aMultiSelection)
   142     	if (aMultiSelection)
   193     		{
   143     		{
   194     		text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_ITEMS_ALBUM);
   144     		text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_ITEMS_ALBUM);
   195     		}
   145     		}
   196     	else
   146     	else
   206     	else
   156     	else
   207     		{
   157     		{
   208     		text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_NAME_TAG);
   158     		text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_NAME_TAG);
   209     		}
   159     		}
   210     	break;
   160     	break;
   211             default: break; // return NULL
   161     	default: break; // return NULL
   212             }
   162     	}
   213         }
       
   214     return text;
   163     return text;
   215     }
   164     }
   216     
   165     
   217 // ---------------------------------------------------------------------------
   166 // ---------------------------------------------------------------------------
   218 // CGlxCommandHandlerRemoveFrom::DoActivateL
   167 // CGlxCommandHandlerRemoveFrom::DoActivateL