Copy Feature Implementation
authorchitta ranjan <chitta.rs@samsung.com>
Fri, 5 Apr 2013 03:56:03 +0000 (12:56 +0900)
committerchitta ranjan <chitta.rs@samsung.com>
Fri, 5 Apr 2013 03:56:03 +0000 (12:56 +0900)
Change-Id: Ia711561ad8d206ae20a966b4a50b57d81cd55e5b
Signed-off-by: chitta ranjan <chitta.rs@samsung.com>
13 files changed:
inc/GlAlbumNameEditorForm.h
inc/GlFileListEditorForm.h
inc/GlFileListPresentationModel.h
inc/GlFileMoveTimer.h
inc/GlTimerBase.h
inc/GlTypes.h
src/GlAlbumListEditorForm.cpp
src/GlAlbumNameEditorForm.cpp
src/GlFileListEditorForm.cpp
src/GlFileListPresentationModel.cpp
src/GlFileMoveTimer.cpp
src/GlProgressBar.cpp
src/GlTimerBase.cpp

index 64bbd32..33d7c2b 100644 (file)
@@ -93,6 +93,7 @@ private:
        AlbumListPresentationModel* __pPresentationModel;
        FileListPresentationModel* __pFilePresentationModel;
        Tizen::Base::Collection::IList* __pMoveIndexList;
+       FileActionMode __fileActionMode;
 
        FileMoveTimer* __pFileMove;
        ProgressAnimation* __pProgressAnim;
index 2424e7f..a0c8def 100644 (file)
@@ -85,6 +85,7 @@ private:
        SlideShowPopUp* __pPopUp;
        FileListPresentationModel* __pPresentationModel;
        FileMoveTimer* __pFileMove;
+       bool __isCopyOperation;
 };
 
 #endif /* _GL_FILE_LIST_EDITOR_FORM_H_ */
index 5c642fc..a67f05e 100644 (file)
@@ -114,7 +114,7 @@ private:
                        const ThumbnailInfo& thumbmailInfo);
        result DeleteContentFile(const Tizen::Content::ContentId& contentId);
        result MoveToContentFile(const Tizen::Content::ContentId& contentId,
-                       const Tizen::Base::String& destDirectory);
+                       const Tizen::Base::String& destDirectory, const bool isCopyOperation);
        Tizen::Graphics::Bitmap* GetShadedBackgroundBitmapN(Tizen::Graphics::Bitmap& bgBitmap,
                        const Tizen::Graphics::Bitmap& orgBitmap, const Tizen::Graphics::Rectangle& orgBitmapPosition);
        Tizen::Base::Collection::IList* GetContentInfoListInDirectoryListN(
index 838cc1d..7cbc57b 100644 (file)
 
 class FileListPresentationModel;
 
+/* FileMoveTimer class is used for Move and Copy operations*/
 class FileMoveTimer
 : public GlTimerBase
   {
 public :
        FileMoveTimer(Tizen::Base::String& , Tizen::Base::Collection::IList* , FileListPresentationModel*,
-                       IFileOpInvalidateListener*);
+                       IFileOpInvalidateListener*, bool __isCopyOperation = false);
        ~FileMoveTimer(void);
 
+       void SetCopy();
+       void ClearCopy();
+
 private:
        //From GlTimerBase
        Tizen::Base::Collection::IList * TimerStart(void);
@@ -44,6 +48,7 @@ private :
        Tizen::Base::Collection::IList* __pMoveIndexList;
        Tizen::Base::String __moveToDir;
        FileListPresentationModel* __pPresentationModel;
+       bool __isCopyOperation;
 
   };
 
index 0795d3a..8acb206 100644 (file)
@@ -50,6 +50,8 @@ class GlTimerBase
        //From ITimerEventListener
        void OnTimerExpired(Timer& timer);
 
+       void SetActionMode(enum FileActionMode actionId);
+
        protected:
        virtual Tizen::Base::Collection::IList * TimerStart(void) = 0;
        virtual result TimerExpired(const ContentId&) = 0;
index 8064035..5445887 100644 (file)
@@ -39,6 +39,7 @@ enum ACTION_ID_
        ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW = 306,
        ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE = 307,
        ACTION_ID_CONTEXT_MENU_SHARE_EMAIL = 308,
+       ACTION_ID_CONTEXT_MENU_MORE_COPY = 309,
        ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START = 401,
        ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM = 600,
        ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START = 601,
@@ -109,7 +110,8 @@ enum FileActionMode
 {
        FILE_DELETE_ACTION,
        FILE_MOVE_ACTION,
-       FILE_RENAME_ACTION
+       FILE_RENAME_ACTION,
+       FILE_COPY_ACTION
 };
 
 enum FileActionCancelRes
@@ -325,6 +327,6 @@ static const unsigned int CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND = Tizen::Gra
 static const unsigned int CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND = Tizen::Graphics::Color32<220, 218, 211>::Value;
 static const unsigned int CUSTOM_COLOR_SETTINGS_GROUPTITLE = Tizen::Graphics::Color32<59, 115, 182>::Value;
 static const int ALBUM_FIRST_ELEMENT = 0;
-
+static const int ALBUM_SECOND_ELEMENT = 1;
 
 #endif /* _GL_TYPES_H_ */
index 74749da..7c31e91 100644 (file)
@@ -376,6 +376,7 @@ AlbumListEditorForm::OnIconListViewOverlayBitmapSelected (IconListView &iconList
        pSelectedIndex->Construct();
        //Adding the Action Type
        pSelectedIndex->Add(new (std::nothrow) Integer(ALBUM_RENAME));
+       pSelectedIndex->Add(new (std::nothrow) Integer(FILE_MOVE_ACTION));
        pSelectedIndex->Add(new (std::nothrow) Integer(index));
 
        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pSelectedIndex);
index 78ff261..78e2283 100644 (file)
@@ -55,6 +55,7 @@ AlbumNameEditorForm::AlbumNameEditorForm()
        , __pPresentationModel(null)
        , __pFilePresentationModel(null)
        , __pMoveIndexList(null)
+       , __fileActionMode(FILE_MOVE_ACTION)
        , __pFileMove(null)
        , __pProgressAnim(null)
 {
@@ -307,7 +308,15 @@ AlbumNameEditorForm::OnCreateAlbum(void)
        delete __pFileMove;
        GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
        __pFileMove = new FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
-       __pFilePresentationModel->SetUpdateProgressStatus(true);
+       if(__fileActionMode == FILE_COPY_ACTION)
+       {
+               AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
+               __pFileMove->SetCopy();
+       }
+       else
+       {
+               __pFileMove->ClearCopy();
+       }
        result r = __pFileMove->StartTimer();
 
        if (IsFailed(r))
@@ -325,6 +334,7 @@ AlbumNameEditorForm::OnCreateAlbum(void)
        {
                AppLogDebug("MoveToContentFileList content in progress");
                __overlayMsg = true;
+               __fileActionMode = FILE_MOVE_ACTION;
        }
 }
 
@@ -415,6 +425,22 @@ AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
                pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
        }
 
+       if (pArgs != null)
+       {
+               Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
+               if (operationTypePtr->ToInt() == FILE_MOVE_ACTION)
+               {
+                       AppLogDebug("Rash: FILE_MOVE_ACTION");
+                       __fileActionMode = FILE_MOVE_ACTION;
+               }
+               else if (operationTypePtr->ToInt()  == FILE_COPY_ACTION)
+               {
+                       AppLogDebug("Rash: FILE_COPY_ACTION");
+                       __fileActionMode = FILE_COPY_ACTION;
+               }
+               pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
+       }
+
        if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
        {
                if (pArgs != null)
index e5e4bd1..4b6f746 100644 (file)
@@ -64,6 +64,7 @@ FileListEditorForm::FileListEditorForm(void)
        , __pContentDirectoryNameList(null)
        , __pPresentationModel(null)
        , __pFileMove(null)
+       ,__isCopyOperation(false)
 {
        AppLogDebug("ENTER");
        __overlayMsg = false;
@@ -257,6 +258,8 @@ FileListEditorForm::InitializeFooter(void)
 
                __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
                                ACTION_ID_CONTEXT_MENU_MORE_MOVE);
+               __pContextMenuMore->AddItem((L"Copy"),
+                                               ACTION_ID_CONTEXT_MENU_MORE_COPY);
 
                if (checkedCount > 1)
                {
@@ -464,8 +467,18 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
        {
                break;
        }
+       case ACTION_ID_CONTEXT_MENU_MORE_COPY:
+       {
+               //__pFileMove->SetCopy();
+               __isCopyOperation = true;
+               //Fall through to next case.
+       }
        case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
        {
+               if(actionId == ACTION_ID_CONTEXT_MENU_MORE_MOVE)
+               {
+                       __isCopyOperation = false;
+               }
                RefreshFolderList();
                if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
                {
@@ -587,6 +600,14 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                        AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
                        IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
                        pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
+                       if(__isCopyOperation)
+                       {
+                               pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
+                       }
+                       else
+                       {
+                               pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
+                       }
                        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
                }
                break;
@@ -599,6 +620,14 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                        (pSceneManager->GetCurrentScene()->GetPanel());
                        IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
                        pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
+                       if(__isCopyOperation)
+                       {
+                               pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
+                       }
+                       else
+                       {
+                               pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
+                       }
                        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
                }
                break;
@@ -708,12 +737,18 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                                IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
                                                GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
                                                __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
-                                               __pPresentationModel->SetUpdateProgressStatus(true);
+                                               if(__isCopyOperation)
+                                               {
+                                                       AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
+                                                       __pFileMove->SetCopy();
+                                               }
+
                                                result r = __pFileMove->StartTimer();
                                                if (IsFailed(r))
                                                {
                                                        delete __pFileMove;
                                                        __pFileMove = null;
+                                                       __isCopyOperation = false;
                                                }
                                                else
                                                {
@@ -747,12 +782,17 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                                IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
                                                GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
                                                __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
-                                               __pPresentationModel->SetUpdateProgressStatus(true);
+                                               if(__isCopyOperation)
+                                               {
+                                                       AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
+                                                       __pFileMove->SetCopy();
+                                               }
                                                result r = __pFileMove->StartTimer();
                                                if (IsFailed(r))
                                                {
                                                        delete __pFileMove;
                                                        __pFileMove = null;
+                                                       __isCopyOperation = false;
                                                }
                                                else
                                                {
index f3f417d..28a0d36 100644 (file)
@@ -938,7 +938,7 @@ FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
 }
 
 result
-FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory)
+FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory, const bool isCopyOperation)
 {
        AppLogDebug("ENTER");
        if (contentId.ToString().IsEmpty() == true || destDirectory.IsEmpty() == true)
@@ -1000,8 +1000,11 @@ FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const S
                                        __pContentManager->CreateContent(contentInfo);
                                        r = GetLastResult();
                                        TryCatch(!IsFailed(r),,"CreateContent::the value is %s",GetErrorMessage(r));
-                                       r = __pContentManager->DeleteContent(contentId);
-                                       TryCatch(!IsFailed(r),,"DeleteContent::the value is %s",GetErrorMessage(r));
+                                       if (!isCopyOperation)
+                                       {
+                                               r = __pContentManager->DeleteContent(contentId);
+                                               TryCatch(!IsFailed(r),,"DeleteContent::the value is %s",GetErrorMessage(r));
+                                       }
                                }
                        }
                }
@@ -1017,8 +1020,11 @@ FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const S
                                __pContentManager->CreateContent(contentInfo);
                                r = GetLastResult();
                                TryCatch(!IsFailed(r),,"CreateContent::the value is %s",GetErrorMessage(r));
-                               r = __pContentManager->DeleteContent(contentId);
-                               TryCatch(!IsFailed(r),,"DeleteContent::the value is %s",GetErrorMessage(r));
+                               if (!isCopyOperation)
+                               {
+                                       r = __pContentManager->DeleteContent(contentId);
+                                       TryCatch(!IsFailed(r),,"DeleteContent::the value is %s",GetErrorMessage(r));
+                               }
                        }
                }
        }
index 39f63a8..2e6f197 100644 (file)
@@ -39,7 +39,8 @@ using namespace Tizen::Ui::Scenes;
 
 FileMoveTimer::FileMoveTimer(String& destDirectory, IList* list
                , FileListPresentationModel* presentationModel
-               , IFileOpInvalidateListener* pInvalidate)
+               , IFileOpInvalidateListener* pInvalidate
+               , bool isCopyOperation)
                : GlTimerBase(pInvalidate, FILE_MOVE_ACTION)
                , __pMoveIndexList(list)
                ,__moveToDir(destDirectory)
@@ -66,6 +67,10 @@ IList * FileMoveTimer::TimerStart(void)
                AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
                return null;
        }
+       if(__isCopyOperation)
+       {
+               SetActionMode(FILE_COPY_ACTION);
+       }
        if (__pMoveIndexList->GetCount() > 0)
        {
                if (File::IsFileExist(__moveToDir) == false)
@@ -85,7 +90,7 @@ IList * FileMoveTimer::TimerStart(void)
 result FileMoveTimer::TimerExpired(const ContentId& contentId)
 {
        AppLogDebug("ENTER");
-       return __pPresentationModel->MoveToContentFile(contentId, __moveToDir);
+       return __pPresentationModel->MoveToContentFile(contentId, __moveToDir, __isCopyOperation);
 }
 
 void FileMoveTimer::TimerCancel(int, enum FileActionCancelRes res)
@@ -129,3 +134,12 @@ void FileMoveTimer::TimerComplete(int, enum FileActionCompleteRes res)
        AppLogDebug("EXIt");
 }
 
+void FileMoveTimer::SetCopy()
+{
+       __isCopyOperation = true;
+}
+
+void FileMoveTimer::ClearCopy()
+{
+       __isCopyOperation = false;
+}
index ba8b4d0..1a372b6 100644 (file)
@@ -146,6 +146,9 @@ GlProgressBar::ShowFileProgressingPopup(int val, enum FileActionMode action)
                        case FILE_DELETE_ACTION:
                                __pFileProgressingHeaderLabel->SetText(L"Deleting...");
                                break;
+                       case FILE_COPY_ACTION:
+                               __pFileProgressingHeaderLabel->SetText(L"Copying...");
+                               break;
                        default:
                                break;
                        }
index 2516b42..b365545 100644 (file)
@@ -181,3 +181,8 @@ void GlTimerBase::OnOpComplete(enum FileActionCompleteRes res)
        TimerComplete(__moveToCount, res);
        AppLogDebug("EXIT");
 }
+
+void GlTimerBase::SetActionMode(enum FileActionMode actionId)
+{
+       __actionId = actionId;
+}