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)
44 , __pPresentationModel(null)
47 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
50 FileListForm::~FileListForm(void)
53 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
57 FileListForm::Initialize(void)
60 result r = Form::Construct(IDL_FORM_FILE_LIST);
61 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
66 FileListForm::OnInitializing(void)
69 Header* pHeader = GetHeader();
70 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
72 SetFormMenuEventListener(this);
74 __pPresentationModel = FileListPresentationModel::GetInstance();
75 __pPresentationModel->ClearThumbnailRequests();
77 __pPopUp = new (std::nothrow) SlideShowPopUp();
81 __pPopUp->Initialize();
82 __pPopUp->SetEventListner(this);
87 SetFormBackEventListener(this);
88 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
94 FileListForm::OnTerminating(void)
98 if ( __pOptionMenu != null )
100 delete __pOptionMenu;
101 __pOptionMenu = null;
104 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
110 FileListForm::OnContentUpdated()
112 AppLogDebug("ENTER");
113 SceneManager* pSceneManager = SceneManager::GetInstance();
114 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
115 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
119 FileListForm::OnActionPerformed(const Control& source, int actionId)
121 AppLogDebug("ENTER");
122 SceneManager* pSceneManager = SceneManager::GetInstance();
123 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
127 case IDA_FOOTER_EDIT:
129 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
131 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
133 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
135 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
137 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
139 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
143 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
148 case IDA_FOOTER_SLIDESHOW:
151 if (__pPopUp != null)
153 __pPopUp->SetShowState(true);
159 case IDA_FOOTER_CAMERA:
161 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
162 pDataList->Construct();
163 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
164 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
165 null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
172 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
176 FileListForm::OnFormBackRequested(Form& source)
178 AppLogDebug("ENTER");
179 SceneManager* pSceneManager = SceneManager::GetInstance();
180 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
182 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
183 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
187 FileListForm::InitializeFooter(void)
189 AppLogDebug("ENTER");
190 result r = E_SUCCESS;
191 Footer* pFooter = GetFooter();
192 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
194 pFooter->RemoveAllItems();
195 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
196 pFooter->SetMenuButton();
197 pFooter->SetBackButton();
199 FooterItem itemCamera;
200 itemCamera.Construct(IDA_FOOTER_CAMERA);
201 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
202 if (pBitmapCamera != null)
204 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
206 pFooter->AddItem(itemCamera);
209 if (__pOptionMenu != null)
211 delete __pOptionMenu;
212 __pOptionMenu = null;
215 __pOptionMenu = new (std::nothrow) OptionMenu();
216 __pOptionMenu->Construct();
218 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
220 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
223 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
225 __pOptionMenu->SetEnabled(false);
229 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
230 __pOptionMenu->AddActionEventListener(*this);
233 pFooter->AddActionEventListener(*this);
234 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
240 FileListForm::SetTitleText(const String& titleText)
242 AppLogDebug("ENTER");
243 Header* pHeader = GetHeader();
244 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
245 pHeader->SetTitleText(titleText);
247 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
251 FileListForm::OnSlideSettingPopUpItemSelected(int index)
253 if (__pPopUp != NULL)
255 __pPopUp->SetShowState(false);
260 result r = E_SUCCESS;
261 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
262 pArrayList->Construct();
263 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
265 for (int i = 0; i < loopCount; ++i)
267 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
270 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
271 pDataList->Construct();
272 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
273 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
275 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
276 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
278 if (r == E_MAX_EXCEEDED)
280 MessageBox messageBox;
281 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
282 MSGBOX_STYLE_NONE, 3000);
284 messageBox.ShowAndWait(modalResult);
289 SceneManager* pSceneManager = SceneManager::GetInstance();
290 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
292 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
297 FileListForm::SetFooterState(bool state)
299 GetFooter()->SetMenuButtonEnabled(state);
300 GetFooter()->Invalidate(true);
304 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
309 if ( __pOptionMenu == null )
314 __pOptionMenu->SetShowState(true);
315 __pOptionMenu->Show();