Fixed issue 48334
[apps/osp/Gallery.git] / src / GlFileListEditorForm.cpp
index 1236ea5..c5a39fa 100644 (file)
@@ -44,7 +44,7 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Base::Utility;
 
 static const int GAP_W_POPUP_ITEM = 5;
-static const int W_DELETE_POPUP = 600;
+static const int W_DELETE_POPUP = 620;
 static const int H_DELETE_POPUP = 300;
 static const int H_DELETE_LABEL = 180;
 static const int Y_DELETE_BUTTON = 180;
@@ -58,7 +58,7 @@ static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Val
 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
 
 FileListEditorForm::FileListEditorForm(void)
-       : __pContextMenuShare(null)
+       : __pShareContextMenu(null)
        , __pOptionMenu(null)
        , __pDeletePopup(null)
        , __morePosition(Point(0, 0))
@@ -79,12 +79,22 @@ FileListEditorForm::~FileListEditorForm(void)
        AppLogDebug("ENTER");
        if (__pContentDirectoryList != null)
        {
+               __pContentDirectoryList->RemoveAll(true);
                delete __pContentDirectoryList;
+               __pContentDirectoryList = null;
+       }
+
+       if (__pPopUp != null)
+       {
+               delete __pPopUp;
+               __pPopUp = null;
        }
 
        if (__pContentDirectoryNameList != null)
        {
+               __pContentDirectoryNameList->RemoveAll(true);
                delete __pContentDirectoryNameList;
+               __pContentDirectoryNameList = null;
        }
        delete __pFileMove;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -107,14 +117,8 @@ 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);
-       }
+       SetOrientation(ORIENTATION_AUTOMATIC);
+       AddOrientationEventListener(*this);
 
        __pPresentationModel = FileListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
@@ -165,19 +169,22 @@ FileListEditorForm::InitializeFooter(void)
                        footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
                        pFooter->AddItem(footerConfirm);
                        pFooter->SetItemEnabled(0, false);
+                       pFooter->SetShowState(true);
+                       pFooter->Invalidate(true);
                }
                else
                {
                        pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
+                       pFooter->SetShowState(false);
+                       pFooter->Invalidate(true);
                }
-               pFooter->SetBackButton();
+
                SetFormBackEventListener(this);
 
        }
        else
        {
                pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
-               pFooter->SetMenuButton();
                SetFormMenuEventListener(this);
 
                FooterItem footerShare;
@@ -214,7 +221,6 @@ FileListEditorForm::InitializeFooter(void)
                delete pBitmapDeleteDim;
                TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
 
-               pFooter->SetBackButton();
                SetFormBackEventListener(this);
 
                SceneManager* pSceneManager = SceneManager::GetInstance();
@@ -263,21 +269,9 @@ FileListEditorForm::InitializeFooter(void)
 
                __pOptionMenu->AddActionEventListener(*this);
 
-
-
-               __pContextMenuShare = new (std::nothrow) ContextMenu();
-               __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
-               __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
-                               IDA_CONTEXT_MENU_SHARE_MESSAGE);
-               __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
-                               IDA_CONTEXT_MENU_SHARE_EMAIL);
-               __pContextMenuShare->SetShowState(false);
-               __pContextMenuShare->AddActionEventListener(*this);
-
-
-
                if (__pContentDirectoryNameList != null)
                {
+                       __pContentDirectoryNameList->RemoveAll(true);
                        delete __pContentDirectoryNameList;
                        __pContentDirectoryNameList = null;
                }
@@ -326,11 +320,11 @@ FileListEditorForm::OnTerminating(void)
                __pOptionMenu = null;
        }
 
-       if (__pContextMenuShare != null)
+       if (__pShareContextMenu != null)
        {
-               __pContextMenuShare->RemoveActionEventListener(*this);
-               delete __pContextMenuShare;
-               __pContextMenuShare = null;
+               __pShareContextMenu->RemoveActionEventListener(*this);
+               delete __pShareContextMenu;
+               __pShareContextMenu = null;
        }
 
        if (__pDeletePopup != null)
