From 5697a08e79bd34e43c1596611d4cf32f9b698781 Mon Sep 17 00:00:00 2001 From: Eugene Kurzberg Date: Mon, 14 Mar 2016 09:31:13 +0200 Subject: [PATCH] Navigator and NavigatorPage refactoring. Change-Id: Ic545ab5a23f90f4c9c7d4767ec4198ef5265e39e Signed-off-by: Eugene Kurzberg --- lib-apps-common/inc/Ui/Naviframe.h | 9 ++-- lib-apps-common/inc/Ui/Navigator.h | 33 +++++++++----- lib-apps-common/inc/Ui/NavigatorPage.h | 25 ++++++++++- lib-apps-common/inc/Ui/TabPage.h | 3 +- lib-apps-common/inc/Ui/TabView.h | 15 ++++--- lib-apps-common/inc/Ui/View.h | 16 +++---- lib-apps-common/src/Ui/Naviframe.cpp | 39 +++++++--------- lib-apps-common/src/Ui/NaviframePage.cpp | 5 ++- lib-apps-common/src/Ui/Navigator.cpp | 51 +++++++++++++-------- lib-apps-common/src/Ui/NavigatorPage.cpp | 49 ++++++++++++++++++++ lib-apps-common/src/Ui/TabPage.cpp | 10 +++-- lib-apps-common/src/Ui/TabView.cpp | 69 ++++++++++++++++------------- lib-apps-common/src/Ui/View.cpp | 18 +++----- main-app/src/OperationDefaultController.cpp | 2 +- 14 files changed, 223 insertions(+), 121 deletions(-) create mode 100644 lib-apps-common/src/Ui/NavigatorPage.cpp diff --git a/lib-apps-common/inc/Ui/Naviframe.h b/lib-apps-common/inc/Ui/Naviframe.h index b10963d..1618c9d 100644 --- a/lib-apps-common/inc/Ui/Naviframe.h +++ b/lib-apps-common/inc/Ui/Naviframe.h @@ -19,6 +19,7 @@ #define UI_NAVIFRAME_H #include "Ui/Navigator.h" +#include "Ui/NaviframePage.h" namespace Ui { @@ -31,14 +32,14 @@ namespace Ui Naviframe(); /** - * @see Navigator::getCurrentView() + * @see Navigator::getCurrentPage() */ - virtual View *getCurrentView() const override; + virtual NaviframePage *getCurrentPage() const override; protected: virtual Evas_Object *onCreate(Evas_Object *parent) override; - virtual NavigatorPage *attachView(View *view) override; - virtual void navigateToView(View *view) override; + virtual NaviframePage *attachView(View *view) override; + virtual void navigateToPage(NavigatorPage *page) override; Eina_Bool onItemPop(Elm_Object_Item *item); void onTransition(Evas_Object *obj, void *eventInfo); diff --git a/lib-apps-common/inc/Ui/Navigator.h b/lib-apps-common/inc/Ui/Navigator.h index 050fe46..19d0517 100644 --- a/lib-apps-common/inc/Ui/Navigator.h +++ b/lib-apps-common/inc/Ui/Navigator.h @@ -23,16 +23,25 @@ namespace Ui { class NavigatorPage; + + /** + * @brief Navigator base class. + */ class EXPORT_API Navigator : public View { public: /** - * @return Currently displayed view + * @return Currently displayed page. + */ + virtual NavigatorPage *getCurrentPage() const = 0; + + /** + * @return Page count. */ - virtual View *getCurrentView() const = 0; + size_t getPageCount() const; /** - * @brief Navigate to existing or new View + * @brief Navigate to existing or new View. * @param[in] view View to navigate to */ void navigateTo(View *view); @@ -41,11 +50,11 @@ namespace Ui Navigator(NavigatorType type); /** - * @brief Notify specified View about navigation - * @param[in] view View to notify - * @param[in] isCurrentView Specifies the new state of the @a view + * @brief Notify specified Page about navigation. + * @param[in] page Page to notify + * @param[in] isCurrent The new state of the @a page */ - void notifyNavigation(View *view, bool isCurrentView); + void notifyNavigation(NavigatorPage *page, bool isCurrent); /** * @brief Called after navigateTo() is called for a new view @@ -56,14 +65,14 @@ namespace Ui /** * @brief Called after navigateTo() is called - * @param[in] view View to navigate to + * @param[in] page Page to navigate to */ - virtual void navigateToView(View *view) = 0; + virtual void navigateToPage(NavigatorPage *page) = 0; /** * @see View::onNavigation() */ - virtual void onNavigation(bool isCurrentView) override; + virtual void onNavigation(bool isCurrent) override; /** * @see View::onBackPressed() @@ -76,7 +85,11 @@ namespace Ui virtual void onMenuPressed() override; private: + friend class NavigatorPage; + void onPageDestroy(NavigatorPage *page); + NavigatorType m_Type; + size_t m_PageCount; }; } diff --git a/lib-apps-common/inc/Ui/NavigatorPage.h b/lib-apps-common/inc/Ui/NavigatorPage.h index 7c5826d..eb19b5f 100644 --- a/lib-apps-common/inc/Ui/NavigatorPage.h +++ b/lib-apps-common/inc/Ui/NavigatorPage.h @@ -23,13 +23,27 @@ namespace Ui { + class Navigator; + class View; + /** - * @brief Navigator page interface + * @brief Navigator page base class. */ class EXPORT_API NavigatorPage { public: - virtual ~NavigatorPage() { } + NavigatorPage(); + virtual ~NavigatorPage(); + + /** + * @return Parent navigator. + */ + Navigator *getNavigator() const; + + /** + * @return Contained view. + */ + View *getView() const; /** * @brief Set page title. @@ -48,6 +62,13 @@ namespace Ui * @param[in] content Content to set to page part */ virtual void setContent(const char *part, Evas_Object *content) = 0; + + private: + friend class Navigator; + void onNavigatorAttached(Navigator *navigator, View *view); + + Navigator *m_Navigator; + View *m_View; }; } diff --git a/lib-apps-common/inc/Ui/TabPage.h b/lib-apps-common/inc/Ui/TabPage.h index 4223028..aa226d5 100644 --- a/lib-apps-common/inc/Ui/TabPage.h +++ b/lib-apps-common/inc/Ui/TabPage.h @@ -26,7 +26,7 @@ namespace Ui class EXPORT_API TabPage : public Control, public NavigatorPage { public: - TabPage(size_t index, Elm_Object_Item *tabItem); + TabPage(size_t index); virtual ~TabPage() override; /** @@ -47,6 +47,7 @@ namespace Ui private: friend class TabView; virtual Evas_Object *onCreate(Evas_Object *parent) override; + void onTabAttached(Elm_Object_Item *tabItem); size_t m_Index; Elm_Object_Item *m_TabItem; diff --git a/lib-apps-common/inc/Ui/TabView.h b/lib-apps-common/inc/Ui/TabView.h index f56b85b..3c28d02 100644 --- a/lib-apps-common/inc/Ui/TabView.h +++ b/lib-apps-common/inc/Ui/TabView.h @@ -19,6 +19,7 @@ #define UI_TAB_VIEW_H #include "Ui/Navigator.h" +#include "Ui/TabPage.h" #include namespace Ui @@ -32,20 +33,20 @@ namespace Ui TabView(); /** - * @see Navigator::getCurrentView() + * @see Navigator::getCurrentPage() */ - virtual View *getCurrentView() const override; + virtual TabPage *getCurrentPage() const override; protected: virtual Evas_Object *onCreate(Evas_Object *parent) override; virtual void onPageAttached() override; - virtual NavigatorPage *attachView(View *view) override; - virtual void navigateToView(View *view) override; + virtual TabPage *attachView(View *view) override; + virtual void navigateToPage(NavigatorPage *page) override; private: static void onTabDestroy(void *data, Evas_Object *obj, void *tabItem); - void onTabSelect(Evas_Object *obj, void *tabItem); + void onTabSelected(Evas_Object *obj, Elm_Object_Item *selectedItem); void onPageChanged(Evas_Object *obj, void *eventInfo); void onResize(Evas *e, Evas_Object *obj, void *eventInfo); @@ -57,8 +58,8 @@ namespace Ui Evas_Coord m_Height; bool m_IsNavigating; - size_t m_CurrentPage; - std::vector m_Views; + TabPage *m_CurrentPage; + std::vector m_Pages; }; } diff --git a/lib-apps-common/inc/Ui/View.h b/lib-apps-common/inc/Ui/View.h index 3f87a7d..8aa1d62 100644 --- a/lib-apps-common/inc/Ui/View.h +++ b/lib-apps-common/inc/Ui/View.h @@ -41,6 +41,9 @@ namespace Ui class EXPORT_API View : public Control { public: + View(); + virtual ~View() override; + /** * @brief Get parent Navigator * @param[in] type Navigator type @@ -55,14 +58,11 @@ namespace Ui NavigatorPage *getPage() const; protected: - View(); - virtual ~View() override; - /** * @brief Called after Navigator has navigated to or from this View - * @param[in] isCurrentView Specifies the new state of this View + * @param[in] isCurrent Specifies the new state of this View */ - virtual void onNavigation(bool isCurrentView) { } + virtual void onNavigation(bool isCurrent) { } /** * @brief Called when NavigatorPage is attached to this View @@ -83,13 +83,11 @@ namespace Ui private: friend class Window; friend class Navigator; - - void onViewAttached(Navigator *stackNavi, Navigator *tabNavi); - void onPageAttached(NavigatorPage *page); + void onNavigatorAttached(Navigator *stackNavi, Navigator *tabNavi, NavigatorPage *page); Navigator *m_StackNavi; Navigator *m_TabNavi; - NavigatorPage *m_NaviPage; + NavigatorPage *m_Page; }; } diff --git a/lib-apps-common/src/Ui/Naviframe.cpp b/lib-apps-common/src/Ui/Naviframe.cpp index 152eb10..69b25f7 100644 --- a/lib-apps-common/src/Ui/Naviframe.cpp +++ b/lib-apps-common/src/Ui/Naviframe.cpp @@ -27,14 +27,10 @@ Naviframe::Naviframe() { } -View *Naviframe::getCurrentView() const +NaviframePage *Naviframe::getCurrentPage() const { Elm_Object_Item *item = elm_naviframe_top_item_get(getEvasObject()); - if (!item) { - return nullptr; - } - - return static_cast(elm_object_item_data_get(item)); + return (NaviframePage *) elm_object_item_data_get(item); } Evas_Object *Naviframe::onCreate(Evas_Object *parent) @@ -42,42 +38,41 @@ Evas_Object *Naviframe::onCreate(Evas_Object *parent) Evas_Object *naviframe = elm_naviframe_add(parent); elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_TRUE); + evas_object_smart_callback_add(naviframe, "transition,finished", + makeCallback(&Naviframe::onTransition), this); + return naviframe; } -NavigatorPage *Naviframe::attachView(View *view) +NaviframePage *Naviframe::attachView(View *view) { + notifyNavigation(getCurrentPage(), false); + Elm_Object_Item *naviItem = elm_naviframe_item_push(getEvasObject(), nullptr, - nullptr, nullptr, view->getEvasObject(), nullptr); - elm_object_item_data_set(naviItem, view); + nullptr, nullptr, view->create(getEvasObject()), nullptr); elm_naviframe_item_pop_cb_set(naviItem, makeCallback(&Naviframe::onItemPop), this); + return new NaviframePage(naviItem); } -void Naviframe::navigateToView(View *view) +void Naviframe::navigateToPage(NavigatorPage *page) { - if (view != getCurrentView()) { - NaviframePage *page = static_cast(view->getPage()); - elm_naviframe_item_pop_to(page->m_NaviItem); + if (page != getCurrentPage()) { + Elm_Object_Item *naviItem = static_cast(page)->m_NaviItem; + elm_naviframe_item_pop_to(naviItem); } } Eina_Bool Naviframe::onItemPop(Elm_Object_Item *item) { - evas_object_smart_callback_add(getEvasObject(), "transition,finished", - makeCallback(&Naviframe::onTransition), this); - - View *view = static_cast(elm_object_item_data_get(item)); - notifyNavigation(view, false); + NaviframePage *page = static_cast(elm_object_item_data_get(item)); + notifyNavigation(page, false); return EINA_TRUE; } void Naviframe::onTransition(Evas_Object *obj, void *eventInfo) { - notifyNavigation(getCurrentView(), true); - - evas_object_smart_callback_del(getEvasObject(), "transition,finished", - makeCallback(&Naviframe::onTransition)); + notifyNavigation(getCurrentPage(), true); } bool Naviframe::onBackPressed() diff --git a/lib-apps-common/src/Ui/NaviframePage.cpp b/lib-apps-common/src/Ui/NaviframePage.cpp index cdf5ad2..6840795 100644 --- a/lib-apps-common/src/Ui/NaviframePage.cpp +++ b/lib-apps-common/src/Ui/NaviframePage.cpp @@ -16,11 +16,13 @@ */ #include "Ui/NaviframePage.h" + using namespace Ui; NaviframePage::NaviframePage(Elm_Object_Item *naviItem) : m_NaviItem(naviItem) { + elm_object_item_data_set(m_NaviItem, this); } NaviframePage::~NaviframePage() @@ -36,8 +38,9 @@ NaviframePage::~NaviframePage() void NaviframePage::setTitle(const char *title) { + bool isEnabled = title && *title; elm_object_item_translatable_part_text_set(m_NaviItem, "elm.text.title", title); - elm_naviframe_item_title_enabled_set(m_NaviItem, title && *title, EINA_TRUE); + elm_naviframe_item_title_enabled_set(m_NaviItem, isEnabled, EINA_TRUE); } void NaviframePage::setStyle(const char *style) diff --git a/lib-apps-common/src/Ui/Navigator.cpp b/lib-apps-common/src/Ui/Navigator.cpp index 23d944c..1a3452a 100644 --- a/lib-apps-common/src/Ui/Navigator.cpp +++ b/lib-apps-common/src/Ui/Navigator.cpp @@ -16,21 +16,30 @@ */ #include "Ui/Navigator.h" +#include "Ui/NavigatorPage.h" using namespace Ui; Navigator::Navigator(NavigatorType type) - : m_Type(type) + : m_Type(type), m_PageCount(0) { } +size_t Navigator::getPageCount() const +{ + return m_PageCount; +} + void Navigator::navigateTo(View *view) { - if (!view || view == getCurrentView()) { + if (!view) { return; } - notifyNavigation(getCurrentView(), false); + NavigatorPage *page = view->getPage(); + if (page && page == getCurrentPage()) { + return; + } if (view->getNavigator(m_Type) != this) { Navigator *stackNavi = m_StackNavi; @@ -41,37 +50,43 @@ void Navigator::navigateTo(View *view) tabNavi = this; } - view->create(getEvasObject()); - view->onViewAttached(stackNavi, tabNavi); - view->onPageAttached(attachView(view)); + page = attachView(view); + page->onNavigatorAttached(this, view); + view->onNavigatorAttached(stackNavi, tabNavi, page); + + ++m_PageCount; } - navigateToView(view); - notifyNavigation(view, true); + navigateToPage(page); } -void Navigator::notifyNavigation(View *view, bool isCurrentView) +void Navigator::notifyNavigation(NavigatorPage *page, bool isCurrent) { - if (view) { - view->onNavigation(isCurrentView); + if (page) { + page->getView()->onNavigation(isCurrent); } } -void Navigator::onNavigation(bool isCurrentView) +void Navigator::onNavigation(bool isCurrent) { - notifyNavigation(getCurrentView(), isCurrentView); + notifyNavigation(getCurrentPage(), isCurrent); } bool Navigator::onBackPressed() { - View *view = getCurrentView(); - return view ? view->onBackPressed() : true; + NavigatorPage *page = getCurrentPage(); + return page ? page->getView()->onBackPressed() : true; } void Navigator::onMenuPressed() { - View *view = getCurrentView(); - if (view) { - view->onMenuPressed(); + NavigatorPage *page = getCurrentPage(); + if (page) { + page->getView()->onMenuPressed(); } } + +void Navigator::onPageDestroy(NavigatorPage *page) +{ + --m_PageCount; +} diff --git a/lib-apps-common/src/Ui/NavigatorPage.cpp b/lib-apps-common/src/Ui/NavigatorPage.cpp new file mode 100644 index 0000000..d8ff1ba --- /dev/null +++ b/lib-apps-common/src/Ui/NavigatorPage.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 "Ui/NavigatorPage.h" +#include "Ui/Navigator.h" + +using namespace Ui; + +NavigatorPage::NavigatorPage() + : m_Navigator(nullptr), m_View(nullptr) +{ +} + +NavigatorPage::~NavigatorPage() +{ + if (m_Navigator) { + m_Navigator->onPageDestroy(this); + } +} + +Navigator *NavigatorPage::getNavigator() const +{ + return m_Navigator; +} + +View *NavigatorPage::getView() const +{ + return m_View; +} + +void NavigatorPage::onNavigatorAttached(Navigator *navigator, View *view) +{ + m_Navigator = navigator; + m_View = view; +} diff --git a/lib-apps-common/src/Ui/TabPage.cpp b/lib-apps-common/src/Ui/TabPage.cpp index e1bfa18..40e9389 100644 --- a/lib-apps-common/src/Ui/TabPage.cpp +++ b/lib-apps-common/src/Ui/TabPage.cpp @@ -16,14 +16,13 @@ */ #include "Ui/TabPage.h" -#include "Utils/Logger.h" #define BUFFER_SIZE 64 using namespace Ui; -TabPage::TabPage(size_t index, Elm_Object_Item *tabItem) - : m_Index(index), m_TabItem(tabItem), m_Sizer(nullptr), m_Page(nullptr) +TabPage::TabPage(size_t index) + : m_Index(index), m_TabItem(nullptr), m_Sizer(nullptr), m_Page(nullptr) { } @@ -70,3 +69,8 @@ void TabPage::setContent(const char *part, Evas_Object *content) elm_layout_signal_emit(m_Page, buffer, "elm"); elm_object_part_content_set(m_Page, part, content); } + +void TabPage::onTabAttached(Elm_Object_Item *tabItem) +{ + m_TabItem = tabItem; +} diff --git a/lib-apps-common/src/Ui/TabView.cpp b/lib-apps-common/src/Ui/TabView.cpp index 7ad327a..2eb097a 100644 --- a/lib-apps-common/src/Ui/TabView.cpp +++ b/lib-apps-common/src/Ui/TabView.cpp @@ -18,18 +18,20 @@ #include "Ui/TabView.h" #include "Ui/TabPage.h" #include "Utils/Callback.h" +#include "Utils/Logger.h" using namespace Ui; TabView::TabView() - : Navigator(TabNavigator), m_Tabbar(nullptr), m_Scroller(nullptr), m_Box(nullptr), - m_Width(0), m_Height(0), m_IsNavigating(false), m_CurrentPage(0) + : Navigator(TabNavigator), + m_Tabbar(nullptr), m_Scroller(nullptr), m_Box(nullptr), + m_Width(0), m_Height(0), m_IsNavigating(false), m_CurrentPage(nullptr) { } -View *TabView::getCurrentView() const +TabPage *TabView::getCurrentPage() const { - return m_CurrentPage < m_Views.size() ? m_Views[m_CurrentPage] : nullptr; + return m_CurrentPage; } Evas_Object *TabView::onCreate(Evas_Object *parent) @@ -61,21 +63,20 @@ void TabView::onPageAttached() elm_toolbar_transverse_expanded_set(m_Tabbar, EINA_TRUE); evas_object_smart_data_set(m_Tabbar, this); evas_object_smart_callback_add(m_Tabbar, "selected", - makeCallback(&TabView::onTabSelect), this); + (Evas_Smart_Cb) makeCallback(&TabView::onTabSelected), this); getPage()->setStyle("tabbar/notitle"); getPage()->setContent("tabbar", m_Tabbar); } -NavigatorPage *TabView::attachView(View *view) +TabPage *TabView::attachView(View *view) { - Elm_Object_Item *item = elm_toolbar_item_append(m_Tabbar, nullptr, nullptr, nullptr, nullptr); - elm_object_item_data_set(item, view); - elm_object_item_del_cb_set(item, &TabView::onTabDestroy); - m_Views.push_back(view); + TabPage *page = new TabPage(m_Pages.size()); + m_Pages.push_back(page); - size_t index = m_Views.size() - 1; - TabPage *page = new TabPage(index, item); + Elm_Object_Item *item = elm_toolbar_item_append(m_Tabbar, nullptr, nullptr, nullptr, page); + elm_object_item_del_cb_set(item, &TabView::onTabDestroy); + page->onTabAttached(item); Evas_Object *layout = page->create(getEvasObject()); page->setContent("elm.swallow.content", view->create(layout)); @@ -86,37 +87,38 @@ NavigatorPage *TabView::attachView(View *view) return page; } -void TabView::navigateToView(View *view) +void TabView::navigateToPage(NavigatorPage *page) { m_IsNavigating = true; + notifyNavigation(getCurrentPage(), false); - TabPage *page = static_cast(view->getPage()); - elm_scroller_page_show(m_Scroller, page->m_Index, 0); - elm_toolbar_item_selected_set(page->m_TabItem, EINA_TRUE); - m_CurrentPage = page->m_Index; + TabPage *tabPage = static_cast(page); + elm_scroller_page_show(m_Scroller, tabPage->m_Index, 0); + elm_toolbar_item_selected_set(tabPage->m_TabItem, EINA_TRUE); + m_CurrentPage = tabPage; m_IsNavigating = false; + notifyNavigation(tabPage, true); } void TabView::onTabDestroy(void *data, Evas_Object *obj, void *tabItem) { TabView *tabView = (TabView *) evas_object_smart_data_get(obj); - TabPage *page = static_cast(((View *) data)->getPage()); + TabPage *page = (TabPage *) data; - auto it = tabView->m_Views.begin() + page->m_Index; - it = tabView->m_Views.erase(it); + size_t index = page->m_Index; + tabView->m_Pages.erase(tabView->m_Pages.begin() + index); - for (; it != tabView->m_Views.end(); ++it) { - page = static_cast((*it)->getPage()); - --page->m_Index; + for (; index < tabView->m_Pages.size(); ++index) { + --(tabView->m_Pages[index]->m_Index); } } -void TabView::onTabSelect(Evas_Object *obj, void *tabItem) +void TabView::onTabSelected(Evas_Object *obj, Elm_Object_Item *selectedItem) { - View *view = (View *) elm_object_item_data_get((Elm_Object_Item *) tabItem); + TabPage *page = (TabPage *) elm_object_item_data_get(selectedItem); if (!m_IsNavigating) { - navigateTo(view); + navigateTo(page->getView()); } } @@ -125,19 +127,22 @@ void TabView::onPageChanged(Evas_Object *obj, void *eventInfo) int index = 0; elm_scroller_current_page_get(m_Scroller, &index, nullptr); if (!m_IsNavigating) { - navigateTo(m_Views[index]); + navigateTo(m_Pages[index]->getView()); } } void TabView::onResize(Evas *e, Evas_Object *obj, void *eventInfo) { evas_object_geometry_get(obj, nullptr, nullptr, &m_Width, &m_Height); - - for (auto &&view : m_Views) { - TabPage *page = static_cast(view->getPage()); + for (auto &&page : m_Pages) { evas_object_size_hint_min_set(page->m_Sizer, m_Width, m_Height); } - elm_scroller_page_size_set(m_Scroller, m_Width, m_Height); - elm_scroller_page_show(m_Scroller, m_CurrentPage, 0); + /* FIXME: elm_scroller_page_show() changes page to 0 regardless what index was passed */ + ecore_job_add([](void *data) { + TabView *tabView = (TabView *) data; + if (tabView->m_CurrentPage) { + elm_scroller_page_show(tabView->m_Scroller, tabView->m_CurrentPage->m_Index, 0); + } + }, this); } diff --git a/lib-apps-common/src/Ui/View.cpp b/lib-apps-common/src/Ui/View.cpp index 4cd255e..e01ff46 100644 --- a/lib-apps-common/src/Ui/View.cpp +++ b/lib-apps-common/src/Ui/View.cpp @@ -20,14 +20,13 @@ using namespace Ui; View::View() - : m_StackNavi(nullptr), m_TabNavi(nullptr), - m_NaviPage(nullptr) + : m_StackNavi(nullptr), m_TabNavi(nullptr), m_Page(nullptr) { } View::~View() { - delete m_NaviPage; + delete m_Page; } Navigator *View::getNavigator(NavigatorType type) const @@ -37,20 +36,17 @@ Navigator *View::getNavigator(NavigatorType type) const NavigatorPage *View::getPage() const { - return m_NaviPage; + return m_Page; } -void View::onViewAttached(Navigator *stackNavi, Navigator *tabNavi) +void View::onNavigatorAttached(Navigator *stackNavi, Navigator *tabNavi, NavigatorPage *page) { m_StackNavi = stackNavi; m_TabNavi = tabNavi; -} -void View::onPageAttached(NavigatorPage *page) -{ - if (page != m_NaviPage) { - delete m_NaviPage; - m_NaviPage = page; + if (page != m_Page) { + delete m_Page; + m_Page = page; } onPageAttached(); diff --git a/main-app/src/OperationDefaultController.cpp b/main-app/src/OperationDefaultController.cpp index dcfcc5e..78f4c30 100644 --- a/main-app/src/OperationDefaultController.cpp +++ b/main-app/src/OperationDefaultController.cpp @@ -105,7 +105,7 @@ unsigned OperationDefaultController::getBadgeCount(const char *package) void OperationDefaultController::saveLastTab() { - Ui::View *currentTab = m_Navigator->getCurrentView(); + Ui::View *currentTab = m_Navigator->getCurrentPage()->getView(); for (int tab = TabFirst; tab < TabMax; ++tab) { if (currentTab == m_Tabs[tab]) { if (tab != TabContacts) { -- 2.7.4