Fix AppControl spec
[apps/osp/Gallery.git] / src / GlAllListSelectionPanel.cpp
index 73d591c..df30312 100644 (file)
@@ -40,10 +40,10 @@ using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 
 static const int LENGTH_COUNT_LABEL = 256;
-static const int H_CONTENT_MARGIN = 24;
-static const int W_CONTENT_MARGIN = 14;
-static const int W_CONTENT_SPACE = 20;
-static const int H_CONTENT_SPACE = 24;
+static const int H_CONTENT_MARGIN = 9;
+static const int W_CONTENT_MARGIN = 6;
+static const int W_CONTENT_SPACE = 6;
+static const int H_CONTENT_SPACE = 6;
 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
 static const int ALPHA_THUMBNAIL_DIM = 70;
 
@@ -100,7 +100,6 @@ AllListSelectionPanel::OnInitializing(void)
        {
                __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
                delete pBitmapEmpty;
-               pBitmapEmpty = null;
        }
        __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
        __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
@@ -109,23 +108,29 @@ AllListSelectionPanel::OnInitializing(void)
        __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
        __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
        __pContentIconListView->SetItemProvider(*this);
-       __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
+       __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
        __pContentIconListView->AddIconListViewItemEventListener(*this);
        __pContentIconListView->SetTouchAnimationEnabled(false);
        AddControl(*__pContentIconListView);
        __pContentIconListView->SetShowState(true);
 
-       __itemCount=0;
+       __itemCount = 0;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return r;
 }
 
 void
-AllListSelectionPanel::OnUpdateContentList()
+AllListSelectionPanel::UpdatePanelContent()
 {
        AppLogDebug("ENTER");
-       if ( __deleteInProgress == false )
+       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));
@@ -204,7 +209,6 @@ AllListSelectionPanel::CreateItem(int index)
                        pIconListviewItem = new (std::nothrow) IconListViewItem();
                        pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
                        delete pSelectedBitmap;
-                       pSelectedBitmap = null;
                }
                else
                {
@@ -222,12 +226,10 @@ AllListSelectionPanel::CreateItem(int index)
        if (pBitmap != null)
        {
                delete pBitmap;
-               pBitmap = null;
        }
        if (pItemText != null)
        {
                delete pItemText;
-               pItemText = null;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -312,7 +314,6 @@ AllListSelectionPanel::OnSceneActivatedN(const SceneId& previousSceneId,
                if (pArgs != null)
                {
                        __pSeletedIndexList = pArgs;
-                       pArgs = null;
                }
                ResetSelection();
                int loopCount = __pSeletedIndexList->GetCount();
@@ -373,7 +374,7 @@ AllListSelectionPanel::GetItemCheckedIndexListN(void)
 {
        AppLogDebug("ENTER");
        IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
-       Integer* pIndex=null;
+       Integer* pIndex = null;
 
        if (__pContentIconListView!=null)
        {
@@ -453,9 +454,7 @@ AllListSelectionPanel::OnRequestDelete(void)
        }
 
        delete __pFileDelete;
-       __pFileDelete = new FileDeleteTimer(pIndexList,
-                       __pPresentationModel,
-                       this );
+       __pFileDelete = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
        result r = __pFileDelete->StartTimer();
 
        if (IsFailed(r))
@@ -482,7 +481,7 @@ void AllListSelectionPanel::OnFileOpInvalidate(enum FileActionMode actionId)
        pFileListEditorForm->Invalidate(true);
 }
 
-void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, result res)
+void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
 {
        __deleteInProgress = false;
        SceneManager* pSceneManager = SceneManager::GetInstance();
@@ -526,34 +525,28 @@ AllListSelectionPanel::OnRequestMessage(void)
                return E_FAILURE;
        }
 
-       String combineText;
-       String path;
        Integer* pIndex = null;
        int checkedIndex;
-
+       ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+       pArrayList->Construct();
        int loopCount = pIndexList->GetCount();
-       AppLogDebug("pIndexList->GetCount(%d)", loopCount);
+
        for (int i = 0; i < loopCount; ++i)
        {
                pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
                if (pIndex != null)
                {
                        checkedIndex = pIndex->ToInt();
-                       path = __pPresentationModel->GetContentFilePath(checkedIndex);
+                       pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
                }
-
-               if (combineText.CompareTo(EMPTY_SPACE) != 0)
-               {
-                       combineText.Append(L";");
-               }
-               combineText.Append(path);
        }
+
        HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
        pDataList->Construct();
-       pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
+       pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
 
        __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
-                       pDataList, null);
+                       new (std::nothrow) String(APPCONTROL_URI_MMS_TO), null, pDataList, null);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -571,34 +564,28 @@ AllListSelectionPanel::OnRequestEmail(void)
                return E_FAILURE;
        }
 
