#ifndef LOGS_LIST_LOG_ITEM_H
#define LOGS_LIST_LOG_ITEM_H
-#include "Ui/GenlistCheckItem.h"
+#include "Contacts/SelectItem.h"
#define PART_LOG_TIME "elm.text.sub.end"
{
class LogGroup;
}
+
namespace List
{
- /**
- * @brief Represents item mode
- */
- enum class ItemMode
- {
- Default, /*< Usual mode */
- Pick /*< Mode with ability to select item */
- };
-
- class LogItem : public Ui::GenlistCheckItem
+ class LogItem : public Contacts::SelectItem
{
public:
/**
/**
* @brief Create log item
* @param[in] group Log group
- * @param[in] mode Item mode
- */
- LogItem(Model::LogGroup *group, ItemMode mode = ItemMode::Default);
-
- /**
- * @brief Set item mode
- * @param[in] mode Item mode
*/
- void setMode(ItemMode mode);
+ LogItem(Model::LogGroup *group);
/**
* @brief Set delete item callback
private:
virtual char *getText(Evas_Object *parent, const char *part) override;
virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+ virtual Contacts::SelectResult getSelectResult() const override;
Evas_Object *createThumbnail(Evas_Object *parent);
Evas_Object *createLayout(Evas_Object *parent, const char *layoutName);
DeleteCallback m_OnDelete;
DetailsCallback m_OnDetails;
Model::LogGroup *m_Group;
- ItemMode m_Mode;
};
}
}
#ifndef LOGS_LIST_LOGS_VIEW_H
#define LOGS_LIST_LOGS_VIEW_H
-#include "Ui/View.h"
+#include "Contacts/SelectView.h"
#include "Logs/Model/LogProvider.h"
#include <system_settings.h>
{
class LogGroupItem;
class LogItem;
- enum class ItemMode;
/**
* @brief Logs list view
*/
- class EXPORT_API LogsView : public Ui::View
+ class EXPORT_API LogsView : public Contacts::SelectView
{
public:
private:
virtual Evas_Object *onCreate(Evas_Object *parent) override;
virtual void onCreated() override;
- virtual void onPageAttached() override;
virtual void onMenuPressed() override;
+ virtual const char *getPageTitle() const override;
+ virtual void onSelectAllInsert(Ui::GenlistItem *item) override;
+ virtual void onItemPressed(Contacts::SelectItem *item) override;
+
void fillLayout();
void updateLayout(bool isEmpty);
Evas_Object *createNoContentsLayout(Evas_Object *parent);
void setLastGroupItem(LogGroupItem *groupItem);
- void setMode(ItemMode mode);
-
void onSettingsChanged(system_settings_key_e key);
void onSelectViewBy();
void onLogInserted(Model::LogGroup *group);
void onLogItemDelete(LogItem *item);
Model::LogProvider m_LogProvider;
- ItemMode m_Mode;
FilterType m_FilterType;
Ui::Genlist *m_Genlist;
#define PART_END "elm.swallow.end"
using namespace Ui;
+using namespace Contacts;
using namespace Logs::List;
using namespace Logs::Model;
using namespace Logs::Details;
const std::string layoutPath = App::getResourcePath(LOG_ITEM_LAYOUT_EDJ);
}
-LogItem::LogItem(LogGroup *group, ItemMode mode)
- : m_Group(group), m_Mode(mode)
+LogItem::LogItem(LogGroup *group)
+ : m_Group(group)
{
setUpdateCallback();
}
-void LogItem::setMode(ItemMode mode)
-{
- m_Mode = mode;
- elm_genlist_item_fields_update(getObjectItem(), PART_END, ELM_GENLIST_ITEM_FIELD_CONTENT);
-}
-
void LogItem::setDeleteCallback(DeleteCallback callback)
{
m_OnDelete = std::move(callback);
const Log *log = m_Group->getLogList().back();
const char *name = log->getName();
const char *number = log->getNumber();
+
if (name == nullptr) {
name = number;
number = _("IDS_LOGS_SBODY_UNSAVED_M_STATUS");
}
+
if (strcmp(part, PART_LOG_NAME) == 0) {
return strdup(name);
} else if (strcmp(part, PART_LOG_NUMBER) == 0) {
if (strcmp(part, PART_PERSON_THUMBNAIL) == 0) {
return createThumbnail(parent);
} else if (strcmp(part, PART_END) == 0) {
- if (m_Mode == ItemMode::Pick) {
- return GenlistCheckItem::getContent(parent, part);
- } else {
+ if (getSelectMode() == SelectNone) {
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;
+ } else {
+ return SelectItem::getContent(parent, part);
}
}
return nullptr;
}
+SelectResult LogItem::getSelectResult() const
+{
+ return { 0, m_Group };
+}
+
Evas_Object *LogItem::createThumbnail(Evas_Object *parent)
{
using Ui::Thumbnail;
#include "Utils/Logger.h"
#include "Utils/Callback.h"
+using namespace Contacts;
using namespace Logs::Model;
using namespace Logs::List;
using namespace Logs::Details;
using namespace std::placeholders;
LogsView::LogsView(FilterType filterType)
- : m_Mode(ItemMode::Default), m_FilterType(filterType),
+ : m_FilterType(filterType),
m_Genlist(nullptr), m_LastGroupItem(nullptr)
{
system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, makeCallbackWithLastParam(&LogsView::onSettingsChanged), this);
fillLayout();
}
-void LogsView::onPageAttached()
-{
- getPage()->setTitle("IDS_LOGS_ITAB3_LOGS");
-}
-
void LogsView::onMenuPressed()
{
- if (m_Mode == ItemMode::Pick) {
+ if (getSelectMode() != SelectNone) {
return;
}
});
menu->addItem("IDS_LOGS_OPT_DELETE", [this] {
- LogsView *deleteView = new LogsView(m_FilterType);
- deleteView->setMode(ItemMode::Pick);
- getNavigator()->navigateTo(deleteView);
+ LogsView *view = new LogsView(m_FilterType);
+ view->setSelectMode(SelectMulti);
+ view->setSelectCallback([](SelectResults results) {
+ for (auto &&result : results) {
+ LogGroup *group = (LogGroup *) result.value.data;
+ group->remove();
+ }
+
+ return true;
+ });
+ getNavigator()->navigateTo(view);
});
+
menu->show();
}
+const char *LogsView::getPageTitle() const
+{
+ if (getSelectMode() == SelectNone) {
+ return "IDS_LOGS_ITAB3_LOGS";
+ }
+
+ return SelectView::getPageTitle();
+}
+
+void LogsView::onSelectAllInsert(Ui::GenlistItem *item)
+{
+ m_Genlist->insert(item, nullptr, nullptr, Ui::Genlist::After);
+}
+
+void LogsView::onItemPressed(Contacts::SelectItem *item)
+{
+ LogItem *logItem = (LogItem *) item;
+ LogGroup *group = logItem->getGroup();
+
+ const char *number = group->getLogList().back()->getNumber();
+ if (number) {
+ App::AppControl appControl = App::requestTelephonyCall(number);
+ appControl.launch(nullptr, nullptr, false);
+ appControl.detach();
+ }
+}
+
void LogsView::fillLayout()
{
if (m_Genlist) {
LogItem *LogsView::createLogItem(LogGroup *group)
{
- LogItem *item = new LogItem(group, m_Mode);
-
+ LogItem *item = new LogItem(group);
item->setDeleteCallback(std::bind(&LogsView::onLogItemDelete, this, _1));
- item->setSelectCallback([this, group]() {
- const char *number = group->getLogList().back()->getNumber();
- if (number) {
- App::AppControl appControl = App::requestTelephonyCall(number);
- appControl.launch(nullptr, nullptr, false);
- appControl.detach();
- }
- });
-
item->setDetailsCallback([this](LogItem *item) {
getNavigator()->navigateTo(new DetailsView(item->getGroup()));
});
LogItem *item = createLogItem(group);
m_Genlist->insert(item, groupItem, *groupItem->begin());
+ onItemInserted(item);
return item;
}
});
}
-void LogsView::setMode(ItemMode mode)
-{
- m_Mode = mode;
-}
-
void LogsView::onSettingsChanged(system_settings_key_e key)
{
if (key == SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY ||
void LogsView::onLogItemDelete(LogItem *item)
{
Ui::GenlistGroupItem *groupItem = item->getParentItem();
+ onItemRemove(item);
delete item;
if (groupItem->empty()) {
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/call</privilege>
<privilege>http://tizen.org/privilege/callhistory.read</privilege>
+ <privilege>http://tizen.org/privilege/callhistory.write</privilege>
<privilege>http://tizen.org/privilege/contact.read</privilege>
<privilege>http://tizen.org/privilege/contact.write</privilege>
<privilege>http://tizen.org/privilege/externalstorage</privilege>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/call</privilege>
<privilege>http://tizen.org/privilege/callhistory.read</privilege>
+ <privilege>http://tizen.org/privilege/callhistory.write</privilege>
<privilege>http://tizen.org/privilege/contact.read</privilege>
<privilege>http://tizen.org/privilege/contact.write</privilege>
<privilege>http://tizen.org/privilege/mediastorage</privilege>