2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 "GlResourceManager.h"
27 #include "GlSlideSettingListener.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37 using namespace Tizen::Content;
39 FileListForm::FileListForm(void)
40 : __pContextMenuMore(null)
41 , __pPresentationModel(null)
44 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
47 FileListForm::~FileListForm(void)
50 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
54 FileListForm::Initialize(void)
57 result r = Form::Construct(IDL_FORM_FILE_LIST);
58 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
63 FileListForm::OnInitializing(void)
66 Header* pHeader = GetHeader();
67 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
69 __pPresentationModel = FileListPresentationModel::GetInstance();
70 __pPresentationModel->ClearThumbnailRequests();
72 __pPopUp = new (std::nothrow) SlideShowPopUp();
76 __pPopUp->Initialize();
77 __pPopUp->SetEventListner(this);
78 AddControl(*__pPopUp);
82 SetFormBackEventListener(this);
83 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
89 FileListForm::OnTerminating(void)
93 if (__pContextMenuMore != null)
95 delete __pContextMenuMore;
96 __pContextMenuMore = null;
98 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104 FileListForm::OnContentUpdated()
106 AppLogDebug("ENTER");
107 SceneManager* pSceneManager = SceneManager::GetInstance();
108 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
109 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
113 FileListForm::OnActionPerformed(const Control& source, int actionId)
115 AppLogDebug("ENTER");
116 SceneManager* pSceneManager = SceneManager::GetInstance();
117 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
121 case IDA_FOOTER_MORE:
123 AppLogDebug("ITEMCOUNT(%d)", __pPresentationModel->GetCurrentAlbumContentInfoCount());
127 if (__pContextMenuMore->GetShowState() == false)
129 Rectangle rect = source.GetBounds();
130 __pContextMenuMore->SetAnchorPosition(Point(rect.width/8, rect.y));
131 __pContextMenuMore->SetShowState(true);
132 __pContextMenuMore->Show();
136 __pContextMenuMore->SetShowState(false);
140 case IDA_FOOTER_EDIT:
142 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
144 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
146 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
148 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
150 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
152 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
156 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
160 case IDA_FOOTER_SLIDESHOW:
163 if (__pPopUp != null)
165 __pPopUp->SetShowState(true);
171 case IDA_FOOTER_CAMERA:
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, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
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::InitializeFooter(void)
200 AppLogDebug("ENTER");
201 result r = E_SUCCESS;
202 Footer* pFooter = GetFooter();
203 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
205 pFooter->RemoveAllItems();
206 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
208 ButtonItem footerMore;
209 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
210 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
211 if (pBitmapMore != null)
213 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
215 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
217 FooterItem itemCamera;
218 itemCamera.Construct(IDA_FOOTER_CAMERA);
219 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
220 if (pBitmapCamera != null)
222 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
224 pFooter->AddItem(itemCamera);
226 if (__pContextMenuMore != null)
228 delete __pContextMenuMore;
229 __pContextMenuMore = null;
232 __pContextMenuMore = new (std::nothrow) ContextMenu();
233 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
235 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
237 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"), IDA_FOOTER_SLIDESHOW);
240 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
242 __pContextMenuMore->SetEnabled(false);
246 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
247 __pContextMenuMore->SetShowState(false);
248 __pContextMenuMore->AddActionEventListener(*this);
251 pFooter->SetBackButton();
253 pFooter->AddActionEventListener(*this);
254 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
260 FileListForm::SetTitleText(const String& titleText)
262 AppLogDebug("ENTER");
263 Header* pHeader = GetHeader();
264 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
265 pHeader->SetTitleText(titleText);
267 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
271 FileListForm::OnSlideSettingPopUpItemSelected(int index)
273 if (__pPopUp != NULL)
275 __pPopUp->SetShowState(false);
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 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
295 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
299 SceneManager* pSceneManager = SceneManager::GetInstance();
300 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
302 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));