2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlFileListForm.cpp
19 * @brief This is the implementation file for FileListForm class.
22 #include "GlAlbumInfo.h"
23 #include "GlAllListPanel.h"
24 #include "GlFileListForm.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlResourceManager.h"
28 #include "GlSlideSettingListener.h"
29 #include "GlSlideShowPopUp.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39 using namespace Tizen::Content;
41 FileListForm::FileListForm(void)
45 , __pPresentationModel(null)
48 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
51 FileListForm::~FileListForm(void)
54 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
58 FileListForm::Initialize(void)
61 result r = Form::Construct(IDL_FORM_FILE_LIST);
62 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
67 FileListForm::OnInitializing(void)
70 Header* pHeader = GetHeader();
71 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
73 SetFormMenuEventListener(this);
75 __pPresentationModel = FileListPresentationModel::GetInstance();
76 __pPresentationModel->ClearThumbnailRequests();
78 __pPopUp = new (std::nothrow) SlideShowPopUp();
82 __pPopUp->Initialize();
83 __pPopUp->SetEventListner(this);
88 SetFormBackEventListener(this);
89 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
95 FileListForm::OnTerminating(void)
99 if ( __pOptionMenu != null )
101 delete __pOptionMenu;
102 __pOptionMenu = null;
105 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
111 FileListForm::OnContentUpdated()
113 AppLogDebug("ENTER");
114 SceneManager* pSceneManager = SceneManager::GetInstance();
115 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
116 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
120 FileListForm::OnActionPerformed(const Control& source, int actionId)
122 AppLogDebug("ENTER");
123 SceneManager* pSceneManager = SceneManager::GetInstance();
124 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
128 case IDA_FOOTER_EDIT:
130 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
132 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
134 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
136 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
138 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
140 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
144 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
149 case IDA_FOOTER_SLIDESHOW:
152 if (__pPopUp != null)
154 __pPopUp->SetShowState(true);
160 case IDA_FOOTER_CAMERA:
162 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
163 pDataList->Construct();
164 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
165 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
166 null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
173 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
177 FileListForm::OnFormBackRequested(Form& source)
179 AppLogDebug("ENTER");
180 SceneManager* pSceneManager = SceneManager::GetInstance();
181 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
183 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
184 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
188 FileListForm::InitializeFooter(void)
190 AppLogDebug("ENTER");
191 result r = E_SUCCESS;
192 Footer* pFooter = GetFooter();
193 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
195 pFooter->RemoveAllItems();
196 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
198 FooterItem itemCamera;
199 itemCamera.Construct(IDA_FOOTER_CAMERA);
200 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
201 if (pBitmapCamera != null)
203 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
205 pFooter->AddItem(itemCamera);
208 if (__pOptionMenu != null)
210 delete __pOptionMenu;
211 __pOptionMenu = null;
214 __pOptionMenu = new (std::nothrow) OptionMenu();
215 __pOptionMenu->Construct();
217 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
219 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
222 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
224 __pOptionMenu->SetEnabled(false);
228 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
229 __pOptionMenu->AddActionEventListener(*this);
232 pFooter->AddActionEventListener(*this);
233 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
239 FileListForm::SetTitleText(const String& titleText)
241 AppLogDebug("ENTER");
242 Header* pHeader = GetHeader();
243 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
244 pHeader->SetTitleText(titleText);
246 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
250 FileListForm::OnSlideSettingPopUpItemSelected(int index)
252 if (__pPopUp != NULL)
254 __pPopUp->SetShowState(false);
259 result r = E_SUCCESS;
260 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
261 pArrayList->Construct();
262 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
264 for (int i = 0; i < loopCount; ++i)
266 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
269 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
270 pDataList->Construct();
271 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
272 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
274 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
275 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
277 if (r == E_MAX_EXCEEDED)
279 MessageBox messageBox;
280 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
281 MSGBOX_STYLE_NONE, 3000);
283 messageBox.ShowAndWait(modalResult);
288 SceneManager* pSceneManager = SceneManager::GetInstance();
289 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
291 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
296 FileListForm::SetMenuState(bool state)
302 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
305 if (__menuState == true )
309 if ( __pOptionMenu == null )
314 __pOptionMenu->SetShowState(true);
315 __pOptionMenu->Show();