Prevent defect fix and Minor issue fix
[apps/osp/Gallery.git] / src / GlAllListEditorPanel.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                GlAllListEditorPanel.cpp
19  * @brief               This is the implementation file for AllListEditorPanel class.
20  */
21
22 #include <FContent.h>
23 #include "GlAllListEditorPanel.h"
24 #include "GlCommonUtil.h"
25 #include "GlFileUpdateTimer.h"
26 #include "GlFileListEditorForm.h"
27 #include "GlFileListPresentationModel.h"
28 #include "GlResourceManager.h"
29 #include "GlTypes.h"
30
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Utility;
35 using namespace Tizen::Content;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Media;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
40
41 static const int H_COUNT_LABEL = 48;
42 static const int H_COUNT_LABEL_BUTTON = 42;
43 static const int W_COUNT_LABEL_BUTTON = 42;
44 static const int COUNT_LABEL_FONT_SIZE = 33;
45 static const int H_CONTENT_MARGIN = 9;
46 static const int W_CONTENT_MARGIN = 6;
47 static const int W_CONTENT_SPACE = 6;
48 static const int H_CONTENT_SPACE = 6;
49 static const int LENGTH_COUNT_LABEL = 256;
50 static const unsigned int COLOR_COUNT_LABEL = Color32<68, 68, 68>::Value;
51 static const unsigned int COLOR_SELECT_COUNT_FONT = Color32<255, 255, 255>::Value;
52 static const unsigned int COLOR_COUNT_LABEL_BUTTON = Color32<120, 120, 120>::Value;
53 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
54 static const int ALPHA_THUMBNAIL_DIM = 70;
55
56 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
57
58 AllListEditorPanel::AllListEditorPanel(void)
59         : __itemCount(0)
60         , __pContentIconListView(null)
61         , __pLabelSelectCnt(null)
62         , __pButtonSelectRegion(null)
63         , __pFileUpdateTimer(null)
64         , __pFileListEditorForm(null)
65         , __pPresentationModel(null)
66 {
67         AppLogDebug("ENTER");
68         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
69 }
70
71 AllListEditorPanel::~AllListEditorPanel(void)
72 {
73         AppLogDebug("ENTER");
74         delete __pFileUpdateTimer;
75         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
76 }
77
78 result
79 AllListEditorPanel::Initialize(void)
80 {
81         AppLogDebug("ENTER");
82         result r = Construct(RECT_INITIAL);
83         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
84
85         return r;
86 }
87
88 result
89 AllListEditorPanel::OnInitializing(void)
90 {
91         AppLogDebug("ENTER");
92         const Form* pForm = dynamic_cast<Form*>(GetParent());
93         TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
94
95         __pPresentationModel = FileListPresentationModel::GetInstance();
96         __pPresentationModel->ClearThumbnailRequests();
97         __pPresentationModel->AddPresentationModelListener(this);
98
99         Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
100         SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
101
102         __pContentIconListView = new (std::nothrow) IconListView();
103         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height - H_COUNT_LABEL),
104                         DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
105         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
106         if (pBitmapEmpty != null)
107         {
108                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
109                 delete pBitmapEmpty;
110         }
111         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
112         __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
113         __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
114         __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
115         __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
116         __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
117         __pContentIconListView->SetItemProvider(*this);
118         __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
119         __pContentIconListView->AddIconListViewItemEventListener(*this);
120         __pContentIconListView->SetTouchAnimationEnabled(false);
121         AddControl(__pContentIconListView);
122         __pContentIconListView->SetShowState(true);
123
124         __pLabelSelectCnt = new (std::nothrow) Label();
125         String strTmp;
126         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED").GetPointer();
127         __pLabelSelectCnt->Construct(
128                         Rectangle(0, clientAreaBounds.height - H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL), strTmp);
129         __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
130         __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
131         __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
132         __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
133         __pLabelSelectCnt->SetTextConfig(COUNT_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
134         AddControl(__pLabelSelectCnt);
135         __pLabelSelectCnt->Invalidate(true);
136
137         __pButtonSelectRegion = new (std::nothrow) Button();
138         __pButtonSelectRegion->Construct(Rectangle(clientAreaBounds.width - W_COUNT_LABEL_BUTTON - 10,
139                         clientAreaBounds.height - H_COUNT_LABEL_BUTTON - 4, W_COUNT_LABEL_BUTTON, H_COUNT_LABEL_BUTTON),
140                         EMPTY_SPACE);
141         __pButtonSelectRegion->SetActionId(IDA_BUTTON_MOVE_TO_SELECTION);
142         __pButtonSelectRegion->SetColor(BUTTON_STATUS_NORMAL, COLOR_COUNT_LABEL_BUTTON);
143         Bitmap* pSelectionBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MOVE_SELECTION);
144         if (pSelectionBitmap != null)
145         {
146                 Rectangle buttonRegionRect = __pButtonSelectRegion->GetBounds();
147                 pSelectionBitmap->Scale(Dimension(buttonRegionRect.width, buttonRegionRect.height));
148                 __pButtonSelectRegion->SetNormalBitmap(Point(buttonRegionRect.width, buttonRegionRect.height),
149                                 *pSelectionBitmap);
150         }
151         AddControl(__pButtonSelectRegion);
152
153         if (pSelectionBitmap != null)
154         {
155                 delete pSelectionBitmap;
156         }
157         __pButtonSelectRegion->AddActionEventListener(*this);
158
159         __itemCount = 0;
160         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
161
162         return E_SUCCESS;
163 }
164
165 result
166 AllListEditorPanel::OnTerminating(void)
167 {
168         AppLogDebug("ENTER");
169         __pPresentationModel->RemovePresentationModelListener(*this);
170         __pPresentationModel->RemoveContentEventListener(__pFileListEditorForm);
171         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
172
173         return E_SUCCESS;
174 }
175
176 void
177 AllListEditorPanel::OnActionPerformed(const Control& source, int actionId)
178 {
179         AppLogDebug("ENTER");
180         SceneManager* pSceneManager = SceneManager::GetInstance();
181         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
182
183         switch (actionId)
184         {
185         case IDA_BUTTON_CHECKED:
186         {
187                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
188                 for (int i=0; i < loopCount; ++i)
189                 {
190                         if (__pContentIconListView->IsItemChecked(i) == false)
191                         {
192                                 __pContentIconListView->SetItemChecked(i, true);
193                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
194                         }
195                 }
196                 int checkedCount = GetItemCheckedCount();
197                 String strTmp;
198
199                 if (checkedCount == 0)
200                 {
201                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
202                 }
203                 else if (checkedCount == 1)
204                 {
205                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
206                 }
207                 else
208                 {
209                         strTmp.Format(LENGTH_COUNT_LABEL,
210                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
211                 }
212
213                 __pLabelSelectCnt->SetText(strTmp);
214                 __pLabelSelectCnt->RequestRedraw(true);
215                 SetButtonState();
216         }
217         break;
218
219         case IDA_BUTTON_UNCHECKED:
220         {
221                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
222                 for (int i = 0; i < loopCount; ++i)
223                 {
224                         if (__pContentIconListView->IsItemChecked(i) == true)
225                         {
226                                 __pContentIconListView->SetItemChecked(i,false);
227                         }
228                 }
229                 int checkedCount = GetItemCheckedCount();
230                 String strTmp;
231
232                 if (checkedCount == 0)
233                 {
234                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
235                 }
236                 else if (checkedCount == 1)
237                 {
238                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
239                 }
240                 else
241                 {
242                         strTmp.Format(LENGTH_COUNT_LABEL,
243                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
244                 }
245
246                 __pLabelSelectCnt->SetText(strTmp);
247                 __pLabelSelectCnt->RequestRedraw(true);
248                 __pContentIconListView->UpdateList();
249                 SetButtonState();
250         }
251         break;
252
253         case IDA_BUTTON_MOVE_TO_SELECTION:
254         {
255                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
256                 {
257                         IList* pList = GetItemCheckedIndexListN();
258                         if (pList == null)
259                         {
260                                 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
261                         }
262                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_SELECTION), pList);
263                 }
264                 else
265                 {
266                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_SELECTION));
267                 }
268         }
269         break;
270
271         default:
272                 break;
273         }
274         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
275 }
276
277 int
278 AllListEditorPanel::GetItemCount(void)
279 {
280         AppLogDebug("ENTER");
281         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
282
283         return __itemCount;
284 }
285
286 IconListViewItem*
287 AllListEditorPanel::CreateItem(int index)
288 {
289         AppLogDebug("ENTER : index(%d)", index);
290         IconListViewItem* pIconListviewItem;
291         Bitmap* pBitmap = null;
292         String* pItemText = null;
293         result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
294         if (pBitmap == null || r == E_FAILURE)
295         {
296                 __pPresentationModel->RequestThumbnail(index);
297                 pBitmap = CommonUtil::GetEmptyThumbnailN();
298         }
299
300         if (pItemText == null)
301         {
302                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
303         }
304         else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
305         {
306                 delete pItemText;
307                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
308         }
309
310         if (__pContentIconListView->IsItemChecked(index) == true)
311         {
312                 if (pBitmap != null)
313                 {
314                         BufferInfo bufferInfo;
315                         pBitmap->Lock(bufferInfo, INFINITE);
316                         pBitmap->Unlock();
317                         Color dimColor(COLOR_THUMBNAIL_DIM);
318                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
319
320                         Canvas canvas;
321                         canvas.Construct(bufferInfo);
322                         canvas.FillRectangle(dimColor, canvas.GetBounds());
323
324                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
325                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
326                         pIconListviewItem = new (std::nothrow) IconListViewItem();
327                         pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
328                         delete pSelectedBitmap;
329                 }
330                 else
331                 {
332                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
333                         delete pItemText;
334                         return null;
335                 }
336         }
337         else
338         {
339                 pIconListviewItem = new (std::nothrow) IconListViewItem();
340                 pIconListviewItem->Construct(*pBitmap, pItemText);
341         }
342
343         if (pBitmap != null)
344         {
345                 delete pBitmap;
346         }
347         if (pItemText != null)
348         {
349                 delete pItemText;
350         }
351         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
352
353         return pIconListviewItem;
354 }
355
356 bool
357 AllListEditorPanel::DeleteItem(int index, IconListViewItem* pItem)
358 {
359         AppLogDebug("ENTER");
360         delete pItem;
361         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
362
363         return true;
364 }
365
366 void
367 AllListEditorPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
368 {
369         AppLogDebug("ENTER");
370         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
371         {
372                 int checkedCount = GetItemCheckedCount();
373                 String strTmp;
374
375                 if (checkedCount == 0)
376                 {
377                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
378                 }
379                 else if (checkedCount == 1)
380                 {
381                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
382                 }
383                 else
384                 {
385                         strTmp.Format(LENGTH_COUNT_LABEL,
386                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
387                 }
388
389                 __pLabelSelectCnt->SetText(strTmp);
390                 __pLabelSelectCnt->RequestRedraw(true);
391                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
392         }
393         SetButtonState();
394         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
395 }
396
397 void
398 AllListEditorPanel::OnFileInfoChanged(const ContentType contentType)
399 {
400         AppLogDebug("ENTER");
401         if (contentType == CONTENT_TYPE_ALL
402                 || contentType == CONTENT_TYPE_IMAGE
403                 || contentType == CONTENT_TYPE_VIDEO)
404         {
405                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
406                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
407                 __pContentIconListView->UpdateList();
408         }
409         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
410 }
411
412 void
413 AllListEditorPanel::OnThumbnailDecoded(const int index)
414 {
415         AppLogDebug("ENTER : index(%d)", index);
416         if (index >= 0)
417         {
418                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
419         }
420         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
421 }
422
423 void
424 AllListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
425                                                                 const SceneId& currentSceneId, IList* pArgs)
426 {
427         AppLogDebug("ENTER");
428
429         ChangeOrientation();
430
431         __pPresentationModel = FileListPresentationModel::GetInstance();
432
433         SceneManager* pSceneManager = SceneManager::GetInstance();
434         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
435         __pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
436         TryReturnVoid(__pFileListEditorForm != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
437         __pPresentationModel->AddContentEventListener(__pFileListEditorForm);
438
439         if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
440         {
441                 if (pArgs != null)
442                 {
443                         if (__pContentIconListView != null)
444                         {
445                                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
446                                 for (int i = 0; i < loopCount; ++i)
447                                 {
448                                         __pContentIconListView->SetItemChecked(i, false);
449                                 }
450                                 __pContentIconListView->UpdateList();
451                         }
452
453                         if (pArgs->GetCount() > 0) //SomeItems are Still Selected.
454                         {
455                                 IList* pSeletedIndexList = pArgs;
456                                 int loopCount = pSeletedIndexList->GetCount();
457                                 if (__pContentIconListView != null)
458                                 {
459                                         for (int i = 0; i < loopCount; ++i)
460                                         {
461                                                 int index = static_cast<Integer*>(pSeletedIndexList->GetAt(i))->ToInt();
462                                                 __pContentIconListView->SetItemChecked(index, true);
463                                         }
464                                         __pContentIconListView->UpdateList();
465                                 }
466                         }
467                 }
468
469                 int checkedCount = GetItemCheckedCount();
470                 String strTmp;
471
472                 if (checkedCount == 0)
473                 {
474                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
475                 }
476                 else if (checkedCount == 1)
477                 {
478                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
479                 }
480                 else
481                 {
482                         strTmp.Format(LENGTH_COUNT_LABEL,
483                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
484                 }
485
486                 __pLabelSelectCnt->SetText(strTmp);
487                 __pLabelSelectCnt->RequestRedraw(true);
488         }
489         else if (previousSceneId == IDSCN_ALL_LIST)
490         {
491                 ResetSelection();
492         }
493
494         SetButtonState();
495
496         __pFileListEditorForm->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
497         
498         if (pArgs != null && pArgs->GetCount() > 0 && previousSceneId != IDSCN_ALL_LIST_SELECTION)
499         {
500                 String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
501                 if (pDirectory != null && pDirectory->GetLength() > 0)
502                 {
503                         __pFileListEditorForm->MoveToAlbum(*pDirectory);
504                 }
505         }
506
507         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
508 }
509
510 void
511 AllListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
512 {
513         AppLogDebug("ENTER");
514         __pPresentationModel->RemoveContentEventListener(__pFileListEditorForm);
515         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
516 }
517
518 int
519 AllListEditorPanel::GetItemCheckedCount(void) const
520 {
521         AppLogDebug("ENTER");
522         int count = 0;
523         if (__pContentIconListView != null)
524         {
525                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
526                 for (int i = 0; i < loopCount; ++i)
527                 {
528                         if (__pContentIconListView->IsItemChecked(i))
529                         {
530                                 ++count;
531                         }
532                         else
533                         {
534                                 AppLog("Index i = %d is Not Checked", i);
535                         }
536                 }
537         }
538         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
539
540         return count;
541 }
542
543 IList*
544 AllListEditorPanel::GetItemCheckedIndexListN(void) const
545 {
546         AppLogDebug("ENTER");
547         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
548         Integer* pIndex = null;
549
550         if (__pContentIconListView!=null)
551         {
552                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
553                 for (int i = 0; i < loopCount; ++i)
554                 {
555                         if (__pContentIconListView->IsItemChecked(i) == true)
556                         {
557                                 pIndex = new (std::nothrow) Integer(i);
558                                 pList->Add(pIndex);
559                                 AppLogDebug("checked index(%d)", i);
560                         }
561                 }
562         }
563         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
564
565         return pList;
566 }
567
568 result
569 AllListEditorPanel::OnRequestDelete(void)
570 {
571         AppLogDebug("ENTER");
572         IList* pIndexList = GetItemCheckedIndexListN();
573         if (pIndexList->GetCount() <= 0)
574         {
575                 delete pIndexList;
576                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
577
578                 return E_FAILURE;
579         }
580
581         delete __pFileUpdateTimer;
582         __pFileUpdateTimer = new (std::nothrow) FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ACTION_DELETE);
583         result r = __pFileUpdateTimer->StartTimer();
584
585         if (IsFailed(r))
586         {
587                 delete __pFileUpdateTimer;
588                 __pFileUpdateTimer = null;
589                 return E_FAILURE;
590         }
591         else
592         {
593                 __pPresentationModel->SetUpdateProgressStatus(true);
594         }
595         return E_SUCCESS;
596 }
597
598 void AllListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
599 {
600         __pFileListEditorForm->Invalidate(true);
601 }
602
603 void AllListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
604 {
605         __pPresentationModel->SetUpdateProgressStatus(false);
606
607         __pLabelSelectCnt->SetText(ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
608         __pLabelSelectCnt->RequestRedraw(true);
609
610         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
611         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
612         __pContentIconListView->UpdateList();
613
614         SceneManager* pSceneManager = SceneManager::GetInstance();
615         if (GetItemCount() > 0)
616         {
617                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST,SCENE_TRANSITION_ANIMATION_TYPE_NONE,
618                                                                    SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
619         }
620         else
621         {
622                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST,SCENE_TRANSITION_ANIMATION_TYPE_NONE,
623                                                                    SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
624         }
625         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
626 }
627
628 void
629 AllListEditorPanel::ChangeOrientation(void)
630 {
631         SceneManager* pSceneManager = SceneManager::GetInstance();
632         const Form* pForm = dynamic_cast<Form*>(pSceneManager->GetCurrentScene()->GetForm());
633         TryReturn(pForm != null,, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
634
635         Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
636         SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
637         __pContentIconListView->SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height - H_COUNT_LABEL);
638         __pLabelSelectCnt->SetBounds(0, clientAreaBounds.height - H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL);
639         __pButtonSelectRegion->SetBounds(clientAreaBounds.width - W_COUNT_LABEL_BUTTON - 10,
640                         clientAreaBounds.height - H_COUNT_LABEL_BUTTON - 4, W_COUNT_LABEL_BUTTON, H_COUNT_LABEL_BUTTON);
641 }
642
643 result
644 AllListEditorPanel::OnRequestMessage(void)
645 {
646         AppLogDebug("ENTER");
647         result r = E_SUCCESS;
648         IList* pIndexList = GetItemCheckedIndexListN();
649         if (pIndexList == null || pIndexList->GetCount() <= 0)
650         {
651                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
652
653                 return E_FAILURE;
654         }
655
656         Integer* pIndex = null;
657         int checkedIndex;
658         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
659         pArrayList->Construct();
660         int loopCount = pIndexList->GetCount();
661
662         for (int i = 0; i < loopCount; ++i)
663         {
664                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
665                 if (pIndex != null)
666                 {
667                         checkedIndex = pIndex->ToInt();
668                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
669                 }
670         }
671
672         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
673         pDataList->Construct();
674         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
675         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
676
677         r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
678                         null, pDataList, null);
679
680         if (r == E_MAX_EXCEEDED)
681         {
682                 MessageBox messageBox;
683                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
684                                 MSGBOX_STYLE_NONE, 3000);
685                 int modalResult;
686                 messageBox.ShowAndWait(modalResult);
687         }
688         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
689
690         return r;
691 }
692
693 result
694 AllListEditorPanel::OnRequestEmail(void)
695 {
696         AppLogDebug("ENTER");
697         result r = E_SUCCESS;
698
699         IList* pIndexList = GetItemCheckedIndexListN();
700         if (pIndexList == null || pIndexList->GetCount() <= 0)
701         {
702                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
703
704                 return E_FAILURE;
705         }
706
707         Integer* pIndex = null;
708         int checkedIndex;
709         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
710         pArrayList->Construct();
711         int loopCount = pIndexList->GetCount();
712
713         for (int i = 0; i < loopCount; ++i)
714         {
715                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
716                 if (pIndex != null)
717                 {
718                         checkedIndex = pIndex->ToInt();
719                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
720                 }
721         }
722
723         const String uriData = APPCONTROL_URI_MAIL_TO;
724         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
725         pDataList->Construct();
726         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
727
728         r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
729                         &uriData, null, pDataList, null);
730
731         if (r == E_MAX_EXCEEDED)
732         {
733                 MessageBox messageBox;
734                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
735                                 MSGBOX_STYLE_NONE, 3000);
736                 int modalResult;
737                 messageBox.ShowAndWait(modalResult);
738         }
739
740         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
741
742         return r;
743 }
744
745 result
746 AllListEditorPanel::OnRequestSlideShow(void)
747 {
748         AppLogDebug("ENTER");
749         result r = E_SUCCESS;
750         IList* pIndexList = GetItemCheckedIndexListN();
751         if (pIndexList == null)
752         {
753                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
754                 return E_FAILURE;
755         }
756
757         Integer* pRealIndex = null;
758         int realIndex = -1;
759         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
760         pArrayList->Construct();
761         int loopCount = pIndexList->GetCount();
762
763         for (int i = 0; i < loopCount; ++i)
764         {
765                 pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
766                 if (pRealIndex != null)
767                 {
768                         realIndex = pRealIndex->ToInt();
769                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(realIndex)));
770                 }
771         }
772
773         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
774         pDataList->Construct();
775         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
776         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
777         const String mimeType = APPCONTROL_MIME_IMAGE_ALL;
778
779         r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
780                         &mimeType, pDataList, null);
781
782         if (r == E_MAX_EXCEEDED)
783         {
784                 MessageBox messageBox;
785                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
786                                 MSGBOX_STYLE_NONE, 3000);
787                 int modalResult;
788                 messageBox.ShowAndWait(modalResult);
789         }
790
791         delete pIndexList;
792         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
793
794         return r;
795 }
796
797 void
798 AllListEditorPanel::ResetSelection(void)
799 {
800         AppLogDebug("ENTER");
801         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
802         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
803         __pContentIconListView->UpdateList();
804
805         for (int index = 0; index < __itemCount; ++index)
806         {
807                 __pContentIconListView->SetItemChecked(index, false);
808                 __pContentIconListView->RefreshList(index,LIST_REFRESH_TYPE_ITEM_MODIFY);
809         }
810
811         String strTmp;
812         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
813
814         __pLabelSelectCnt->SetText(strTmp);
815         __pLabelSelectCnt->RequestRedraw(true);
816         SetButtonState();
817         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
818 }
819
820 void
821 AllListEditorPanel::SetButtonState(void)
822 {
823         AppLogDebug("ENTER");
824         SceneManager* pSceneManager = SceneManager::GetInstance();
825         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
826
827         if (GetItemCheckedCount() > 0)
828         {
829                 AppLogDebug("BUTTONSTATE : Request Enable");
830                 __pFileListEditorForm->SetFooterButtonsState(true);
831                 __pButtonSelectRegion->SetShowState(true);
832         }
833         else
834         {
835                 AppLogDebug("BUTTONSTATE : Request disable");
836                 __pFileListEditorForm->SetFooterButtonsState(false);
837                 __pButtonSelectRegion->SetShowState(false);
838         }
839         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
840 }
841
842 void
843 AllListEditorPanel::OnSelectAllPressed(void)
844 {
845         bool needToSelectAll = true;
846         int checkedCount = GetItemCheckedCount();
847         int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
848         if (checkedCount == totalFileCount)
849         {
850                 needToSelectAll = false;
851         }
852
853         if (needToSelectAll == true)
854         {
855                 for (int i = 0; i < totalFileCount; ++i)
856                 {
857                         if (__pContentIconListView->IsItemChecked(i) == false)
858                         {
859                                 __pContentIconListView->SetItemChecked(i,true);
860                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
861                         }
862                 }
863         }
864         else
865         {
866                 for (int i = 0; i < totalFileCount; ++i)
867                 {
868                         if (__pContentIconListView->IsItemChecked(i) == true)
869                         {
870                                 __pContentIconListView->SetItemChecked(i, false);
871                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
872                         }
873                 }
874         }
875
876         String tempString;
877         if (needToSelectAll == true)
878         {
879                 tempString.Format(LENGTH_COUNT_LABEL,
880                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
881         }
882         else
883         {
884                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
885         }
886
887         __pLabelSelectCnt->SetText(tempString);
888         __pLabelSelectCnt->RequestRedraw(true);
889         SetButtonState();
890 }
891
892 result
893 AllListEditorPanel::OnRequestRotate(RotateMode rotateMode)
894 {
895         AppLogDebug("ENTER");
896         IList* pIndexList = GetItemCheckedIndexListN();
897         if (pIndexList == null)
898         {
899                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
900                 return E_FAILURE;
901         }
902         else if (pIndexList->GetCount() <= 0)
903         {
904                 delete pIndexList;
905                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
906
907                 return E_FAILURE;
908         }
909
910         delete __pFileUpdateTimer;
911         __pFileUpdateTimer = new (std::nothrow) FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ACTION_ROTATE, rotateMode);
912         result r = __pFileUpdateTimer->StartTimer();
913
914         if (IsFailed(r))
915         {
916                 delete __pFileUpdateTimer;
917                 __pFileUpdateTimer = null;
918                 return E_FAILURE;
919         }
920         else
921         {
922                 __pPresentationModel->SetUpdateProgressStatus(true);
923         }
924         return E_SUCCESS;
925 }
926
927 void AllListEditorPanel::CancelUpdateProgress(void)
928 {
929         if (__pFileUpdateTimer!= null && __pFileUpdateTimer->IsStarted())
930         {
931                 __pFileUpdateTimer->Cancel();
932                 delete __pFileUpdateTimer;
933                 __pFileUpdateTimer = null;
934         }
935 }