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)
62 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
66 FileListForm::Initialize(void)
69 result r = Form::Construct(IDL_FORM_FILE_LIST);
70 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
75 FileListForm::OnInitializing(void)
78 Header* pHeader = GetHeader();
79 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
81 SetFormMenuEventListener(this);
83 __pPresentationModel = FileListPresentationModel::GetInstance();
84 __pPresentationModel->ClearThumbnailRequests();
87 SetFormBackEventListener(this);
88 SetOrientation(ORIENTATION_AUTOMATIC);
89 AddOrientationEventListener(*this);
90 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
96 FileListForm::OnTerminating(void)
100 if (__pOptionMenu != null)
102 delete __pOptionMenu;
103 __pOptionMenu = null;
106 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
112 FileListForm::OnContentUpdated()
114 AppLogDebug("ENTER");
115 SceneManager* pSceneManager = SceneManager::GetInstance();
116 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
117 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
121 FileListForm::OnActionPerformed(const Control& source, int actionId)
123 AppLogDebug("ENTER");
124 SceneManager* pSceneManager = SceneManager::GetInstance();
125 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
129 case IDA_FOOTER_EDIT:
131 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
133 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
135 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
137 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
139 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
141 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
145 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
150 case IDA_FOOTER_SLIDESHOW:
153 if (__pPopUp != NULL)
158 __pPopUp = new (std::nothrow) SlideShowPopUp();
160 if (__pPopUp != null)
162 __pPopUp->Initialize();
163 __pPopUp->SetEventListner(this);
164 __pPopUp->SetShowState(true);
170 case IDA_FOOTER_CAMERA:
172 const String mimeType = APPCONTROL_MIME_IMAGE_JPG;
173 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
174 pDataList->Construct();
175 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
176 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
177 null, &mimeType, pDataList, this);
184 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
188 FileListForm::OnFormBackRequested(Form& source)
190 AppLogDebug("ENTER");
191 SceneManager* pSceneManager = SceneManager::GetInstance();
192 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
194 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
195 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
199 FileListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
203 SceneManager* pSceneManager = SceneManager::GetInstance();
204 pSceneManager->GetCurrentScene();
206 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
208 AllListPanel* pListPanel = dynamic_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
209 if (pListPanel != null)
211 pListPanel->ChangeOrientation();
217 FileListForm::InitializeFooter(void)
219 AppLogDebug("ENTER");
220 result r = E_SUCCESS;
221 Footer* pFooter = GetFooter();
222 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
224 pFooter->RemoveAllItems();
225 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
227 FooterItem itemCamera;
228 itemCamera.Construct(IDA_FOOTER_CAMERA);
229 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
230 if (pBitmapCamera != null)
232 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
234 pFooter->AddItem(itemCamera);
236 delete pBitmapCamera;
238 if (__pOptionMenu != null)
240 delete __pOptionMenu;
241 __pOptionMenu = null;
244 __pOptionMenu = new (std::nothrow) OptionMenu();
245 __pOptionMenu->Construct();
247 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
249 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
252 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
254 __pOptionMenu->SetEnabled(false);
258 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
259 __pOptionMenu->AddActionEventListener(*this);
262 pFooter->AddActionEventListener(*this);
263 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
269 FileListForm::SetTitleText(const String& titleText)
271 AppLogDebug("ENTER");
272 Header* pHeader = GetHeader();
273 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
275 if (titleText == ALL_ALBUMS_REAL_NAME)
277 String text = ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS");
278 pHeader->SetTitleText(text);
282 pHeader->SetTitleText(titleText);
286 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
290 FileListForm::OnSlideSettingPopUpItemSelected(int index)
292 if (__pPopUp != NULL)
294 __pPopUp->SetShowState(false);
299 result r = E_SUCCESS;
300 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
301 pArrayList->Construct();
302 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
304 for (int i = 0; i < loopCount; ++i)
306 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
309 const String mimeType = APPCONTROL_MIME_IMAGE_ALL;
310 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
311 pDataList->Construct();
312 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
313 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
315 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
316 &mimeType, pDataList, null);
318 if (r == E_MAX_EXCEEDED)
320 MessageBox messageBox;
321 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
322 MSGBOX_STYLE_NONE, 3000);
324 messageBox.ShowAndWait(modalResult);
329 SceneManager* pSceneManager = SceneManager::GetInstance();
330 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
332 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
337 FileListForm::SetMenuState(bool state)
343 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
346 if (__menuState == true)
350 if (__pOptionMenu == null)
355 __pOptionMenu->SetShowState(true);
356 __pOptionMenu->Show();
361 FileListForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
362 AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
364 AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
366 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
367 TryReturnVoid(pGalleryApp != null, "pGalleryApp is null");
368 pGalleryApp->SetFrameEnabled(true);