Arrange code
[apps/osp/Gallery.git] / src / GlImageListEditorPanel.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                GlImageListEditorPanel.cpp
19  * @brief               This is the implementation file for ImageListEditorPanel class.
20  */
21
22 #include <FContent.h>
23 #include <FMedia.h>
24 #include "GlAlbumInfo.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListPresentationModel.h"
27 #include "GlGalleryApp.h"
28 #include "GlImageListEditorPanel.h"
29 #include "GlResourceManager.h"
30 #include "GlTypes.h"
31 #include "GlFileUpdateTimer.h"
32 #include "GlFileListEditorForm.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Content;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Media;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43
44 static const int H_SELECTALL_REGION = 112;
45 static const int COUNT_LABEL_FONT_SIZE = 33;
46 static const unsigned int COLOR_COUNT_LABEL = Color32<68, 68, 68>::Value;
47 static const unsigned int COLOR_SELECT_COUNT_FONT = Color32<255, 255, 255>::Value;
48 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
49 static const int H_COUNT_LABEL = 48;
50 static const int LENGTH_COUNT_LABEL = 256;
51 static const int ALPHA_THUMBNAIL_DIM = 70;
52 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
53
54 ImageListEditorPanel::ImageListEditorPanel(void)
55         : __itemCount(0)
56         , __pContentIconListView(null)
57         , __pCheckButton(null)
58         , __pLabelSelectCnt(null)
59         , __pPresentationModel(null)
60         , __pFileListEditorForm(null)
61 {
62         AppLogDebug("ENTER");
63         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
64 }
65
66 ImageListEditorPanel::~ImageListEditorPanel(void)
67 {
68         AppLogDebug("ENTER");
69         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
70 }
71
72 result
73 ImageListEditorPanel::Initialize(void)
74 {
75         AppLogDebug("ENTER");
76         result r = Construct(RECT_INITIAL);
77         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
78
79         return r;
80 }
81
82 result
83 ImageListEditorPanel::OnInitializing(void)
84 {
85         AppLogDebug("ENTER");
86         const Form* pForm = dynamic_cast<Form*>(GetParent());
87         TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
88
89         __pPresentationModel = FileListPresentationModel::GetInstance();
90         __pPresentationModel->ClearThumbnailRequests();
91         __pPresentationModel->AddPresentationModelListener(this);
92         __itemCount = 0;
93
94         Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
95         SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
96
97         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
98         {
99                 __pContentIconListView = new (std::nothrow) IconListView();
100
101                 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
102                 {
103                         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height - H_COUNT_LABEL),
104                                         DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_MARK,
105                                         ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
106                         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
107                         if (pBitmapEmpty != null)
108                         {
109                                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
110                                 delete pBitmapEmpty;
111                         }
112                         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
113                         __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
114                         __pContentIconListView->SetItemProvider(*this);
115                         __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
116                         __pContentIconListView->AddIconListViewItemEventListener(*this);
117                         __pContentIconListView->SetTouchAnimationEnabled(false);
118                         AddControl(__pContentIconListView);
119                         __pContentIconListView->SetShowState(true);
120
121                         __pLabelSelectCnt = new (std::nothrow) Label();
122                         __pLabelSelectCnt->Construct(Rectangle(0, clientAreaBounds.height - H_COUNT_LABEL,
123                                         clientAreaBounds.width, H_COUNT_LABEL), ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
124                         __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
125                         __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
126                         __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
127                         __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
128                         __pLabelSelectCnt->SetTextConfig(COUNT_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
129                         AddControl(__pLabelSelectCnt);
130                 }
131                 else
132                 {
133                         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height),
134                                         DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL,
135                                         ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
136                         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
137                         if (pBitmapEmpty != null)
138                         {
139                                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
140                                 delete pBitmapEmpty;
141                         }
142                         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
143                         __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
144                         __pContentIconListView->SetItemProvider(*this);
145                         __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
146                         __pContentIconListView->AddIconListViewItemEventListener(*this);
147                         __pContentIconListView->SetTouchAnimationEnabled(false);
148                         AddControl(__pContentIconListView);
149                         __pContentIconListView->SetShowState(true);
150                 }
151         }
152         else
153         {
154                 __pContentIconListView = new (std::nothrow) IconListView();
155                 __pContentIconListView->Construct(Rectangle(0, H_SELECTALL_REGION, clientAreaBounds.width,
156                                 clientAreaBounds.height - H_SELECTALL_REGION), DIMENSION_DEFAULT_THUMBNAIL,
157                                 ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
158                 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
159                 if (pBitmapEmpty != null)
160                 {
161                         __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
162                         delete pBitmapEmpty;
163                 }
164                 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
165                 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
166                 __pContentIconListView->SetItemProvider(*this);
167                 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
168                 __pContentIconListView->AddIconListViewItemEventListener(*this);
169                 __pContentIconListView->SetTouchAnimationEnabled(false);
170                 AddControl(__pContentIconListView);
171                 __pContentIconListView->SetShowState(true);
172
173                 __pLabelSelectCnt = new (std::nothrow) Label();
174                 __pLabelSelectCnt->Construct(
175                                 Rectangle(0, clientAreaBounds.height - H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL),
176                                 ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
177                 __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
178                 __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
179                 __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
180                 __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
181                 AddControl(__pLabelSelectCnt);
182         }
183         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
184
185         return E_SUCCESS;
186 }
187
188 result
189 ImageListEditorPanel::OnTerminating(void)
190 {
191         AppLogDebug("ENTER");
192         __pPresentationModel->RemovePresentationModelListener(*this);
193         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
194
195         return E_SUCCESS;
196 }
197
198 int
199 ImageListEditorPanel::GetItemCount(void)
200 {
201         AppLogDebug("ENTER");
202         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
203
204         return __itemCount;
205 }
206
207 IconListViewItem*
208 ImageListEditorPanel::CreateItem(int index)
209 {
210         AppLogDebug("ENTER : index(%d)", index);
211         IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
212         Bitmap* pBitmap = null;
213         String* pItemText = null;
214
215         result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
216         if (pBitmap == null || r == E_FAILURE)
217         {
218                 __pPresentationModel->RequestThumbnail(index);
219                 pBitmap = CommonUtil::GetEmptyThumbnailN();
220         }
221
222         if (pItemText == null)
223         {
224                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
225         }
226         else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
227         {
228                 delete pItemText;
229                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
230         }
231
232         if (__pContentIconListView->IsItemChecked(index) == true)
233         {
234                 if (pBitmap != null)
235                 {
236                         BufferInfo bufferInfo;
237                         pBitmap->Lock(bufferInfo, INFINITE);
238                         pBitmap->Unlock();
239                         Color dimColor(COLOR_THUMBNAIL_DIM);
240                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
241
242                         Canvas canvas;
243                         canvas.Construct(bufferInfo);
244                         canvas.FillRectangle(dimColor, canvas.GetBounds());
245
246                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
247                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
248                         pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
249                         delete pSelectedBitmap;
250                 }
251                 else
252                 {
253                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
254                         delete pIconListviewItem;
255                         delete pItemText;
256                         return null;
257                 }
258         }
259         else
260         {
261                 pIconListviewItem->Construct(*pBitmap, pItemText);
262         }
263
264         if (pBitmap != null)
265         {
266                 delete pBitmap;
267         }
268         if (pItemText != null)
269         {
270                 delete pItemText;
271         }
272         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
273
274         return pIconListviewItem;
275 }
276
277 bool
278 ImageListEditorPanel::DeleteItem(int index, IconListViewItem* pItem)
279 {
280         AppLogDebug("ENTER");
281         delete pItem;
282         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
283
284         return true;
285 }
286
287 void
288 ImageListEditorPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
289 {
290         AppLogDebug("ENTER");
291
292         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
293         {
294                 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
295                 {
296                         if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
297                         {
298                                 int checkedCount = GetItemCheckedCount();
299                                 String strTmp;
300                                 if (checkedCount == 0)
301                                 {
302                                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
303                                 }
304                                 else if (checkedCount == 1)
305                                 {
306                                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
307                                 }
308                                 else
309                                 {
310                                         strTmp.Format(LENGTH_COUNT_LABEL,
311                                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
312                                 }
313
314                                 __pLabelSelectCnt->SetText(strTmp);
315                                 __pLabelSelectCnt->RequestRedraw(true);
316                                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
317                         }
318                 }
319                 else
320                 {
321                         int checkedCount = GetItemCheckedCount();
322                         String strTmp;
323                         if (checkedCount == 0)
324                         {
325                                 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
326                         }
327                         else if (checkedCount == 1)
328                         {
329                                 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
330                         }
331                         else
332                         {
333                                 strTmp.Format(LENGTH_COUNT_LABEL,
334                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
335                         }
336
337                         __pLabelSelectCnt->SetText(strTmp);
338                         __pLabelSelectCnt->RequestRedraw(true);
339                         if (__pCheckButton->IsSelected())
340                         {
341                                 __pCheckButton->SetSelected(false);
342                         }
343                         __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
344                 }
345         }
346
347         if (    __pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
348                 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE)
349         {
350                 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
351                 {
352                         HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
353                         result r = pMap->Construct();
354                         if (r == E_SUCCESS)
355                         {
356                                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
357                                 r = pArrayList->Construct();
358
359                                 if (r == E_SUCCESS)
360                                 {
361                                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
362                                         pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
363
364                                         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
365                                         if (pApp != null)
366                                         {
367                                                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
368                                                 pApp->Terminate();
369                                         }
370                                         else
371                                         {
372                                                 delete pMap;
373                                         }
374                                 }
375                                 else
376                                 {
377                                         delete pArrayList;
378                                         delete pMap;
379                                 }
380                         }
381                         else
382                         {
383                                 delete pMap;
384                         }
385                 }
386         }
387         SetButtonState();
388
389         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
390 }
391
392 void
393 ImageListEditorPanel::OnFileInfoChanged(const ContentType contentType)
394 {
395         AppLogDebug("ENTER");
396         if (contentType == CONTENT_TYPE_IMAGE)
397         {
398                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_IMAGE);
399                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
400                 __pContentIconListView->UpdateList();
401         }
402         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
403 }
404
405 void
406 ImageListEditorPanel::OnThumbnailDecoded(const int index)
407 {
408         AppLogDebug("ENTER : index(%d)",index);
409         if (index >= 0)
410         {
411                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
412         }
413         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
414 }
415
416 void
417 ImageListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
418                                                                 const SceneId& currentSceneId, IList* pArgs)
419 {
420         AppLogDebug("ENTER");
421
422         ChangeOrientation();
423
424         SceneManager* pSceneManager = SceneManager::GetInstance();
425         __pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
426
427         __pPresentationModel = FileListPresentationModel::GetInstance();
428
429         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
430         {
431                 if (currentSceneId == IDSCN_IMAGE_LIST_EDITOR)
432                 {
433                         if (previousSceneId == IDSCN_ALBUM_LIST)
434                         {
435                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
436                                 if (pAlbumInfo == null)
437                                 {
438                                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
439
440                                         return;
441                                 }
442
443                                 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
444                                 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
445
446                                 if (pDirectoryList != null)
447                                 {
448                                         delete pDirectoryList;
449                                 }
450                                 delete pArgs;
451
452                                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
453                                 __pContentIconListView->UpdateList();
454                         }
455                 }
456         }
457         else
458         {
459                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
460                 __pContentIconListView->RequestRedraw(true);
461         }
462         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
463 }
464
465 void
466 ImageListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId,
467                                                                 const SceneId& nextSceneId)
468 {
469         AppLogDebug("ENTER");
470         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
471 }
472
473 int
474 ImageListEditorPanel::GetItemCheckedCount(void) const
475 {
476         AppLogDebug("ENTER");
477         int count = 0;
478         if (__pContentIconListView != null)
479         {
480                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
481                 for (int i = 0; i < loopCount; ++i)
482                 {
483                         if (__pContentIconListView->IsItemChecked(i))
484                         {
485                                 ++count;
486                         }
487                 }
488         }
489         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
490
491         return count;
492 }
493
494 IList*
495 ImageListEditorPanel::GetItemCheckedIndexListN(void) const
496 {
497         AppLogDebug("ENTER");
498         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
499         Integer* pIndex = null;
500
501         if (__pContentIconListView != null)
502         {
503                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
504                 AppLogDebug("ENTER loopCount(%d)", loopCount);
505                 for (int i = 0; i < loopCount; ++i)
506                 {
507                         if (__pContentIconListView->IsItemChecked(i))
508                         {
509                                 pIndex = new (std::nothrow) Integer(i);
510                                 AppLogDebug("ENTER loopCount(%d)", loopCount);
511                                 AppLogDebug("ENTER loopCount(%d)", pIndex->ToInt());
512                                 pList->Add(pIndex);
513                         }
514                 }
515         }
516         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
517
518         return pList;
519 }
520
521 void ImageListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
522 {
523         SceneManager* pSceneManager = SceneManager::GetInstance();
524         FileListEditorForm* pFileListEditorForm =
525                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
526         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
527                         GetErrorMessage(GetLastResult()));
528         pFileListEditorForm->Invalidate(true);
529 }
530
531 void ImageListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
532 {
533 }
534
535 void
536 ImageListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void)
537 {
538         AppLogDebug("ENTER");
539         IList* pIndexList = GetItemCheckedIndexListN();
540
541         if (pIndexList->GetCount() <= 0)
542         {
543                 delete pIndexList;
544                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
545                 return;
546         }
547
548         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
549         pArrayList->Construct();
550         int loopCount = pIndexList->GetCount();
551         Integer* pTemp = null;
552         for (int i = 0; i < loopCount; ++i)
553         {
554                 pTemp = static_cast<Integer*>(pIndexList->GetAt(i));
555                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(pTemp->ToInt())));
556         }
557
558         HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
559         pMap->Construct();
560         pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), pArrayList);
561
562         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
563         if (pApp != null)
564         {
565                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
566                 pApp->Terminate();
567         }
568
569         delete pIndexList;
570         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
571 }
572
573 void
574 ImageListEditorPanel::OnSelectAllPressed(void)
575 {
576         bool needToSelectAll = true;
577         int checkedCount = GetItemCheckedCount();
578         int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
579         if (checkedCount == totalFileCount)
580         {
581                 needToSelectAll = false;
582         }
583
584         if (needToSelectAll == true)
585         {
586                 for (int i = 0; i < totalFileCount; ++i)
587                 {
588                         if (__pContentIconListView->IsItemChecked(i) == false)
589                         {
590                                 __pContentIconListView->SetItemChecked(i, true);
591                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
592                         }
593                         __pFileListEditorForm->SetFooterButtonsState(true);
594                 }
595         }
596         else
597         {
598                 for (int i = 0; i < totalFileCount; ++i)
599                 {
600                         if (__pContentIconListView->IsItemChecked(i) == true)
601                         {
602                                 __pContentIconListView->SetItemChecked(i, false);
603                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
604                         }
605                         __pFileListEditorForm->SetFooterButtonsState(false);
606                 }
607         }
608
609         String tempString;
610         if (needToSelectAll == true)
611         {
612                 tempString.Format(LENGTH_COUNT_LABEL,
613                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
614         }
615         else
616         {
617                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
618         }
619
620         __pLabelSelectCnt->SetText(tempString);
621         __pLabelSelectCnt->RequestRedraw(true);
622 }
623
624 void
625 ImageListEditorPanel::SetButtonState(void)
626 {
627         AppLogDebug("ENTER");
628         SceneManager* pSceneManager = SceneManager::GetInstance();
629         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
630
631         if (GetItemCheckedCount() > 0)
632         {
633                 AppLogDebug("BUTTONSTATE : Request Enable");
634                 __pFileListEditorForm->SetFooterButtonsState(true);
635         }
636         else
637         {
638                 AppLogDebug("BUTTONSTATE : Request disable");
639                 __pFileListEditorForm->SetFooterButtonsState(false);
640         }
641         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
642 }
643
644 void
645 ImageListEditorPanel::ChangeOrientation(void)
646 {
647         AppLogDebug("ENTER");
648         SceneManager* pSceneManager = SceneManager::GetInstance();
649         const Form* pForm = dynamic_cast<Form*>(pSceneManager->GetCurrentScene()->GetForm());
650         TryReturn(pForm != null,, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
651
652         Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
653         SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
654         if (__pLabelSelectCnt != NULL)
655         {
656         __pLabelSelectCnt->SetBounds(0, clientAreaBounds.height - H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL);
657         }
658         __pContentIconListView->SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height -H_COUNT_LABEL);
659 }