@@ -359,24 +353,52 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_FOOTER_SHARE:
        {
-               if (__pContextMenuShare->GetShowState() == false)
+               if (__pShareContextMenu != NULL)
                {
-                       Rectangle rect = source.GetBounds();
-                       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
-                       {
-                               __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
-                       }
-                       else
-                       {
-                               __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
-                       }
-                       __pContextMenuShare->SetShowState(true);
-                       __pContextMenuShare->Show();
+                       delete __pShareContextMenu;
+                       __pShareContextMenu = null;
+               }
+
+               Bitmap* pBitmapEmailContextItem = null;
+               Bitmap* pBitmapMessageContextItem = null;
+               pBitmapEmailContextItem = ResourceManager::GetBitmapN(IDB_IMAGE_CONTEXT_EMAIL_ICON);
+               pBitmapMessageContextItem = ResourceManager::GetBitmapN(IDB_IMAGE_CONTEXT_MESSAGE_ICON);
+
+               __pShareContextMenu = new (std::nothrow) ContextMenu();
+               __pShareContextMenu->Construct(Point(GetClientAreaBounds().width/3 + 15, GetClientAreaBounds().height),
+                               CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
+
+               if ( pBitmapMessageContextItem != null)
+               {
+                       __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
+                               IDA_CONTEXT_MENU_SHARE_MESSAGE, *pBitmapMessageContextItem, null, null);
+                       delete pBitmapMessageContextItem;
+               }
+
+               if ( pBitmapEmailContextItem != null)
+               {
+                       __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
+                               IDA_CONTEXT_MENU_SHARE_EMAIL, *pBitmapEmailContextItem, null, null);
+                       delete pBitmapEmailContextItem;
+               }
+               __pShareContextMenu->SetFocusable(true);
+               __pShareContextMenu->AddActionEventListener(*this);
+
+
+               Rectangle rect = source.GetBounds();
+
+               if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
+               {
+                       __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
                }
                else
                {
-                       __pContextMenuShare->SetShowState(false);
+                       __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
                }
+
+               __pShareContextMenu->SetShowState(true);
+               __pShareContextMenu->Show();
+
        }
        break;
 
