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)
45 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
48 FileListForm::~FileListForm(void)
51 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
55 FileListForm::Initialize(void)
58 result r = Form::Construct(IDL_FORM_FILE_LIST);
59 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
64 FileListForm::OnInitializing(void)
67 Header* pHeader = GetHeader();
68 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
70 __pPresentationModel = FileListPresentationModel::GetInstance();
71 __pPresentationModel->ClearThumbnailRequests();
73 __pPresentationModel->AddContentEventListener(this);
75 __pPopUp = new (std::nothrow) SlideShowPopUp();
79 __pPopUp->Initialize();
80 __pPopUp->SetEventListner(this);
81 AddControl(*__pPopUp);
85 SetFormBackEventListener(this);
86 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
92 FileListForm::OnTerminating(void)
96 __pPresentationModel->RemoveContentEventListener(this);
97 if (__pContextMenuMore != null)
99 delete __pContextMenuMore;
100 __pContextMenuMore = null;
102 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
108 FileListForm::OnContentUpdated()
110 AppLogDebug("ENTER");
111 SceneManager* pSceneManager = SceneManager::GetInstance();
112 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
113 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
117 FileListForm::OnActionPerformed(const Control& source, int actionId)
119 AppLogDebug("ENTER");
120 SceneManager* pSceneManager = SceneManager::GetInstance();
121 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
125 case ACTION_ID_FOOTER_MORE:
127 AppLogDebug("ITEMCOUNT(%d)", __pPresentationModel->GetCurrentAlbumContentInfoCount());
131 if (__pContextMenuMore->GetShowState() == false)
133 Rectangle rect = source.GetBounds();
134 __pContextMenuMore->SetAnchorPosition(Point(rect.width/8, rect.y));
135 __pContextMenuMore->SetShowState(true);
136 __pContextMenuMore->Show();
140 __pContextMenuMore->SetShowState(false);
144 case ACTION_ID_FOOTER_EDIT:
146 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
148 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
150 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
152 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
154 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
156 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
160 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
164 case ACTION_ID_FOOTER_SLIDESHOW:
167 if (__pPopUp != null)
169 __pPopUp->SetShowState(true);
175 case ACTION_ID_FOOTER_CAMERA:
177 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
178 pDataList->Construct();
179 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
180 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
181 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
187 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
191 FileListForm::OnFormBackRequested(Form& source)
193 AppLogDebug("ENTER");
194 SceneManager* pSceneManager = SceneManager::GetInstance();
195 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
197 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
198 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
202 FileListForm::InitializeFooter(void)
204 AppLogDebug("ENTER");
205 result r = E_SUCCESS;
206 Footer* pFooter = GetFooter();
207 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
209 pFooter->RemoveAllItems();
210 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
212 ButtonItem footerMore;
213 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
214 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
215 if (pBitmapMore != null)
217 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
219 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
221 FooterItem itemCamera;
222 itemCamera.Construct(ACTION_ID_FOOTER_CAMERA);
223 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
224 if (pBitmapCamera != null)
226 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
228 pFooter->AddItem(itemCamera);
230 if (__pContextMenuMore != null)
232 delete __pContextMenuMore;
233 __pContextMenuMore = null;
236 __pContextMenuMore = new (std::nothrow) ContextMenu();
237 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
239 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
241 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"), ACTION_ID_FOOTER_SLIDESHOW);
244 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
246 __pContextMenuMore->SetEnabled(false);
250 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), ACTION_ID_FOOTER_EDIT);
251 __pContextMenuMore->SetShowState(false);
252 __pContextMenuMore->AddActionEventListener(*this);
255 pFooter->SetBackButton();
257 pFooter->AddActionEventListener(*this);
258 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
264 FileListForm::SetTitleText(const String& titleText)
266 AppLogDebug("ENTER");
267 Header* pHeader = GetHeader();
268 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
269 pHeader->SetTitleText(titleText);
271 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
275 FileListForm::OnSlideSettingPopUpItemSelected(int index)
278 if ( __pPopUp != NULL)
280 __pPopUp->SetShowState(false);
283 if (index == 0) // start slide show
285 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
286 pArrayList->Construct();
287 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
289 for (int i = 0; i < loopCount; ++i)
291 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
294 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
295 pDataList->Construct();
296 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
297 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
299 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW,null, pDataList, null);
302 else if (index == 1) // go to settingsForm
304 SceneManager* pSceneManager = SceneManager::GetInstance();
305 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
307 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));