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.
24 #include "GlAlbumInfo.h"
25 #include "GlAllListPanel.h"
26 #include "GlCommonUtil.h"
27 #include "GlFileListForm.h"
28 #include "GlFileListPresentationModel.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Content;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Media;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
41 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
42 static const int W_CLIENT = 720;
43 static const int H_CONTENT_MARGIN = 9;
44 static const int W_CONTENT_MARGIN = 6;
45 static const int W_CONTENT_SPACE = 6;
46 static const int H_CONTENT_SPACE = 6;
48 AllListPanel::AllListPanel()
49 : __pContentIconListView(null)
51 , __pPresentationModel(null)
54 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
57 AllListPanel::~AllListPanel()
60 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
64 AllListPanel::Refresh(void)
67 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
69 if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
71 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_IMAGE);
73 else if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_VIDEO)
75 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
79 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
84 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
87 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
88 __pContentIconListView->UpdateList();
89 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
93 AllListPanel::Initialize(void)
96 result r = Construct(RECT_INITIAL);
97 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
103 AllListPanel::OnInitializing(void)
105 AppLogDebug("ENTER");
106 const Form* pForm = dynamic_cast<Form*>(GetParent());
109 __pPresentationModel = FileListPresentationModel::GetInstance();
110 __pPresentationModel->ClearThumbnailRequests();
111 __pPresentationModel->AddPresentationModelListener(this);
113 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
114 clientAreaBounds.x = clientAreaBounds.y = 0;
115 SetBounds(clientAreaBounds);
117 __pContentIconListView = new (std::nothrow) IconListView();
118 __pContentIconListView->Construct(Rectangle(0, 0, W_CLIENT, clientAreaBounds.height),
119 DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
120 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
121 if (pBitmapEmpty != null)
123 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
126 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
127 __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
128 __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
129 __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
130 __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
131 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
132 __pContentIconListView->SetItemProvider(*this);
133 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
134 __pContentIconListView->AddIconListViewItemEventListener(*this);
135 __pContentIconListView->SetTouchAnimationEnabled(false);
136 result r = AddControl(*__pContentIconListView);
137 __pContentIconListView->SetShowState(true);
140 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
146 AllListPanel::OnTerminating(void)
148 AppLogDebug("ENTER");
149 __pPresentationModel->RemovePresentationModelListener(*this);
150 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
156 AllListPanel::GetItemCount(void)
158 AppLogDebug("ENTER");
159 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
165 AllListPanel::CreateItem(int index)
167 AppLogDebug("ENTER : index(%d)", index);
168 Bitmap* pBitmap=null;
169 String* pItemText=null;
170 result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
173 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
177 IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
181 __pPresentationModel->RequestThumbnail(index);
182 pBitmap = CommonUtil::GetEmptyThumbnailN();
185 if (pItemText == null)
187 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
189 else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
192 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
195 if (pItemText != null)
197 pIconListviewItem->Construct(*pBitmap, pItemText);
204 if (pItemText != null)
208 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
210 return pIconListviewItem;
214 AllListPanel::DeleteItem(int index, IconListViewItem* pItem)
216 AppLogDebug("ENTER : index(%d)", index);
218 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
224 AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
226 AppLogDebug("ENTER");
227 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
229 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() <= 0)
231 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
235 ArrayList* pArrayList = new (std::nothrow) ArrayList();
236 pArrayList->Construct();
237 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
239 for (int i = 0 ; i < loopCount; ++i)
241 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
245 listIndex.Format(10, L"%d", index);
247 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
248 pDataList->Construct();
249 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
250 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pArrayList);
251 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
253 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
257 loopCount = pArrayList->GetCount();
258 for (int i = 0; i < loopCount; ++i)
260 temp = static_cast<String*>(pArrayList->GetAt(i));
261 AppLog("print temp(%ls)", temp->GetPointer());
264 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
268 AllListPanel::OnFileInfoChanged(const ContentType contentType)
270 AppLogDebug("ENTER");
271 if (contentType == CONTENT_TYPE_ALL
272 || contentType == CONTENT_TYPE_IMAGE
273 || contentType == CONTENT_TYPE_VIDEO)
275 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
276 __pContentIconListView->UpdateList();
278 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
282 AllListPanel::OnThumbnailDecoded(const int index)
284 AppLogDebug("ENTER : index(%d)", index);
287 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
289 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
293 AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
294 const SceneId& currentSceneId, IList* pArgs)
296 AppLogDebug("ENTER");
297 __pPresentationModel = FileListPresentationModel::GetInstance();
299 if (currentSceneId == IDSCN_ALL_LIST)
301 if (previousSceneId == IDSCN_ALBUM_LIST)
303 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
304 if (pAlbumInfo == null)
306 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
310 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
311 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
312 if (pDirectoryList != null)
314 delete pDirectoryList;
319 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
320 __pContentIconListView->UpdateList();
324 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
325 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
326 __pContentIconListView->UpdateList();
330 SceneManager* pSceneManager = SceneManager::GetInstance();
331 AppAssert(pSceneManager);
332 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
334 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
335 if (pFileListForm != null)
337 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
340 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
344 AllListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
345 const SceneId& nextSceneId)
347 AppLogDebug("ENTER");
348 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
352 AllListPanel::UpdatePanelContent()
354 AppLogDebug("ENTER");
356 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));