Fix AppControl spec
[apps/osp/Gallery.git] / src / GlAllListEditorPanel.cpp
index bf807f3..9fa810a 100644 (file)
@@ -39,7 +39,6 @@ using namespace Tizen::Media;
 using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 
-static const int H_SELECTALL_REGION = 112;
 static const int H_COUNT_LABEL = 48;
 static const int H_COUNT_LABEL_BUTTON = 42;
 static const int W_COUNT_LABEL_BUTTON = 42;
@@ -51,7 +50,6 @@ static const int LENGTH_COUNT_LABEL = 256;
 static const unsigned int COLOR_COUNT_LABEL = Color32<68, 68, 68>::Value;
 static const unsigned int COLOR_SELECT_COUNT_FONT = Color32<255, 255, 255>::Value;
 static const unsigned int COLOR_COUNT_LABEL_BUTTON = Color32<120, 120, 120>::Value;
-static const unsigned int COLOR_SELECTALL_REGION = Color32<0x2A, 0x36, 0x4A>::Value;
 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
 static const int ALPHA_THUMBNAIL_DIM = 70;
 
@@ -59,7 +57,6 @@ static const Rectangle RECT_INITIAL (0, 0, 10, 10);
 
 AllListEditorPanel::AllListEditorPanel(void)
        : __pContentIconListView(null)
-       , __pCheckButton(null)
        , __pLabelSelectCnt(null)
        , __pButtonSelectRegion(null)
        , __itemCount(0)
@@ -100,30 +97,16 @@ AllListEditorPanel::OnInitializing(void)
        __pPresentationModel->AddPresentationModelListener(this);
 
        Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
-       clientAreaBounds.x = clientAreaBounds.y = 0;
-       result r = SetBounds(clientAreaBounds);
-
-       Panel* pCheckPanel = new (std::nothrow) Panel();
-       pCheckPanel->Construct(Rectangle(0, 0, clientAreaBounds.width, H_SELECTALL_REGION));
-       pCheckPanel->SetBackgroundColor(COLOR_SELECTALL_REGION);
-       __pCheckButton = new (std::nothrow) CheckButton();
-       __pCheckButton->Construct(pCheckPanel->GetBounds(), CHECK_BUTTON_STYLE_MARK, BACKGROUND_STYLE_DEFAULT, false,
-                       ResourceManager::GetString(L"IDS_COM_BODY_SELECT_ALL"));
-       __pCheckButton->SetActionId(ACTION_ID_BUTTON_CHECKED, ACTION_ID_BUTTON_UNCHECKED);
-       __pCheckButton->AddActionEventListener(*this);
-       pCheckPanel->AddControl(*__pCheckButton);
-       AddControl(*pCheckPanel);
+       SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
 
        __pContentIconListView = new (std::nothrow) IconListView();
-       __pContentIconListView->Construct(Rectangle(0, H_SELECTALL_REGION, clientAreaBounds.width,
-                       clientAreaBounds.height - H_COUNT_LABEL - H_SELECTALL_REGION), DIMENSION_DEFAULT_THUMBNAIL,
-                       ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
+       __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height - H_COUNT_LABEL),
+                       DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
        Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
        if (pBitmapEmpty != null)
        {
                __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);
@@ -169,14 +152,13 @@ AllListEditorPanel::OnInitializing(void)
        if (pSelectionBitmap != null)
        {
                delete pSelectionBitmap;
-               pSelectionBitmap = null;
        }
        __pButtonSelectRegion->AddActionEventListener(*this);
 
-       __itemCount=0;
+       __itemCount = 0;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
-       return r;
+       return E_SUCCESS;
 }
 
 result
@@ -190,7 +172,7 @@ AllListEditorPanel::OnTerminating(void)
 }
 
 void
-AllListEditorPanel::OnUpdateContentList()
+AllListEditorPanel::UpdatePanelContent()
 {
        AppLogDebug("ENTER");
        SceneManager* pSceneManager = SceneManager::GetInstance();
@@ -199,7 +181,7 @@ AllListEditorPanel::OnUpdateContentList()
        TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
                        GetErrorMessage(GetLastResult()));
 
