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)
55 if ( __pPopUp != NULL )
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();
86 __pPopUp = new (std::nothrow) SlideShowPopUp();
90 __pPopUp->Initialize();
91 __pPopUp->SetEventListner(this);
96 SetFormBackEventListener(this);
97 SetOrientation(ORIENTATION_AUTOMATIC);
98 AddOrientationEventListener(*this);
99 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
105 FileListForm::OnTerminating(void)
107 AppLogDebug("ENTER");
109 if ( __pOptionMenu != null )
111 delete __pOptionMenu;
112 __pOptionMenu = null;
115 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
121 FileListForm::OnContentUpdated()
123 AppLogDebug("ENTER");
124 SceneManager* pSceneManager = SceneManager::GetInstance();
125 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
126 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
130 FileListForm::OnActionPerformed(const Control& source, int actionId)
132 AppLogDebug("ENTER");
133 SceneManager* pSceneManager = SceneManager::GetInstance();
134 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
138 case IDA_FOOTER_EDIT:
140 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
142 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
144 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
146 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
148 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
150 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
154 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
159 case IDA_FOOTER_SLIDESHOW:
162 if (__pPopUp != null)
164 __pPopUp->SetShowState(true);
170 case IDA_FOOTER_CAMERA:
172 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
173 pDataList->Construct();
174 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
175 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
176 null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, this);
183 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
187 FileListForm::OnFormBackRequested(Form& source)
189 AppLogDebug("ENTER");
190 SceneManager* pSceneManager = SceneManager::GetInstance();
191 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
193 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
194 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
198 FileListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
202 SceneManager* pSceneManager = SceneManager::GetInstance();
203 pSceneManager->GetCurrentScene();
205 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
207 AllListPanel* pListPanel = dynamic_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
208 if (pListPanel != null)
210 pListPanel->ChangeOrientation();
216 FileListForm::InitializeFooter(void)
218 AppLogDebug("ENTER");
219 result r = E_SUCCESS;
220 Footer* pFooter = GetFooter();
221 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
223 pFooter->RemoveAllItems();
224 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
226 FooterItem itemCamera;
227 itemCamera.Construct(IDA_FOOTER_CAMERA);
228 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
229 if (pBitmapCamera != null)
231 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
233 pFooter->AddItem(itemCamera);
235 delete pBitmapCamera;
237 if (__pOptionMenu != null)
239 delete __pOptionMenu;
240 __pOptionMenu = null;
243 __pOptionMenu = new (std::nothrow) OptionMenu();
244 __pOptionMenu->Construct();
246 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
248 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
251 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
253 __pOptionMenu->SetEnabled(false);
257 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
258 __pOptionMenu->AddActionEventListener(*this);
261 pFooter->AddActionEventListener(*this);
262 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
268 FileListForm::SetTitleText(const String& titleText)
270 AppLogDebug("ENTER");
271 Header* pHeader = GetHeader();
272 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
273 pHeader->SetTitleText(titleText);
275 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
279 FileListForm::OnSlideSettingPopUpItemSelected(int index)
281 if (__pPopUp != NULL)
283 __pPopUp->SetShowState(false);
288 result r = E_SUCCESS;
289 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
290 pArrayList->Construct();
291 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
293 for (int i = 0; i < loopCount; ++i)
295 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
298 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
299 pDataList->Construct();
300 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
301 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
303 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
304 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
306 if (r == E_MAX_EXCEEDED)
308 MessageBox messageBox;
309 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
310 MSGBOX_STYLE_NONE, 3000);
312 messageBox.ShowAndWait(modalResult);
317 SceneManager* pSceneManager = SceneManager::GetInstance();
318 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
320 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
325 FileListForm::SetMenuState(bool state)
331 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
334 if (__menuState == true )
338 if ( __pOptionMenu == null )
343 __pOptionMenu->SetShowState(true);
344 __pOptionMenu->Show();
350 FileListForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
351 AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
353 AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
355 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
356 TryReturnVoid(pGalleryApp != null, "pGalleryApp is null");
357 pGalleryApp->SetFrameEnabled(true);