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 MpArtistContentPickerPanel.cpp
19 * @brief This is the implementation file for ArtistContentPickerPanel class.
22 #include "MpArtistContentPickerPanel.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 ArtistContentPickerPanel::ArtistContentPickerPanel(void)
34 : __checkedItemCount(0)
35 , __pContentTableView(null)
36 , __pSelectAllCheckedButton(null)
37 , __pCheckedCountLabel(null)
43 ArtistContentPickerPanel::~ArtistContentPickerPanel(void)
50 ArtistContentPickerPanel::Initialize(void)
53 result r = Construct(Rectangle(INIT_VALUE, INIT_VALUE, INIT_VALUE, INIT_VALUE));
63 ArtistContentPickerPanel::OnInitializing(void)
66 Form* pForm = dynamic_cast<Form*>(GetParent());
69 int width = pForm->GetClientAreaBounds().width;
70 int height = pForm->GetClientAreaBounds().height;
72 SetBounds(INIT_VALUE, INIT_VALUE, width, height);
74 __pContentTableView = CommonUtil::CreateEditorTableView(width, height);
75 __pContentTableView->AddTableViewItemEventListener(*this);
76 __pContentTableView->SetItemProvider(this);
78 __pSelectAllCheckedButton = CommonUtil::CreateSelectAllCheckedButton(width);
79 __pSelectAllCheckedButton->AddActionEventListener(*this);
81 __pCheckedCountLabel = CommonUtil::CreateCheckedCountLabel(width, height);
82 __pCheckedCountLabel->SetShowState(false);
84 AddControl(__pContentTableView);
85 AddControl(__pSelectAllCheckedButton);
86 AddControl(__pCheckedCountLabel);
88 __pPresentationModel = ArtistListPresentationModel::GetInstance();
95 ArtistContentPickerPanel::OnTerminating(void)
103 ArtistContentPickerPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
105 AppLogDebug("ENTER");
106 SceneManager* pSceneManager = SceneManager::GetInstance();
107 AppAssert(pSceneManager);
109 int totalCount = __pPresentationModel->GetArtistContentListCount();
113 case IDA_CHECK_BUTTON:
115 __checkedItemCount = totalCount;
116 CommonUtil::SetAllCheckState(true, *__pContentTableView, totalCount);
117 Form* pForm = dynamic_cast<Form*>(GetParent());
119 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
120 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount, actionId);
124 case IDA_UNCHECK_BUTTON:
126 __checkedItemCount = INIT_VALUE;
127 CommonUtil::SetAllCheckState(false, *__pContentTableView, totalCount);
128 Form* pForm = dynamic_cast<Form*>(GetParent());
130 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
131 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount, actionId);
135 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
137 if (__checkedItemCount <= 0)
142 int totalCount = __pPresentationModel->GetArtistContentListCount();
143 for (int iCount = 0; iCount < totalCount; iCount++)
145 if (__pContentTableView->IsItemChecked(iCount) == true)
147 __pPresentationModel->AddContent(CommonUtil::GetAddtoPlaylistName(), iCount);
148 __pContentTableView->SetItemChecked(iCount, false);
152 Form* pForm = dynamic_cast<Form*>(GetParent());
154 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount, actionId);
156 __checkedItemCount = 0;
157 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
158 CommonUtil::ShowSelectAllCheckButton(*__pSelectAllCheckedButton);
159 CommonUtil::SetAddtoPlaylistState(false);
163 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYLIST_LIST,
164 SCENE_TRANSITION_ANIMATION_TYPE_NONE,
165 SCENE_HISTORY_OPTION_NO_HISTORY,
166 SCENE_DESTROY_OPTION_DESTROY));
170 case IDA_FOOTER_BUTTON_CANCEL:
172 Form* pForm = dynamic_cast<Form*>(GetParent());
174 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount, actionId);
175 pSceneManager->GoBackward(BackwardSceneTransition());
186 ArtistContentPickerPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
187 const Tizen::Ui::Scenes::SceneId& currentSceneId,
188 Tizen::Base::Collection::IList* pArgs)
190 AppLogDebug("ENTER");
191 Form* pForm = dynamic_cast<Form*>(GetParent());
194 Footer* pFooter = CommonUtil::CreateAddtoPlaylistPickerFooter(*pForm);
195 pFooter->AddActionEventListener(*this);
196 if (pArgs != null && (previousSceneId.Equals(IDSCN_ARTIST_PICKER, true)))
198 String* pTemp = static_cast<String*>(pArgs->GetAt(0));
199 __pPresentationModel->InitializeArtistAlbumList(*pTemp);
202 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount);
206 pArgs->RemoveAll(true);
213 ArtistContentPickerPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
214 const Tizen::Ui::Scenes::SceneId& nextSceneId)
216 AppLogDebug("ENTER");
217 Form* pForm = dynamic_cast<Form*>(GetParent());
220 Footer* pFooter = pForm->GetFooter();
223 pFooter->RemoveAllButtons();
224 pFooter->RemoveAllItems();
225 pFooter->RemoveActionEventListener(*this);
231 ArtistContentPickerPanel::GetItemCount(void)
233 AppLogDebug("ENTER");
234 if (__pPresentationModel == null)
239 return __pPresentationModel->GetArtistContentListCount();
242 Tizen::Ui::Controls::TableViewItem*
243 ArtistContentPickerPanel::CreateItem(const int itemIndex, int itemWidth)
245 AppLogDebug("ENTER");
246 ContentInformation* pContentInfoStruct = __pPresentationModel->GetArtistContentInfoN(itemIndex);
247 if (pContentInfoStruct == null)
252 TableViewItem* pItem = new (std::nothrow) TableViewItem();
253 pItem->Construct(Dimension(itemWidth, ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_MARK);
254 // pItem->SetBackgroundColor(COLOR_ITEM);
256 CommonUtil::CreateContentPikerTableViewItem(*pItem, pContentInfoStruct->TitleName, CommonUtil::GetFormatDate(pContentInfoStruct->Duration));
258 delete pContentInfoStruct;
259 pContentInfoStruct = null;
266 ArtistContentPickerPanel::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
268 AppLogDebug("ENTER");
274 ArtistContentPickerPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
276 AppLogDebug("ENTER");
281 ArtistContentPickerPanel::GetDefaultItemHeight(void)
283 AppLogDebug("ENTER");
289 ArtistContentPickerPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
291 Tizen::Ui::Controls::TableViewItem* pItem,
292 Tizen::Ui::Controls::TableViewItemStatus status)
294 AppLogDebug("ENTER");
297 case TABLE_VIEW_ITEM_STATUS_CHECKED:
299 __checkedItemCount++;
300 tableView.SetItemChecked(itemIndex, true);
304 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
306 __checkedItemCount--;
307 tableView.SetItemChecked(itemIndex, false);
315 CommonUtil::ShowSelectAllCheckButton(*__pSelectAllCheckedButton);
317 if (__checkedItemCount == __pPresentationModel->GetArtistContentListCount())
319 __pSelectAllCheckedButton->SetSelected(true);
324 Form* pForm = dynamic_cast<Form*>(GetParent());
326 CommonUtil::ShowCheckedCountLabel(*__pCheckedCountLabel, __checkedItemCount, *__pContentTableView, *pForm);
327 CommonUtil::SetButtonEnabled(*pForm, __checkedItemCount);
332 ArtistContentPickerPanel::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView,
334 Tizen::Ui::Controls::TableViewContextItem* pContextItem,
337 AppLogDebug("ENTER");
341 ArtistContentPickerPanel::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
345 AppLogDebug("ENTER");