#ifndef LOGS_DETAILS_DETAILS_VIEW_H
#define LOGS_DETAILS_DETAILS_VIEW_H
-#include "Ui/View.h"
+#include "Contacts/SelectView.h"
namespace Ui
{
/**
* @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;
*/
#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)
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);
+ }
}