-       if ( pFileListEditorForm->GetOverlayStatus() == false && __deleteInProgress == false )
+       if (pFileListEditorForm->GetOverlayStatus() == false && __deleteInProgress == false)
        {
                SceneManager* pSceneManager = SceneManager::GetInstance();
                pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
@@ -359,7 +341,6 @@ AllListEditorPanel::CreateItem(int index)
                        pIconListviewItem = new (std::nothrow) IconListViewItem();
                        pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
                        delete pSelectedBitmap;
-                       pSelectedBitmap = null;
                }
                else
                {
@@ -376,12 +357,10 @@ AllListEditorPanel::CreateItem(int index)
        if (pBitmap != null)
        {
                delete pBitmap;
-               pBitmap = null;
        }
        if (pItemText != null)
        {
                delete pItemText;
-               pItemText = null;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -423,17 +402,6 @@ AllListEditorPanel::OnIconListViewItemStateChanged(IconListView& view, int index
 
                __pLabelSelectCnt->SetText(strTmp);
                __pLabelSelectCnt->RequestRedraw(true);
-               if (__pCheckButton->IsSelected() == true)
-               {
-                       __pCheckButton->SetSelected(false);
-               }
-               else
-               {
-                       if (checkedCount != 0 && checkedCount == __pPresentationModel->GetCurrentAlbumContentInfoCount())
-                       {
-                               __pCheckButton->SetSelected(true);
-                       }
-               }
                __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
        }
        SetButtonState();
@@ -479,6 +447,17 @@ AllListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
        if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
        {
                ResetSelection();
+               if (pArgs != null && pArgs->GetCount() > 0)
+               {
+                       IList* pSeletedIndexList = pArgs;
+                       int loopCount = pSeletedIndexList->GetCount();
+                       for (int i = 0; i < loopCount; ++i)
+                       {
+                               int index = static_cast<Integer*>(pSeletedIndexList->GetAt(i))->ToInt();
+                               __pContentIconListView->SetItemChecked(index, true);
+                       }
+                       __pContentIconListView->RequestRedraw(true);
+               }
        }
        else if (previousSceneId == IDSCN_ALL_LIST)
        {
@@ -494,7 +473,7 @@ AllListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
 
        pFileListEditorForm->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
        
-       if (pArgs != null && pArgs->GetCount() > 0)
+       if (pArgs != null && pArgs->GetCount() > 0 && previousSceneId != IDSCN_ALL_LIST_SELECTION)
        {
                String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
                if (pDirectory != null && pDirectory->GetLength() > 0)
@@ -573,9 +552,7 @@ AllListEditorPanel::OnRequestDelete(void)
        }
 
        delete __pFileDelete;
-       __pFileDelete = new FileDeleteTimer(pIndexList,
-                       __pPresentationModel,
-                       this );
+       __pFileDelete = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
        result r = __pFileDelete->StartTimer();
 
        if (IsFailed(r))
@@ -603,7 +580,6 @@ void AllListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
 
 void AllListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
 {
-       __pCheckButton->SetSelected(false);
        __deleteInProgress = false;     
 
        __pLabelSelectCnt->SetText(ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
@@ -637,36 +613,28 @@ AllListEditorPanel::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);
-               }
-
-               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_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
-       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;
@@ -684,35 +652,28 @@ AllListEditorPanel::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);
+                       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_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
-                       pDataList, null);
+                       new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, null);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -726,56 +687,34 @@ AllListEditorPanel::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;
+       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,
+                       new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
+
+       delete pIndexList;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -808,7 +747,6 @@ AllListEditorPanel::ResetSelection(void)
 
        __pLabelSelectCnt->SetText(strTmp);
        __pLabelSelectCnt->RequestRedraw(true);
-       __pCheckButton->SetSelected(false);
        SetButtonState();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -839,3 +777,53 @@ AllListEditorPanel::SetButtonState(void)
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
+
+void
+AllListEditorPanel::SelectAllPressed(void)
+{
+       bool needToSelectAll = true;
+       int checkedCount = GetItemCheckedCount();
+       int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
+       if (checkedCount == totalFileCount)
+       {
+               needToSelectAll = false;
+       }
+
+       if (needToSelectAll == true)
+       {
+               for (int i = 0 ; i < totalFileCount; ++i)
+               {
+                       if (__pContentIconListView->IsItemChecked(i) == false)
+                       {
+                               __pContentIconListView->SetItemChecked(i,true);
+                               __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
+                       }
+               }
+       }
+       else
+       {
+               for (int i = 0 ; i < totalFileCount; ++i)
+               {
+                       if (__pContentIconListView->IsItemChecked(i) == true)
+                       {
+                               __pContentIconListView->SetItemChecked(i, false);
+                               __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
+                       }
+               }
+       }
+
+       String tempString;
+       if (needToSelectAll == true)
+       {
+               tempString.Format(LENGTH_COUNT_LABEL,
+                                               ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
+       }
+       else
+       {
+               tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
+       }
+
+       __pLabelSelectCnt->SetText(tempString);
+       __pLabelSelectCnt->RequestRedraw(true);
+       SetButtonState();
+}