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 GlImageListPanel.cpp
19 * @brief This is the implementation file for ImageListPanel class.
24 #include "GlAlbumInfo.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListForm.h"
27 #include "GlFileListPresentationModel.h"
28 #include "GlImageListPanel.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 = 24;
44 static const int W_CONTENT_MARGIN = 14;
45 static const int W_CONTENT_SPACE = 20;
46 static const int H_CONTENT_SPACE = 24;
48 ImageListPanel::ImageListPanel(void)
50 , __pContentIconListView(null)
51 , __pPresentationModel(null)
54 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
57 ImageListPanel::~ImageListPanel(void)
60 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
64 ImageListPanel::Initialize(void)
67 result r = Construct(RECT_INITIAL);
68 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
74 ImageListPanel::OnInitializing(void)
77 const Form* pForm = dynamic_cast<Form*>(GetParent());
78 TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
80 __pPresentationModel = FileListPresentationModel::GetInstance();
81 __pPresentationModel->ClearThumbnailRequests();
82 __pPresentationModel->AddPresentationModelListener(this);
84 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
85 clientAreaBounds.x = clientAreaBounds.y = 0;
86 SetBounds(clientAreaBounds);
87 __pContentIconListView = new (std::nothrow) IconListView();
88 __pContentIconListView->Construct(Rectangle(0, 0, W_CLIENT, clientAreaBounds.height),
89 DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
90 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
91 if (pBitmapEmpty != null)
93 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
96 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
97 __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
98 __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
99 __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
100 __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
101 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
102 __pContentIconListView->SetItemProvider(*this);
103 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
104 __pContentIconListView->AddIconListViewItemEventListener(*this);
105 __pContentIconListView->SetTouchAnimationEnabled(false);
106 AddControl(__pContentIconListView);
107 __pContentIconListView->SetShowState(true);
109 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
115 ImageListPanel::OnTerminating(void)
117 AppLogDebug("ENTER");
118 __pPresentationModel->RemovePresentationModelListener(*this);
119 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
125 ImageListPanel::GetItemCount(void)
127 AppLogDebug("ENTER");
128 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
134 ImageListPanel::CreateItem(int index)
136 AppLogDebug("ENTER");
137 IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
138 Bitmap* pBitmap = null;
139 String* pItemText = null;
140 result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
141 if (pBitmap == null || r == E_FAILURE)
143 __pPresentationModel->RequestThumbnail(index);
144 pBitmap = CommonUtil::GetEmptyThumbnailN();
147 if (pItemText == null)
149 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
151 else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
154 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
157 pIconListviewItem->Construct(*pBitmap, pItemText);
163 if (pItemText != null)
167 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
169 return pIconListviewItem;
173 ImageListPanel::DeleteItem(int index, IconListViewItem* pItem)
175 AppLogDebug("ENTER");
177 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
183 ImageListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
185 AppLogDebug("ENTER");
186 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
188 ArrayList* pArrayList = new (std::nothrow) ArrayList();
189 pArrayList->Construct();
190 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
192 for (int i = 0; i < loopCount; ++i)
194 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
197 listIndex.Format(10, L"%d", index);
199 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
200 pDataList->Construct();
201 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
202 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
203 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
205 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
206 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
208 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
212 ImageListPanel::OnFileInfoChanged(const ContentType contentType)
214 AppLogDebug("ENTER");
215 if (contentType == CONTENT_TYPE_IMAGE)
217 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
218 __pContentIconListView->UpdateList();
220 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
224 ImageListPanel::OnThumbnailDecoded(const int index)
226 AppLogDebug("ENTER : index(%d)", index);
229 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
231 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
235 ImageListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
236 const SceneId& currentSceneId, IList* pArgs)
238 AppLogDebug("ENTER");
239 __pPresentationModel = FileListPresentationModel::GetInstance();
241 if (currentSceneId == IDSCN_IMAGE_LIST)
243 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_IMAGE);
244 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
245 __pContentIconListView->UpdateList();
248 SceneManager* pSceneManager = SceneManager::GetInstance();
249 AppAssert(pSceneManager);
250 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
252 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
253 if (pFileListForm != null)
255 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
258 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
262 ImageListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
263 const SceneId& nextSceneId)
265 AppLogDebug("ENTER");
266 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));