From 8fbf6b9ffe672b14794ae4f2e40b7799046df150 Mon Sep 17 00:00:00 2001 From: Nataliia Kamyshna Date: Wed, 24 Feb 2016 15:23:29 +0200 Subject: [PATCH] TizenRefApp-5765 Implement base Logs/Details/DetailsView and Integrate to LogList Change-Id: I3faf4043dbcc8120972c59a8b39bfb275a53aaa3 Signed-off-by: Nataliia Kamyshna --- lib-logs/inc/Logs/Details/DetailsView.h | 57 +++++++++++++++++++++++++++++++ lib-logs/inc/Logs/List/LogItem.h | 18 ++++++++++ lib-logs/src/Logs/Details/DetailsView.cpp | 36 +++++++++++++++++++ lib-logs/src/Logs/List/LogItem.cpp | 28 +++++++++++++-- lib-logs/src/Logs/List/LogsView.cpp | 6 ++++ 5 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 lib-logs/inc/Logs/Details/DetailsView.h create mode 100644 lib-logs/src/Logs/Details/DetailsView.cpp diff --git a/lib-logs/inc/Logs/Details/DetailsView.h b/lib-logs/inc/Logs/Details/DetailsView.h new file mode 100644 index 0000000..d76d6d3 --- /dev/null +++ b/lib-logs/inc/Logs/Details/DetailsView.h @@ -0,0 +1,57 @@ +/* + * 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. + * + */ + +#ifndef LOGS_DETAILS_DETAILS_VIEW_H +#define LOGS_DETAILS_DETAILS_VIEW_H + +#include "Ui/View.h" + +namespace Ui +{ + class Genlist; +} + +namespace Logs +{ + namespace Model + { + class LogGroup; + } + namespace Details + { + /** + * @brief Log details view. + */ + class DetailsView : public Ui::View + { + public: + + /** + * @brief Create log details view. + */ + DetailsView(Model::LogGroup *group); + + private: + virtual Evas_Object *onCreate(Evas_Object *parent) override; + + Model::LogGroup *m_Group; + Ui::Genlist *m_Genlist; + }; + } +} + +#endif /* LOGS_DETAILS_DETAILS_VIEW_H */ diff --git a/lib-logs/inc/Logs/List/LogItem.h b/lib-logs/inc/Logs/List/LogItem.h index ac4d0c6..d8d28b6 100644 --- a/lib-logs/inc/Logs/List/LogItem.h +++ b/lib-logs/inc/Logs/List/LogItem.h @@ -46,6 +46,11 @@ namespace Logs typedef std::function DeleteCallback; /** + * @brief Item details callback + */ + typedef std::function DetailsCallback; + + /** * @brief Create log item * @param[in] group Log group * @param[in] mode Item mode @@ -65,6 +70,17 @@ namespace Logs void setDeleteCallback(DeleteCallback callback); /** + * @brief Set log details callback + * @param[in] callback Details callback + */ + void setDetailsCallback(DetailsCallback callback); + + /** + * @brief Get group + */ + Model::LogGroup *getGroup() const; + + /** * @brief Remove group */ void removeGroup(); @@ -77,11 +93,13 @@ namespace Logs Evas_Object *createLayout(Evas_Object *parent, const char *layoutName); Evas_Object *createIcon(Evas_Object *parent, const char *path); const char *getImagePath(int type); + void onInfoIconPressed(); void updateItem(); void setUpdateCallback(); DeleteCallback m_OnDelete; + DetailsCallback m_OnDetails; Model::LogGroup *m_Group; ItemMode m_Mode; }; diff --git a/lib-logs/src/Logs/Details/DetailsView.cpp b/lib-logs/src/Logs/Details/DetailsView.cpp new file mode 100644 index 0000000..011bb2b --- /dev/null +++ b/lib-logs/src/Logs/Details/DetailsView.cpp @@ -0,0 +1,36 @@ +/* + * 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 "Logs/Details/DetailsView.h" +#include "Logs/Model/LogGroup.h" + +#include "App/Path.h" +#include "Ui/Genlist.h" + +using namespace Logs::Model; +using namespace Logs::Details; + +DetailsView::DetailsView(LogGroup *group) + : m_Group(group), m_Genlist(nullptr) +{ +} + +Evas_Object *DetailsView::onCreate(Evas_Object *parent) +{ + m_Genlist = new Ui::Genlist(); + return m_Genlist->create(parent); +} diff --git a/lib-logs/src/Logs/List/LogItem.cpp b/lib-logs/src/Logs/List/LogItem.cpp index 0f637cf..a5c5c1d 100644 --- a/lib-logs/src/Logs/List/LogItem.cpp +++ b/lib-logs/src/Logs/List/LogItem.cpp @@ -18,6 +18,8 @@ #include "Logs/List/LogItem.h" #include "Logs/Model/Log.h" #include "Logs/Model/LogGroup.h" +#include "Logs/Details/DetailsView.h" +#include "Utils/Callback.h" #include "App/Path.h" #include "Ui/Scale.h" @@ -44,6 +46,7 @@ using namespace Ui; using namespace Logs::List; using namespace Logs::Model; +using namespace Logs::Details; namespace { @@ -51,7 +54,7 @@ namespace } LogItem::LogItem(LogGroup *group, ItemMode mode) - :m_Group(group), m_Mode(mode) + : m_Group(group), m_Mode(mode) { setUpdateCallback(); } @@ -67,6 +70,23 @@ void LogItem::setDeleteCallback(DeleteCallback callback) m_OnDelete = std::move(callback); } +void LogItem::setDetailsCallback(DetailsCallback callback) +{ + m_OnDetails = std::move(callback); +} + +void LogItem::onInfoIconPressed() +{ + if (m_OnDetails) { + m_OnDetails(this); + } +} + +LogGroup *LogItem::getGroup() const +{ + return m_Group; +} + void LogItem::removeGroup() { m_Group->remove(); @@ -110,7 +130,11 @@ Evas_Object *LogItem::getContent(Evas_Object *parent, const char *part) if (m_Mode == ItemMode::Pick) { return GenlistCheckItem::getContent(parent, part); } else { - return createIcon(parent, ICON_INFO); + Evas_Object *icon = createIcon(parent, ICON_INFO); + evas_object_propagate_events_set(icon, EINA_FALSE); + evas_object_smart_callback_add(icon, "clicked", + (Evas_Smart_Cb) makeCallback(&LogItem::onInfoIconPressed), this); + return icon; } } diff --git a/lib-logs/src/Logs/List/LogsView.cpp b/lib-logs/src/Logs/List/LogsView.cpp index ffb3c34..3d2f699 100644 --- a/lib-logs/src/Logs/List/LogsView.cpp +++ b/lib-logs/src/Logs/List/LogsView.cpp @@ -18,6 +18,7 @@ #include "Logs/List/LogsView.h" #include "Logs/List/LogGroupItem.h" #include "Logs/List/LogItem.h" +#include "Logs/Details/DetailsView.h" #include "Ui/Genlist.h" #include "Ui/Menu.h" @@ -26,6 +27,7 @@ using namespace Logs::Model; using namespace Logs::List; +using namespace Logs::Details; using namespace std::placeholders; LogsView::LogsView(FilterType filterType) @@ -163,6 +165,10 @@ LogItem *LogsView::createLogItem(LogGroup *group) } }); + item->setDetailsCallback([this](LogItem *item) { + getNavigator()->navigateTo(new DetailsView(item->getGroup())); + }); + return item; } -- 2.7.4