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 MpAllListEditorPanel.cpp
19 * @brief This is the implementation file for AllListEditorPanel class.
22 #include "MpAllListEditorPanel.h"
23 #include "MpAllListPresentationModel.h"
24 #include "MpThumbnailInfo.h"
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Content;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Social;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 AllListEditorPanel::AllListEditorPanel(void)
37 : ContentEditPanel::ContentEditPanel()
38 , ThumbnailBase::ThumbnailBase()
46 AllListEditorPanel::~AllListEditorPanel(void)
53 AllListEditorPanel::OnInitializing(void)
56 __pPresentationModel = AllListPresentationModel::GetInstance();
57 __fontSizeValue = CommonUtil::GetFontSizeValue();
58 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
62 return ThumbnailBase::Construct();
66 AllListEditorPanel::OnTerminating(void)
69 ThumbnailBase::Stop();
70 CancelAllThumbnailRequest();
72 return ContentEditPanel::OnTerminating();
76 AllListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
79 if (__pPresentationModel == null)
84 int totalCount = __pPresentationModel->GetTotalCount();
88 case IDA_HEADER_BUTTON_SELECTE_ALL:
90 if (totalCount == __checkedItemCount)
92 SetItemCheckedAll(false);
96 SetItemCheckedAll(true);
101 case IDA_FOOTER_BUTTON_DELETE:
103 int totalCount = __pPresentationModel->GetTotalCount();
104 for (int iCount = totalCount - 1; iCount >= 0; iCount--)
106 if (__pContentTableView->IsItemChecked(iCount) == true)
108 __pPresentationModel->RemoveContent(iCount);
114 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
116 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
120 case IDA_FOOTER_BUTTON_SHARE:
122 LanucherPicker(PICKER_TYPE_SHARE_PICKER);
133 AllListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
134 const Tizen::Ui::Scenes::SceneId& currentSceneId,
135 Tizen::Base::Collection::IList* pArgs)
137 AppLogDebug("ENTER");
138 ContentPanel::OnSceneActivatedN(previousSceneId, currentSceneId, null);
140 Form* pForm = dynamic_cast<Form*>(GetParent());
141 Footer* pFooter = null;
144 pForm->SetFormBackEventListener(this);
145 if (pArgs != null && (previousSceneId.Equals(IDSCN_ALL_LIST, true)))
147 __editType = static_cast<Integer*>(pArgs->GetAt(0))->ToInt();
150 SetEditHeaderStyle();
152 if (__editType == IDA_CONTEXT_MENU_ITEM_EDIT)
154 SetFooterStyle(STYLE_ADDTO_DELETE_ADD);
156 pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_ADDTO_DELETE_ADD);
160 SetFooterStyle(STYLE_SHARE_ADD);
162 pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_SHARE_ADD);
167 pFooter->AddActionEventListener(*this);
168 pFooter->SetShowState(true);
169 CommonUtil::SetFooterItemEnabled(*pFooter, false);
172 UpdateContentEditScreenState();
174 if (previousSceneId.Equals(IDSCN_PLAYLIST_CREATOR, true))
179 __pContentTableView->UpdateTableView();
180 __checkedItemCount = INIT_VALUE;
181 SetCheckedCountBallonTooltip(__checkedItemCount);
183 totalCount = __pPresentationModel->GetTotalCount();
184 for (int count = 0; count < totalCount; count++)
186 __pContentTableView->SetItemChecked(count, false);
193 CommonUtil::SetFooterItemEnabled(*pFooter, true);
200 pArgs->RemoveAll(true);
207 AllListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
208 const Tizen::Ui::Scenes::SceneId& nextSceneId)
210 AppLogDebug("ENTER");
211 ContentPanel::OnSceneDeactivated(currentSceneId, nextSceneId);
213 if (!(nextSceneId.Equals(IDSCN_PLAYLIST_CREATOR, false)))
215 Footer* pFooter = GetFooter();
218 pFooter->RemoveAllButtons();
219 pFooter->RemoveAllItems();
220 pFooter->RemoveActionEventListener(*this);
223 __checkedItemCount = INIT_VALUE;
224 SetCheckedCountBallonTooltip(__checkedItemCount);
226 int totalCount = __pPresentationModel->GetTotalCount();
227 for (int iCount = 0; iCount < totalCount; iCount++)
229 __pContentTableView->SetItemChecked(iCount, false);
232 CancelAllThumbnailRequest();
237 AllListEditorPanel::OnFontSizeChanged(void)
239 __fontSizeValue = CommonUtil::GetFontSizeValue();
240 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
241 __pContentTableView->UpdateTableView();
246 AllListEditorPanel::GetItemCount(void)
248 AppLogDebug("ENTER");
249 int musicItem = INIT_VALUE;
250 if (__pPresentationModel == null)
255 musicItem = __pPresentationModel->GetTotalCount();
260 Tizen::Ui::Controls::TableViewItem*
261 AllListEditorPanel::CreateItem(const int itemIndex, int itemWidth)
263 AppLogDebug("ENTER");
264 RelativeLayout layout;
267 TableViewItem* pItem = new (std::nothrow) TableViewItem();
268 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
270 result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), TABLE_VIEW_ANNEX_STYLE_MARK);
271 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
272 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
274 r = CreateTableViewItem(*pItem, *pContentInfo);
275 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
277 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
284 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
290 AllListEditorPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
292 Tizen::Ui::Controls::TableViewItem* pItem,
293 Tizen::Ui::Controls::TableViewItemStatus status)
295 AppLogDebug("ENTER");
296 Form* pForm = dynamic_cast<Form*>(GetParent());
299 Footer* pFooter = pForm->GetFooter();
303 case TABLE_VIEW_ITEM_STATUS_CHECKED:
305 __checkedItemCount++;
306 tableView.SetItemChecked(itemIndex, true);
310 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
312 __checkedItemCount--;
313 tableView.SetItemChecked(itemIndex, false);
321 if (__checkedItemCount > INIT_VALUE)
325 CommonUtil::SetFooterItemEnabled(*pFooter, true);
332 CommonUtil::SetFooterItemEnabled(*pFooter, false);
336 SetCheckedCountBallonTooltip(__checkedItemCount);
342 AllListEditorPanel::CreateTableViewItem(Tizen::Ui::Container& parent,
343 const ContentInformation& contentInfoStruct)
345 AppLogDebug("ENTER");
346 Panel* pTableViewItem = new (std::nothrow) Panel();
348 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
350 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_GIANT)))
352 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
356 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
358 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_HUGE)))
360 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
364 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
366 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_LARGE)))
368 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
372 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
374 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_FONT_SIZE_SMALL)))
376 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
382 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL_DEFAULT)))
384 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
389 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.TitleName);
390 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
391 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
393 parent.AddControl(pTableViewItem);
394 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
401 AllListEditorPanel::UpdateContentList(void)
403 AppLogDebug("ENTER");
404 if (__pPresentationModel != null)
406 __pPresentationModel->UpdateContentList();
412 AllListEditorPanel::SetEditHeaderStyle(void)
414 AppLogDebug("ENTER");
415 Header* pHeader = GetHeader();
416 if(__editType == IDA_CONTEXT_MENU_ITEM_EDIT)
418 String titleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
419 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
423 String titleText(ResourceManager::GetString(L"IDS_IV_BODY_SHARE_VIA"));
424 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
426 pHeader->Invalidate(true);
431 AllListEditorPanel::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
433 AppLogDebug("ENTER");
434 __pThumbnail = pThumbnailInfo->GetBitmapN();
435 Object* pParam = pThumbnailInfo->GetUserParamN();
438 __pContentTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
442 delete pThumbnailInfo;
447 AllListEditorPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
449 AppLogDebug("ENTER");
450 SceneManager* pSceneManager = SceneManager::GetInstance();
451 AppAssert(pSceneManager);
452 if (CommonUtil::GetAddtoPlaylistState())
454 ArrayList* pList = new (std::nothrow) ArrayList();
457 CommonUtil::SetAddtoPlaylistState(false);
458 pSceneManager->GoBackward(BackwardSceneTransition(),pList);
462 pSceneManager->GoBackward(BackwardSceneTransition());
468 AllListEditorPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
470 AppLogDebug("ENTER");
473 AppLogDebug("pItem is null");
479 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(IDC_CONTENTS_THUMBNAIL, true));
480 if (__pThumbnail == null || pThumbnailLabel == null)
482 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
487 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
490 pThumbnailLabel->Invalidate(true);
495 AllListEditorPanel::IsEmptyContentList(void)
497 AppLogDebug("ENTER");
498 if (__pPresentationModel->GetTotalCount() == INIT_VALUE)
507 Tizen::Base::Collection::IList*
508 AllListEditorPanel::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
510 AppLogDebug("ENTER");
511 ArrayList* pContentPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
512 result r = pContentPathList->Construct();
515 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(r));
516 delete pContentPathList;
520 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
522 int totalCount = __pPresentationModel->GetTotalCount();
523 for (int iCount = 0; iCount < totalCount; iCount++)
525 if (__pContentTableView->IsItemChecked(iCount) == true)
527 pContentPathList->Add(__pPresentationModel->GetCheckedContent(iCount));
531 else if (pickerType == PICKER_TYPE_SHARE_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
533 int totalCount = __pPresentationModel->GetTotalCount();
534 for (int iCount = 0; iCount < totalCount; iCount++)
536 if (__pContentTableView->IsItemChecked(iCount) == true)
538 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(iCount);
539 if (pContentInfo == null)
541 pContentPathList->RemoveAll(true);
542 delete pContentPathList;
547 pContentPathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
555 delete pContentPathList;
560 return pContentPathList;