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 SetOrientation(ORIENTATION_AUTOMATIC);
90 AddOrientationEventListener(*this);
91 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
97 FileListForm::OnTerminating(void)
101 if ( __pOptionMenu != null )
103 delete __pOptionMenu;
104 __pOptionMenu = null;
107 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
113 FileListForm::OnContentUpdated()
115 AppLogDebug("ENTER");
116 SceneManager* pSceneManager = SceneManager::GetInstance();
117 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
118 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
122 FileListForm::OnActionPerformed(const Control& source, int actionId)
124 AppLogDebug("ENTER");
125 SceneManager* pSceneManager = SceneManager::GetInstance();
126 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
130 case IDA_FOOTER_EDIT:
132 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
134 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
136 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
138 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
140 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
142 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
146 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
151 case IDA_FOOTER_SLIDESHOW:
154 if (__pPopUp != null)
156 __pPopUp->SetShowState(true);
162 case IDA_FOOTER_CAMERA:
164 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
165 pDataList->Construct();
166 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
167 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
168 null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
175 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
179 FileListForm::OnFormBackRequested(Form& source)
181 AppLogDebug("ENTER");
182 SceneManager* pSceneManager = SceneManager::GetInstance();
183 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
185 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
186 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
190 FileListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
194 SceneManager* pSceneManager = SceneManager::GetInstance();
195 pSceneManager->GetCurrentScene();
197 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
199 AllListPanel* pListPanel = dynamic_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
200 if (pListPanel != null)
202 pListPanel->ChangeOrientation();
208 FileListForm::InitializeFooter(void)
210 AppLogDebug("ENTER");
211 result r = E_SUCCESS;
212 Footer* pFooter = GetFooter();
213 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
215 pFooter->RemoveAllItems();
216 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
218 FooterItem itemCamera;
219 itemCamera.Construct(IDA_FOOTER_CAMERA);
220 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
221 if (pBitmapCamera != null)
223 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
225 pFooter->AddItem(itemCamera);
228 if (__pOptionMenu != null)
230 delete __pOptionMenu;
231 __pOptionMenu = null;
234 __pOptionMenu = new (std::nothrow) OptionMenu();
235 __pOptionMenu->Construct();
237 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
239 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
242 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
244 __pOptionMenu->SetEnabled(false);
248 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
249 __pOptionMenu->AddActionEventListener(*this);
252 pFooter->AddActionEventListener(*this);
253 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
259 FileListForm::SetTitleText(const String& titleText)
261 AppLogDebug("ENTER");
262 Header* pHeader = GetHeader();
263 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
264 pHeader->SetTitleText(titleText);
266 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
270 FileListForm::OnSlideSettingPopUpItemSelected(int index)
272 if (__pPopUp != NULL)
274 __pPopUp->SetShowState(false);
279 result r = E_SUCCESS;
280 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
281 pArrayList->Construct();
282 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
284 for (int i = 0; i < loopCount; ++i)
286 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
289 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
290 pDataList->Construct();
291 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
292 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
294 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
295 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
297 if (r == E_MAX_EXCEEDED)
299 MessageBox messageBox;
300 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
301 MSGBOX_STYLE_NONE, 3000);
303 messageBox.ShowAndWait(modalResult);
308 SceneManager* pSceneManager = SceneManager::GetInstance();
309 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
311 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
316 FileListForm::SetMenuState(bool state)
322 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
325 if (__menuState == true )
329 if ( __pOptionMenu == null )
334 __pOptionMenu->SetShowState(true);
335 __pOptionMenu->Show();