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