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 __pPresentationModel->ClearImageCache();
\r
87 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
90 SceneManager* pSceneManager = SceneManager::GetInstance();
91 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
93 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
96 __pContentIconListView->UpdateList();
97 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
101 AllListPanel::Initialize(void)
103 AppLogDebug("ENTER");
104 result r = Construct(RECT_INITIAL);
105 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
111 AllListPanel::OnInitializing(void)
113 AppLogDebug("ENTER");
114 const Form* pForm = dynamic_cast<Form*>(GetParent());
117 __pPresentationModel = FileListPresentationModel::GetInstance();
118 __pPresentationModel->ClearThumbnailRequests();
119 __pPresentationModel->AddPresentationModelListener(this);
121 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
122 clientAreaBounds.x = clientAreaBounds.y = 0;
123 SetBounds(clientAreaBounds);
125 __pContentIconListView = new (std::nothrow) IconListView();
126 __pContentIconListView->Construct(Rectangle(0, 0, W_CLIENT, clientAreaBounds.height),
127 DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
128 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
129 if (pBitmapEmpty != null)
131 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
134 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
135 __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
136 __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
137 __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
138 __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
139 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
140 __pContentIconListView->SetItemProvider(*this);
141 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
142 __pContentIconListView->AddIconListViewItemEventListener(*this);
143 __pContentIconListView->SetTouchAnimationEnabled(false);
144 result r = AddControl(*__pContentIconListView);
145 __pContentIconListView->SetShowState(true);
148 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
154 AllListPanel::OnTerminating(void)
156 AppLogDebug("ENTER");
157 SceneManager* pSceneManager = SceneManager::GetInstance();
158 AppAssert(pSceneManager);
159 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
161 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
162 __pPresentationModel->RemoveContentEventListener(pFileListForm);
164 __pPresentationModel->RemovePresentationModelListener(*this);
165 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
171 AllListPanel::GetItemCount(void)
173 AppLogDebug("ENTER");
174 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
180 AllListPanel::CreateItem(int index)
182 AppLogDebug("ENTER : index(%d)", index);
183 Bitmap* pBitmap=null;
184 String* pItemText=null;
185 result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
188 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
192 IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
196 __pPresentationModel->RequestThumbnail(index);
197 pBitmap = CommonUtil::GetEmptyThumbnailN();
200 if (pItemText == null)
202 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
204 else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
207 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
210 if (pItemText != null)
212 pIconListviewItem->Construct(*pBitmap, pItemText);
219 if (pItemText != null)
223 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
225 return pIconListviewItem;
229 AllListPanel::DeleteItem(int index, IconListViewItem* pItem)
231 AppLogDebug("ENTER : index(%d)", index);
233 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
239 AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
241 AppLogDebug("ENTER");
242 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
244 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() <= 0)
246 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
250 ArrayList* pArrayList = new (std::nothrow) ArrayList();
251 pArrayList->Construct();
252 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
254 for (int i = 0; i < loopCount; ++i)
256 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
260 listIndex.Format(10, L"%d", index);
262 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
263 pDataList->Construct();
264 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
265 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pArrayList);
266 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
268 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
269 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
271 String* pTemp = null;
272 loopCount = pArrayList->GetCount();
273 for (int i = 0; i < loopCount; ++i)
275 pTemp = static_cast<String*>(pArrayList->GetAt(i));
276 AppLog("print temp(%ls)", pTemp->GetPointer());
279 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
283 AllListPanel::OnFileInfoChanged(const ContentType contentType)
285 AppLogDebug("ENTER");
286 if (contentType == CONTENT_TYPE_ALL || contentType == CONTENT_TYPE_IMAGE
287 || contentType == CONTENT_TYPE_VIDEO)
289 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
290 __pContentIconListView->UpdateList();
292 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
296 AllListPanel::OnThumbnailDecoded(const int index)
298 AppLogDebug("ENTER : index(%d)", index);
301 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
303 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
307 AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
308 const SceneId& currentSceneId, IList* pArgs)
310 AppLogDebug("ENTER");
312 __pPresentationModel = FileListPresentationModel::GetInstance();
314 if (currentSceneId == IDSCN_ALL_LIST)
316 if (previousSceneId == IDSCN_ALBUM_LIST && pArgs != null)
318 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
319 if (pAlbumInfo == null)
321 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
325 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
326 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
327 if (pDirectoryList != null)
329 delete pDirectoryList;
334 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
335 __pContentIconListView->UpdateList();
339 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
340 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
341 __pContentIconListView->UpdateList();
344 SceneManager* pSceneManager = SceneManager::GetInstance();
345 AppAssert(pSceneManager);
346 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
348 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
349 if (pFileListForm != null)
351 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
353 __pPresentationModel->AddContentEventListener(pFileListForm);
355 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
359 AllListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
360 const SceneId& nextSceneId)
362 AppLogDebug("ENTER");
363 SceneManager* pSceneManager = SceneManager::GetInstance();
364 AppAssert(pSceneManager);
365 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
367 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
368 __pPresentationModel->RemoveContentEventListener(pFileListForm);
370 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));