Fixed prevent issue
[apps/osp/Gallery.git] / src / GlAllListSelectionPanel.cpp
index 428ecad..51c2f45 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
  * @brief              This is the implementation file for AllListSelectionPanel class.
  */
 
-#include <FContent.h>
-#include <FMedia.h>
 #include "GlAllListSelectionPanel.h"
 #include "GlCommonUtil.h"
 #include "GlFileListEditorForm.h"
 #include "GlFileListPresentationModel.h"
 #include "GlResourceManager.h"
 #include "GlTypes.h"
-#include "GlFileDeleteTimer.h"
+#include "GlFileUpdateTimer.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -50,12 +48,12 @@ static const int ALPHA_THUMBNAIL_DIM = 70;
 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
 
 AllListSelectionPanel::AllListSelectionPanel(void)
-       : __pContentIconListView(null)
+       : __itemCount(0)
+       , __pContentIconListView(null)
        , __pSeletedIndexList(null)
-       , __itemCount(0)
-//     , __deleteInProgress(false)
+       , __pFileListEditorForm(null)
+       , __pFileUpdateTimer(null)
        , __pPresentationModel(null)
-       , __pFileDelete(null)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -64,7 +62,7 @@ AllListSelectionPanel::AllListSelectionPanel(void)
 AllListSelectionPanel::~AllListSelectionPanel(void)
 {
        AppLogDebug("ENTER");
-       delete __pFileDelete;
+       delete __pFileUpdateTimer;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -111,7 +109,7 @@ AllListSelectionPanel::OnInitializing(void)
        __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
        __pContentIconListView->AddIconListViewItemEventListener(*this);
        __pContentIconListView->SetTouchAnimationEnabled(false);
-       AddControl(*__pContentIconListView);
+       AddControl(__pContentIconListView);
        __pContentIconListView->SetShowState(true);
 
        __itemCount = 0;
@@ -119,24 +117,6 @@ AllListSelectionPanel::OnInitializing(void)
 
        return r;
 }
-/*
-void
-AllListSelectionPanel::UpdatePanelContent()
-{
-       AppLogDebug("ENTER");
-       SceneManager* pSceneManager = SceneManager::GetInstance();
-       FileListEditorForm* __pFileListEditorForm =
-                       dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
-       TryReturnVoid(__pFileListEditorForm != null, "[%s] fail to get SceneManager.",
-                       GetErrorMessage(GetLastResult()));
-
-       if (__pFileListEditorForm->GetOverlayStatus() == false && __deleteInProgress == false)
-       {
-               SceneManager* pSceneManager = SceneManager::GetInstance();
-               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
-       }
-       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
-}*/
 
 result
 AllListSelectionPanel::OnTerminating(void)
@@ -213,6 +193,7 @@ AllListSelectionPanel::CreateItem(int index)
                else
                {
                        AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
+                       delete pItemText;
                        return null;
                }
 
@@ -299,6 +280,9 @@ AllListSelectionPanel::OnSceneActivatedN(const SceneId& previousSceneId,
                const SceneId& currentSceneId, IList* pArgs)
 {
        AppLogDebug("ENTER");
+
+       ChangeOrientation();
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
 
        SceneManager* pSceneManager = SceneManager::GetInstance();
@@ -366,7 +350,7 @@ AllListSelectionPanel::GetItemCheckedCount(void) const
 }
 
 IList*
-AllListSelectionPanel::GetItemCheckedIndexListN(void)
+AllListSelectionPanel::GetItemCheckedIndexListN(void) const
 {
        AppLogDebug("ENTER");
        IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
@@ -392,7 +376,7 @@ AllListSelectionPanel::GetItemCheckedIndexListN(void)
 }
 
 int
-AllListSelectionPanel::GetRealindexFromVirtualIndex(int virtualIndex)
+AllListSelectionPanel::GetRealindexFromVirtualIndex(const int virtualIndex) const
 {
        if (__pSeletedIndexList == null || __pSeletedIndexList->GetCount() == 0)
        {
@@ -413,7 +397,7 @@ AllListSelectionPanel::GetRealindexFromVirtualIndex(int virtualIndex)
 }
 
 int
-AllListSelectionPanel::GetVirtualIndexFromRealIndex(int realIndex)
+AllListSelectionPanel::GetVirtualIndexFromRealIndex(const int realIndex) const
 {
        int returnValue = -1;
        int loopCount = __pSeletedIndexList->GetCount();
@@ -449,14 +433,14 @@ AllListSelectionPanel::OnRequestDelete(void)
                return E_FAILURE;
        }
 
-       delete __pFileDelete;
-       __pFileDelete = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
-       result r = __pFileDelete->StartTimer();
+       delete __pFileUpdateTimer;
+       __pFileUpdateTimer = new (std::nothrow) FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ACTION_DELETE);
+       result r = __pFileUpdateTimer->StartTimer();
 
        if (IsFailed(r))
        {
-               delete __pFileDelete;
-               __pFileDelete = null;
+               delete __pFileUpdateTimer;
+               __pFileUpdateTimer = null;
                return E_FAILURE;
        }
        else
