Modify Select all button in FileListForm
[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.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
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 <FMedia.h>
24 #include "GlAllListEditorPanel.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListEditorForm.h"
27 #include "GlFileListPresentationModel.h"
28 #include "GlResourceManager.h"
29 #include "GlTypes.h"
30 #include "GlFileDeleteTimer.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::Content;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Media;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
41
42 static const int H_COUNT_LABEL = 48;
43 static const int H_COUNT_LABEL_BUTTON = 42;
44 static const int W_COUNT_LABEL_BUTTON = 42;
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         : __pContentIconListView(null)
60         , __pLabelSelectCnt(null)
61         , __pButtonSelectRegion(null)
62         , __itemCount(0)
63         , __deleteInProgress(false)
64         , __pPresentationModel(null)
65         , __pFileDelete(null)
66 {
67         AppLogDebug("ENTER");
68         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
69 }
70
71 AllListEditorPanel::~AllListEditorPanel(void)
72 {
73         AppLogDebug("ENTER");
74         delete __pFileDelete;
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         AddControl(*__pLabelSelectCnt);
134         __pLabelSelectCnt->Invalidate(true);
135
136         __pButtonSelectRegion = new (std::nothrow) Button();
137         __pButtonSelectRegion->Construct(Rectangle(clientAreaBounds.width - W_COUNT_LABEL_BUTTON - 10,
138                         clientAreaBounds.height - H_COUNT_LABEL_BUTTON - 4, W_COUNT_LABEL_BUTTON, H_COUNT_LABEL_BUTTON),
139                         EMPTY_SPACE);
140         __pButtonSelectRegion->SetActionId(ACTION_ID_BUTTON_MOVE_TO_SELECTION);
141         __pButtonSelectRegion->SetColor(BUTTON_STATUS_NORMAL, COLOR_COUNT_LABEL_BUTTON);
142         Bitmap* pSelectionBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MOVE_SELECTION);
143         if (pSelectionBitmap != null)
144         {
145                 Rectangle buttonRegionRect = __pButtonSelectRegion->GetBounds();
146                 pSelectionBitmap->Scale(Dimension(buttonRegionRect.width, buttonRegionRect.height));
147                 __pButtonSelectRegion->SetNormalBitmap(Point(buttonRegionRect.width, buttonRegionRect.height),
148                                 *pSelectionBitmap);
149         }
150         AddControl(*__pButtonSelectRegion);
151
152         if (pSelectionBitmap != null)
153         {
154                 delete pSelectionBitmap;
155         }
156         __pButtonSelectRegion->AddActionEventListener(*this);
157
158         __itemCount = 0;
159         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
160
161         return E_SUCCESS;
162 }
163
164 result
165 AllListEditorPanel::OnTerminating(void)
166 {
167         AppLogDebug("ENTER");
168         __pPresentationModel->RemovePresentationModelListener(*this);
169         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
170
171         return E_SUCCESS;
172 }
173
174 void
175 AllListEditorPanel::UpdatePanelContent()
176 {
177         AppLogDebug("ENTER");
178         SceneManager* pSceneManager = SceneManager::GetInstance();
179         FileListEditorForm* pFileListEditorForm =
180                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
181         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
182                         GetErrorMessage(GetLastResult()));
183
184         if (pFileListEditorForm->GetOverlayStatus() == false && __deleteInProgress == false)
185         {
186                 SceneManager* pSceneManager = SceneManager::GetInstance();
187                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
188                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
189         }
190 }
191
192 void
193 AllListEditorPanel::OnActionPerformed(const Control& source, int actionId)
194 {
195         AppLogDebug("ENTER");
196         SceneManager* pSceneManager = SceneManager::GetInstance();
197         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
198
199         switch (actionId)
200         {
201         case ACTION_ID_BUTTON_CHECKED:
202         {
203                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
204                 for (int i=0 ; i < loopCount; ++i)
205                 {
206                         if (__pContentIconListView->IsItemChecked(i) == false)
207                         {
208                                 __pContentIconListView->SetItemChecked(i,true);
209                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
210                         }
211                 }
212                 int checkedCount = GetItemCheckedCount();
213                 String strTmp;
214
215                 if (checkedCount == 0)
216                 {
217                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
218                 }
219                 else if (checkedCount == 1)
220                 {
221                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
222                 }
223                 else
224                 {
225                         strTmp.Format(LENGTH_COUNT_LABEL,
226                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
227                 }
228
229                 __pLabelSelectCnt->SetText(strTmp);
230                 __pLabelSelectCnt->RequestRedraw(true);
231                 SetButtonState();
232                 break;
233         }
234         case ACTION_ID_BUTTON_UNCHECKED:
235         {
236                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
237                 for (int i = 0; i < loopCount; ++i)
238                 {
239                         if (__pContentIconListView->IsItemChecked(i) == true)
240                         {
241                                 __pContentIconListView->SetItemChecked(i,false);
242                         }
243                 }
244                 int checkedCount = GetItemCheckedCount();
245                 String strTmp;
246
247                 if (checkedCount == 0)
248                 {
249                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
250                 }
251                 else if (checkedCount == 1)
252                 {
253                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
254                 }
255                 else
256                 {
257                         strTmp.Format(LENGTH_COUNT_LABEL,
258                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
259                 }
260
261                 __pLabelSelectCnt->SetText(strTmp);
262                 __pLabelSelectCnt->RequestRedraw(true);
263                 __pContentIconListView->UpdateList();
264                 SetButtonState();
265                 break;
266         }
267         case ACTION_ID_BUTTON_MOVE_TO_SELECTION:
268         {
269                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
270                 {
271                         IList* pList = GetItemCheckedIndexListN();
272                         if (pList == null)
273                         {
274                                 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
275                         }
276                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_SELECTION), pList);
277                 }
278                 else
279                 {
280                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_SELECTION));
281                 }
282                 break;
283         }
284         default:
285         {
286                 break;
287         }
288         }
289         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
290 }
291
292 int
293 AllListEditorPanel::GetItemCount(void)
294 {
295         AppLogDebug("ENTER");
296         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
297
298         return __itemCount;
299 }
300
301 IconListViewItem*
302 AllListEditorPanel::CreateItem(int index)
303 {
304         AppLogDebug("ENTER : index(%d)", index);
305         IconListViewItem* pIconListviewItem;
306         Bitmap* pBitmap = null;
307         String* pItemText = null;
308         result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
309         if (pBitmap == null || r == E_FAILURE)
310         {
311                 __pPresentationModel->RequestThumbnail(index);
312                 pBitmap = CommonUtil::GetEmptyThumbnailN();
313         }
314
315         if (pItemText == null)
316         {
317                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
318         }
319         else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
320         {
321                 delete pItemText;
322                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
323         }
324
325         if (__pContentIconListView->IsItemChecked(index) == true)
326         {
327                 if (pBitmap != null)
328                 {
329                         BufferInfo bufferInfo;
330                         pBitmap->Lock(bufferInfo, INFINITE);
331                         pBitmap->Unlock();
332                         Color dimColor(COLOR_THUMBNAIL_DIM);
333                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
334
335                         Canvas canvas;
336                         canvas.Construct(bufferInfo);
337                         canvas.FillRectangle(dimColor, canvas.GetBounds());
338
339                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
340                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
341                         pIconListviewItem = new (std::nothrow) IconListViewItem();
342                         pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
343                         delete pSelectedBitmap;
344                 }
345                 else
346                 {
347                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
348                         return null;
349                 }
350         }
351         else
352         {
353                 pIconListviewItem = new (std::nothrow) IconListViewItem();
354                 pIconListviewItem->Construct(*pBitmap, pItemText);
355         }
356
357         if (pBitmap != null)
358         {
359                 delete pBitmap;
360         }
361         if (pItemText != null)
362         {
363                 delete pItemText;
364         }
365         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
366
367         return pIconListviewItem;
368 }
369
370 bool
371 AllListEditorPanel::DeleteItem(int index, IconListViewItem* pItem)
372 {
373         AppLogDebug("ENTER");
374         delete pItem;
375         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
376
377         return true;
378 }
379
380 void
381 AllListEditorPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
382 {
383         AppLogDebug("ENTER");
384         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
385         {
386                 int checkedCount = GetItemCheckedCount();
387                 String strTmp;
388
389                 if (checkedCount == 0)
390                 {
391                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
392                 }
393                 else if (checkedCount == 1)
394                 {
395                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
396                 }
397                 else
398                 {
399                         strTmp.Format(LENGTH_COUNT_LABEL,
400                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
401                 }
402
403                 __pLabelSelectCnt->SetText(strTmp);
404                 __pLabelSelectCnt->RequestRedraw(true);
405                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
406         }
407         SetButtonState();
408         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
409 }
410
411 void
412 AllListEditorPanel::OnFileInfoChanged(const ContentType contentType)
413 {
414         AppLogDebug("ENTER");
415         if (contentType == CONTENT_TYPE_ALL
416                 || contentType == CONTENT_TYPE_IMAGE
417                 || contentType == CONTENT_TYPE_VIDEO)
418         {
419                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
420                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
421                 __pContentIconListView->UpdateList();
422         }
423         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
424 }
425
426 void
427 AllListEditorPanel::OnThumbnailDecoded(const int index)
428 {
429         AppLogDebug("ENTER : index(%d)", index);
430         if (index >= 0)
431         {
432                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
433         }
434         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
435 }
436
437 void
438 AllListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
439                                                                 const SceneId& currentSceneId, IList* pArgs)
440 {
441         AppLogDebug("ENTER");
442         __pPresentationModel = FileListPresentationModel::GetInstance();
443
444         SceneManager* pSceneManager = SceneManager::GetInstance();
445         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
446
447         if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
448         {
449                 ResetSelection();
450                 if (pArgs != null && pArgs->GetCount() > 0)
451                 {
452                         IList* pSeletedIndexList = pArgs;
453                         int loopCount = pSeletedIndexList->GetCount();
454                         for (int i = 0; i < loopCount; ++i)
455                         {
456                                 int index = static_cast<Integer*>(pSeletedIndexList->GetAt(i))->ToInt();
457                                 __pContentIconListView->SetItemChecked(index, true);
458                         }
459                         __pContentIconListView->RequestRedraw(true);
460                 }
461         }
462         else if (previousSceneId == IDSCN_ALL_LIST)
463         {
464                 ResetSelection();
465         }
466
467         SetButtonState();
468
469         FileListEditorForm* pFileListEditorForm =
470                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
471         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
472                         GetErrorMessage(GetLastResult()));
473
474         pFileListEditorForm->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
475         
476         if (pArgs != null && pArgs->GetCount() > 0 && previousSceneId != IDSCN_ALL_LIST_SELECTION)
477         {
478                 String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
479                 if (pDirectory != null && pDirectory->GetLength() > 0)
480                 {
481                         pFileListEditorForm->MoveToAlbum(*pDirectory);
482                 }
483         }
484
485         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
486 }
487
488 void
489 AllListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
490 {
491         AppLogDebug("ENTER");
492         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
493 }
494
495 int
496 AllListEditorPanel::GetItemCheckedCount(void) const
497 {
498         AppLogDebug("ENTER");
499         int count = 0;
500         if (__pContentIconListView != null)
501         {
502                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
503                 for (int i = 0; i < loopCount; ++i)
504                 {
505                         if (__pContentIconListView->IsItemChecked(i))
506                         {
507                                 ++count;
508                         }
509                 }
510         }
511         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
512
513         return count;
514 }
515
516 IList*
517 AllListEditorPanel::GetItemCheckedIndexListN(void) const
518 {
519         AppLogDebug("ENTER");
520         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
521         Integer* pIndex = null;
522
523         if (__pContentIconListView!=null)
524         {
525                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
526                 for (int i = 0; i < loopCount; ++i)
527                 {
528                         if (__pContentIconListView->IsItemChecked(i) == true)
529                         {
530                                 pIndex = new (std::nothrow) Integer(i);
531                                 pList->Add(pIndex);
532                                 AppLogDebug("checked index(%d)", i);
533                         }
534                 }
535         }
536         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
537
538         return pList;
539 }
540
541 result
542 AllListEditorPanel::OnRequestDelete(void)
543 {
544         AppLogDebug("ENTER");
545         IList* pIndexList = GetItemCheckedIndexListN();
546         if (pIndexList->GetCount() <= 0)
547         {
548                 delete pIndexList;
549                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
550
551                 return E_FAILURE;
552         }
553
554         delete __pFileDelete;
555         __pFileDelete = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
556         result r = __pFileDelete->StartTimer();
557
558         if (IsFailed(r))
559         {
560                 delete __pFileDelete;
561                 __pFileDelete = null;
562                 return E_FAILURE;
563         }
564         else
565         {
566                 __deleteInProgress = true;
567         }
568         return E_SUCCESS;
569 }
570
571 void AllListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
572 {
573         SceneManager* pSceneManager = SceneManager::GetInstance();
574         FileListEditorForm* pFileListEditorForm =
575                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
576         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
577                         GetErrorMessage(GetLastResult()));
578         pFileListEditorForm->Invalidate(true);
579 }
580
581 void AllListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
582 {
583         __deleteInProgress = false;     
584
585         __pLabelSelectCnt->SetText(ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
586         __pLabelSelectCnt->RequestRedraw(true);
587
588         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
589         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
590         __pContentIconListView->UpdateList();
591
592         SceneManager* pSceneManager = SceneManager::GetInstance();
593         if (GetItemCount() > 0)
594         {
595                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
596         }
597         else
598         {
599                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
600         }
601         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
602 }
603
604 result
605 AllListEditorPanel::OnRequestMessage(void)
606 {
607         AppLogDebug("ENTER");
608         IList* pIndexList = GetItemCheckedIndexListN();
609         if (pIndexList == null || pIndexList->GetCount() <= 0)
610         {
611                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
612
613                 return E_FAILURE;
614         }
615
616         String combineText;
617         String path;
618         Integer* pIndex = null;
619         int checkedIndex;
620
621         int loopCount = pIndexList->GetCount();
622         AppLogDebug("pIndexList->GetCount(%d)", loopCount);
623         for (int i = 0; i < loopCount; ++i)
624         {
625                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
626                 if (pIndex != null)
627                 {
628                         checkedIndex = pIndex->ToInt();
629                         path = __pPresentationModel->GetContentFilePath(checkedIndex);
630                 }
631
632                 if (combineText.CompareTo(EMPTY_SPACE) != 0)
633                 {
634                         combineText.Append(L";");
635                 }
636                 combineText.Append(path);
637         }
638
639         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
640         pDataList->Construct();
641         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
642         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
643
644         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
645                         pDataList, null);
646         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
647
648         return E_SUCCESS;
649 }
650
651 result
652 AllListEditorPanel::OnRequestEmail(void)
653 {
654         AppLogDebug("ENTER");
655         IList* pIndexList = GetItemCheckedIndexListN();
656         if (pIndexList == null || pIndexList->GetCount() <= 0)
657         {
658                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
659
660                 return E_FAILURE;
661         }
662
663         String combineText;
664         String path;
665         Integer* pIndex = null;
666         int checkedIndex;
667
668         int loopCount = pIndexList->GetCount();
669         AppLogDebug("pIndexList->GetCount(%d)", loopCount);
670         for (int i = 0; i < loopCount; ++i)
671         {
672                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
673                 if (pIndex != null)
674                 {
675                         checkedIndex = pIndex->ToInt();
676                         path = __pPresentationModel->GetContentFilePath(checkedIndex);
677                 }
678
679                 if (combineText.CompareTo(EMPTY_SPACE) != 0)
680                 {
681                         combineText.Append(L";");
682                 }
683                 combineText.Append(path);
684         }
685
686         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
687         pDataList->Construct();
688         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
689
690         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
691                         pDataList, null);
692         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
693
694         return E_SUCCESS;
695 }
696
697 result
698 AllListEditorPanel::OnRequestSlideShow(void)
699 {
700         AppLogDebug("ENTER");
701         IList* pIndexList = GetItemCheckedIndexListN();
702         if (pIndexList == null)
703         {
704                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
705
706                 return E_FAILURE;
707         }
708
709         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
710         result r = pDataList->Construct();
711         if (r != E_SUCCESS)
712         {
713                 delete pDataList;
714                 delete pIndexList;
715                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
716
717                 return E_FAILURE;
718         }
719
720         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),
721                         new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
722
723         Integer* pRealIndex = null;
724         int realIndex = -1;
725         String combineText;
726         String path;
727
728         int loopCount = pIndexList->GetCount();
729         if (loopCount > 0)
730         {
731                 for (int i = 0; i < loopCount; ++i)
732                 {
733                         pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
734                         if (pRealIndex != null)
735                         {
736                                 realIndex = pRealIndex->ToInt();
737                         }
738
739                         path = __pPresentationModel->GetContentFilePath(realIndex);
740                         if (combineText.CompareTo(EMPTY_SPACE) != 0)
741                         {
742                                 combineText.Append(L";");
743                         }
744                         combineText.Append(path);
745                 }
746                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), new (std::nothrow) String(combineText));
747         }
748
749         delete pIndexList;
750
751         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE,
752                         APPCONTROL_OPERATION_ID_VIEW, pDataList, null);
753         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
754
755         return E_SUCCESS;
756 }
757
758 void
759 AllListEditorPanel::ResetSelection(void)
760 {
761         AppLogDebug("ENTER");
762         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
763         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
764         __pContentIconListView->UpdateList();
765
766         int checkedCount = GetItemCheckedCount();
767         String strTmp;
768
769         if (checkedCount == 0)
770         {
771                 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
772         }
773         else if (checkedCount == 1)
774         {
775                 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
776         }
777         else
778         {
779                 strTmp.Format(LENGTH_COUNT_LABEL,
780                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
781         }
782
783         __pLabelSelectCnt->SetText(strTmp);
784         __pLabelSelectCnt->RequestRedraw(true);
785         SetButtonState();
786         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
787 }
788
789 void
790 AllListEditorPanel::SetButtonState(void)
791 {
792         AppLogDebug("ENTER");
793         SceneManager* pSceneManager = SceneManager::GetInstance();
794         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
795
796         FileListEditorForm* pFileListEditorForm =
797                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
798         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
799                         GetErrorMessage(GetLastResult()));
800
801         if (GetItemCheckedCount() > 0)
802         {
803                 AppLogDebug("BUTTONSTATE : Request Enable");
804                 pFileListEditorForm->SetFooterButtonsState(true);
805                 __pButtonSelectRegion->SetShowState(true);
806         }
807         else
808         {
809                 AppLogDebug("BUTTONSTATE : Request disable");
810                 pFileListEditorForm->SetFooterButtonsState(false);
811                 __pButtonSelectRegion->SetShowState(false);
812         }
813         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
814 }
815
816 void
817 AllListEditorPanel::SelectAllPressed(void)
818 {
819         bool needToSelectAll = true;
820         int checkedCount = GetItemCheckedCount();
821         int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
822         if (checkedCount == totalFileCount)
823         {
824                 needToSelectAll = false;
825         }
826
827         if (needToSelectAll == true)
828         {
829                 for (int i = 0 ; i < totalFileCount; ++i)
830                 {
831                         if (__pContentIconListView->IsItemChecked(i) == false)
832                         {
833                                 __pContentIconListView->SetItemChecked(i,true);
834                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
835                         }
836                 }
837         }
838         else
839         {
840                 for (int i = 0 ; i < totalFileCount; ++i)
841                 {
842                         if (__pContentIconListView->IsItemChecked(i) == true)
843                         {
844                                 __pContentIconListView->SetItemChecked(i, false);
845                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
846                         }
847                 }
848         }
849
850         String tempString;
851         if (needToSelectAll == true)
852         {
853                 tempString.Format(LENGTH_COUNT_LABEL,
854                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
855         }
856         else
857         {
858                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
859         }
860
861         __pLabelSelectCnt->SetText(tempString);
862         __pLabelSelectCnt->RequestRedraw(true);
863         SetButtonState();
864 }