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 MpArtistListEditorPanel.cpp
19 * @brief This is the implementation file for ArtistListEditorPanel class.
22 #include "MpArtistListEditorPanel.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 ArtistListEditorPanel::ArtistListEditorPanel(void)
35 : ContentEditPanel::ContentEditPanel()
36 , ThumbnailBase::ThumbnailBase()
43 ArtistListEditorPanel::~ArtistListEditorPanel(void)
50 ArtistListEditorPanel::OnInitializing(void)
53 __pPresentationModel = ArtistListPresentationModel::GetInstance();
54 __fontSizeValue = CommonUtil::GetFontSizeValue();
55 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
60 return ThumbnailBase::Construct();
64 ArtistListEditorPanel::OnFontSizeChanged(void)
66 __fontSizeValue = CommonUtil::GetFontSizeValue();
67 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
68 __pContentTableView->UpdateTableView();
73 ArtistListEditorPanel::OnTerminating(void)
76 ThumbnailBase::Stop();
78 return ContentEditPanel::OnTerminating();
82 ArtistListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
85 SceneManager* pSceneManager = SceneManager::GetInstance();
86 AppAssert(pSceneManager);
88 int totalCount = __pPresentationModel->GetArtistListCount();
92 case IDA_HEADER_BUTTON_SELECTE_ALL:
94 if (totalCount == __checkedItemCount)
96 SetItemCheckedAll(false);
100 SetItemCheckedAll(true);
105 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
107 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
111 case IDA_FOOTER_BUTTON_DELETE:
113 ShowCommonDeletePopup(this);
117 case IDA_DELETE_POPUP_DELETE:
119 for (int iCount = totalCount - 1; iCount >= 0; iCount--)
121 if (__pContentTableView->IsItemChecked(iCount) == true)
123 __pPresentationModel->RemoveArtistList(iCount);
127 HideCommonDeletePopup(false);
131 case IDA_DELETE_POPUP_CANCEL:
133 HideCommonDeletePopup(false);
143 ArtistListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
144 const Tizen::Ui::Scenes::SceneId& currentSceneId,
145 Tizen::Base::Collection::IList* pArgs)
147 AppLogDebug("ENTER");
148 ContentPanel::OnSceneActivatedN(previousSceneId, currentSceneId, null);
150 Form* pForm = dynamic_cast<Form*>(GetParent());
152 pForm->SetFormBackEventListener(this);
153 SetEditHeaderStyle();
155 SetFooterStyle(STYLE_ADDTO_DELETE_ADD);
157 Footer* pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_ADDTO_DELETE_ADD);
160 pFooter->AddActionEventListener(*this);
161 pFooter->SetShowState(true);
162 CommonUtil::SetFooterItemEnabled(*pFooter, false);
165 UpdateContentEditScreenState();
167 if (previousSceneId.Equals(IDSCN_PLAYLIST_CREATOR, true))
172 __pContentTableView->UpdateTableView();
173 __checkedItemCount = INIT_VALUE;
174 SetCheckedCountBallonTooltip(__checkedItemCount);
176 totalCount = __pPresentationModel->GetArtistListCount();
177 for (int count = 0; count < totalCount; count++)
179 __pContentTableView->SetItemChecked(count, false);
184 if (pFooter != null && __checkedItemCount != 0)
186 CommonUtil::SetFooterItemEnabled(*pFooter, true);
193 pArgs->RemoveAll(true);
200 ArtistListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
201 const Tizen::Ui::Scenes::SceneId& nextSceneId)
203 AppLogDebug("ENTER");
204 ContentPanel::OnSceneDeactivated(currentSceneId, nextSceneId);
205 if (!(nextSceneId.Equals(IDSCN_PLAYLIST_CREATOR, false)))
207 Footer* pFooter = GetFooter();
210 pFooter->RemoveAllButtons();
211 pFooter->RemoveAllItems();
212 pFooter->RemoveActionEventListener(*this);
215 __checkedItemCount = INIT_VALUE;
216 SetCheckedCountBallonTooltip(__checkedItemCount);
217 int totalCount = __pPresentationModel->GetArtistListCount();
218 for (int iCount = 0; iCount < totalCount; iCount++)
220 __pContentTableView->SetItemChecked(iCount, false);
223 CancelAllThumbnailRequest();
228 ArtistListEditorPanel::GetItemCount(void)
230 AppLogDebug("ENTER");
231 if (__pContentTableView == null)
237 return __pPresentationModel->GetArtistListCount();
240 Tizen::Ui::Controls::TableViewItem*
241 ArtistListEditorPanel::CreateItem(const int itemIndex, int itemWidth)
243 AppLogDebug("ENTER");
244 RelativeLayout layout;
247 TableViewItem* pItem = new (std::nothrow) TableViewItem();
248 ContentInformation* pContentInfo = __pPresentationModel->GetArtistnIfoN(itemIndex);
250 result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), TABLE_VIEW_ANNEX_STYLE_MARK);
251 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
252 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
254 r = CreateTableViewItem(*pItem, *pContentInfo);
255 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
257 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
264 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
270 ArtistListEditorPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
272 Tizen::Ui::Controls::TableViewItem* pItem,
273 Tizen::Ui::Controls::TableViewItemStatus status)
275 AppLogDebug("ENTER");
276 Form* pForm = dynamic_cast<Form*>(GetParent());
279 Footer* pFooter = pForm->GetFooter();
283 case TABLE_VIEW_ITEM_STATUS_CHECKED:
285 __checkedItemCount++;
286 tableView.SetItemChecked(itemIndex, true);
290 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
292 __checkedItemCount--;
293 tableView.SetItemChecked(itemIndex, false);
301 if (__checkedItemCount > INIT_VALUE)
305 CommonUtil::SetFooterItemEnabled(*pFooter, true);
312 CommonUtil::SetFooterItemEnabled(*pFooter, false);
316 SetCheckedCountBallonTooltip(__checkedItemCount);
322 ArtistListEditorPanel::CreateTableViewItem(Tizen::Ui::Container& parent,
323 const ContentInformation& contentInfoStruct)
325 AppLogDebug("ENTER");
326 result r = E_SUCCESS;
328 Panel* pTableViewItem = new (std::nothrow) Panel();
330 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
332 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_ARTIST_EDITOR_ITEM_PANEL_FONT_SIZE_GIANT)))
334 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
338 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
340 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_ARTIST_EDITOR_ITEM_PANEL_FONT_SIZE_HUGE)))
342 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
346 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
348 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_ARTIST_EDITOR_ITEM_PANEL_FONT_SIZE_LARGE)))
350 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
354 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
356 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_ARTIST_EDITOR_ITEM_PANEL_FONT_SIZE_SMALL)))
358 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
364 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_ARTIST_EDITOR_ITEM_PANEL_DEFAULT)))
366 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
371 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
372 // static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
374 parent.AddControl(pTableViewItem);
375 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
382 ArtistListEditorPanel::UpdateContentList(void)
384 AppLogDebug("ENTER");
385 if (__pPresentationModel != null)
387 __pPresentationModel->UpdateArtistList();
393 ArtistListEditorPanel::SetEditHeaderStyle(void)
395 AppLogDebug("ENTER");
396 Header* pHeader = GetHeader();
397 String titleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
398 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
399 pHeader->Invalidate(true);
404 ArtistListEditorPanel::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
406 AppLogDebug("ENTER");
407 __pThumbnail = pThumbnailInfo->GetBitmapN();
408 Object* pParam = pThumbnailInfo->GetUserParamN();
411 __pContentTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
415 delete pThumbnailInfo;
420 ArtistListEditorPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
422 AppLogDebug("ENTER");
423 SceneManager* pSceneManager = SceneManager::GetInstance();
424 AppAssert(pSceneManager);
426 pSceneManager->GoBackward(BackwardSceneTransition());
431 ArtistListEditorPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
433 AppLogDebug("ENTER");
437 AppLogDebug("pItem is null");
443 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(IDC_CONTENTS_THUMBNAIL, true));
444 if (__pThumbnail == null || pThumbnailLabel == null)
446 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
452 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
455 pThumbnailLabel->Invalidate(true);
460 ArtistListEditorPanel::IsEmptyContentList(void)
462 AppLogDebug("ENTER");
463 if (__pPresentationModel->GetArtistListCount() == INIT_VALUE)
472 Tizen::Base::Collection::IList*
473 ArtistListEditorPanel::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
475 AppLogDebug("ENTER");
476 ArrayList* pContentPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
477 result r = pContentPathList->Construct();
480 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(r));
481 delete pContentPathList;
485 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
487 int totalCount = __pPresentationModel->GetArtistListCount();
488 for (int iCount = 0; iCount < totalCount; iCount++)
490 if (__pContentTableView->IsItemChecked(iCount) == true)
492 pContentPathList->AddItems(*(__pPresentationModel->GetContentPathListN(iCount)));
499 delete pContentPathList;
504 return pContentPathList;