-       String combineText;
-       String path;
        Integer* pIndex = null;
        int checkedIndex;
-
+       ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+       pArrayList->Construct();
        int loopCount = pIndexList->GetCount();
-       AppLogDebug("pIndexList->GetCount(%d)", loopCount);
+
        for (int i = 0; i < loopCount; ++i)
        {
                pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
                if (pIndex != null)
                {
                        checkedIndex = pIndex->ToInt();
-                       path = __pPresentationModel->GetContentFilePath(checkedIndex);
-               }
-
-               if (combineText.CompareTo(EMPTY_SPACE) != 0)
-               {
-                       combineText.Append(L";");
+                       pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
                }
-               combineText.Append(path);
        }
+
        HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
        pDataList->Construct();
-       pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
+       pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
 
-       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL,
-                       APPCONTROL_OPERATION_ID_COMPOSE, pDataList, null);
+       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE, null,
+                       pDataList, null);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -612,58 +599,32 @@ AllListSelectionPanel::OnRequestSlideShow(void)
        if (pIndexList == null)
        {
                AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
-
-               return E_FAILURE;
-       }
-
-       HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
-       result r = pDataList->Construct();
-       if (r != E_SUCCESS)
-       {
-               delete pDataList;
-               pDataList = null;
-               delete pIndexList;
-               pIndexList = null;
-               AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
-
                return E_FAILURE;
        }
 
-       pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),
-                       new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
-
        Integer* pRealIndex = null;
        int realIndex = -1;
-       String combineText;
-       String path;
-
+       ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+       pArrayList->Construct();
        int loopCount = pIndexList->GetCount();
-       if (loopCount > 0)
+
+       for (int i = 0; i < loopCount; ++i)
        {
-               for (int i = 0; i < loopCount; ++i)
+               pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
+               if (pRealIndex != null)
                {
-                       pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
-                       if (pRealIndex != null)
-                       {
-                               realIndex = pRealIndex->ToInt();
-                       }
-
-                       path = __pPresentationModel->GetContentFilePath(realIndex);
-                       if (combineText.CompareTo(EMPTY_SPACE) != 0)
-                       {
-                               combineText.Append(L";");
-                       }
-                       combineText.Append(path);
+                       realIndex = pRealIndex->ToInt();
+                       pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(realIndex)));
                }
-               pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH),
-                               new (std::nothrow) String(combineText));
        }
 
-       delete pIndexList;
-       pIndexList = null;
+       HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
+       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);
 
-       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE,
-                       APPCONTROL_OPERATION_ID_VIEW, pDataList, null);
+       __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
+                       pDataList, null);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -724,4 +685,59 @@ AllListSelectionPanel::SetButtonState(void)
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+AllListSelectionPanel::SelectAllPressed(void)
+{
+       bool needToSelectAll = true;
+       int checkedCount = GetItemCheckedCount();
+       if (checkedCount == __itemCount)
+       {
+               needToSelectAll = false;
+       }
+
+       if (needToSelectAll == true)
+       {
+               for (int i = 0 ; i < __itemCount; ++i)
+               {
+                       if (__pContentIconListView->IsItemChecked(i) == false)
+                       {
+                               __pContentIconListView->SetItemChecked(i,true);
+                               __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
+                       }
+               }
+       }
+       else
+       {
+               for (int i = 0 ; i < __itemCount; ++i)
+               {
+                       if (__pContentIconListView->IsItemChecked(i) == true)
+                       {
+                               __pContentIconListView->SetItemChecked(i, false);
+                               __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
+                       }
+               }
+       }
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
 
+       FileListEditorForm* pFileListEditorForm =
+                       dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
+       TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.",
+                       GetErrorMessage(GetLastResult()));
+
+       String tempString;
+       if (needToSelectAll == true)
+       {
+               tempString.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
+                               ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), __itemCount);
+       }
+       else
+       {
+               tempString.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
+                               ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), 0);
+       }
+       pFileListEditorForm->SetTitleText(tempString);
+
+       SetButtonState();
+}