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 "GlResourceManager.h"
27 #include "GlSlideSettingListener.h"
28 #include "GlSlideShowPopUp.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38 using namespace Tizen::Content;
40 FileListForm::FileListForm(void)
41 : __pContextMenuMore(null)
43 , __pPresentationModel(null)
46 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
49 FileListForm::~FileListForm(void)
52 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
56 FileListForm::Initialize(void)
59 result r = Form::Construct(IDL_FORM_FILE_LIST);
60 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
65 FileListForm::OnInitializing(void)
68 Header* pHeader = GetHeader();
69 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
71 __pPresentationModel = FileListPresentationModel::GetInstance();
72 __pPresentationModel->ClearThumbnailRequests();
74 __pPopUp = new (std::nothrow) SlideShowPopUp();
78 __pPopUp->Initialize();
79 __pPopUp->SetEventListner(this);
84 SetFormBackEventListener(this);
85 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
91 FileListForm::OnTerminating(void)
95 if (__pContextMenuMore != null)
97 delete __pContextMenuMore;
98 __pContextMenuMore = null;
100 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
106 FileListForm::OnContentUpdated()
108 AppLogDebug("ENTER");
109 SceneManager* pSceneManager = SceneManager::GetInstance();
110 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
111 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
115 FileListForm::OnActionPerformed(const Control& source, int actionId)
117 AppLogDebug("ENTER");
118 SceneManager* pSceneManager = SceneManager::GetInstance();
119 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
123 case IDA_FOOTER_MORE:
125 AppLogDebug("ITEMCOUNT(%d)", __pPresentationModel->GetCurrentAlbumContentInfoCount());
129 if (__pContextMenuMore->GetShowState() == false)
131 Rectangle rect = source.GetBounds();
132 __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y));
133 __pContextMenuMore->SetShowState(true);
134 __pContextMenuMore->Show();
138 __pContextMenuMore->SetShowState(false);
143 case IDA_FOOTER_EDIT:
145 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
147 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
149 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
151 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
153 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
155 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
159 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
164 case IDA_FOOTER_SLIDESHOW:
167 if (__pPopUp != null)
169 __pPopUp->SetShowState(true);
175 case IDA_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 null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
188 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
192 FileListForm::OnFormBackRequested(Form& source)
194 AppLogDebug("ENTER");
195 SceneManager* pSceneManager = SceneManager::GetInstance();
196 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
198 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
199 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
203 FileListForm::InitializeFooter(void)
205 AppLogDebug("ENTER");
206 result r = E_SUCCESS;
207 Footer* pFooter = GetFooter();
208 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
210 pFooter->RemoveAllItems();
211 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
213 ButtonItem footerMore;
214 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
216 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
217 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
218 Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
220 if (pBitmapMore != null && pBitmapMoreDim != null && pBitmapMorePressed != null)
222 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
223 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
224 footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
226 pFooter->SetButton(BUTTON_POSITION_LEFT, footerMore);
229 delete pBitmapMoreDim;
230 delete pBitmapMorePressed;
232 FooterItem itemCamera;
233 itemCamera.Construct(IDA_FOOTER_CAMERA);
234 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
235 if (pBitmapCamera != null)
237 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
239 pFooter->AddItem(itemCamera);
241 if (__pContextMenuMore != null)
243 delete __pContextMenuMore;
244 __pContextMenuMore = null;
247 __pContextMenuMore = new (std::nothrow) ContextMenu();
248 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
250 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
252 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
255 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
257 __pContextMenuMore->SetEnabled(false);
261 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
262 __pContextMenuMore->SetShowState(false);
263 __pContextMenuMore->AddActionEventListener(*this);
266 pFooter->SetBackButton();
268 pFooter->AddActionEventListener(*this);
269 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
275 FileListForm::SetTitleText(const String& titleText)
277 AppLogDebug("ENTER");
278 Header* pHeader = GetHeader();
279 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
280 pHeader->SetTitleText(titleText);
282 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
286 FileListForm::OnSlideSettingPopUpItemSelected(int index)
288 if (__pPopUp != NULL)
290 __pPopUp->SetShowState(false);
295 result r = E_SUCCESS;
296 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
297 pArrayList->Construct();
298 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
300 for (int i = 0; i < loopCount; ++i)
302 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
305 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
306 pDataList->Construct();
307 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
308 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
310 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
311 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
313 if (r == E_MAX_EXCEEDED)
315 MessageBox messageBox;
316 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
317 MSGBOX_STYLE_NONE, 3000);
319 messageBox.ShowAndWait(modalResult);
324 SceneManager* pSceneManager = SceneManager::GetInstance();
325 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
327 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
332 FileListForm::SetFooterState(bool state)
334 GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT,state);
335 GetFooter()->Invalidate(true);