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 MpAlbumListEditorPanel.cpp
19 * @brief This is the implementation file for AlbumListEditorPanel class.
22 #include "MpAlbumListEditorPanel.h"
23 #include "MpThumbnailInfo.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Content;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Social;
30 using namespace Tizen::Ui;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
34 AlbumListEditorPanel::AlbumListEditorPanel(void)
35 : ContentEditPanel::ContentEditPanel()
36 , ThumbnailBase::ThumbnailBase()
43 AlbumListEditorPanel::~AlbumListEditorPanel(void)
50 AlbumListEditorPanel::OnInitializing(void)
54 __pPresentationModel = AlbumListPresentationModel::GetInstance();
55 __fontSizeValue = CommonUtil::GetFontSizeValue();
56 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
59 return ThumbnailBase::Construct();
63 AlbumListEditorPanel::OnTerminating(void)
66 ThumbnailBase::Stop();
68 return ContentEditPanel::OnTerminating();
72 AlbumListEditorPanel::OnFontSizeChanged(void)
74 __fontSizeValue = CommonUtil::GetFontSizeValue();
75 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
76 __pContentTableView->UpdateTableView();
81 AlbumListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
83 AppLogDebug("ENTER %d",actionId);
84 SceneManager* pSceneManager = SceneManager::GetInstance();
85 AppAssert(pSceneManager);
87 int totalCount = __pPresentationModel->GetAllAlbumCount();
91 case IDA_HEADER_BUTTON_SELECTE_ALL:
93 if (totalCount == __checkedItemCount)
95 SetItemCheckedAll(false);
99 SetItemCheckedAll(true);
104 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
106 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
110 case IDA_FOOTER_BUTTON_DELETE:
112 int totalCount = __pPresentationModel->GetAllAlbumCount();
113 for (int iCount = totalCount - 1; iCount >= 0; iCount--)
115 if (__pContentTableView->IsItemChecked(iCount) == true)
117 __pPresentationModel->RemoveAlbumList(iCount);
130 AlbumListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
131 const Tizen::Ui::Scenes::SceneId& currentSceneId,
132 Tizen::Base::Collection::IList* pArgs)
134 AppLogDebug("ENTER");
135 ContentPanel::OnSceneActivatedN(previousSceneId, currentSceneId, null);
137 Form* pForm = dynamic_cast<Form*>(GetParent());
138 Footer* pFooter = null;
140 pForm->SetFormBackEventListener(this);
141 SetEditHeaderStyle();
143 SetFooterStyle(STYLE_ADDTO_DELETE_ADD);
145 pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_ADDTO_DELETE_ADD);
148 pFooter->AddActionEventListener(*this);
149 pFooter->SetShowState(true);
150 CommonUtil::SetFooterItemEnabled(*pFooter, false);
153 UpdateContentEditScreenState();
155 if (previousSceneId.Equals(IDSCN_PLAYLIST_CREATOR, true))
160 __pContentTableView->UpdateTableView();
161 __checkedItemCount = INIT_VALUE;
162 SetCheckedCountBallonTooltip(__checkedItemCount);
164 totalCount = __pPresentationModel->GetAllAlbumCount();
165 for (int count = 0; count < totalCount; count++)
167 __pContentTableView->SetItemChecked(count, false);
174 CommonUtil::SetFooterItemEnabled(*pFooter, true);
181 pArgs->RemoveAll(true);
188 AlbumListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
189 const Tizen::Ui::Scenes::SceneId& nextSceneId)
191 AppLogDebug("ENTER");
192 ContentPanel::OnSceneDeactivated(currentSceneId, nextSceneId);
194 Form* pForm = dynamic_cast<Form*>(GetParent());
197 if (!(nextSceneId.Equals(IDSCN_PLAYLIST_CREATOR, false)))
199 Footer* pFooter = pForm->GetFooter();
203 pFooter->RemoveAllButtons();
204 pFooter->RemoveAllItems();
205 pFooter->RemoveActionEventListener(*this);
208 __checkedItemCount = INIT_VALUE;
209 SetCheckedCountBallonTooltip(__checkedItemCount);
211 int totalCount = __pPresentationModel->GetAllAlbumCount();
212 for (int iCount = 0; iCount < totalCount; iCount++)
214 __pContentTableView->SetItemChecked(iCount, false);
218 CancelAllThumbnailRequest();
223 AlbumListEditorPanel::GetItemCount(void)
225 AppLogDebug("ENTER");
226 int retCount = INIT_VALUE;
227 if (__pPresentationModel == null)
231 retCount = __pPresentationModel->GetAllAlbumCount();
236 Tizen::Ui::Controls::TableViewItem*
237 AlbumListEditorPanel::CreateItem(const int itemIndex, int itemWidth)
239 AppLogDebug("ENTER");
240 RelativeLayout layout;
243 TableViewItem* pItem = new (std::nothrow) TableViewItem();
244 ContentInformation* pContentInfo = __pPresentationModel->GetAlbumInfoN(itemIndex);
246 result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), TABLE_VIEW_ANNEX_STYLE_MARK);
247 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
248 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
250 r = CreateTableViewItem(*pItem, *pContentInfo);
251 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
253 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
260 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
266 AlbumListEditorPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
268 Tizen::Ui::Controls::TableViewItem* pItem,
269 Tizen::Ui::Controls::TableViewItemStatus status)
271 AppLogDebug("ENTER");
272 Form* pForm = dynamic_cast<Form*>(GetParent());
277 case TABLE_VIEW_ITEM_STATUS_CHECKED:
279 __checkedItemCount++;
280 tableView.SetItemChecked(itemIndex, true);
284 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
286 __checkedItemCount--;
287 tableView.SetItemChecked(itemIndex, false);
295 if (__checkedItemCount > INIT_VALUE)
297 Footer* pFooter = pForm->GetFooter();
300 CommonUtil::SetFooterItemEnabled(*pFooter, true);
305 Footer* pFooter = pForm->GetFooter();
308 CommonUtil::SetFooterItemEnabled(*pFooter, false);
312 SetCheckedCountBallonTooltip(__checkedItemCount);
318 AlbumListEditorPanel::CreateTableViewItem(Tizen::Ui::Container& parent,
319 const ContentInformation& contentInfoStruct)
321 AppLogDebug("ENTER");
322 Panel* pTableViewItem = new (std::nothrow) Panel();
324 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
326 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_GIANT)))
328 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
332 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
334 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_HUGE)))
336 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
340 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
342 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_LARGE)))
344 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
348 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
350 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_SMALL)))
352 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
358 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_DEFAULT)))
360 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
365 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.AlbumName);
366 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
367 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
369 parent.AddControl(pTableViewItem);
370 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
377 AlbumListEditorPanel::UpdateContentList(void)
379 AppLogDebug("ENTER");
380 if (__pPresentationModel != null)
382 __pPresentationModel->UpdateAlbumList();
388 AlbumListEditorPanel::SetEditHeaderStyle(void)
390 AppLogDebug("ENTER");
391 Header* pHeader = GetHeader();
392 String titleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
393 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
394 pHeader->Invalidate(true);
399 AlbumListEditorPanel::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
401 AppLogDebug("ENTER");
402 __pThumbnail = pThumbnailInfo->GetBitmapN();
403 Object* pParam = pThumbnailInfo->GetUserParamN();
406 __pContentTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
410 delete pThumbnailInfo;
415 AlbumListEditorPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
417 AppLogDebug("ENTER");
418 SceneManager* pSceneManager = SceneManager::GetInstance();
419 AppAssert(pSceneManager);
421 pSceneManager->GoBackward(BackwardSceneTransition());
426 AlbumListEditorPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
428 AppLogDebug("ENTER");
431 AppLogDebug("pItem is null");
437 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(IDC_CONTENTS_THUMBNAIL, true));
438 if (__pThumbnail == null || pThumbnailLabel == null)
440 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
445 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
448 pThumbnailLabel->Invalidate(true);
453 AlbumListEditorPanel::IsEmptyContentList(void)
455 AppLogDebug("ENTER");
456 if (__pPresentationModel->GetAllAlbumCount() == INIT_VALUE)
465 Tizen::Base::Collection::IList*
466 AlbumListEditorPanel::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
468 AppLogDebug("ENTER");
469 ArrayList* pContentPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
470 result r = pContentPathList->Construct();
473 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(r));
474 delete pContentPathList;
478 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
480 int totalCount = __pPresentationModel->GetAllAlbumCount();
481 for (int iCount = 0; iCount < totalCount; iCount++)
483 if (__pContentTableView->IsItemChecked(iCount) == true)
485 pContentPathList->AddItems(*(__pPresentationModel->GetContentPathListN(iCount)));
492 delete pContentPathList;
497 return pContentPathList;