@@ -490,7 +474,8 @@ void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, enum
 
        if (GetItemCount() > 0)
        {
-               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
+               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
+                               SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
        }
        else
        {
@@ -499,10 +484,23 @@ void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, enum
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+AllListSelectionPanel::ChangeOrientation()
+{
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       const Form* pForm = dynamic_cast<Form*>(pSceneManager->GetCurrentScene()->GetForm());
+       TryReturn(pForm != null,, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
+
+       Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
+       SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
+       __pContentIconListView->SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
+}
+
 result
 AllListSelectionPanel::OnRequestMessage(void)
 {
        AppLogDebug("ENTER");
+       result r = E_SUCCESS;
        IList* pIndexList = GetItemCheckedIndexListN();
        if (pIndexList == null || pIndexList->GetCount() <= 0)
        {
@@ -532,17 +530,28 @@ AllListSelectionPanel::OnRequestMessage(void)
        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
 
-       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
+       r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
                        null, pDataList, null);
+       if (r == E_MAX_EXCEEDED)
+       {
+               MessageBox messageBox;
+               messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
+                               MSGBOX_STYLE_NONE, 3000);
+               int modalResult;
+               messageBox.ShowAndWait(modalResult);
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
-       return E_SUCCESS;
+       return r;
 }
 
 result
 AllListSelectionPanel::OnRequestEmail(void)
 {
        AppLogDebug("ENTER");
+       result r = E_SUCCESS;
+
        IList* pIndexList = GetItemCheckedIndexListN();
        if (pIndexList == null || pIndexList->GetCount() <= 0)
        {
@@ -567,21 +576,33 @@ AllListSelectionPanel::OnRequestEmail(void)
                }
        }
 
+       const String uriData = APPCONTROL_URI_MAIL_TO;
        HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
        pDataList->Construct();
        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
 
-       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
-                       new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, null);
+       r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
+                       &uriData, null, pDataList, null);
+
+       if (r == E_MAX_EXCEEDED)
+       {
+               MessageBox messageBox;
+               messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
+                               MSGBOX_STYLE_NONE, 3000);
+               int modalResult;
+               messageBox.ShowAndWait(modalResult);
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
-       return E_SUCCESS;
+       return r;
 }
 
 result
 AllListSelectionPanel::OnRequestSlideShow(void)
 {
        AppLogDebug("ENTER");
+       result r = E_SUCCESS;
        IList* pIndexList = GetItemCheckedIndexListN();
        if (pIndexList == null)
        {
@@ -609,12 +630,23 @@ AllListSelectionPanel::OnRequestSlideShow(void)
        pDataList->Construct();
        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
+       const String mimeType = APPCONTROL_MIME_IMAGE_ALL;
+
+       r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
+                       &mimeType, pDataList, null);
+
+       if (r == E_MAX_EXCEEDED)
+       {
+               MessageBox messageBox;
+               messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
+                               MSGBOX_STYLE_NONE, 3000);
+               int modalResult;
+               messageBox.ShowAndWait(modalResult);
+       }
 
-       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
-                       new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
-       return E_SUCCESS;
+       return r;
 }
 
 void
@@ -638,10 +670,7 @@ AllListSelectionPanel::ResetSelection(void)
        String bodyText = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
        strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", bodyText.GetPointer(), __itemCount);
        __pFileListEditorForm->SetTitleText(strTmp);
-       if (__pContentIconListView != null)
-       {
-               __pContentIconListView->UpdateList();
-       }
+
        SetButtonState();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -667,7 +696,7 @@ AllListSelectionPanel::SetButtonState(void)
 }
 
 void
-AllListSelectionPanel::SelectAllPressed(void)
+AllListSelectionPanel::OnSelectAllPressed(void)
 {
        bool needToSelectAll = true;
        int checkedCount = GetItemCheckedCount();
@@ -678,18 +707,18 @@ AllListSelectionPanel::SelectAllPressed(void)
 
        if (needToSelectAll == true)
        {
-               for (int i = 0 ; i < __itemCount; ++i)
+               for (int i = 0; i < __itemCount; ++i)
                {
                        if (__pContentIconListView->IsItemChecked(i) == false)
                        {
-                               __pContentIconListView->SetItemChecked(i,true);
+                               __pContentIconListView->SetItemChecked(i, true);
                                __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
                        }
                }
        }
        else
        {
-               for (int i = 0 ; i < __itemCount; ++i)
+               for (int i = 0; i < __itemCount; ++i)
                {
                        if (__pContentIconListView->IsItemChecked(i) == true)
                        {
@@ -717,3 +746,63 @@ AllListSelectionPanel::SelectAllPressed(void)
 
        SetButtonState();
 }
+
+result
+AllListSelectionPanel::OnRotateRequested(RotateMode rotateMode)
+{
+       AppLogDebug("ENTER");
+       IList* pIndexList = GetItemCheckedIndexListN();
+       if (pIndexList == null)
+       {
+               AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
+               return E_FAILURE;
+       }
+       else if (pIndexList->GetCount() <= 0)
+       {
+               delete pIndexList;
+               AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
+
+               return E_FAILURE;
+       }
+
+       delete __pFileUpdateTimer;
+       __pFileUpdateTimer = new (std::nothrow) FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ACTION_ROTATE, rotateMode);
+       result r = __pFileUpdateTimer->StartTimer();
+
+       if (IsFailed(r))
+       {
+               delete __pFileUpdateTimer;
+               __pFileUpdateTimer = null;
+               return E_FAILURE;
+       }
+       else
+       {
+               __pPresentationModel->SetUpdateProgressStatus(true);
+       }
+       return E_SUCCESS;
+}
+
+void AllListSelectionPanel::CancelUpdateProgress(void)
+{
+       if (__pFileUpdateTimer!= null && __pFileUpdateTimer->IsStarted())
+       {
+               __pFileUpdateTimer->Cancel();
+               delete __pFileUpdateTimer;
+               __pFileUpdateTimer = null;
+       }
+}
+
+void
+AllListSelectionPanel::OnScanDirStart()
+{
+       AppLogDebug("ENTER");
+       __pFileListEditorForm->SetProgressState(true);
+       AppLogDebug("EXIT");
+}
+void
+AllListSelectionPanel::OnScanDirComplete()
+{
+       AppLogDebug("ENTER");
+       __pFileListEditorForm->SetProgressState(false);
+       AppLogDebug("EXIT");
+}