Removed the deprecated Menu and Back buuton api
[apps/osp/Gallery.git] / src / GlAllListPanel.cpp
index 4b3fd86..e7590a6 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
 //
@@ -19,8 +19,6 @@
  * @brief              This is the implementation file for AllListPanel class.
  */
 
-#include <FContent.h>
-#include <FMedia.h>
 #include "GlAlbumInfo.h"
 #include "GlAllListPanel.h"
 #include "GlCommonUtil.h"
@@ -45,16 +43,16 @@ static const int W_CONTENT_MARGIN = 6;
 static const int W_CONTENT_SPACE = 6;
 static const int H_CONTENT_SPACE = 6;
 
-AllListPanel::AllListPanel()
-       : __pContentIconListView(null)
-       , __itemCount(0)
+AllListPanel::AllListPanel(void)
+       : __itemCount(0)
+       , __pContentIconListView(null)
        , __pPresentationModel(null)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
-AllListPanel::~AllListPanel()
+AllListPanel::~AllListPanel(void)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -64,7 +62,7 @@ void
 AllListPanel::Refresh(void)
 {
        AppLogDebug("ENTER");
-       if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
+       if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
                if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
                {
@@ -85,6 +83,14 @@ AllListPanel::Refresh(void)
        }
 
        __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
+       if (__itemCount == 0)
+       {
+               SceneManager* pSceneManager = SceneManager::GetInstance();
+               TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
+
+               pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
+       }
+
        __pContentIconListView->UpdateList();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -133,7 +139,7 @@ AllListPanel::OnInitializing(void)
        __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
        __pContentIconListView->AddIconListViewItemEventListener(*this);
        __pContentIconListView->SetTouchAnimationEnabled(false);
-       result r = AddControl(*__pContentIconListView);
+       result r = AddControl(__pContentIconListView);
        __pContentIconListView->SetShowState(true);
 
        __itemCount = 0;
@@ -146,6 +152,13 @@ result
 AllListPanel::OnTerminating(void)
 {
        AppLogDebug("ENTER");
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
+       {
+               FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
+               __pPresentationModel->RemoveContentEventListener(pFileListForm);
+       }
        __pPresentationModel->RemovePresentationModelListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -224,6 +237,7 @@ void
 AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
 {
        AppLogDebug("ENTER");
+       result r = E_SUCCESS;
        if (status == ICON_LIST_VIEW_ITEM_SELECTED)
        {
                if (__pPresentationModel->GetCurrentAlbumContentInfoCount() <= 0)
@@ -236,7 +250,7 @@ AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, Icon
                pArrayList->Construct();
                int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
 
-               for (int i = 0 ; i < loopCount; ++i)
+               for (int i = 0; i < loopCount; ++i)
                {
                        pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
                }
@@ -250,15 +264,24 @@ AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, Icon
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pArrayList);
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
 
-               __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
+               r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
                                new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
 
-               String* temp = 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);
+               }
+
+               String* pTemp = null;
                loopCount = pArrayList->GetCount();
                for (int i = 0; i < loopCount; ++i)
                {
-                       temp = static_cast<String*>(pArrayList->GetAt(i));
-                       AppLog("print temp(%ls)", temp->GetPointer());
+                       pTemp = static_cast<String*>(pArrayList->GetAt(i));
+                       AppLog("print temp(%ls)", pTemp->GetPointer());
                }
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -268,8 +291,7 @@ void
 AllListPanel::OnFileInfoChanged(const ContentType contentType)
 {
        AppLogDebug("ENTER");
-       if (contentType == CONTENT_TYPE_ALL
-               || contentType == CONTENT_TYPE_IMAGE
+       if (contentType == CONTENT_TYPE_ALL || contentType == CONTENT_TYPE_IMAGE
                || contentType == CONTENT_TYPE_VIDEO)
        {
                __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
@@ -294,6 +316,7 @@ AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
                                                                const SceneId& currentSceneId, IList* pArgs)
 {
        AppLogDebug("ENTER");
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
 
        if (currentSceneId == IDSCN_ALL_LIST)
@@ -326,7 +349,6 @@ AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
                        __pContentIconListView->UpdateList();
                }
        }
-
        SceneManager* pSceneManager = SceneManager::GetInstance();
        AppAssert(pSceneManager);
        if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
@@ -335,7 +357,18 @@ AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
                if (pFileListForm != null)
                {
                        pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
+
+                       if( __itemCount == 0)
+                       {
+                               pFileListForm->SetMenuState(false);
+                       }
+                       else
+                       {
+                               pFileListForm->SetMenuState(true);
+                       }
+
                }
+               __pPresentationModel->AddContentEventListener(pFileListForm);
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -345,13 +378,12 @@ AllListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
                                                                const SceneId& nextSceneId)
 {
        AppLogDebug("ENTER");
-       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
-}
-
-void
-AllListPanel::UpdatePanelContent()
-{
-       AppLogDebug("ENTER");
-       Refresh();
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
+       {
+               FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
+               __pPresentationModel->RemoveContentEventListener(pFileListForm);
+       }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }