TizenRefApp-8314 [Gallery] Rename ViewerPage into PreviewPage 72/122772/1
authorIgor Nazarov <i.nazarov@samsung.com>
Mon, 3 Apr 2017 09:47:07 +0000 (12:47 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Mon, 3 Apr 2017 09:47:07 +0000 (12:47 +0300)
- ViewerPage was renamed to PreviewPage.

Change-Id: Ia2e61a072ba54f0ecab0742309c43d2db5399f07

inc/presentation/PreviewPage.h [new file with mode: 0644]
inc/presentation/ViewerPage.h [deleted file]
inc/presentation/types.h
src/presentation/PreviewPage.cpp [new file with mode: 0644]
src/presentation/ThumbnailPage.cpp
src/presentation/ViewerPage.cpp [deleted file]

diff --git a/inc/presentation/PreviewPage.h b/inc/presentation/PreviewPage.h
new file mode 100644 (file)
index 0000000..d47f05d
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTATION_PREVIEW_PAGE_H__
+#define __GALLERY_PRESENTATION_PREVIEW_PAGE_H__
+
+#include "Page.h"
+
+#include "IImageGridListener.h"
+
+#include "model/types.h"
+
+namespace gallery {
+
+       class PreviewPage final : public Page,
+                       private IImageGridListener {
+       public:
+               class Builder {
+               public:
+                       Builder();
+                       ~Builder();
+                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+                       Builder &setAlbum(const IMediaAlbumSRef &album);
+                       Builder &setStartItemIndex(int index);
+                       PreviewPageSRef build(ExitRequestHandler onExitRequest) const;
+               private:
+                       ucl::NaviframeSRef m_navi;
+                       IMediaAlbumSRef m_album;
+                       int m_startItemIndex;
+               };
+
+       public:
+               void reload();
+
+       private:
+               friend class ucl::RefCountObj<PreviewPage>;
+               PreviewPage(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
+                               ExitRequestHandler onExitRequest, const IMediaAlbumSRef &album);
+               virtual ~PreviewPage();
+
+               ucl::Result prepare();
+               void showItem(int itemIndex);
+
+               bool onEachMedia(MediaItemUPtr &&media);
+
+               // Page //
+
+               virtual void onActivate() final override;
+               virtual void onDeactivate() final override;
+
+               // IImageGridListener //
+
+               virtual void onItemRealized(int itemIndex) final override;
+               virtual void onItemUnrealized(int itemIndex) final override;
+               virtual void onItemClicked(int itemIndex) final override;
+
+       private:
+               class Item;
+               using ItemUPtr = std::unique_ptr<Item>;
+
+       private:
+               const IMediaAlbumSRef m_album;
+               ImageGridSRef m_imageGrid;
+               std::vector<ItemUPtr> m_items;
+       };
+}
+
+#endif // __GALLERY_PRESENTATION_PREVIEW_PAGE_H__
diff --git a/inc/presentation/ViewerPage.h b/inc/presentation/ViewerPage.h
deleted file mode 100644 (file)
index 4f89dc8..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTATION_VIEWER_PAGE_H__
-#define __GALLERY_PRESENTATION_VIEWER_PAGE_H__
-
-#include "Page.h"
-
-#include "IImageGridListener.h"
-
-#include "model/types.h"
-
-namespace gallery {
-
-       class ViewerPage final : public Page,
-                       private IImageGridListener {
-       public:
-               class Builder {
-               public:
-                       Builder();
-                       ~Builder();
-                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       Builder &setAlbum(const IMediaAlbumSRef &album);
-                       Builder &setStartItemIndex(int index);
-                       ViewerPageSRef build(ExitRequestHandler onExitRequest) const;
-               private:
-                       ucl::NaviframeSRef m_navi;
-                       IMediaAlbumSRef m_album;
-                       int m_startItemIndex;
-               };
-
-       public:
-               void reload();
-
-       private:
-               friend class ucl::RefCountObj<ViewerPage>;
-               ViewerPage(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
-                               ExitRequestHandler onExitRequest, const IMediaAlbumSRef &album);
-               virtual ~ViewerPage();
-
-               ucl::Result prepare();
-               void showItem(int itemIndex);
-
-               bool onEachMedia(MediaItemUPtr &&media);
-
-               // Page //
-
-               virtual void onActivate() final override;
-               virtual void onDeactivate() final override;
-
-               // IImageGridListener //
-
-               virtual void onItemRealized(int itemIndex) final override;
-               virtual void onItemUnrealized(int itemIndex) final override;
-               virtual void onItemClicked(int itemIndex) final override;
-
-       private:
-               class Item;
-               using ItemUPtr = std::unique_ptr<Item>;
-
-       private:
-               const IMediaAlbumSRef m_album;
-               ImageGridSRef m_imageGrid;
-               std::vector<ItemUPtr> m_items;
-       };
-}
-
-#endif // __GALLERY_PRESENTATION_VIEWER_PAGE_H__
index f07d41788ee14c6f7cc39a30a4bb5d4150b98672..25837fbbde1ae370b98d88f8eaa0e04ecd18341e 100644 (file)
@@ -30,7 +30,7 @@ namespace gallery {
        UCL_DECLARE_REF_ALIASES(Page);
 
        UCL_DECLARE_REF_ALIASES(ThumbnailPage);
-       UCL_DECLARE_REF_ALIASES(ViewerPage);
+       UCL_DECLARE_REF_ALIASES(PreviewPage);
        UCL_DECLARE_REF_ALIASES(NoContentPage);
 }
 
diff --git a/src/presentation/PreviewPage.cpp b/src/presentation/PreviewPage.cpp
new file mode 100644 (file)
index 0000000..3666cf3
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "presentation/PreviewPage.h"
+
+#include "model/IMediaAlbum.h"
+#include "model/MediaItem.h"
+
+#include "presentation/ImageGrid.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       using namespace ucl;
+
+       // PreviewPage::Builder //
+
+       PreviewPage::Builder::Builder() :
+               m_startItemIndex(0)
+       {
+       }
+
+       PreviewPage::Builder::~Builder()
+       {
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setNaviframe(
+                       const NaviframeSRef &navi)
+       {
+               m_navi = navi;
+               return *this;
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setAlbum(
+                       const IMediaAlbumSRef &album)
+       {
+               m_album = album;
+               return *this;
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setStartItemIndex(
+                       const int index)
+       {
+               m_startItemIndex = index;
+               return *this;
+       }
+
+       PreviewPageSRef PreviewPage::Builder::build(
+                       const ExitRequestHandler onExitRequest) const
+       {
+               if (!onExitRequest) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "onExitRequest is NULL");
+               }
+               if (!m_navi) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+               }
+               if (!m_album) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
+               }
+
+               auto result = makeShared<PreviewPage>(
+                               m_navi, onExitRequest, m_album);
+
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+
+               if (m_startItemIndex > 0) {
+                       result->showItem(m_startItemIndex);
+               }
+
+               return result;
+       }
+
+       // PreviewPage::Item //
+
+       class PreviewPage::Item : public NonCopyable {
+       public:
+               Item(MediaItemUPtr &&media, ImageGrid &imageGrid, const int itemIndex) :
+                       m_media(std::move(media)),
+                       m_imageGrid(imageGrid),
+                       m_index(itemIndex)
+               {
+               }
+
+               void realize()
+               {
+                       FAIL_LOG(m_media->getThumbnailPath(
+                                       DELEGATE(Item::onThumbnail, this)),
+                                       "getThumbnailPath() failed!");
+               }
+
+               void unrealize()
+               {
+                       m_media->cancelThumbnailPathGet();
+               }
+
+       private:
+               void onThumbnail(const Result result, const std::string &path)
+               {
+                       FAIL_LOG(result, "Failed to get thumbnail!");
+
+                       ImageGrid::ItemParams params = {};
+                       m_media->getResolution(params.aspectX, params.aspectY);
+                       params.imagePath = m_media->getFilePath();
+                       params.bgImagePath = path;
+
+                       m_imageGrid.updateItem(m_index, params);
+               }
+
+       private:
+               const MediaItemUPtr m_media;
+               ImageGrid &m_imageGrid;
+               const int m_index;
+       };
+
+       // PreviewPage //
+
+       PreviewPage::PreviewPage(RefCountObjBase &rc,
+                       const NaviframeSRef &navi,
+                       const ExitRequestHandler onExitRequest,
+                       const IMediaAlbumSRef &album) :
+               Page(rc, navi, onExitRequest),
+               m_album(album)
+       {
+       }
+
+       PreviewPage::~PreviewPage()
+       {
+               m_imageGrid->setListener(nullptr);
+       }
+
+       void PreviewPage::reload()
+       {
+               ImageGrid::Unrealizer u(*m_imageGrid);
+
+               m_items.clear();
+
+               FAIL_LOG(m_album->forEachMedia(
+                               DELEGATE(PreviewPage::onEachMedia, this)),
+                               "m_album->forEachMedia() failed!");
+
+               m_imageGrid->setItemCount(m_items.size());
+       }
+
+       Result PreviewPage::prepare()
+       {
+               m_imageGrid = ImageGrid::Builder().
+                               setListener(this).
+                               setType(ImageGrid::Type::LINEAR).
+                               build(getNaviframe());
+               if (!m_imageGrid) {
+                       LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
+               }
+
+               FAIL_RETURN(m_album->forEachMedia(
+                               DELEGATE(PreviewPage::onEachMedia, this)),
+                               "m_album->forEachMedia() failed!");
+
+               FAIL_RETURN(Page::prepare(
+                       [this]()
+                       {
+                               return getNaviframe().push(*m_imageGrid);
+                       }),
+                       "Page::prepare() failed!");
+
+               m_imageGrid->setItemCount(m_items.size());
+
+               return RES_OK;
+       }
+
+       void PreviewPage::showItem(const int itemIndex)
+       {
+               m_imageGrid->scrollToItem(itemIndex);
+       }
+
+       bool PreviewPage::onEachMedia(MediaItemUPtr &&media)
+       {
+               m_items.emplace_back(
+                               new Item(std::move(media), *m_imageGrid, m_items.size()));
+               return true;
+       }
+
+       void PreviewPage::onActivate()
+       {
+               m_imageGrid->activateRotary();
+       }
+
+       void PreviewPage::onDeactivate()
+       {
+               m_imageGrid->deactivateRotary();
+       }
+
+       void PreviewPage::onItemRealized(const int itemIndex)
+       {
+               m_items[itemIndex]->realize();
+       }
+
+       void PreviewPage::onItemUnrealized(const int itemIndex)
+       {
+               m_items[itemIndex]->unrealize();
+       }
+
+       void PreviewPage::onItemClicked(const int itemIndex)
+       {
+               ILOG("TODO Not implemented. Item: %d;", itemIndex);
+       }
+}
index ee15ea9a06cf6e0e2b603c6f59936e24b677c34c..bff4a29e6c0f079c18bbfcbbf9179c9b7e595bf2 100644 (file)
@@ -20,7 +20,7 @@
 #include "model/MediaItem.h"
 
 #include "presentation/ImageGrid.h"
