TizenRefApp-5887 Integrate LogDetailItem to Logs/Details/DetailsView 60/61160/4
authorNataliia Kamyshna <n.kamyshna@samsung.com>
Fri, 4 Mar 2016 09:10:30 +0000 (11:10 +0200)
committerNataliia Kamyshna <n.kamyshna@samsung.com>
Mon, 7 Mar 2016 06:38:40 +0000 (08:38 +0200)
Change-Id: I5eaf8b22e97a656ab69235cc64b1a4dd48e32a27
Signed-off-by: Nataliia Kamyshna <n.kamyshna@samsung.com>
lib-logs/inc/Logs/Details/DetailsView.h
lib-logs/inc/Logs/Details/LogDetailItem.h
lib-logs/src/Logs/Details/DetailsView.cpp
lib-logs/src/Logs/Details/LogDetailItem.cpp

index 357c0ee..4a2c8df 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef LOGS_DETAILS_DETAILS_VIEW_H
 #define LOGS_DETAILS_DETAILS_VIEW_H
 
-#include "Ui/View.h"
+#include "Contacts/SelectView.h"
 
 namespace Ui
 {
@@ -38,19 +38,26 @@ namespace Logs
                /**
                 * @brief Log details view.
                 */
-               class DetailsView : public Ui::View
+               class DetailsView : public Contacts::SelectView
                {
                public:
-
                        /**
                         * @brief Create log details view.
+                        * @param[in]   group   Log group
                         */
                        DetailsView(Model::LogGroup *group);
 
                private:
                        virtual Evas_Object *onCreate(Evas_Object *parent) override;
                        virtual void onCreated() override;
-                       virtual void onPageAttached() override;
+                       virtual void onSelectModeChanged(Contacts::SelectMode selectMode) override;
+                       virtual void onSelectAllInsert(Ui::GenlistItem *item) override;
+                       virtual void onMenuPressed() override;
+
+                       void fillGenList();
+                       void insertBasicInfoItem();
+                       void insertLogGroupItem();
+                       void insertLogDetailItems();
 
                        Model::LogGroup *m_Group;
                        Ui::Genlist *m_Genlist;
index bbcdfdc..08752c6 100644 (file)
@@ -42,6 +42,7 @@ namespace Logs
                private:
                        virtual char *getText(Evas_Object *parent, const char *part) override;
                        virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+                       virtual void onSelectModeChanged(Contacts::SelectMode selectMode) override;
                        virtual Contacts::SelectResult getSelectResult() const override;
 
                        static Evas_Object *createIcon(Evas_Object *parent, const char *path);
index 69ea4f3..9f90566 100644 (file)
  */
 
 #include "Logs/Details/DetailsView.h"
-#include "Logs/Model/LogGroup.h"
 #include "Logs/Details/BasicInfoItem.h"
+#include "Logs/Details/LogDetailItem.h"
+#include "Logs/List/LogGroupItem.h"
+#include "Logs/Model/LogGroup.h"
+#include "Logs/Model/Log.h"
 #include "LogsDetailsItemLayout.h"
 
 #include "App/Path.h"
 #include "Ui/Genlist.h"
+#include "Ui/Menu.h"
+#include "Ui/Navigator.h"
 
 using namespace Logs::Model;
 using namespace Logs::Details;
+using namespace Logs::List;
+using namespace Contacts;
 
 DetailsView::DetailsView(LogGroup *group)
        : m_Group(group), m_Genlist(nullptr), m_BasicInfoItem(nullptr)
@@ -41,15 +48,79 @@ Evas_Object *DetailsView::onCreate(Evas_Object *parent)
 
 void DetailsView::onCreated()
 {
+       fillGenList();
+}
+
+void DetailsView::onSelectModeChanged(SelectMode selectMode)
+{
+       if (getSelectMode() == SelectNone) {
+               insertBasicInfoItem();
+       } else if (m_BasicInfoItem) {
+               delete m_BasicInfoItem;
+               m_BasicInfoItem = nullptr;
+       }
+}
+
+void DetailsView::onSelectAllInsert(Ui::GenlistItem *item)
+{
+       m_Genlist->insert(item, nullptr, nullptr, Ui::Genlist::After);
+}
+
+void DetailsView::onMenuPressed()
+{
+       if (getSelectMode() != SelectNone) {
+               return;
+       }
+
+       Ui::Menu *menu = new Ui::Menu();
+       menu->create(getEvasObject());
+
+       menu->addItem("IDS_LOGS_OPT_DELETE", [this] {
+               DetailsView *view = new DetailsView(m_Group);
+               view->setSelectMode(SelectMulti);
+               view->setSelectCallback([](SelectResults results) {
+                       for (auto &&result : results) {
+                               Log *log = (Log *)result.value.data;
+                               log->remove();
+                       }
+                       return true;
+               });
+               getNavigator()->navigateTo(view);
+       });
+       menu->show();
+}
+
+void DetailsView::fillGenList()
+{
+       if (getSelectMode() == SelectNone) {
+               insertBasicInfoItem();
+       }
+       insertLogGroupItem();
+       insertLogDetailItems();
+}
+
+void DetailsView::insertBasicInfoItem()
+{
        m_BasicInfoItem = new BasicInfoItem(m_Group);
        m_BasicInfoItem->setBackCallback([this] {
                delete this;
        });
-       m_Genlist->insert(m_BasicInfoItem);
+       m_Genlist->insert(m_BasicInfoItem, nullptr, nullptr, Ui::Genlist::After);
+}
+
+void DetailsView::insertLogGroupItem()
+{
+       Log *log = m_Group->getLogList().back();
+       LogGroupItem *groupItem = new LogGroupItem(log->getTime());
+       m_Genlist->insert(groupItem);
+       elm_genlist_item_select_mode_set(groupItem->getObjectItem(), ELM_OBJECT_SELECT_MODE_NONE);
 }
 
-void DetailsView::onPageAttached()
+void DetailsView::insertLogDetailItems()
 {
-       Ui::NavigatorPage *page = getPage();
-       page->setTitle(nullptr);
+       for (auto &log:m_Group->getLogList()) {
+               LogDetailItem *logItem = new LogDetailItem(log);
+               m_Genlist->insert(logItem);
+               onItemInserted(logItem);
+       }
 }
index dd11a17..f971ce6 100644 (file)
@@ -72,6 +72,15 @@ Evas_Object *LogDetailItem::getContent(Evas_Object *parent, const char *part)
        return nullptr;
 }
 
+void LogDetailItem::onSelectModeChanged(SelectMode selectMode)
+{
+       if (getSelectMode() == SelectNone) {
+               elm_genlist_item_select_mode_set(getObjectItem(), ELM_OBJECT_SELECT_MODE_NONE);
+       } else {
+               elm_genlist_item_select_mode_set(getObjectItem(), ELM_OBJECT_SELECT_MODE_DEFAULT);
+       }
+}
+
 SelectResult LogDetailItem::getSelectResult() const
 {
        return { 0, m_Log };