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 MpFolderListEditorPanel.cpp
19 * @brief This is the implementation file for FolderListEditorPanel class.
22 #include "MpFolderListEditorPanel.h"
24 using namespace Tizen::Base;
25 using namespace Tizen::Base::Collection;
26 using namespace Tizen::Content;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Social;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Ui::Scenes;
33 FolderListEditorPanel::FolderListEditorPanel(void)
34 : ContentEditPanel::ContentEditPanel()
35 , __pPresentationModel(null)
41 FolderListEditorPanel::~FolderListEditorPanel(void)
48 FolderListEditorPanel::OnInitializing(void)
51 __pPresentationModel = FolderListPresentationModel::GetInstance();
54 __fontSizeValue = CommonUtil::GetFontSizeValue();
55 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
61 FolderListEditorPanel::OnTerminating(void)
65 return ContentEditPanel::OnTerminating();
69 FolderListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
71 AppLogDebug("ENTER %d", actionId);
72 SceneManager* pSceneManager = SceneManager::GetInstance();
73 AppAssert(pSceneManager);
75 int totalCount = __pPresentationModel->GetAllFolderCount();
79 case IDA_HEADER_BUTTON_SELECTE_ALL:
81 if (totalCount == __checkedItemCount)
83 SetItemCheckedAll(false);
87 SetItemCheckedAll(true);
92 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
94 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
98 case IDA_FOOTER_BUTTON_DELETE:
100 int totalCount = __pPresentationModel->GetAllFolderCount();
101 for (int iCount = totalCount - 1; iCount >= 0; iCount--)
103 if (__pContentTableView->IsItemChecked(iCount) == true)
105 __pPresentationModel->RemoveFolderList(iCount);
118 FolderListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
119 const Tizen::Ui::Scenes::SceneId& currentSceneId,
120 Tizen::Base::Collection::IList* pArgs)
122 AppLogDebug("ENTER");
123 ContentPanel::OnSceneActivatedN(previousSceneId, currentSceneId, null);
125 Form* pForm = dynamic_cast<Form*>(GetParent());
127 pForm->SetFormBackEventListener(this);
128 SetEditHeaderStyle();
130 SetFooterStyle(STYLE_ADDTO_DELETE_ADD);
132 Footer* pFooter = CommonUtil::CreateBackButtonStyleFooter(*pForm, STYLE_ADDTO_DELETE_ADD);
136 pFooter->AddActionEventListener(*this);
137 pFooter->SetShowState(true);
138 CommonUtil::SetFooterItemEnabled(*pFooter, false);
141 UpdateContentEditScreenState();
143 if (previousSceneId.Equals(IDSCN_PLAYLIST_CREATOR, true))
148 __pContentTableView->UpdateTableView();
149 __checkedItemCount = INIT_VALUE;
150 SetCheckedCountBallonTooltip(__checkedItemCount);
152 totalCount = __pPresentationModel->GetAllFolderCount();
153 for (int count = 0; count < totalCount; count++)
155 __pContentTableView->SetItemChecked(count, false);
162 CommonUtil::SetFooterItemEnabled(*pFooter, true);
169 pArgs->RemoveAll(true);
176 FolderListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
177 const Tizen::Ui::Scenes::SceneId& nextSceneId)
179 AppLogDebug("ENTER");
180 ContentPanel::OnSceneDeactivated(currentSceneId, nextSceneId);
181 if (!(nextSceneId.Equals(IDSCN_PLAYLIST_CREATOR, false)))
183 Footer* pFooter = GetFooter();
187 pFooter->RemoveAllButtons();
188 pFooter->RemoveAllItems();
189 pFooter->RemoveActionEventListener(*this);
192 __checkedItemCount = INIT_VALUE;
193 SetCheckedCountBallonTooltip(__checkedItemCount);
195 int totalCount = __pPresentationModel->GetAllFolderCount();
196 for (int iCount = 0; iCount < totalCount; iCount++)
198 __pContentTableView->SetItemChecked(iCount, false);
205 FolderListEditorPanel::GetItemCount(void)
207 AppLogDebug("ENTER");
208 if (__pPresentationModel == null)
214 return __pPresentationModel->GetAllFolderCount();
217 Tizen::Ui::Controls::TableViewItem*
218 FolderListEditorPanel::CreateItem(const int itemIndex, int itemWidth)
220 AppLogDebug("ENTER");
221 RelativeLayout layout;
224 TableViewItem* pItem = new (std::nothrow) TableViewItem();
225 result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), TABLE_VIEW_ANNEX_STYLE_MARK);
226 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
228 r = CreateTableViewItem(*pItem, *__pPresentationModel->GetFolderPath(itemIndex), __pPresentationModel->GetContentCount(itemIndex));
229 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
235 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
240 FolderListEditorPanel::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
242 AppLogDebug("ENTER");
248 FolderListEditorPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
250 AppLogDebug("ENTER");
255 FolderListEditorPanel::GetDefaultItemHeight(void)
257 AppLogDebug("ENTER");
263 FolderListEditorPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
265 Tizen::Ui::Controls::TableViewItem* pItem,
266 Tizen::Ui::Controls::TableViewItemStatus status)
268 AppLogDebug("ENTER");
269 Form* pForm = dynamic_cast<Form*>(GetParent());
272 Footer* pFooter = pForm->GetFooter();
276 case TABLE_VIEW_ITEM_STATUS_CHECKED:
278 __checkedItemCount++;
279 tableView.SetItemChecked(itemIndex, true);
283 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
285 __checkedItemCount--;
286 tableView.SetItemChecked(itemIndex, false);
294 if (__checkedItemCount > INIT_VALUE)
298 CommonUtil::SetFooterItemEnabled(*pFooter, true);
305 CommonUtil::SetFooterItemEnabled(*pFooter, false);
309 SetCheckedCountBallonTooltip(__checkedItemCount);
315 FolderListEditorPanel::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView,
317 Tizen::Ui::Controls::TableViewContextItem* pContextItem,
320 AppLogDebug("ENTER");
325 FolderListEditorPanel::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
329 AppLogDebug("ENTER");
334 FolderListEditorPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
336 AppLogDebug("ENTER");
337 SceneManager* pSceneManager = SceneManager::GetInstance();
338 AppAssert(pSceneManager);
340 pSceneManager->GoBackward(BackwardSceneTransition());
345 FolderListEditorPanel::UpdateContentList(void)
347 AppLogDebug("ENTER");
348 if (__pPresentationModel != null)
350 __pPresentationModel->UpdateFolderPathList();
356 FolderListEditorPanel::SetEditHeaderStyle(void)
358 AppLogDebug("ENTER");
359 Header* pHeader = GetHeader();
360 String titleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
361 CommonUtil::SetEditHeaderStyle(*pHeader, titleText);
362 pHeader->Invalidate(true);
367 FolderListEditorPanel::CreateTableViewItem(Tizen::Ui::Container& parent, const Tizen::Base::String& contentPath, int contentCount)
369 AppLogDebug("ENTER");
370 Bitmap* StorageIconBitmap = null;
371 String strFolderName;
373 int folderNamePosition = 0;
374 contentPath.LastIndexOf(IDS_SEPARATOR_SLASH, contentPath.GetLength() - 1, folderNamePosition);
375 contentPath.SubString(folderNamePosition + 1, strFolderName);
377 String phonePath = IDS_STORAGE_PHONE_PATH;
378 phonePath.Remove(IDS_STORAGE_PHONE_PATH.GetLength() - 1, 1);
380 String sdCardPath = IDS_STORAGE_SDCARD_PATH;
381 sdCardPath.Remove(IDS_STORAGE_SDCARD_PATH.GetLength() - 1, 1);
383 if (contentPath.Contains(phonePath))
385 StorageIconBitmap = ResourceManager::GetBitmapN(IDB_STORAGE_PHONE);
387 else if (contentPath.Contains(sdCardPath))
389 StorageIconBitmap = ResourceManager::GetBitmapN(IDB_STORAGE_SDCARD);
393 StorageIconBitmap = ResourceManager::GetBitmapN(IDB_STORAGE_PHONE);
396 Panel* pTableViewItem = new (std::nothrow) Panel();
398 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
400 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIBARY_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_GIANT)))
402 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
406 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
408 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIBARY_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_HUGE)))
410 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
414 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
416 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIBARY_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_LARGE)))
418 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
422 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
424 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIBARY_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_SMALL)))
426 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
432 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIBARY_FOLDER_EDITOR_ITEM_PANEL_DEFAULT)))
434 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
439 static_cast<Label*>(pTableViewItem->GetControl(IDC_STORAGE_TYPE_ICON))->SetBackgroundBitmap(*StorageIconBitmap);
440 delete StorageIconBitmap;
442 String fullContentPath;
443 contentPath.SubString(INIT_VALUE, folderNamePosition, fullContentPath);
444 static_cast<Label*>(pTableViewItem->GetControl(IDC_FOLDER_PATH))->SetText(CommonUtil::SetHighDepthToEllipsisPath(fullContentPath));
446 static_cast<Label*>(pTableViewItem->GetControl(IDC_FOLDER_NAME))->SetText(strFolderName);
447 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ITEM_COUNT))->SetText(CommonUtil::SetSongsString(contentCount));
449 parent.AddControl(pTableViewItem);
450 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
457 FolderListEditorPanel::IsEmptyContentList(void)
459 AppLogDebug("ENTER");
460 if (__pPresentationModel->GetAllFolderCount() == INIT_VALUE)
469 Tizen::Base::Collection::IList*
470 FolderListEditorPanel::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
472 AppLogDebug("ENTER");
473 ArrayList* pContentPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
474 result r = pContentPathList->Construct();
477 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(r));
478 delete pContentPathList;
482 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER && argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
484 int totalCount = __pPresentationModel->GetAllFolderCount();
485 for (int iCount = 0; iCount < totalCount; iCount++)
487 if (__pContentTableView->IsItemChecked(iCount) == true)
489 pContentPathList->AddItems(*(__pPresentationModel->GetContentPathListN(iCount)));
496 delete pContentPathList;
501 return pContentPathList;
505 FolderListEditorPanel::OnFontSizeChanged(void)
507 __fontSizeValue = CommonUtil::GetFontSizeValue();
508 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
509 __pContentTableView->UpdateTableView();