-#include "presentation/ViewerPage.h"
+#include "presentation/PreviewPage.h"
 
 #include "common.h"
 
@@ -144,7 +144,7 @@ namespace gallery {
 
                m_imageGrid->setItemCount(m_mediaItems.size());
 
-               if (const auto vp = dynamic_cast<ViewerPage *>(m_page.get())) {
+               if (const auto vp = dynamic_cast<PreviewPage *>(m_page.get())) {
                        vp->reload();
                }
        }
@@ -213,7 +213,7 @@ namespace gallery {
 
        void ThumbnailPage::onItemClicked(const int itemIndex)
        {
-               m_page = ViewerPage::Builder().
+               m_page = PreviewPage::Builder().
                                setNaviframe(asShared(getNaviframe())).
                                setAlbum(m_album).
                                setStartItemIndex(itemIndex).
diff --git a/src/presentation/ViewerPage.cpp b/src/presentation/ViewerPage.cpp
deleted file mode 100644 (file)
index c1e8b4e..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "presentation/ViewerPage.h"
-
-#include "model/IMediaAlbum.h"
-#include "model/MediaItem.h"
-
-#include "presentation/ImageGrid.h"
-
-#include "common.h"
-
-namespace gallery {
-
-       using namespace ucl;
-
-       // ViewerPage::Builder //
-
-       ViewerPage::Builder::Builder() :
-               m_startItemIndex(0)
-       {
-       }
-
-       ViewerPage::Builder::~Builder()
-       {
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setNaviframe(
-                       const NaviframeSRef &navi)
-       {
-               m_navi = navi;
-               return *this;
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setAlbum(
-                       const IMediaAlbumSRef &album)
-       {
-               m_album = album;
-               return *this;
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setStartItemIndex(
-                       const int index)
-       {
-               m_startItemIndex = index;
-               return *this;
-       }
-
-       ViewerPageSRef ViewerPage::Builder::build(
-                       const ExitRequestHandler onExitRequest) const
-       {
-               if (!onExitRequest) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "onExitRequest is NULL");
-               }
-               if (!m_navi) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
-               }
-               if (!m_album) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
-               }
-
-               auto result = makeShared<ViewerPage>(
-                               m_navi, onExitRequest, m_album);
-
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-
-               if (m_startItemIndex > 0) {
-                       result->showItem(m_startItemIndex);
-               }
-
-               return result;
-       }
-
-       // ViewerPage::Item //
-
-       class ViewerPage::Item : public NonCopyable {
-       public:
-               Item(MediaItemUPtr &&media, ImageGrid &imageGrid, const int itemIndex) :
-                       m_media(std::move(media)),
-                       m_imageGrid(imageGrid),
-                       m_index(itemIndex)
-               {
-               }
-
-               void realize()
-               {
-                       FAIL_LOG(m_media->getThumbnailPath(
-                                       DELEGATE(Item::onThumbnail, this)),
-                                       "getThumbnailPath() failed!");
-               }
-
-               void unrealize()
-               {
-                       m_media->cancelThumbnailPathGet();
-               }
-
-       private:
-               void onThumbnail(const Result result, const std::string &path)
-               {
-                       FAIL_LOG(result, "Failed to get thumbnail!");
-
-                       ImageGrid::ItemParams params = {};
-                       m_media->getResolution(params.aspectX, params.aspectY);
-                       params.imagePath = m_media->getFilePath();
-                       params.bgImagePath = path;
-
-                       m_imageGrid.updateItem(m_index, params);
-               }
-
-       private:
-               const MediaItemUPtr m_media;
-               ImageGrid &m_imageGrid;
-               const int m_index;
-       };
-
-       // ViewerPage //
-
-       ViewerPage::ViewerPage(RefCountObjBase &rc,
-                       const NaviframeSRef &navi,
-                       const ExitRequestHandler onExitRequest,
-                       const IMediaAlbumSRef &album) :
-               Page(rc, navi, onExitRequest),
-               m_album(album)
-       {
-       }
-
-       ViewerPage::~ViewerPage()
-       {
-               m_imageGrid->setListener(nullptr);
-       }
-
-       void ViewerPage::reload()
-       {
-               ImageGrid::Unrealizer u(*m_imageGrid);
-
-               m_items.clear();
-
-               FAIL_LOG(m_album->forEachMedia(
-                               DELEGATE(ViewerPage::onEachMedia, this)),
-                               "m_album->forEachMedia() failed!");
-
-               m_imageGrid->setItemCount(m_items.size());
-       }
-
-       Result ViewerPage::prepare()
-       {
-               m_imageGrid = ImageGrid::Builder().
-                               setListener(this).
-                               setType(ImageGrid::Type::LINEAR).
-                               build(getNaviframe());
-               if (!m_imageGrid) {
-                       LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
-               }
-
-               FAIL_RETURN(m_album->forEachMedia(
-                               DELEGATE(ViewerPage::onEachMedia, this)),
-                               "m_album->forEachMedia() failed!");
-
-               FAIL_RETURN(Page::prepare(
-                       [this]()
-                       {
-                               return getNaviframe().push(*m_imageGrid);
-                       }),
-                       "Page::prepare() failed!");
-
-               m_imageGrid->setItemCount(m_items.size());
-
-               return RES_OK;
-       }
-
-       void ViewerPage::showItem(const int itemIndex)
-       {
-               m_imageGrid->scrollToItem(itemIndex);
-       }
-
-       bool ViewerPage::onEachMedia(MediaItemUPtr &&media)
-       {
-               m_items.emplace_back(
-                               new Item(std::move(media), *m_imageGrid, m_items.size()));
-               return true;
-       }
-
-       void ViewerPage::onActivate()
-       {
-               m_imageGrid->activateRotary();
-       }
-
-       void ViewerPage::onDeactivate()
-       {
-               m_imageGrid->deactivateRotary();
-       }
-
-       void ViewerPage::onItemRealized(const int itemIndex)
-       {
-               m_items[itemIndex]->realize();
-       }
-
-       void ViewerPage::onItemUnrealized(const int itemIndex)
-       {
-               m_items[itemIndex]->unrealize();
-       }
-
-       void ViewerPage::onItemClicked(const int itemIndex)
-       {
-               ILOG("TODO Not implemented. Item: %d;", itemIndex);
-       }
-}