@@ -460,8 +482,17 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
        {
+               if (__pPopUp != NULL)
+               {
+                       delete __pPopUp;
+                       __pPopUp = NULL;
+               }
+               __pPopUp = new (std::nothrow) SlideShowPopUp();
+
                if (__pPopUp != null)
                {
+                       __pPopUp->Initialize();
+                       __pPopUp->SetEventListner(this);
                        __pPopUp->SetShowState(true);
                        __pPopUp->Show();
                }
@@ -695,7 +726,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                        {
                                                delete __pFileMove;
                                                IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
-                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
+                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel , __isCopyOperation);
                                                __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                if (__isCopyOperation)
                                                {
@@ -720,7 +751,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                }
                else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
                {
-                       if ((IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
+                       if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
                                        (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
                        {
                                if (__pContentDirectoryList == null)
@@ -728,10 +759,10 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
                                        return;
                                }
-                               if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
+                               if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
                                {
                                        String* pDirectory = static_cast<String*>
-                                       (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
+                                       (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
 
                                        AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
                                                (pSceneManager->GetCurrentScene()->GetPanel());
@@ -740,7 +771,7 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                        {
                                                delete __pFileMove;
                                                IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
-                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
+                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel , __isCopyOperation);
                                                __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                if (__isCopyOperation)
                                                {
@@ -864,6 +895,7 @@ FileListEditorForm::SetUpPopup(void)
 
        __pDeletePopup = new (std::nothrow) Popup();
        __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
+       __pDeletePopup->SetPropagatedKeyEventListener(this);
 
        Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
 
@@ -875,7 +907,7 @@ FileListEditorForm::SetUpPopup(void)
        __pDeletePopup->AddControl(pLabelText);
 
        Button* pDeleteButton = new (std::nothrow) Button();
-       pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
+       pDeleteButton->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
                        ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
        pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
        pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
@@ -885,8 +917,8 @@ FileListEditorForm::SetUpPopup(void)
        __pDeletePopup->AddControl(pDeleteButton);
 
        Button* pButtonCancel = new (std::nothrow) Button();
-       pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
-                       popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
+       pButtonCancel->Construct(Rectangle(10, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
+                       ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
        pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
        pButtonCancel->AddActionEventListener(*this);
        __pDeletePopup->AddControl(pButtonCancel);
@@ -924,9 +956,19 @@ FileListEditorForm::RefreshFolderList(void)
 
        if (__pContentDirectoryList != null)
        {
+               __pContentDirectoryList->RemoveAll(true);
                delete __pContentDirectoryList;
+               __pContentDirectoryList = null;
        }
        __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
+
+       if (__pContentDirectoryNameList != NULL)
+       {
+               __pContentDirectoryNameList->RemoveAll(true);
+               delete __pContentDirectoryNameList;
+               __pContentDirectoryNameList = null;
+       }
+
        __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
        String* pDirPath = null;
        String* pDirName = null;
@@ -940,7 +982,7 @@ FileListEditorForm::RefreshFolderList(void)
                pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
                pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
 
-               if ( *pDirPath == mediaPath)
+               if (*pDirPath == mediaPath)
                {
                        *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
                        __pContentDirectoryNameList->Add(pDirName);
@@ -957,11 +999,13 @@ FileListEditorForm::RefreshFolderList(void)
 
                loopCount = __pContentDirectoryNameList->GetCount();
 
+               String dirAllAlbums = L"All albums";
+
                for (int i = 0; i < loopCount; ++i)
                {
                        pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
 
-                       if ( *pDirName != __pPresentationModel->GetCurrentAlbumName())
+                       if (*pDirName != __pPresentationModel->GetCurrentAlbumName() || *pDirName == dirAllAlbums)
                        {
                                __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
                                                IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
@@ -1007,18 +1051,25 @@ FileListEditorForm::OnFormBackRequested(Form& source)
                }
                else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
                {
-                       AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
-                               (pSceneManager->GetCurrentScene()->GetPanel());
-                       if (pSelectionPanel != null)
+                       if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true)
+                       {
+                               __pShareContextMenu->SetShowState(false);
+                       }
+                       else
                        {
-                               IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
-                               if (pList == null)
+                               AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
+                               (pSceneManager->GetCurrentScene()->GetPanel());
+                               if (pSelectionPanel != null)
                                {
-                                       pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
-                               }
+                                       IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
+                                       if (pList == null)
+                                       {
+                                               pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+                                       }
 
-                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
-                                                  SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
+                                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
+                                                       SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
+                               }
                        }
                }
                else
@@ -1053,13 +1104,11 @@ FileListEditorForm::SetFooterButtonsState(const bool enableState)
        {
                if (enableState == true)
                {
-                       pFooter->SetMenuButtonEnabled(true);
                        pFooter->SetItemEnabled(0, true);
                        pFooter->SetItemEnabled(1, true);
                }
                else
                {
-                       pFooter->SetMenuButtonEnabled(false);
                        pFooter->SetItemEnabled(0, false);
                        pFooter->SetItemEnabled(1, false);
                }
@@ -1068,6 +1117,64 @@ FileListEditorForm::SetFooterButtonsState(const bool enableState)
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+       AppLogDebug("ENTER");
+       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->ChangeOrientation();
+               }
+       }
+       else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
+       {
+               ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->ChangeOrientation();
+               }
+       }
+       else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
+       {
+               VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->ChangeOrientation();
+               }
+       }
+       else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
+       {
+               AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pEditorPanel != null)
+               {
+                       pEditorPanel->ChangeOrientation();
+               }
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+bool
+FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
+{
+       AppLogDebug("ENTER");
+
+       if(keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
+       {
+               _overlayMsg = false;
+               __pDeletePopup->SetShowState(false);
+               __pDeletePopup->Invalidate(true);
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+
+       return false;
+}
+
 result
 FileListEditorForm::MoveToAlbum(const String& destDirectory)
 {
@@ -1211,16 +1318,16 @@ FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                }
        }
 
-       if (__pContextMenuShare != null && __pContextMenuShare->GetShowState() == true )
+       if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true)
        {
-               __pContextMenuShare->SetShowState(false);
+               __pShareContextMenu->SetShowState(false);
        }
 
-       if ( checkedCount > 0)
+       if (checkedCount > 0)
        {
-               if ( __pOptionMenu == null )
+               if (__pOptionMenu == null)
                {
-                       return ;
+                       return;
                }
 
                __pOptionMenu->RemoveAllItems();
@@ -1240,6 +1347,5 @@ FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
 
                __pOptionMenu->SetShowState(true);
                __pOptionMenu->Show();
-
        }
 }