3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 /*@file: MfSplitPanelForm.cpp
19 *@brief: This file contains the implementation of the MfSplitPanelForm class,
20 which is the landscape view for the application.
23 #include "MfSplitPanelForm.h"
25 using namespace Tizen::App;
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Base::Utility;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Io;
31 using namespace Tizen::System;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 SplitPanelForm::SplitPanelForm(void)
38 , __pFirstPanePanel(null)
39 , __pSecondPanePanel(null)
43 , __pDirectoryTreeProvider(null)
44 , __pDirectoryTreePM(null)
45 , __pDirectoryTreeItemProvider(null)
46 , __pDirectoryList(null)
47 ,_pFileEventManager(null)
48 , __dirTreeCurrentSelection(0)
53 SplitPanelForm::~SplitPanelForm(void)
58 SplitPanelForm::Initialize(void)
61 Form::Construct(L"IDL_SPLIT_PANEL");
66 SplitPanelForm::OnInitializing(void)
70 //AddOrientationEventListener(*this);
71 SetFormBackEventListener(this);
74 __pHeader = GetHeader();
75 if (__pHeader != null)
77 __pHeader->SetTitleText("MyFiles");
78 __pHomeButton = new (std::nothrow) ButtonItem();
79 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
80 __pHomeButton->SetText(L"Home");
82 __pUpButton = new (std::nothrow) ButtonItem();
83 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
84 __pUpButton->SetText("Up");
86 __pHeader->AddActionEventListener(*this);
89 CreateFooterControls();
91 //Rectangle clientBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
92 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SPLIT_PANEL_FORM;
94 //initialize presentation models
95 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
96 if (_pFolderEntryPM == null)
98 _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
99 AppAssert(_pFolderEntryPM != null);
100 r = _pFolderEntryPM->Construct();
101 AppAssert(r==E_SUCCESS);
102 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SPLIT_PANEL_LIST);
104 _pFolderEntryPM->SetFolderEntryPath(__currentDirectoryPath);
105 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
107 //initialize itemproviders
108 _pBaseItemProvider = new (std::nothrow) BaseItemProvider();
109 _pBaseItemProvider->Construct();
110 _pBaseItemProvider->SetSourceForm(CREATE_ITEM_SOURCE_SPLIT_PANEL_LIST);
111 _pBaseItemProvider->SetFolderEntryProvider(this);
113 //initialize pm, item provider and listner for directory tree
114 __pDirectoryTreePM = new (std::nothrow) FolderEntryPresentationModel();
115 AppAssert(__pDirectoryTreePM != null);
116 __pDirectoryTreePM->Construct();
117 __pDirectoryTreePM->SetSourceForm(CREATE_ITEM_SOURCE_SPLIT_PANEL_DIR_TREE);
118 __pDirectoryTreePM->SetFolderEntryPath(BasePresentationModel::GetMediaPath());
119 __pDirectoryTreePM->SetSortEnabled(false);
120 __pDirectoryList = __pDirectoryTreePM->GetFolderEntryList();
122 DirectoryEntry* pRootDirectory = new (std::nothrow) DirectoryEntry();
123 pRootDirectory->SetFullFilePath(BasePresentationModel::GetMediaPath());
124 pRootDirectory->SetFileName(L"Phone");
125 pRootDirectory->SetDirectoryOpenStatus(true);
126 pRootDirectory->SetCheckDirectory(true);
127 __pDirectoryList->InsertAt(pRootDirectory,0);
129 __pDirectoryTreeProvider = new (std::nothrow) DirectoryTreeProvider(__pDirectoryTreePM);
130 __pDirectoryTreeItemProvider = new (std::nothrow) BaseItemProvider();
131 __pDirectoryTreeItemProvider->Construct();
132 __pDirectoryTreeItemProvider->SetSourceForm(CREATE_ITEM_SOURCE_SPLIT_PANEL_DIR_TREE);
133 __pDirectoryTreeItemProvider->SetFolderEntryProvider(__pDirectoryTreeProvider);
135 _pThumbnailItemProvider = new (std::nothrow) ThumbnailItemProviderAndListener(__currentDirectoryPath, sourceForm);
136 _pThumbnailItemProvider->SetFolderEntryProvider(this);
137 _pThumbnailItemProvider->SetFooterItemStateChangeListener(this);
139 if (_pCustomListViewForPopup == null)
141 _pCustomListViewForPopup = new (std::nothrow) CustomListViewForPopup();
143 _pCustomListViewForPopup->SetEventListener(this);
145 CreateViewAsPopupControl();
146 CreateFileProgressingPopup();
147 CreateDeleteConfirmationPopUp();
150 __pFirstPanePanel = new (std::nothrow) Panel();
151 __pFirstPanePanel->Construct(Rectangle(0,0,GetClientAreaBounds().width, GetClientAreaBounds().height), GROUP_STYLE_NONE);
153 __pSecondPanePanel = new (std::nothrow) Panel();
154 __pSecondPanePanel->Construct(Rectangle(0,0,GetClientAreaBounds().width, GetClientAreaBounds().height), GROUP_STYLE_NONE);
156 __pDirTreeListView = new (std::nothrow) ListView();
157 __pDirTreeListView->Construct(Rectangle(__pFirstPanePanel->GetBounds()), true, false);
158 __pDirTreeListView->SetTextOfEmptyList(L"No Files!");
159 __pDirTreeListView->SetItemProvider(*__pDirectoryTreeItemProvider);
160 __pDirTreeListView->AddListViewItemEventListener(*this);
161 __pDirTreeListView->SetBackgroundColor(Color::GetColor(COLOR_ID_WHITE));
162 __pDirTreeListView->SetSweepEnabled(false);
164 _pListView = new (std::nothrow) ListView();
165 _pListView->Construct(Rectangle(0, H_DISPLAY_PATH_LABEL, __pSecondPanePanel->GetBounds().width, __pSecondPanePanel->GetBounds().height - H_DISPLAY_PATH_LABEL), true, false);
166 _pListView->SetTextOfEmptyList(L"No Files!");
167 _pListView->SetItemProvider(*_pBaseItemProvider);
168 _pListView->AddListViewItemEventListener(*this);
169 _pListView->SetBackgroundColor(Color::GetColor(COLOR_ID_WHITE));
171 _pIconListView = new (std::nothrow) IconListView();
172 _pIconListView->Construct(Rectangle(0, H_DISPLAY_PATH_LABEL, __pSecondPanePanel->GetBounds().width, __pSecondPanePanel->GetBounds().height - H_DISPLAY_PATH_LABEL),
174 ICON_LIST_VIEW_STYLE_NORMAL,
175 ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL,
176 ICON_LIST_SCROLL_STYLE_FIXED);
177 _pIconListView->SetItemSpacing(10, 10);
178 _pIconListView->SetBackgroundColor(Color::GetColor(COLOR_ID_WHITE));
179 _pIconListView->SetItemTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_BLACK));
180 _pIconListView->SetItemTextSize(36);
181 _pIconListView->SetTextOfEmptyList(L"No Files!");
182 _pIconListView->SetTextVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM);
183 _pIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW);
184 _pIconListView->SetItemProvider(*_pThumbnailItemProvider);
185 _pIconListView->AddIconListViewItemEventListener(*this);
187 __pFirstPanePanel->AddControl(*__pDirTreeListView);
188 __pSecondPanePanel->AddControl(*_pListView);
189 __pSecondPanePanel->AddControl(*_pIconListView);
191 _pLabelDisplayPath = new (std::nothrow) Label();
192 _pLabelDisplayPath->Construct(Rectangle(0, 0, __pSecondPanePanel->GetBounds().width, H_DISPLAY_PATH_LABEL),__currentDirectoryPath);//>SetBounds(0, 0, __pSecondPanePanel->GetBounds().width, H_DISPLAY_PATH_LABEL);
193 _pLabelDisplayPath->SetBackgroundColor(Color(IDC_RGB_GREY,IDC_RGB_GREY,IDC_RGB_GREY));
194 _pLabelDisplayPath->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
195 _pLabelDisplayPath->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
196 __pSecondPanePanel->AddControl(*_pLabelDisplayPath);
198 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
199 AppRegistry* pAppRegistry = null;
200 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
201 pAppRegistry->Get(L"ListDisplayType", listViewDisplayType);
202 if (listViewDisplayType == VIEW_TYPE_AS_NORMAL_LIST || listViewDisplayType == VIEW_TYPE_AS_DETAILED_LIST)
204 _pIconListView->SetShowState(false);
208 _pListView->SetShowState(false);
211 __pSplitPanel = new (std::nothrow) SplitPanel();
212 __pSplitPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), SPLIT_PANEL_DIVIDER_STYLE_MOVABLE, SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL );
213 __pSplitPanel->AddSplitPanelEventListener(*this);
214 __pSplitPanel->SetDividerPosition(GetClientAreaBounds().width / 3);
215 __pSplitPanel->SetPane(__pFirstPanePanel, SPLIT_PANEL_PANE_ORDER_FIRST);
216 __pSplitPanel->SetPane(__pSecondPanePanel, SPLIT_PANEL_PANE_ORDER_SECOND);
218 AddControl(*__pSplitPanel);
219 _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
225 SplitPanelForm::OnTerminating(void)
231 SplitPanelForm::OnActionPerformed(const Control& source, int actionId)
243 homeRootPath.Append(__currentDirectoryPath);
244 while ((homeRootPath != BasePresentationModel::GetMediaPath()) && (homeRootPath != BasePresentationModel::GetSdCardPath()))
246 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
247 homeRootPath.Clear();
248 homeRootPath = FolderNavigationPresentationModel::GetParentPath();
250 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
256 bool searchHistory = CheckSearchHistory();
260 previousPath = FolderNavigationPresentationModel::GetCurrentPath();
261 AppLogDebug("previousPath is %S", previousPath.GetPointer());
262 FolderNavigationPresentationModel::SetSearchPreviousPath(previousPath);
264 ShowParentDirectoryView();
265 //update display label with current path
266 _displayPath = __rootDirectory;
267 _displayPath.Append(L"/");
268 SetNextDisplayPath();
271 case IDA_CONTEXT_MENU_HIDE_EXTENSION:
273 __currentDirectoryPath.Clear();
274 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
276 if (_pFolderEntryPM != null)
278 _pFolderEntryPM->SetFolderEntryPath(__currentDirectoryPath);
279 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
284 case IDA_CONTEXT_MENU_SHOW_EXTENSION:
286 __currentDirectoryPath.Clear();
287 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
289 if (_pFolderEntryPM != null)
291 _pFolderEntryPM->SetFolderEntryPath(__currentDirectoryPath);
292 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
299 SubBaseOnActionPerformed(source, actionId);
303 __pFirstPanePanel->Invalidate(true);
304 __pSecondPanePanel->Invalidate(true);
309 SplitPanelForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
311 AppLogDebug("ENTER");
313 switch (orientationStatus)
315 case ORIENTATION_STATUS_PORTRAIT:
317 ChangeOrientationToPortrait();
326 SplitPanelForm::ChangeOrientationToPortrait(void)
328 AppLogDebug("ENTER");
329 SceneManager* pSceneManager = SceneManager::GetInstance();
330 String checkPath = FolderNavigationPresentationModel::GetCurrentPath();
332 if (checkPath == BasePresentationModel::GetMediaPath() || checkPath == BasePresentationModel::GetSdCardPath())
334 if (pSceneManager != null)
336 if (pSceneManager->IsSceneAlive(IDSCN_ROOT_DIRECTORY_FORM))
338 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
342 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
348 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
353 SplitPanelForm::OnDividerPositionChanged(SplitPanel& source, int position)
357 dividerPosition = source.GetDividerPosition();
358 AppLogDebug("Divider Position = %d", dividerPosition);
360 TryCatch(__pFirstPanePanel != null, , "MfMyFilesApp::First Pane in SplitPanel is null");
361 TryCatch(__pSecondPanePanel != null, , "MfMyFilesApp::Second Pane in SplitPanel is null");
363 __pFirstPanePanel->SetBounds(Rectangle(0,0,dividerPosition, GetClientAreaBounds().height));
364 __pSecondPanePanel->SetBounds(Rectangle(dividerPosition + 13,0,GetClientAreaBounds().width - dividerPosition - 13, GetClientAreaBounds().height));
366 if (_pListView != null)
368 _pListView->SetBounds(Rectangle(0, H_DISPLAY_PATH_LABEL, __pSecondPanePanel->GetBounds().width, __pSecondPanePanel->GetBounds().height - H_DISPLAY_PATH_LABEL));
371 if (_pIconListView != null)
373 _pIconListView->SetBounds(Rectangle(0, H_DISPLAY_PATH_LABEL, __pSecondPanePanel->GetBounds().width, __pSecondPanePanel->GetBounds().height - H_DISPLAY_PATH_LABEL));
376 if (__pDirTreeListView != null)
378 __pDirTreeListView->SetBounds(Rectangle(__pFirstPanePanel->GetBounds()));
382 __pFirstPanePanel->Invalidate(true);
383 __pSecondPanePanel->Invalidate(true);
393 SplitPanelForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
395 if (&listView == __pDirTreeListView)
397 UpdateListsOnDirTreeSelection(index);
401 DirectoryEntry* pDirEntry;
402 pDirEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
403 if (pDirEntry->IsDirectory() == true)
405 UpdateListsOnFolderSelection(index);
409 _pathOfSelectedFile = pDirEntry->GetFullFilePath();
410 __selectedIndex = index;
414 SetHeaderTitleText(__currentDirectoryPath);
415 _displayPath = __rootDirectory;
416 _displayPath.Append(L"/");
417 SetNextDisplayPath();
422 SplitPanelForm::OnIconListViewItemStateChanged(IconListView& listView, int index, IconListViewItemStatus status)
424 AppLogDebug("ENTER");
425 if (_pFilenames == null)
430 DirectoryEntry* pDirEntry;
431 pDirEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
432 if (pDirEntry->IsDirectory() == true)
434 UpdateListsOnFolderSelection(index);
435 _displayPath = __rootDirectory;
436 _displayPath.Append(L"/");
437 SetNextDisplayPath();
441 AppLogDebug("not directory");
442 _pathOfSelectedFile = pDirEntry->GetFullFilePath();
443 __selectedIndex = index;
450 SplitPanelForm::OpenFile()
452 if (_pathOfSelectedFile.EndsWith(L".tpk"))
458 CustomAppControl* customAppControl = CustomAppControl::GetInstance();
459 if (customAppControl != null)
461 customAppControl->SetAppControlListener(this);
462 AppControl* pAppControlInUse = customAppControl->LaunchAppControl(_pathOfSelectedFile);
463 if (pAppControlInUse != null)
465 CustomAppControl::SetAppControlInUse(pAppControlInUse);
472 SplitPanelForm::UpdateListsOnDirTreeSelection(int index)
474 DirectoryEntry* pDirStr = null;
475 if (__pDirectoryList == null)
479 pDirStr = static_cast< DirectoryEntry* >(__pDirectoryList->GetAt(index));
482 RefreshIconListView(pDirStr);
484 //update the directory tree
485 if (pDirStr->IsDirectoryOpened() == false)
487 __pDirectoryTreePM->AddFolderEntryList(__currentDirectoryPath,index);
488 pDirStr->SetDirectoryOpenStatus(true);
490 else if (__dirTreeCurrentSelection == index)
492 __pDirectoryTreePM->RemoveFolderEntryList(index);
493 pDirStr->SetDirectoryOpenStatus(false);
495 if (__pDirTreeListView != null)
497 __pDirTreeListView->UpdateList();
499 __dirTreeCurrentSelection = index;
500 __pFirstPanePanel->Invalidate(true);
501 __pSecondPanePanel->Invalidate(true);
506 SplitPanelForm::UpdateListsOnFolderSelection(int index)
508 AppLogDebug("__dirTreeCurrentSelection = %d", __dirTreeCurrentSelection);
509 DirectoryEntry* pDirEntryList = null;
510 String selectedFilePath = null;
511 if (_pFilenames != null)
513 pDirEntryList = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
514 selectedFilePath = pDirEntryList->GetFullFilePath();
516 RefreshIconListView(pDirEntryList);
519 //update left pane: directory tree
520 DirectoryEntry* pDirTreeEntry = null;
521 if (__pDirectoryList != null)
523 pDirTreeEntry = static_cast< DirectoryEntry* >(__pDirectoryList->GetAt(__dirTreeCurrentSelection));
524 if (pDirTreeEntry->IsDirectoryOpened() == false)
525 {//if current selected dir is not opened, open it
526 __pDirectoryTreePM->AddFolderEntryList(pDirTreeEntry->GetFullFilePath(),__dirTreeCurrentSelection);
527 pDirTreeEntry->SetDirectoryOpenStatus(true);
528 __dirTreeCurrentSelection = __pDirectoryTreePM->GetDirectoryTreeIndex(selectedFilePath, __dirTreeCurrentSelection + 1);
531 {//if current dir is already opened, open sub dir if the sub directory is not yet opened
532 __dirTreeCurrentSelection = __pDirectoryTreePM->GetDirectoryTreeIndex(selectedFilePath, __dirTreeCurrentSelection + 1);
533 pDirTreeEntry = static_cast< DirectoryEntry* >(__pDirectoryList->GetAt(__dirTreeCurrentSelection));
534 if (pDirTreeEntry->IsDirectoryOpened() == false)
536 __pDirectoryTreePM->AddFolderEntryList(pDirTreeEntry->GetFullFilePath(),__dirTreeCurrentSelection);
537 pDirTreeEntry->SetDirectoryOpenStatus(true);
541 if (__pDirTreeListView != null)
543 __pDirTreeListView->UpdateList();
545 __pFirstPanePanel->Invalidate(true);
546 __pSecondPanePanel->Invalidate(true);
548 if (_pFileEventManager != null)
550 delete _pFileEventManager;
551 _pFileEventManager = null;
554 _pFileEventManager = new (std::nothrow)FileEventManager();
555 _pFileEventManager->Construct(*this);
557 _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE );
563 SplitPanelForm::RefreshIconListView(DirectoryEntry* pDirStr)
565 AppLogDebug("ENTER");
569 if (pDirStr->IsDirectory())
571 __currentDirectoryPath = pDirStr->GetFullFilePath();
572 _currentFileName.Clear();
573 _currentFileName = pDirStr->GetFileName();
575 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
578 if (_pFolderEntryPM != null)
580 _pFolderEntryPM->SetFileEventListener(null);
581 _pFolderEntryPM->SetFolderEntryPath(__currentDirectoryPath);
582 _pFolderEntryPM->InitThumbnailManager();
583 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
584 TryCatch(_pFilenames != null, , "MfMyFilesApp::Failed to allocate Memory to Filenames ArrayList");
585 if (_pFilenames->GetCount() == 0)
587 SetFooterVisibility(DISABLE_FOOTER_ITEM);
591 SetFooterVisibility(ENABLE_FOOTER_ITEM);
596 if (_pListView != null && _pListView->IsVisible())
598 _pListView->UpdateList();
600 if (_pIconListView != null && _pIconListView->IsVisible())
602 _pIconListView->UpdateList();
607 if (_pFolderEntryPM != null)
609 delete _pFolderEntryPM;
610 _pFolderEntryPM = null;
616 SplitPanelForm::ShowParentDirectoryView(void)
618 AppLogDebug("ENTER");
621 String backupCurrentPath;
623 backupCurrentPath = FolderNavigationPresentationModel::GetCurrentPath();
625 if (backupCurrentPath == BasePresentationModel::GetMediaPath() || backupCurrentPath == BasePresentationModel::GetSdCardPath())
634 parentPath = FolderNavigationPresentationModel::GetParentPath();
635 __currentDirectoryPath.Clear();
636 __currentDirectoryPath.Append(parentPath);
637 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
638 //SetParentDisplayPath();
639 SetHeaderTitleText(parentPath);
641 //update the current files from the filenames list
642 if (_pFolderEntryPM != null)
644 _pFolderEntryPM->SetFolderEntryPath(parentPath);
645 //Get the files in the parent path of the current view
646 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
647 TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
648 _pFolderEntryPM->InitThumbnailManager();
651 SetFooterVisibility(ENABLE_FOOTER_ITEM);
652 if (_pFooter != null)
654 _pFooter->RequestRedraw(true);
657 //Update the icon list to view the files of the parent directory
658 if (__pDirTreeListView != null)
660 __pDirTreeListView->UpdateList();
662 if (_pListView != null && _pListView->IsVisible())
664 _pListView->UpdateList();
666 if (_pIconListView != null && _pIconListView->IsVisible())
668 _pIconListView->UpdateList();
670 __pFirstPanePanel->Invalidate(true);
671 __pSecondPanePanel->Invalidate(true);
673 __dirTreeCurrentSelection = __pDirectoryTreePM->GetDirectoryTreeIndex(__currentDirectoryPath, 1);
678 if (_pFolderEntryPM != null)
680 delete _pFolderEntryPM;
681 _pFolderEntryPM = null;
686 SplitPanelForm::ShowHomeView(void)
688 AppLogDebug("Enter");
689 SceneManager* pSceneManager = null;
690 result r = E_SUCCESS;
691 pSceneManager = SceneManager::GetInstance();
692 if (pSceneManager != null)
694 if (CheckSearchHistory())
696 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
697 TryCatch(r == E_SUCCESS, , "scene transition failed");
701 r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
702 TryCatch(r == E_SUCCESS, , "scene transition failed");
706 if (_pFolderEntryPM != null)
708 _pFolderEntryPM->InitThumbnailManager();
718 SplitPanelForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
720 AppLogDebug("ENTER");
722 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
724 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
727 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SPLIT_PANEL_FORM;
729 String viewStyleKeyName(L"ListDisplayType");
731 AppResource* pAppResource = null;
732 AppRegistry* pAppRegistry = null;
734 pAppResource = UiApp::GetInstance()->GetAppResource();
735 //TryCatch(pAppResource != null, , "Failed to fetch AppResource");
736 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
737 pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
738 _flagViewAsStatus = listViewDisplayType;
739 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
742 SetHeaderTitleText(__currentDirectoryPath);
743 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
744 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
745 __pHeader->RequestRedraw(true);
747 if (_pMoreContextMenu != null)
749 _pMoreContextMenu->SetShowState(false);
752 //update iconlistview list
753 if (_pFolderEntryPM != null)
755 _pFolderEntryPM->SetFolderEntryPath(__currentDirectoryPath);
756 _pFolderEntryPM->GetFolderEntryCount(__currentDirectoryPath,folderCount, fileCount);
758 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
761 if (_pThumbnailItemProvider)
763 _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
767 if (_pFilenames->GetCount() == 0)
769 SetFooterVisibility(DISABLE_FOOTER_ITEM);
773 SetFooterVisibility(ENABLE_FOOTER_ITEM);
777 _pFooter = GetFooter();
780 _pFooter->SetItemEnabled(1, false);
785 //update directorytree
786 DirectoryEntry* pRootDirectory = new (std::nothrow) DirectoryEntry();
787 switch (FolderNavigationPresentationModel::GetStorageType())
789 case MEMORY_TYPE_PHONE:
791 __pDirectoryTreePM->SetFolderEntryPath(BasePresentationModel::GetMediaPath());
792 pRootDirectory->SetFullFilePath(BasePresentationModel::GetMediaPath());
793 pAppResource->GetString(L"IDS_MF_TAB_PHONE", __rootDirectory);
797 case MEMORY_TYPE_SD_CARD:
799 __pDirectoryTreePM->SetFolderEntryPath(BasePresentationModel::GetSdCardPath());
800 pRootDirectory->SetFullFilePath(BasePresentationModel::GetSdCardPath());
801 //pRootDirectory->SetFileName(defaultSdCardBody);
802 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", __rootDirectory);
806 case MEMORY_TYPE_EXTERNAL:
808 __pDirectoryTreePM->SetFolderEntryPath(BasePresentationModel::GetUsbPath());
809 pRootDirectory->SetFullFilePath(BasePresentationModel::GetUsbPath());
810 //pRootDirectory->SetFileName(defaultExternalStorageBody);
811 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", __rootDirectory);
819 //set the folder path to be displayed
820 _displayPath = __rootDirectory;
821 _displayPath.Append(L"/");
822 SetNextDisplayPath();
824 //set the root directory for the directory tree
825 pRootDirectory->SetFileName(__rootDirectory);
826 pRootDirectory->SetDirectoryOpenStatus(true);
827 pRootDirectory->SetCheckDirectory(true);
828 //construct directory tree
829 __pDirectoryList = __pDirectoryTreePM->GetFolderEntryList();
830 __pDirectoryList->InsertAt(pRootDirectory,0);
831 ConstructDirTreeList(__currentDirectoryPath);
832 if (__pDirTreeListView != null)
834 __pDirTreeListView->UpdateList();
837 //update iconlist view
838 if (_pListView != null && _pListView->IsVisible())
840 _pListView->UpdateList();
843 if (_pIconListView != null && _pIconListView->IsVisible())
845 _pIconListView->UpdateList();
848 _pFolderEntryPM->InitThumbnailManager();
849 __pFirstPanePanel->Invalidate(true);
850 __pSecondPanePanel->Invalidate(true);
852 if (_pFileManager != null)
854 _pFileManager->SetFileManagingListener(this);
859 pArgs->RemoveAll(false);
866 SplitPanelForm::SetHeaderTitleText(String& filePath)
869 String parentFileName;
870 String delimiter(L"/");
871 StringTokenizer tokenizer(filePath, delimiter);
873 AppResource* pAppResource = null;
874 pAppResource = UiApp::App::GetInstance()->GetAppResource();
876 //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
877 if (pAppResource != null)
879 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
882 if (filePath == BasePresentationModel::GetMediaPath())
884 if (pAppResource != null)
886 pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
889 else if (filePath == BasePresentationModel::GetSdCardPath())
891 if (pAppResource != null)
893 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
898 while (tokenizer.HasMoreTokens())
900 int tokenCount = tokenizer.GetTokenCount();
904 tokenizer.GetNextToken(parentFileName);
908 tokenizer.GetNextToken(token);
913 __pHeader = GetHeader();
914 if (__pHeader != null)
916 if (!parentFileName.IsEmpty())
918 __pHeader->SetTitleText(parentFileName);
919 __pHeader->Invalidate(true);
924 void SplitPanelForm::ConstructDirTreeList(String rootMediaPath)
926 AppLogDebug("__dirTreeCurrentSelection = %d", __dirTreeCurrentSelection);
928 if (rootMediaPath == BasePresentationModel::GetMediaPath() || rootMediaPath == BasePresentationModel::GetSdCardPath())
930 __dirTreeCurrentSelection = 0;
934 FolderNavigationPresentationModel::SetCurrentFilePath(rootMediaPath);
935 ConstructDirTreeList(FolderNavigationPresentationModel::GetParentPath());
936 FolderNavigationPresentationModel::SetCurrentFilePath(rootMediaPath);
938 __dirTreeCurrentSelection = __pDirectoryTreePM->GetDirectoryTreeIndex(rootMediaPath, __dirTreeCurrentSelection + 1);
939 DirectoryEntry* pDirTreeEntry = static_cast< DirectoryEntry* >(__pDirectoryList->GetAt(__dirTreeCurrentSelection));
941 //if dir is opened, close and open it again, as the dir structure might have changed (onSceneActivated)
942 if (pDirTreeEntry->IsDirectoryOpened() == true)
944 __pDirectoryTreePM->RemoveFolderEntryList(__dirTreeCurrentSelection);
946 __pDirectoryTreePM->AddFolderEntryList(rootMediaPath,__dirTreeCurrentSelection);
947 pDirTreeEntry->SetDirectoryOpenStatus(true);
953 SplitPanelForm::OnSceneDeactivated(const SceneId& currentSceneId,
954 const SceneId& nextSceneId)
956 ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
957 DeviceManager::RemoveAllDeviceEventListeners();
958 TryReturn(_pFolderEntryPM!=null, , "FolderEntryPresentationModel is NULL") ;
959 _pFolderEntryPM->StopThumbnailManager(true);
960 _pFolderEntryPM->SetCurrentReqId(0);
962 if(_pFileEventManager != null)
964 _pFileEventManager->RemovePath(__currentDirectoryPath);
969 SplitPanelForm::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId ¤tSceneId)
971 AppLogDebug("Enter");
972 AppRegistry* pAppRegistry = null;
973 String sortbyKeyName(L"SortBy");
974 int sortStyle = SORT_BY_TYPE_DATE_RECENT;
976 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
977 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
979 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
981 if (_renameOrCreate == SELECT_RENAME)
983 pAppRegistry->Get(sortbyKeyName, sortStyle);
985 if (sortStyle == SORT_BY_TYPE_NAME_ASCENDING || sortStyle == SORT_BY_TYPE_NAME_DESCENDING)
987 _pFolderEntryPM->SetFolderEntryPath(FolderNavigationPresentationModel::GetCurrentPath());
988 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
990 if (_pListView != null && _pListView->IsVisible())
992 _pListView->UpdateList();
997 _pListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1006 if (_pThumbnailItemProvider != null)
1008 _pThumbnailItemProvider->SetFileEventListener(this);
1013 SplitPanelForm::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId ¤tSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1015 //Empty Implementation.
1019 SplitPanelForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1021 CustomAppControl::GetInstance()->SetAppControlInUse(null);
1022 if ( _pFolderEntryPM != null)
1024 _pFolderEntryPM->RefreshFolderEntries();
1025 _pFolderEntryPM->InitThumbnailManager();
1030 SplitPanelForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1032 result res = E_SUCCESS;
1033 AppLogDebug("Enter");
1035 if (_pFolderEntryPM)
1037 if (pThumbReq != null)
1039 if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
1041 if (pThumbReq->pBitmap != null)
1043 delete pThumbReq->pBitmap;
1051 if (pThumbReq->iRquestId < _pFilenames->GetCount())
1053 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
1054 if (_pListView && _pListView->IsVisible())
1056 res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1058 if (_pIconListView && _pIconListView->IsVisible())
1060 res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1064 AppLogDebug("Thumbnail Request is not valid");
1068 _pFolderEntryPM->OnThumbnailResponseFailed();
1071 __pFirstPanePanel->Invalidate(true);
1072 __pSecondPanePanel->Invalidate(true);
1073 AppLogDebug("Exit %s", GetErrorMessage(res));
1078 SplitPanelForm::OnFormBackRequested(Form& source)
1080 ShowParentDirectoryView();
1083 SplitPanelForm::DirectoryTreeProvider::DirectoryTreeProvider(FolderEntryPresentationModel* pDirectoryTreePM)
1084 :__pDirectoryTreePM(pDirectoryTreePM)
1089 FolderEntryPresentationModel*
1090 SplitPanelForm::DirectoryTreeProvider::GetFolderEntryPresentationModel(void)
1092 return __pDirectoryTreePM;
1096 SplitPanelForm::OnFileEventExecuted(const Tizen::Base::String& path, const unsigned long eventId)
1098 AppLogDebug("ENTER");
1100 int badgeNumber = 0;
1101 result r = E_SUCCESS;
1103 // Tizen::Shell::NotificationManager* pNotiMgr = null;
1105 NotificationManager* pNotiMgr = null;
1106 AppResource* pAppResource = null;
1107 pAppResource = UiApp::GetInstance()->GetAppResource();
1108 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
1110 pNotiMgr = new (std::nothrow) NotificationManager();
1111 TryCatch(pNotiMgr != null, , "Failed to fetch AppNotificationManager");
1113 pNotiMgr->Construct();
1114 badgeNumber = pNotiMgr->GetBadgeNumber();
1117 if (_pFolderEntryPM != null)
1119 //_pFolderEntryPM->SetFileEventListener(null);
1120 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1121 TryCatch(_pFilenames != null, , "File Names List retrieval failed");
1126 case FILE_EVENT_TYPE_CREATE:
1128 if (_pListView != null && _pListView->IsVisible())
1130 _pListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1132 if (_pIconListView != null && _pIconListView->IsVisible())
1134 _pIconListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1140 case FILE_EVENT_TYPE_DELETE:
1142 if (_pListView != null && _pListView->IsVisible())
1144 _pListView->RefreshList(__selectedIndex, LIST_REFRESH_TYPE_ITEM_REMOVE);
1146 if (_pIconListView != null && _pIconListView->IsVisible())
1148 if (_pThumbnailItemProvider != null)
1150 __selectedIndex = _pThumbnailItemProvider->GetPressedIndex();
1152 _pIconListView->RefreshList(__selectedIndex, LIST_REFRESH_TYPE_ITEM_REMOVE);
1158 case FILE_EVENT_TYPE_DELETE_SELF:
1171 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1173 if (pNotiMgr != null)
1181 if (pNotiMgr != null)
1190 SplitPanelForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1192 Integer* pFileProcessingResult = null;
1193 HashMap* pCacheList = null;
1194 DirectoryEntry* pCurrentEntry = null;
1195 bool cacheKeyStatus = false;
1197 TryCatch(pArgs != null, , "Argument list received is invalid!");
1198 pFileProcessingResult = (Integer*) pArgs->GetAt(0);
1200 TryCatch(pFileProcessingResult != null, , "FileProcessing Result list is invalid!");
1202 switch (pFileProcessingResult->ToInt())
1204 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1206 if (_pFilenames != null)
1208 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1210 if (pCacheList != null)
1212 pCurrentEntry = static_cast<DirectoryEntry*>(_pFilenames->GetAt(_indexTracker));
1214 if (pCurrentEntry != null)
1216 cachePath = pCurrentEntry->GetFullFilePath();
1219 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1223 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1227 _pFilenames->RemoveAt(_indexTracker, true);
1228 //r = __pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_REMOVE);
1229 if (_pListView != null)
1231 //_pListView->UpdateList();
1232 _pListView->RefreshList(_indexTracker, LIST_REFRESH_TYPE_ITEM_REMOVE);
1234 if (_pIconListView != null && _pIconListView->IsVisible())
1236 _pIconListView->RefreshList(_indexTracker, LIST_REFRESH_TYPE_ITEM_REMOVE);
1239 HideFileProgressingPopup();
1243 case FILE_MANAGING_RESULT_DELETING_FAILED:
1245 HideFileProgressingPopup();
1248 case FILE_MANAGING_RESULT_THREAD_STOP:
1250 HideFileProgressingPopup();
1262 pArgs->RemoveAll(true);
1269 SplitPanelForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1271 AppLogDebug("TopMostFolderFileListForm::OnFileEventOccured");
1272 if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE))
1274 if (_pFolderEntryPM!=null)
1276 _pFolderEntryPM->RefreshFolderEntries();
1279 if (_pListView != null && _pListView->IsVisible())
1281 _pListView->UpdateList();
1284 if (_pIconListView != null && _pIconListView->IsVisible())
1286 _pIconListView->UpdateList();
1289 if (_pFolderEntryPM!=null)
1291 _pFolderEntryPM->InitThumbnailManager();