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 MpGenreListEditorPanel.cpp
19 * @brief This is the implementation file for GenreListEditorPanel class.
22 #include "MpGenreListEditorPanel.h"
23 #include "MpPlaylistPickerPopup.h"
24 #include "MpThumbnailInfo.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Content;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Social;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
34 GenresListEditorPanel::GenresListEditorPanel(void)
35 : ThumbnailBase::ThumbnailBase()
36 , __checkedItemCount(0)
37 , __pContentTableView(null)
38 , __pSelectAllCheckedButton(null)
39 , __pCheckedCountLabel(null)
41 , __pPlayListPickerPopup(null)
47 GenresListEditorPanel::~GenresListEditorPanel(void)
54 GenresListEditorPanel::Initialize(void)
57 result r = BasePanel::Construct(Rectangle(INIT_VALUE, INIT_VALUE, INIT_VALUE, INIT_VALUE));
67 GenresListEditorPanel::OnInitializing(void)
70 __pPresentationModel = GenreListPresentationModel::GetInstance();
72 Form* pForm = dynamic_cast<Form*>(GetParent());
75 int width = pForm->GetClientAreaBounds().width;
76 int height = pForm->GetClientAreaBounds().height;
78 SetBounds(INIT_VALUE, INIT_VALUE, width, height);
80 __pContentTableView = CommonUtil::CreateEditorTableView(width, height);
81 __pContentTableView->AddTableViewItemEventListener(*this);
82 __pContentTableView->SetItemProvider(this);
84 __pSelectAllCheckedButton = CommonUtil::CreateSelectAllCheckedButton(width);
85 __pSelectAllCheckedButton->AddActionEventListener(*this);
87 __pCheckedCountLabel = CommonUtil::CreateCheckedCountLabel(width, height);
88 __pCheckedCountLabel->SetShowState(false);
90 AddControl(__pContentTableView);
91 AddControl(__pSelectAllCheckedButton);
92 AddControl(__pCheckedCountLabel);
95 return ThumbnailBase::Construct();
99 GenresListEditorPanel::OnTerminating(void)
101 AppLogDebug("ENTER");
107 GenresListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
109 AppLogDebug("ENTER");
110 SceneManager* pSceneManager = SceneManager::GetInstance();
111 AppAssert(pSceneManager);
113 int totalCount = __pPresentationModel->GetAllGenreCount();
117 case IDA_CHECK_BUTTON:
119 __checkedItemCount = totalCount;
120 CommonUtil::SetAllCheckState(true, *__pContentTableView, totalCount);
121 Form* pForm = dynamic_cast<Form*>(GetParent());
123 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
127 case IDA_UNCHECK_BUTTON:
129 __checkedItemCount = INIT_VALUE;
130 CommonUtil::SetAllCheckState(false, *__pContentTableView, totalCount);
131 Form* pForm = dynamic_cast<Form*>(GetParent());
133 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
137 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
139 if (__checkedItemCount <= INIT_VALUE)
144 ArrayList* pDataList = new (std::nothrow) ArrayList();
145 pDataList->Construct();
147 int totalCount = __pPresentationModel->GetAllGenreCount();
148 for (int iCount = 0; iCount < totalCount; iCount++)
150 if (__pContentTableView->IsItemChecked(iCount) == true)
152 pDataList->AddItems(*(__pPresentationModel->GetContentPathListN(iCount)));
156 __pPlayListPickerPopup = new (std::nothrow) PlayListPickerPopup();
157 __pPlayListPickerPopup->Initialize(this, pDataList);
158 //__pPlayListPickerPopup->SetCollectedContent(pDataList);
159 __pPlayListPickerPopup->SetShowState(true);
160 __pPlayListPickerPopup->Show();
164 case IDA_FOOTER_BUTTON_CANCEL:
166 pSceneManager->GoBackward(BackwardSceneTransition());
174 Form* pForm = dynamic_cast<Form*>(GetParent());
176 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount, actionId);
181 GenresListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
182 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
184 AppLogDebug("ENTER");
185 Form* pForm = dynamic_cast<Form*>(GetParent());
188 Footer* pFooter = CommonUtil::CreateAddtoPlaylistPickerFooter(*pForm);
189 pFooter->AddActionEventListener(*this);
191 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount);
197 pArgs->RemoveAll(true);
204 GenresListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
205 const Tizen::Ui::Scenes::SceneId& nextSceneId)
207 AppLogDebug("ENTER");
208 Form* pForm = dynamic_cast<Form*>(GetParent());
211 Footer* pFooter = pForm->GetFooter();
214 pFooter->RemoveAllButtons();
215 pFooter->RemoveAllItems();
216 pFooter->RemoveActionEventListener(*this);
219 __checkedItemCount = INIT_VALUE;
220 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
221 CommonUtil::ShowSelectAllCheckButton(*__pSelectAllCheckedButton);
223 int totalCount = __pPresentationModel->GetAllGenreCount();
224 for (int iCount = 0; iCount < totalCount; iCount++)
226 __pContentTableView->SetItemChecked(iCount, false);
229 CancelAllThumbnailRequest();
234 GenresListEditorPanel::GetItemCount(void)
236 AppLogDebug("ENTER");
237 if (__pPresentationModel == null)
243 return __pPresentationModel->GetAllGenreCount();
246 Tizen::Ui::Controls::TableViewItem*
247 GenresListEditorPanel::CreateItem(const int itemIndex, int itemWidth)
249 AppLogDebug("ENTER");
250 ContentInformation* pContentInfoStruct = __pPresentationModel->GetGenreInfoN(itemIndex);
251 if (pContentInfoStruct == null)
256 TableViewItem* pItem = new (std::nothrow) TableViewItem();
257 pItem->Construct(Dimension(itemWidth, ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_MARK);
258 // pItem->SetBackgroundColor(COLOR_ITEM);
260 // RequestThumbnail(pContentInfoStruct->contentId, (new (std::nothrow) int(itemIndex)));
261 CommonUtil::CreateEditListTableViewItem(*pItem, *GetDefaultThumbnail(), pContentInfoStruct->GenreName, __pPresentationModel->GetContentCount(itemIndex));
263 delete pContentInfoStruct;
264 pContentInfoStruct = null;
271 GenresListEditorPanel::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
273 AppLogDebug("ENTER");
279 GenresListEditorPanel::GetDefaultItemHeight(void)
281 AppLogDebug("ENTER");
287 GenresListEditorPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
289 Tizen::Ui::Controls::TableViewItem* pItem,
290 Tizen::Ui::Controls::TableViewItemStatus status)
292 AppLogDebug("ENTER");
295 case TABLE_VIEW_ITEM_STATUS_CHECKED:
297 __checkedItemCount++;
298 tableView.SetItemChecked(itemIndex, true);
302 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
304 __checkedItemCount--;
305 tableView.SetItemChecked(itemIndex, false);
313 Form* pForm = dynamic_cast<Form*>(GetParent());
315 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount);
317 CommonUtil::ShowSelectAllCheckButton(*__pSelectAllCheckedButton);
319 if (__checkedItemCount == __pPresentationModel->GetAllGenreCount())
321 __pSelectAllCheckedButton->SetSelected(true);
325 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
330 GenresListEditorPanel::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView,
332 Tizen::Ui::Controls::TableViewContextItem* pContextItem,
335 AppLogDebug("ENTER");
340 GenresListEditorPanel::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
344 AppLogDebug("ENTER");
349 GenresListEditorPanel::OnMusicContentUpdateCompleted(void)
351 AppLogDebug("ENTER");
357 GenresListEditorPanel::UpdateContentList(void)
359 AppLogDebug("ENTER");
360 if (__pPresentationModel != null && __pContentTableView != null)
362 __pPresentationModel->UpdateGnereList();
363 __pContentTableView->UpdateTableView();
369 GenresListEditorPanel::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
371 AppLogDebug("ENTER");
374 __pThumbnail = pThumbnailInfo->GetBitmapN();
375 pParam = pThumbnailInfo->GetUserParamN();
378 itemIndex = *(static_cast<int*>(pParam));
380 __pContentTableView->RefreshItem(itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
381 delete pThumbnailInfo;
382 delete static_cast<int*>(pParam);
387 GenresListEditorPanel::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
389 AppLogDebug("ENTER");
390 AppLogDebug("OnUserEventReceivedN %d", requestId);
391 if (requestId == ID_DESTORY_PLAY_LIST_PICKER_POPUP)
393 if (__pPlayListPickerPopup != null)
395 delete __pPlayListPickerPopup;
396 __pPlayListPickerPopup = null;
403 GenresListEditorPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
405 AppLogDebug("ENTER");
406 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(L"pSongThumbnailLabel"));
407 if (__pThumbnail == null || pThumbnailLabel == null)
409 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
414 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
417 pThumbnailLabel->Invalidate(true);