Fix AppControl spec
[apps/osp/Gallery.git] / src / GlFileListEditorForm.cpp
index c541fe5..f385405 100644 (file)
@@ -26,6 +26,7 @@
 #include "GlGalleryApp.h"
 #include "GlImageListEditorPanel.h"
 #include "GlResourceManager.h"
+#include "GlSlideSettingListener.h"
 #include "GlTypes.h"
 #include "GlVideoListEditorPanel.h"
 #include "GlFileMoveTimer.h"
@@ -93,6 +94,7 @@ FileListEditorForm::Initialize(void)
 
        return r;
 }
+
 result
 FileListEditorForm::OnInitializing(void)
 {
@@ -100,11 +102,36 @@ FileListEditorForm::OnInitializing(void)
        Header* pHeader = GetHeader();
        TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
 
+       __pPopUp = new (std::nothrow) SlideShowPopUp();
+
+       if (__pPopUp != null)
+       {
+               __pPopUp->Initialize();
+               __pPopUp->SetEventListner(this);
+               AddControl(*__pPopUp);
+       }
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
+       __pPresentationModel->AddContentEventListener(this);
 
        pHeader->SetStyle(HEADER_STYLE_TITLE);
        pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
+
+       if ((__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
+               && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
+       {
+               Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
+               Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
+               ButtonItem selectAll;
+               selectAll.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FILE_LIST_SELECT_ALL);
+               selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
+               selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
+               pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
+               delete pNormalBitmap;
+               delete pPressBitmap;
+       }
+
        pHeader->AddActionEventListener(*this);
 
        InitializeFooter();
@@ -127,24 +154,19 @@ FileListEditorForm::InitializeFooter(void)
        {
                if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
                {
-                       pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
+                       pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
 
                        FooterItem footerConfirm;
-                       r = footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
-                       TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
-                       footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_POP_DONE"));
-                       r = pFooter->AddItem(footerConfirm);
-                       TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
-
-                       pFooter->SetBackButton();
-                       SetFormBackEventListener(this);
+                       footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
+                       footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
+                       pFooter->AddItem(footerConfirm);
                }
                else
                {
                        pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
-                       pFooter->SetBackButton();
-                       SetFormBackEventListener(this);
                }
+               pFooter->SetBackButton();
+               SetFormBackEventListener(this);
        }
        else
        {
@@ -155,7 +177,7 @@ FileListEditorForm::InitializeFooter(void)
                Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
                Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
 
-               if (pBitmapMore != null && pBitmapMoreDim != NULL )
+               if (pBitmapMore != null && pBitmapMoreDim != NULL)
                {
                        footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
                        footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
@@ -171,7 +193,7 @@ FileListEditorForm::InitializeFooter(void)
                Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
                Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
 
-               if (pBitmapShare != null &&  pBitmapShareDim != null )
+               if (pBitmapShare != null &&  pBitmapShareDim != null)
                {
                        footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
                        footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
@@ -304,6 +326,7 @@ FileListEditorForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
 
+       __pPresentationModel->RemoveContentEventListener(this);
        if (__pContextMenuMore != null)
        {
                __pContextMenuMore->RemoveActionEventListener(*this);
@@ -352,9 +375,11 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
        switch (actionId)
        {
+       case ACTION_ID_FILE_LIST_SELECT_ALL:
+               SelectAllPressed();
+               break;
        case ACTION_ID_FOOTER_MORE:
        {
-
                InitializeFooter();
 
                if (__pContextMenuMore->GetShowState() == false)
@@ -473,21 +498,10 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
        }
        case ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW:
        {
-               if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
-               {
-                       AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
-                       if (pEditorPanel != null)
-                       {
-                               pEditorPanel->OnRequestSlideShow();
-                       }
-               }
-               else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
+               if (__pPopUp != null)
                {
-                       AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
-                       if (pSelectionPanel != null)
-                       {
-                               pSelectionPanel->OnRequestSlideShow();
-                       }
+                       __pPopUp->SetShowState(true);
+                       __pPopUp->Show();
                }
 
                break;
@@ -572,7 +586,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                {
                        AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
                        IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
-
+                       pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
                        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
                }
                break;
@@ -584,6 +598,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                        AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
                        (pSceneManager->GetCurrentScene()->GetPanel());
                        IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
+                       pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
                        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
                }
                break;
@@ -600,7 +615,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                        if (pEditorPanel != null)
                        {
                                result r = pEditorPanel->OnRequestDelete();
-                               if ( IsFailed(r) )
+                               if (IsFailed(r))
                                {
                                        AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
                                }
@@ -632,13 +647,12 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                        if (pSelectionPanel != null)
                        {
                                result r = pSelectionPanel->OnRequestDelete();
-                               if ( IsFailed(r) )
+                               if (IsFailed(r))
                                {
                                        AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
                                }
                        }
                }
-
                break;
        }
        case ACTION_ID_DELETE_POPUP_CANCEL:
@@ -693,8 +707,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                                delete __pFileMove;
                                                IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
                                                GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
-                                               __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList,
-                                                               __pPresentationModel, this );
+                                               __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                result r = __pFileMove->StartTimer();
                                                if (IsFailed(r))
                                                {
@@ -732,8 +745,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                                delete __pFileMove;
                                                IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
                                                GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
-                                               __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList,
-                                                               __pPresentationModel, this );
+                                               __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                result r = __pFileMove->StartTimer();
                                                if (IsFailed(r))
                                                {
@@ -748,7 +760,6 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                }
                        }
                }
-
                break;
        }
        }
@@ -784,7 +795,7 @@ void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum Fil
 }
 
 void
-FileListEditorForm::OnUpdateContentList()
+FileListEditorForm::OnContentUpdated()
 {
        AppLogDebug("ENTER");
        if (__overlayMsg == false)
@@ -860,7 +871,6 @@ FileListEditorForm::RefreshFolderList(void)
        pContentTypeList->Add(CONTENT_TYPE_VIDEO);
        contentDirectory.Construct(*pContentTypeList);
        delete pContentTypeList;
-       pContentTypeList = null;
 
        if (__pContentDirectoryList != null)
        {
@@ -1001,3 +1011,83 @@ FileListEditorForm::MoveToAlbum(String& destDirectory)
 
        return r;
 }
+
+void
+FileListEditorForm::SelectAllPressed(void)
+{
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       pSceneManager->GetCurrentScene();
+
+       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
+       {
+               AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->SelectAllPressed();
+               }
+       }
+       else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
+       {
+               ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->SelectAllPressed();
+               }
+       }
+       else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
+       {
+               VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->SelectAllPressed();
+               }
+       }
+       else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
+       {
+               AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->SelectAllPressed();
+               }
+       }
+}
+
+void
+FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
+{
+       if (__pPopUp != NULL)
+       {
+               __pPopUp->SetShowState(false);
+       }
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+
+       if (index == 0)   // start slide show
+       {
+               if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
+               {
+                       AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+                       if (pEditorPanel != null)
+                       {
+                               pEditorPanel->OnRequestSlideShow();
+                       }
+               }
+               else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
+               {
+                       AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
+                                       (pSceneManager->GetCurrentScene()->GetPanel());
+
+                       if (pSelectionPanel != null)
+                       {
+                               pSelectionPanel->OnRequestSlideShow();
+                       }
+               }
+       }
+       else if (index == 1) // go to settingsForm
+       {
+               SceneManager* pSceneManager = SceneManager::GetInstance();
+               TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
+
+               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
+       }
+}