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 GlAllListPanel.cpp
19 * @brief This is the implementation file for AllListPanel class.
22 #include "GlAlbumInfo.h"
23 #include "GlAllListPanel.h"
24 #include "GlCommonUtil.h"
25 #include "GlFileListForm.h"
26 #include "GlFileListPresentationModel.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Media;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
40 static const int W_CLIENT = 720;
41 static const int H_CONTENT_MARGIN = 9;
42 static const int W_CONTENT_MARGIN = 6;
43 static const int W_CONTENT_SPACE = 6;
44 static const int H_CONTENT_SPACE = 6;
46 AllListPanel::AllListPanel(void)
48 , __pContentIconListView(null)
49 , __pPresentationModel(null)
52 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
55 AllListPanel::~AllListPanel(void)
58 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
62 AllListPanel::Refresh(void)
65 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
67 if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
69 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_IMAGE);
71 else if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_VIDEO)
73 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
77 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
82 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
85 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
88 SceneManager* pSceneManager = SceneManager::GetInstance();
89 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
91 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
94 __pContentIconListView->UpdateList();
95 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
99 AllListPanel::Initialize(void)
101 AppLogDebug("ENTER");
102 result r = Construct(RECT_INITIAL);
103 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
109 AllListPanel::OnInitializing(void)
111 AppLogDebug("ENTER");
112 const Form* pForm = dynamic_cast<Form*>(GetParent());
115 __pPresentationModel = FileListPresentationModel::GetInstance();
116 __pPresentationModel->ClearThumbnailRequests();
117 __pPresentationModel->AddPresentationModelListener(this);
119 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
120 clientAreaBounds.x = clientAreaBounds.y = 0;
121 SetBounds(clientAreaBounds);
123 __pContentIconListView = new (std::nothrow) IconListView();
124 __pContentIconListView->Construct(Rectangle(0, 0, W_CLIENT, clientAreaBounds.height),
125 DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
126 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
127 if (pBitmapEmpty != null)
129 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
132 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
133 __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
134 __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
135 __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
136 __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
137 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
138 __pContentIconListView->SetItemProvider(*this);
139 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
140 __pContentIconListView->AddIconListViewItemEventListener(*this);
141 __pContentIconListView->SetTouchAnimationEnabled(false);
142 result r = AddControl(__pContentIconListView);
143 __pContentIconListView->SetShowState(true);
146 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
152 AllListPanel::OnTerminating(void)
154 AppLogDebug("ENTER");
155 SceneManager* pSceneManager = SceneManager::GetInstance();
156 AppAssert(pSceneManager);
157 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
159 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
160 __pPresentationModel->RemoveContentEventListener(pFileListForm);
162 __pPresentationModel->RemovePresentationModelListener(*this);
163 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
169 AllListPanel::GetItemCount(void)
171 AppLogDebug("ENTER");
172 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
178 AllListPanel::CreateItem(int index)
180 AppLogDebug("ENTER : index(%d)", index);
181 Bitmap* pBitmap=null;
182 String* pItemText=null;
183 result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
186 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
190 IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
194 __pPresentationModel->RequestThumbnail(index);
195 pBitmap = CommonUtil::GetEmptyThumbnailN();
198 if (pItemText == null)
200 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
202 else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
205 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
208 if (pItemText != null)
210 pIconListviewItem->Construct(*pBitmap, pItemText);
217 if (pItemText != null)
221 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
223 return pIconListviewItem;
227 AllListPanel::DeleteItem(int index, IconListViewItem* pItem)
229 AppLogDebug("ENTER : index(%d)", index);
231 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
237 AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
239 AppLogDebug("ENTER");
240 result r = E_SUCCESS;
241 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
243 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() <= 0)
245 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
249 ArrayList* pArrayList = new (std::nothrow) ArrayList();
250 pArrayList->Construct();
251 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
253 for (int i = 0; i < loopCount; ++i)
255 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
259 listIndex.Format(10, L"%d", index);
261 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
262 pDataList->Construct();
263 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
264 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pArrayList);
265 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
267 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
268 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
270 if (r == E_MAX_EXCEEDED)
272 MessageBox messageBox;
273 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
274 MSGBOX_STYLE_NONE, 3000);
276 messageBox.ShowAndWait(modalResult);
279 String* pTemp = null;
280 loopCount = pArrayList->GetCount();
281 for (int i = 0; i < loopCount; ++i)
283 pTemp = static_cast<String*>(pArrayList->GetAt(i));
284 AppLog("print temp(%ls)", pTemp->GetPointer());
287 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
291 AllListPanel::OnFileInfoChanged(const ContentType contentType)
293 AppLogDebug("ENTER");
294 if (contentType == CONTENT_TYPE_ALL || contentType == CONTENT_TYPE_IMAGE
295 || contentType == CONTENT_TYPE_VIDEO)
297 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
298 __pContentIconListView->UpdateList();
300 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
304 AllListPanel::OnThumbnailDecoded(const int index)
306 AppLogDebug("ENTER : index(%d)", index);
309 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
311 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
315 AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
316 const SceneId& currentSceneId, IList* pArgs)
318 AppLogDebug("ENTER");
320 __pPresentationModel = FileListPresentationModel::GetInstance();
322 if (currentSceneId == IDSCN_ALL_LIST)
324 if (previousSceneId == IDSCN_ALBUM_LIST && pArgs != null)
326 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
327 if (pAlbumInfo == null)
329 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
333 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
334 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
335 if (pDirectoryList != null)
337 delete pDirectoryList;
342 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
343 __pContentIconListView->UpdateList();
347 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
348 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
349 __pContentIconListView->UpdateList();
352 SceneManager* pSceneManager = SceneManager::GetInstance();
353 AppAssert(pSceneManager);
354 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
356 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
357 if (pFileListForm != null)
359 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
361 if( __itemCount == 0)
363 pFileListForm->SetMenuState(false);
367 pFileListForm->SetMenuState(true);
371 __pPresentationModel->AddContentEventListener(pFileListForm);
373 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
377 AllListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
378 const SceneId& nextSceneId)
380 AppLogDebug("ENTER");
381 SceneManager* pSceneManager = SceneManager::GetInstance();
382 AppAssert(pSceneManager);
383 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
385 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
386 __pPresentationModel->RemoveContentEventListener(pFileListForm);
388 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));