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 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();
60 return ThumbnailBase::Construct();
64 AllListEditorPanel::OnTerminating(void)
67 ThumbnailBase::Stop();
69 return ContentEditPanel::OnTerminating();
73 AllListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
76 if (__pPresentationModel == null)
81 int totalCount = __pPresentationModel->GetTotalCount();
85 case IDA_HEADER_BUTTON_SELECTE_ALL:
87 if (totalCount == __checkedItemCount)
89 SetItemCheckedAll(false);
93 SetItemCheckedAll(true);
98 case IDA_FOOTER_BUTTON_DELETE:
100 int totalCount = __pPresentationModel->GetTotalCount();
101 for (int iCount = totalCount - 1; iCount >= 0; iCount--)
103 if (__pContentTableView->IsItemChecked(iCount) == true)
105 __pPresentationModel->RemoveContent(iCount);
111 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
113 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
117 case IDA_FOOTER_BUTTON_SHARE:
119 LanucherPicker(PICKER_TYPE_SHARE_PICKER);
130 AllListEditorPanel::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;
141 pForm->SetFormBackEventListener(this);
142 if (pArgs != null && (previousSceneId.Equals(IDSCN_ALL_LIST, true)))
144 __editType = static_cast<Integer*>(pArgs->GetAt(0))->ToInt();
147 SetEditHeaderStyle();
149 if (__editType == IDA_CONTEXT_MENU_ITEM_EDIT)
151 pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_ADDTO_DELETE_ADD);
155 pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_SHARE_ADD);
157 pFooter->AddActionEventListener(*this);
158 pFooter->SetShowState(true);
159 CommonUtil::SetFooterItemEnabled(*pFooter, false);
161 UpdateContentEditScreenState();
165 pArgs->RemoveAll(true);
172 AllListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
173 const Tizen::Ui::Scenes::SceneId& nextSceneId)
175 AppLogDebug("ENTER");
176 ContentPanel::OnSceneDeactivated(currentSceneId, nextSceneId);
178 Footer* pFooter = GetFooter();
179 pFooter->RemoveAllButtons();
180 pFooter->RemoveAllItems();
181 pFooter->RemoveActionEventListener(*this);
183 __checkedItemCount = INIT_VALUE;
184 SetCheckedCountBallonTooltip(__checkedItemCount);
186 int totalCount = __pPresentationModel->GetTotalCount();
187 for (int iCount = 0; iCount < totalCount; iCount++)
189 __pContentTableView->SetItemChecked(iCount, false);
191 CancelAllThumbnailRequest();
196 AllListEditorPanel::GetItemCount(void)
198 AppLogDebug("ENTER");
199 int musicItem = INIT_VALUE;
200 if (__pPresentationModel == null)
205 musicItem = __pPresentationModel->GetTotalCount();
210 Tizen::Ui::Controls::TableViewItem*
211 AllListEditorPanel::CreateItem(const int itemIndex, int itemWidth)
213 AppLogDebug("ENTER");
214 RelativeLayout layout;
217 TableViewItem* pItem = new (std::nothrow) TableViewItem();
218 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
220 result r = pItem->Construct(layout, Dimension(itemWidth, ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_MARK);
221 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
222 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
224 r = CreateTableViewItem(*pItem, *pContentInfo);
225 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
227 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
234 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
240 AllListEditorPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
242 Tizen::Ui::Controls::TableViewItem* pItem,
243 Tizen::Ui::Controls::TableViewItemStatus status)
245 AppLogDebug("ENTER");
246 Form* pForm = dynamic_cast<Form*>(GetParent());
249 Footer* pFooter = pForm->GetFooter();
253 case TABLE_VIEW_ITEM_STATUS_CHECKED:
255 __checkedItemCount++;
256 tableView.SetItemChecked(itemIndex, true);
260 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
262 __checkedItemCount--;
263 tableView.SetItemChecked(itemIndex, false);
271 if (__checkedItemCount > INIT_VALUE)
273 CommonUtil::SetFooterItemEnabled(*pFooter, true);
277 CommonUtil::SetFooterItemEnabled(*pFooter, false);
280 SetCheckedCountBallonTooltip(__checkedItemCount);
286 AllListEditorPanel::CreateTableViewItem(Tizen::Ui::Container& parent,
287 const ContentInformation& contentInfoStruct)
289 AppLogDebug("ENTER");
290 Panel* pTableViewItem = new (std::nothrow) Panel();
291 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL)))
293 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
297 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.TitleName);
298 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
299 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
301 parent.AddControl(*pTableViewItem);
302 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
309 AllListEditorPanel::UpdateContentList(void)
311 AppLogDebug("ENTER");
312 if (__pPresentationModel != null)
314 __pPresentationModel->UpdateContentList();
320 AllListEditorPanel::SetEditHeaderStyle(void)
322 AppLogDebug("ENTER");
323 Header* pHeader = GetHeader();
324 if(__editType == IDA_CONTEXT_MENU_ITEM_EDIT)
326 String titleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
327 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
331 String titleText(ResourceManager::GetString(L"IDS_IV_BODY_SHARE_VIA"));
332 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
334 pHeader->Invalidate(true);
339 AllListEditorPanel::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
341 AppLogDebug("ENTER");
342 __pThumbnail = pThumbnailInfo->GetBitmapN();
343 Object* pParam = pThumbnailInfo->GetUserParamN();
346 __pContentTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
350 delete pThumbnailInfo;
355 AllListEditorPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
357 AppLogDebug("ENTER");
358 SceneManager* pSceneManager = SceneManager::GetInstance();
359 AppAssert(pSceneManager);
360 if (CommonUtil::GetAddtoPlaylistState())
362 CommonUtil::SetAddtoPlaylistState(false);
363 pSceneManager->GoBackward(BackwardSceneTransition());
367 pSceneManager->GoBackward(BackwardSceneTransition());
373 AllListEditorPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
375 AppLogDebug("ENTER");
376 Panel* pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL));
377 if (pItemPanel == null)
379 AppLogDebug("pItemPanel is null");
385 Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
386 if (__pThumbnail == null || pThumbnailLabel == null)
388 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
393 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
396 pThumbnailLabel->Invalidate(true);
401 AllListEditorPanel::IsEmptyContentList(void)
403 AppLogDebug("ENTER");
404 if (__pPresentationModel->GetTotalCount() == INIT_VALUE)
413 Tizen::Base::Collection::IList*
414 AllListEditorPanel::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
416 AppLogDebug("ENTER");
417 ArrayList* pContentPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
418 result r = pContentPathList->Construct();
421 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(r));
422 delete pContentPathList;
426 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
428 int totalCount = __pPresentationModel->GetTotalCount();
429 for (int iCount = 0; iCount < totalCount; iCount++)
431 if (__pContentTableView->IsItemChecked(iCount) == true)
433 pContentPathList->Add(__pPresentationModel->GetCheckedContent(iCount));
437 else if (pickerType == PICKER_TYPE_SHARE_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
439 int totalCount = __pPresentationModel->GetTotalCount();
440 for (int iCount = 0; iCount < totalCount; iCount++)
442 if (__pContentTableView->IsItemChecked(iCount) == true)
444 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(iCount);
445 if (pContentInfo == null)
447 pContentPathList->RemoveAll(true);
448 delete pContentPathList;
453 pContentPathList->Add(*(new (std::nothrow) String(L"attachment:" + pContentInfo->ContentFilePath)));
461 delete pContentPathList;
466 return pContentPathList;