Added possibility to set Tab title separately from Page title. 40/84340/3
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 18 Aug 2016 14:28:34 +0000 (17:28 +0300)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 18 Aug 2016 14:59:29 +0000 (17:59 +0300)
Refactored Contacts-Groups navigator pages.

Change-Id: I72907c109cbcf9f4e29e240303a64f86b082692a
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-apps-common/inc/Ui/TabPage.h
lib-apps-common/src/Ui/TabPage.cpp
lib-contacts/inc/Contacts/Chooser/ContactsPage.h
lib-contacts/src/Contacts/Chooser/ContactsGroupsNavigator.cpp
lib-contacts/src/Contacts/Chooser/ContactsPage.cpp

index 4159278..37ea321 100644 (file)
@@ -37,6 +37,17 @@ namespace Ui
                virtual ~TabPage() override;
 
                /**
+                * @brief Set tab item title to be different from page title.
+                * @param[in]   title   Tab item title text
+                */
+               void setTabTitle(const char *title);
+
+               /**
+                * @brief Set tab item title to be the same as page title.
+                */
+               void unsetTabTitle();
+
+               /**
                 * @see NavigatorPage::setTitle()
                 */
                virtual void setTitle(const char *title) override;
@@ -74,6 +85,7 @@ namespace Ui
 
                Elm_Object_Item *m_TabItem;
                Evas_Object *m_Page;
+               bool m_HasTabTitle;
        };
 }
 
index 502a1bd..27c4415 100644 (file)
@@ -23,7 +23,7 @@
 using namespace Ui;
 
 TabPage::TabPage(Elm_Object_Item *tabItem)
-       : m_TabItem(tabItem), m_Page(nullptr)
+       : m_TabItem(tabItem), m_Page(nullptr), m_HasTabTitle(false)
 {
        elm_object_item_data_set(tabItem, this);
        elm_object_item_del_cb_set(tabItem, makeCallback(&TabPage::onTabItemDestroy));
@@ -34,19 +34,24 @@ TabPage::~TabPage()
        elm_object_item_del(m_TabItem);
 }
 
-Evas_Object *TabPage::onCreate(Evas_Object *parent)
+void TabPage::setTabTitle(const char *title)
 {
-       m_Page = elm_layout_add(parent);
-       elm_layout_theme_set(m_Page, "naviframe", "item", "basic/default");
-       elm_layout_signal_emit(m_Page, "elm,state,title,hide", "elm");
-       elm_layout_signal_emit(m_Page, "elm,state,toolbar,hide", "elm");
+       elm_object_item_translatable_text_set(m_TabItem, title);
+       m_HasTabTitle = true;
+}
 
-       return m_Page;
+void TabPage::unsetTabTitle()
+{
+       const char *title = elm_object_translatable_part_text_get(m_Page, "elm.text.title");
+       elm_object_item_translatable_text_set(m_TabItem, title);
+       m_HasTabTitle = false;
 }
 
 void TabPage::setTitle(const char *title)
 {
-       elm_object_item_translatable_text_set(m_TabItem, title);
+       if (!m_HasTabTitle) {
+               elm_object_item_translatable_text_set(m_TabItem, title);
+       }
        elm_object_translatable_part_text_set(m_Page, "elm.text.title", title);
 }
 
@@ -75,6 +80,16 @@ Elm_Object_Item *TabPage::getTabItem() const
        return m_TabItem;
 }
 
+Evas_Object *TabPage::onCreate(Evas_Object *parent)
+{
+       m_Page = elm_layout_add(parent);
+       elm_layout_theme_set(m_Page, "naviframe", "item", "basic/default");
+       elm_layout_signal_emit(m_Page, "elm,state,title,hide", "elm");
+       elm_layout_signal_emit(m_Page, "elm,state,toolbar,hide", "elm");
+
+       return m_Page;
+}
+
 void TabPage::onTabItemDestroy(Evas_Object *obj, void *eventInfo)
 {
        m_TabItem = nullptr;
index f26092b..2b136b5 100644 (file)
@@ -43,11 +43,6 @@ namespace Contacts
                        virtual void setTitle(const char *title) override;
 
                        /**
-                        * @see NavigatorPage::setTitleVisibility()
-                        */
-                       virtual void setTitleVisibility(bool isVisible) override;
-
-                       /**
                         * @see NavigatorPage::setContent()
                         */
                        virtual void setContent(const char *part, Evas_Object *content) override;
index dc7e4d4..a5ae625 100644 (file)
@@ -17,7 +17,8 @@
 
 #include "Contacts/Chooser/ContactsGroupsNavigator.h"
 #include "Contacts/Chooser/ContactsPage.h"
-#include "Contacts/List/PersonSearchItem.h"
+#include "Contacts/List/PersonItem.h"
+#include "Contacts/List/Model/Person.h"
 
 #include "App/Path.h"
 #include "Ui/Hoversel.h"
@@ -56,7 +57,7 @@ void ContactsGroupsNavigator::addSelectedItem(Ux::SelectItem *item)
                elm_object_part_content_set(m_TitleLayout, PART_MULTI_BTN, m_MultiBtn);
        }
 
-       const char *name = static_cast<List::PersonSearchItem *>(item)->getPerson().getName();
+       const char *name = static_cast<List::PersonItem *>(item)->getPerson().getName();
        elm_multibuttonentry_item_append(m_MultiBtn, name, nullptr, item);
 }
 
@@ -102,11 +103,19 @@ void ContactsGroupsNavigator::onPageAttached(Ui::NavigatorPage *page)
 
 Ui::TabPage *ContactsGroupsNavigator::createPage(Ui::View *view, Elm_Object_Item *item)
 {
+       Ui::TabPage *page = nullptr;
        if (view == m_ContactsView) {
-               return new ContactsPage(getNavigator()->getPage(), item);
+               page = new ContactsPage(getNavigator()->getPage(), item);
+               page->setTabTitle("IDS_PB_BODY_ALL_CONTACTS");
+       } else if (view == m_GroupsView) {
+               page = TabNavigator::createPage(view, item);
+               page->setTabTitle("IDS_PB_BODY_GROUPS");
+       } else {
+               page = TabNavigator::createPage(view, item);
        }
 
-       return TabNavigator::createPage(view, item);
+       page->setTitleVisibility(false);
+       return page;
 }
 
 void ContactsGroupsNavigator::onButtonPressed(Evas_Object *obj, Elm_Object_Item *button)
index 6fcb28b..9143082 100644 (file)
@@ -22,8 +22,6 @@ using namespace Contacts::Chooser;
 ContactsPage::ContactsPage(Ui::NavigatorPage *titlePage, Elm_Object_Item *tabItem)
        : TabPage(tabItem), m_TitlePage(titlePage)
 {
-       TabPage::setTitle("IDS_PB_BODY_ALL_CONTACTS");
-       TabPage::setTitleVisibility(false);
 }
 
 void ContactsPage::setTitle(const char *title)
@@ -31,11 +29,6 @@ void ContactsPage::setTitle(const char *title)
        m_TitlePage->setTitle(title);
 }
 
-void ContactsPage::setTitleVisibility(bool isVisible)
-{
-       m_TitlePage->setTitleVisibility(isVisible);
-}
-
 void ContactsPage::setContent(const char *part, Evas_Object *content)
 {
        if (strcmp(part, "title_right_btn") == 0