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 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));
93 __pContentIconListView->UpdateList();
94 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
98 AllListPanel::Initialize(void)
100 AppLogDebug("ENTER");
101 result r = Construct(RECT_INITIAL);
102 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
108 AllListPanel::OnInitializing(void)
110 AppLogDebug("ENTER");
111 const Form* pForm = dynamic_cast<Form*>(GetParent());
114 __pPresentationModel = FileListPresentationModel::GetInstance();
115 __pPresentationModel->ClearThumbnailRequests();
116 __pPresentationModel->AddPresentationModelListener(this);
118 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
119 clientAreaBounds.x = clientAreaBounds.y = 0;
120 SetBounds(clientAreaBounds);
122 __pContentIconListView = new (std::nothrow) IconListView();
123 __pContentIconListView->Construct(Rectangle(0, 0, W_CLIENT, clientAreaBounds.height),
124 DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
125 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
126 if (pBitmapEmpty != null)
128 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
131 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
132 __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
133 __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
134 __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
135 __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
136 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
137 __pContentIconListView->SetItemProvider(*this);
138 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
139 __pContentIconListView->AddIconListViewItemEventListener(*this);
140 __pContentIconListView->SetTouchAnimationEnabled(false);
141 result r = AddControl(*__pContentIconListView);
142 __pContentIconListView->SetShowState(true);
145 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
151 AllListPanel::OnTerminating(void)
153 AppLogDebug("ENTER");
154 SceneManager* pSceneManager = SceneManager::GetInstance();
155 AppAssert(pSceneManager);
156 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
158 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
159 __pPresentationModel->RemoveContentEventListener(pFileListForm);
161 __pPresentationModel->RemovePresentationModelListener(*this);
162 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
168 AllListPanel::GetItemCount(void)
170 AppLogDebug("ENTER");
171 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
177 AllListPanel::CreateItem(int index)
179 AppLogDebug("ENTER : index(%d)", index);
180 Bitmap* pBitmap=null;
181 String* pItemText=null;
182 result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
185 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
189 IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
193 __pPresentationModel->RequestThumbnail(index);
194 pBitmap = CommonUtil::GetEmptyThumbnailN();
197 if (pItemText == null)
199 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
201 else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
204 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
207 if (pItemText != null)
209 pIconListviewItem->Construct(*pBitmap, pItemText);
216 if (pItemText != null)
220 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
222 return pIconListviewItem;
226 AllListPanel::DeleteItem(int index, IconListViewItem* pItem)
228 AppLogDebug("ENTER : index(%d)", index);
230 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
236 AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
238 AppLogDebug("ENTER");
239 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
241 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() <= 0)
243 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
247 ArrayList* pArrayList = new (std::nothrow) ArrayList();
248 pArrayList->Construct();
249 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
251 for (int i = 0; i < loopCount; ++i)
253 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
257 listIndex.Format(10, L"%d", index);
259 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
260 pDataList->Construct();
261 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
262 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pArrayList);
263 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
265 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
266 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
268 String* pTemp = null;
269 loopCount = pArrayList->GetCount();
270 for (int i = 0; i < loopCount; ++i)
272 pTemp = static_cast<String*>(pArrayList->GetAt(i));
273 AppLog("print temp(%ls)", pTemp->GetPointer());
276 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
280 AllListPanel::OnFileInfoChanged(const ContentType contentType)
282 AppLogDebug("ENTER");
283 if (contentType == CONTENT_TYPE_ALL || contentType == CONTENT_TYPE_IMAGE
284 || contentType == CONTENT_TYPE_VIDEO)
286 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
287 __pContentIconListView->UpdateList();
289 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
293 AllListPanel::OnThumbnailDecoded(const int index)
295 AppLogDebug("ENTER : index(%d)", index);
298 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
300 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
304 AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
305 const SceneId& currentSceneId, IList* pArgs)
307 AppLogDebug("ENTER");
309 __pPresentationModel = FileListPresentationModel::GetInstance();
311 if (currentSceneId == IDSCN_ALL_LIST)
313 if (previousSceneId == IDSCN_ALBUM_LIST && pArgs != null)
315 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
316 if (pAlbumInfo == null)
318 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
322 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
323 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
324 if (pDirectoryList != null)
326 delete pDirectoryList;
331 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
332 __pContentIconListView->UpdateList();
336 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
337 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
338 __pContentIconListView->UpdateList();
341 SceneManager* pSceneManager = SceneManager::GetInstance();
342 AppAssert(pSceneManager);
343 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
345 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
346 if (pFileListForm != null)
348 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
350 __pPresentationModel->AddContentEventListener(pFileListForm);
352 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
356 AllListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
357 const SceneId& nextSceneId)
359 AppLogDebug("ENTER");
360 SceneManager* pSceneManager = SceneManager::GetInstance();
361 AppAssert(pSceneManager);
362 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
364 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
365 __pPresentationModel->RemoveContentEventListener(pFileListForm);
367 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));