merge with master
[apps/osp/Gallery.git] / src / GlFileListEditorForm.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                GlFileListEditorForm.cpp
19  * @brief               This is the implementation file for FileListEditorForm class.
20  */
21
22 #include "GlAllListEditorPanel.h"
23 #include "GlAllListSelectionPanel.h"
24 #include "GlFileListEditorForm.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlImageListEditorPanel.h"
28 #include "GlResourceManager.h"
29 #include "GlTypes.h"
30 #include "GlVideoListEditorPanel.h"
31 #include "GlFileMoveTimer.h"
32
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::Ui;
40 using namespace Tizen::Ui::Controls;
41 using namespace Tizen::Ui::Scenes;
42 using namespace Tizen::Base::Utility;
43
44 static const int GAP_W_POPUP_ITEM = 5;
45 static const int W_DELETE_POPUP = 600;
46 static const int H_DELETE_POPUP = 300;
47 static const int H_DELETE_LABEL = 180;
48 static const int Y_DELETE_BUTTON = 180;
49 static const int H_DELETE_BUTTON = 80;
50
51 FileListEditorForm::FileListEditorForm(void)
52         : __pContextMenuMore(null)
53         , __pContextMenuShare(null)
54         , __pContextEditorMenuMove(null)
55         , __pContextSelectionMenuMove(null)
56         , __pDeletePopup(null)
57         , __morePosition(Point(0, 0))
58         , __pContentDirectoryList(null)
59         , __pContentDirectoryNameList(null)
60         , __pPresentationModel(null)
61         , __pFileMove(null)
62         ,__moveInProgress(false)
63 {
64         AppLogDebug("ENTER");
65         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
66 }
67
68 FileListEditorForm::~FileListEditorForm(void)
69 {
70         AppLogDebug("ENTER");
71         if (__pContentDirectoryList != null)
72         {
73                 delete __pContentDirectoryList;
74         }
75         if (__pContentDirectoryNameList != null)
76         {
77                 delete __pContentDirectoryNameList;
78         }
79         delete __pFileMove;
80         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
81 }
82
83 result
84 FileListEditorForm::Initialize(void)
85 {
86         AppLogDebug("ENTER");
87         result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
88         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
89
90         return r;
91 }
92 result
93 FileListEditorForm::OnInitializing(void)
94 {
95         AppLogDebug("ENTER");
96         Header* pHeader = GetHeader();
97         TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
98
99         __pPresentationModel = FileListPresentationModel::GetInstance();
100         __pPresentationModel->ClearThumbnailRequests();
101
102         pHeader->SetStyle(HEADER_STYLE_TITLE);
103         pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
104         pHeader->AddActionEventListener(*this);
105
106         InitializeFooter();
107         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
108
109         return E_SUCCESS;
110 }
111
112 result
113 FileListEditorForm::InitializeFooter(void)
114 {
115         AppLogDebug("ENTER");
116         Footer* pFooter = GetFooter();
117         TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
118         pFooter->RemoveAllItems();
119
120         result r = E_SUCCESS;
121
122         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
123         {
124                 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
125                 {
126                         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
127
128                         FooterItem footerConfirm;
129                         r = footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
130                         TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
131                         footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_POP_DONE"));
132                         r = pFooter->AddItem(footerConfirm);
133                         TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
134
135                         pFooter->SetBackButton();
136                         SetFormBackEventListener(this);
137                 }
138                 else
139                 {
140                         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
141                         pFooter->SetBackButton();
142                         SetFormBackEventListener(this);
143                 }
144         }
145         else
146         {
147                 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
148
149                 ButtonItem footerMore;
150                 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
151                 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
152                 if (pBitmapMore != null)
153                 {
154                         footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
155                 }
156                 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
157
158                 FooterItem footerShare;
159                 r = footerShare.Construct(ACTION_ID_FOOTER_SHARE);
160                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
161                 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
162                 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
163
164                 if (pBitmapShare != null &&  pBitmapShareDim != null )
165                 {
166                         footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
167                         footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
168                 }
169
170                 r = pFooter->AddItem(footerShare);
171                 delete pBitmapShare;
172                 delete pBitmapShareDim;
173                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
174
175                 FooterItem footerDelete;
176                 r = footerDelete.Construct(ACTION_ID_FOOTER_DELETE);
177                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
178                 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
179                 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
180
181                 if (pBitmapDelete != null && pBitmapDeleteDim != null)
182                 {
183                         footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
184                         footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
185                 }
186
187                 r = pFooter->AddItem(footerDelete);
188                 delete pBitmapDelete;
189                 delete pBitmapDeleteDim;
190                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
191
192                 pFooter->SetBackButton();
193                 SetFormBackEventListener(this);
194
195                 SceneManager* pSceneManager = SceneManager::GetInstance();
196                 int checkedCount = 0;
197
198                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
199                 {
200                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
201                         if (pEditorPanel != null)
202                         {
203                                 checkedCount = pEditorPanel->GetItemCheckedCount();
204                         }
205                 }
206                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
207                 {
208                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
209                         if (pSelectionPanel != null)
210                         {
211                                 checkedCount = pSelectionPanel->GetItemCheckedCount();
212                         }
213                 }
214
215                 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
216
217                 if(__pContextMenuMore != null)
218                 {
219                         delete __pContextMenuMore;
220                         __pContextMenuMore = null;
221                 }
222
223                 __pContextMenuMore = new (std::nothrow) ContextMenu();
224                 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
225
226                 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
227                                 ACTION_ID_CONTEXT_MENU_MORE_MOVE);
228
229                 if (checkedCount > 1)
230                 {
231                         __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"),
232                                         ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW);
233                 }
234
235                 __pContextMenuMore->SetShowState(false);
236                 __pContextMenuMore->AddActionEventListener(*this);
237
238                 __pContextMenuShare = new (std::nothrow) ContextMenu();
239                 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
240                 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
241                                 ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE);
242                 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
243                                 ACTION_ID_CONTEXT_MENU_SHARE_EMAIL);
244                 __pContextMenuShare->SetShowState(false);
245                 __pContextMenuShare->AddActionEventListener(*this);
246
247                 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
248                 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
249                 __pContextEditorMenuMove->AddActionEventListener(*this);
250
251                 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
252                 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
253                 __pContextSelectionMenuMove->AddActionEventListener(*this);
254
255                 if (__pContentDirectoryNameList != null)
256                 {
257                         delete __pContentDirectoryNameList;
258                         __pContentDirectoryNameList = null;
259                 }
260
261                 SetUpPopup();
262         }
263
264         pFooter->AddActionEventListener(*this);
265         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
266
267         return r;
268 }
269
270 String
271 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
272 {
273         AppLogDebug("ENTER");
274         if (fullPath == null)
275         {
276                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
277
278                 return null;
279         }
280         String delim(DIRECTORY_SEPARATOR);
281         StringTokenizer st(fullPath,delim);
282         String token;
283         while (st.HasMoreTokens())
284         {
285                 st.GetNextToken(token);
286         }
287         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
288
289         return token;
290 }
291
292 result
293 FileListEditorForm::OnTerminating(void)
294 {
295         AppLogDebug("ENTER");
296
297         if (__pContextMenuMore != null)
298         {
299                 __pContextMenuMore->RemoveActionEventListener(*this);
300                 delete __pContextMenuMore;
301                 __pContextMenuMore = null;
302         }
303
304         if (__pContextMenuShare != null)
305         {
306                 __pContextMenuShare->RemoveActionEventListener(*this);
307                 delete __pContextMenuShare;
308                 __pContextMenuShare = null;
309         }
310
311         if (__pContextEditorMenuMove != null)
312         {
313                 __pContextEditorMenuMove->RemoveActionEventListener(*this);
314                 delete __pContextEditorMenuMove;
315                 __pContextEditorMenuMove = null;
316         }
317
318         if (__pContextSelectionMenuMove != null)
319         {
320                 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
321                 delete __pContextSelectionMenuMove;
322                 __pContextSelectionMenuMove = null;
323         }
324
325         if (__pDeletePopup != null)
326         {
327                 delete __pDeletePopup;
328                 __pDeletePopup = null;
329         }
330         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
331
332         return E_SUCCESS;
333 }
334
335 void
336 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
337 {
338         AppLogDebug("ENTER(actionId=%d)", actionId);
339         SceneManager* pSceneManager = SceneManager::GetInstance();
340         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
341
342         switch (actionId)
343         {
344         case ACTION_ID_FOOTER_MORE:
345         {
346
347                 InitializeFooter();
348
349                 if (__pContextMenuMore->GetShowState() == false)
350                 {
351                         Rectangle rect = source.GetBounds();
352                         __morePosition = Point(rect.width/8,rect.y);
353                         __pContextMenuMore->SetAnchorPosition(Point(rect.width/8,rect.y));
354                         __pContextMenuMore->SetShowState(true);
355                         __pContextMenuMore->Show();
356                 }
357                 else
358                 {
359                         __pContextMenuMore->SetShowState(false);
360                 }
361                 break;
362         }
363         case ACTION_ID_FOOTER_SHARE:
364         {
365                 if (__pContextMenuShare->GetShowState() == false)
366                 {
367                         Rectangle rect = source.GetBounds();
368                         __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y));
369                         __pContextMenuShare->SetShowState(true);
370                         __pContextMenuShare->Show();
371                 }
372                 else
373                 {
374                         __pContextMenuShare->SetShowState(false);
375                 }
376                 break;
377         }
378         case ACTION_ID_FOOTER_DELETE:
379         {
380                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
381                 {
382                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
383                         if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
384                         {
385                                 __pDeletePopup->SetShowState(true);
386                                 __pDeletePopup->Show();
387                         }
388                 }
389                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
390                 {
391                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
392                         if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
393                         {
394                                 __pDeletePopup->SetShowState(true);
395                                 __pDeletePopup->Show();
396                         }
397                 }
398                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
399                 {
400                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
401                         if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
402                         {
403                                 __pDeletePopup->SetShowState(true);
404                                 __pDeletePopup->Show();
405                         }
406                 }
407                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
408                 {
409                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
410                         (pSceneManager->GetCurrentScene()->GetPanel());
411                         if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
412                         {
413                                 __pDeletePopup->SetShowState(true);
414                                 __pDeletePopup->Show();
415                         }
416                 }
417                 break;
418         }
419         case ACTION_ID_CONTEXT_MENU_MORE_EDIT:
420         {
421                 break;
422         }
423         case ACTION_ID_CONTEXT_MENU_MORE_ADD_TAG:
424         {
425                 break;
426         }
427         case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
428         {
429                 RefreshFolderList();
430                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
431                 {
432                         if (__pContextEditorMenuMove->GetShowState() == false)
433                         {
434                                 __pContextEditorMenuMove->SetAnchorPosition(__morePosition);
435                                 __pContextEditorMenuMove->SetShowState(true);
436                                 __pContextEditorMenuMove->Show();
437                         }
438                         else
439                         {
440                                 __pContextEditorMenuMove->SetShowState(false);
441                         }
442                 }
443                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
444                 {
445                         if (__pContextSelectionMenuMove->GetShowState() == false)
446                         {
447                                 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
448                                 __pContextSelectionMenuMove->SetShowState(true);
449                                 __pContextSelectionMenuMove->Show();
450                         }
451                         else
452                         {
453                                 __pContextSelectionMenuMove->SetShowState(false);
454                         }
455                 }
456
457                 break;
458         }
459         case ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW:
460         {
461                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
462                 {
463                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
464                         if (pEditorPanel != null)
465                         {
466                                 pEditorPanel->OnRequestSlideShow();
467                         }
468                 }
469                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
470                 {
471                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
472                         if (pSelectionPanel != null)
473                         {
474                                 pSelectionPanel->OnRequestSlideShow();
475                         }
476                 }
477
478                 break;
479         }
480         case ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE:
481         {
482                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
483                 {
484                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
485                         if (pEditorPanel != null)
486                         {
487                                 pEditorPanel->OnRequestMessage();
488                         }
489                 }
490                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
491                 {
492                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
493                         if (pEditorPanel != null)
494                         {
495                                 pEditorPanel->OnRequestMessage();
496                         }
497                 }
498                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
499                 {
500                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
501                         if (pEditorPanel != null)
502                         {
503                                 pEditorPanel->OnRequestMessage();
504                         }
505
506                 }
507                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
508                 {
509                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
510                         if (pSelectionPanel != null)
511                         {
512                                 pSelectionPanel->OnRequestMessage();
513                         }
514                 }
515                 break;
516         }
517         case ACTION_ID_CONTEXT_MENU_SHARE_EMAIL:
518         {
519                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
520                 {
521                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
522                         if (pEditorPanel != null)
523                         {
524                                 pEditorPanel->OnRequestEmail();
525                         }
526                 }
527                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
528                 {
529                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
530                         if (pEditorPanel != null)
531                         {
532                                 pEditorPanel->OnRequestEmail();
533                         }
534                 }
535                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
536                 {
537                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
538                         if (pEditorPanel != null)
539                         {
540                                 pEditorPanel->OnRequestEmail();
541                         }
542
543                 }
544                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
545                 {
546                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
547                         if (pSelectionPanel != null)
548                         {
549                                 pSelectionPanel->OnRequestEmail();
550                         }
551                 }
552                 break;
553         }
554         case ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
555         {
556                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
557                 {
558                         AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
559                         IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
560
561                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
562                 }
563                 break;
564         }
565         case ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
566         {
567                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
568                 {
569                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
570                         (pSceneManager->GetCurrentScene()->GetPanel());
571                         IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
572                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
573                 }
574                 break;
575         }
576         case ACTION_ID_DELETE_POPUP_DEL:
577         {
578                 __pDeletePopup->SetShowState(false);
579                 __pDeletePopup->Invalidate(true);
580
581                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
582                 {
583                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
584                         if (pEditorPanel != null)
585                         {
586                                 result r = pEditorPanel->OnRequestDelete();
587                                 if ( IsFailed(r) )
588                                 {
589                                         AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
590                                 }
591                         }
592                 }
593                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
594                 {
595                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
596                         if (pEditorPanel != null)
597                         {
598                                 pEditorPanel->OnRequestDelete();
599                         }
600                 }
601                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
602                 {
603                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>
604                         (pSceneManager->GetCurrentScene()->GetPanel());
605
606                         if (pEditorPanel != null)
607                         {
608                                 pEditorPanel->OnRequestDelete();
609                         }
610                 }
611                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
612                 {
613                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
614                         (pSceneManager->GetCurrentScene()->GetPanel());
615
616                         if (pSelectionPanel != null)
617                         {
618                                 result r = pSelectionPanel->OnRequestDelete();
619                                 if ( IsFailed(r) )
620                                 {
621                                         AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
622                                 }
623                         }
624                 }
625
626                 break;
627         }
628         case ACTION_ID_DELETE_POPUP_CANCEL:
629         {
630                 __pDeletePopup->SetShowState(false);
631                 __pDeletePopup->Invalidate(true);
632                 break;
633         }
634         case ACTION_ID_FOOTER_CONFIRM:
635         {
636                 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
637                 {
638                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
639                         if (pEditorPanel != null)
640                         {
641                                 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
642                         }
643                 }
644                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
645                 {
646                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
647                         if (pEditorPanel != null)
648                         {
649                                 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
650                         }
651                 }
652                 break;
653         }
654         default:
655         {
656                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
657                 {
658                         if ((ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
659                                         (actionId <= ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
660                         {
661                                 if (__pContentDirectoryList == null)
662                                 {
663
664                                         return;
665                                 }
666                                 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
667                                 {
668                                         String* pDirectory = static_cast<String*>
669                                         (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
670
671                                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
672                                         (pSceneManager->GetCurrentScene()->GetPanel());
673
674                                         if (pEditorPanel != null)
675                                         {
676                                                 delete __pFileMove;
677                                                 __pFileMove = new FileMoveTimer(*pDirectory, pEditorPanel->GetItemCheckedIndexListN(),
678                                                                 __pPresentationModel, this );
679                                                 result r = __pFileMove->StartTimer();
680                                                 if (IsFailed(r))
681                                                 {
682                                                         delete __pFileMove;
683                                                         __pFileMove = null;
684                                                 } else
685                                                 {
686                                                         __moveInProgress = true;
687                                                 }
688                                         }
689                                 }
690                         }
691                 }
692                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
693                 {
694                         if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
695                                         (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
696                         {
697                                 if (__pContentDirectoryList == null)
698                                 {
699
700                                         return;
701                                 }
702                                 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
703                                 {
704                                         String* pDirectory = static_cast<String*>
705                                         (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
706
707                                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
708                                                 (pSceneManager->GetCurrentScene()->GetPanel());
709
710                                         if (pSelectionPanel != null)
711                                         {
712                                                 delete __pFileMove;
713                                                 __pFileMove = new FileMoveTimer(*pDirectory, pSelectionPanel->GetItemCheckedIndexListN(),
714                                                                 __pPresentationModel, this );
715                                                 result r = __pFileMove->StartTimer();
716                                                 if (IsFailed(r))
717                                                 {
718                                                         delete __pFileMove;
719                                                         __pFileMove = null;
720                                                 }
721                                                 else
722                                                 {
723                                                         __moveInProgress = true;
724                                                 }
725                                         }
726                                 }
727                         }
728                 }
729
730                 break;
731         }
732         }
733         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
734 }
735
736 void FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
737 {
738         Invalidate(true);
739 }
740
741 bool FileListEditorForm::GetFileMoveProgress()
742 {
743         return __moveInProgress;
744 }
745
746 void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, result res)
747 {
748         __moveInProgress = false;
749 }
750
751 void
752 FileListEditorForm::OnUpdateContentList()
753 {
754         AppLogDebug("ENTER");
755         SceneManager* pSceneManager = SceneManager::GetInstance();
756         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
757         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
758 }
759
760 result
761 FileListEditorForm::SetUpPopup(void)
762 {
763         AppLogDebug("ENTER");
764         result r = E_SUCCESS;
765
766         if (__pDeletePopup != null)
767         {
768                 delete __pDeletePopup;
769                 __pDeletePopup = null;
770         }
771
772         __pDeletePopup = new (std::nothrow) Popup();
773         __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
774
775         Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
776
777         Label* pLabelText = new (std::nothrow) Label();
778         pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
779                         ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
780         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
781         __pDeletePopup->AddControl(*pLabelText);
782
783         Button* pButtonDel = new (std::nothrow) Button();
784         pButtonDel->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
785                         ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
786         pButtonDel->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
787         pButtonDel->AddActionEventListener(*this);
788         __pDeletePopup->AddControl(*pButtonDel);
789
790         Button* pButtonCancel = new (std::nothrow) Button();
791         pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
792                         popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
793         pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
794         pButtonCancel->AddActionEventListener(*this);
795         __pDeletePopup->AddControl(*pButtonCancel);
796         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
797
798         return r;
799 }
800
801 void
802 FileListEditorForm::SetTitleText(const String& titleText)
803 {
804         AppLogDebug("ENTER");
805         Header* pHeader = GetHeader();
806         TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
807         pHeader->SetTitleText(titleText);
808         pHeader->Invalidate(true);
809         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
810 }
811
812 void
813 FileListEditorForm::RefreshFolderList(void)
814 {
815         AppLogDebug("ENTER");
816         ContentDirectory contentDirectory;
817         IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
818         pContentTypeList->Add(CONTENT_TYPE_IMAGE);
819         pContentTypeList->Add(CONTENT_TYPE_VIDEO);
820         contentDirectory.Construct(*pContentTypeList);
821         delete pContentTypeList;
822         pContentTypeList = null;
823
824         if (__pContentDirectoryList != null)
825         {
826                 delete __pContentDirectoryList;
827                 __pContentDirectoryList = null;
828         }
829         __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
830         __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
831         String* pDirPath = null;
832         String* pDirName = null;
833
834         int loopCount = __pContentDirectoryList->GetCount();
835         for (int i = 0; i < loopCount; ++i)
836         {
837                 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
838                 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
839                 __pContentDirectoryNameList->Add(pDirName);
840         }
841         __pContextEditorMenuMove->RemoveAllItems();
842         __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
843                         ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
844         __pContextSelectionMenuMove->RemoveAllItems();
845         __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
846                         ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
847
848         loopCount = __pContentDirectoryNameList->GetCount();
849         for (int i = 0; i < loopCount; ++i)
850         {
851                 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
852                 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
853                                 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
854                 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
855                                 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
856         }
857         __pContextEditorMenuMove->SetShowState(false);
858         __pContextSelectionMenuMove->SetShowState(false);
859         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
860 }
861
862 void
863 FileListEditorForm::OnFormBackRequested(Form& source)
864 {
865         AppLogDebug("ENTER");
866
867         SceneManager* pSceneManager = SceneManager::GetInstance();
868         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
869
870         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
871         {
872                 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
873                 {
874                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
875                 }
876                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
877                 {
878                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
879                 }
880         }
881         else
882         {
883                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
884                 {
885                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
886                 }
887                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
888                 {
889                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
890                 }
891                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
892                 {
893                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
894                 }
895                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
896                 {
897                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
898                                 (pSceneManager->GetCurrentScene()->GetPanel());
899                         if (pSelectionPanel != null)
900                         {
901                                 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
902                                 if (pList == null)
903                                 {
904                                         pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
905                                 }
906
907                                 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
908                         }
909                 }
910                 else
911                 {
912                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
913                 }
914         }
915         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
916 }
917
918 void
919 FileListEditorForm::SetFooterButtonsState(bool enableState)
920 {
921         AppLogDebug("ENTER");
922         Footer* pFooter = GetFooter();
923         TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
924
925         if (enableState == true)
926         {
927                 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
928                 pFooter->SetItemEnabled(0, true);
929                 pFooter->SetItemEnabled(1, true);
930         }
931         else
932         {
933                 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
934                 pFooter->SetItemEnabled(0, false);
935                 pFooter->SetItemEnabled(1, false);
936         }
937
938         pFooter->RequestRedraw(true);
939         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
940 }
941
942 result
943 FileListEditorForm::MoveToAlbum(String& destDirectory)
944 {
945         AppLogDebug("ENTER");
946         result r = E_FAILURE;
947         String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
948         if (albumName != EMPTY_SPACE)
949         {
950                 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
951                 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
952                 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
953                 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
954                 delete pDirectoryList;
955
956                 SceneManager* pSceneManager = SceneManager::GetInstance();
957                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
958                 r = E_SUCCESS;
959         }
960         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
961
962         return r;
963 }