From: Eugene Kurzberg Date: Tue, 9 Aug 2016 07:32:46 +0000 (+0300) Subject: Remove ContactData dependency from Logs to simplify transition to new model. X-Git-Tag: submit/tizen/20160826.132643~1^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a8951eb4f88e4f760ece540c9b5cf33b2edcc2c;p=profile%2Fmobile%2Fapps%2Fnative%2Fphone-contacts.git Remove ContactData dependency from Logs to simplify transition to new model. Change-Id: I9aa5073b0d66a89449a06353b1aee16449332374 Signed-off-by: Eugene Kurzberg --- diff --git a/lib-logs/inc/Logs/Model/Log.h b/lib-logs/inc/Logs/Model/Log.h index 60a31e8..b237d79 100644 --- a/lib-logs/inc/Logs/Model/Log.h +++ b/lib-logs/inc/Logs/Model/Log.h @@ -18,11 +18,10 @@ #ifndef LOGS_MODEL_LOG_H #define LOGS_MODEL_LOG_H -#include "Contacts/Model/ContactData.h" +#include "Model/DataItem.h" #include #include -#include #include namespace Logs @@ -30,57 +29,42 @@ namespace Logs namespace Model { class LogGroup; + /** * @brief Log record information */ - class Log : public Contacts::Model::ContactData + class Log : public ::Model::DataItem { public: /** - * @brief Callback to be called when log was removed to group. - * @param[in] log Removed log - */ - typedef std::function RemoveCallback; - - /** * @brief Create log record - * @param[in] record Log record (_contact_person_phone_log) + * @param[in] record Log record (_contact_phone_log) */ Log(contacts_record_h record); - ~Log(); + virtual ~Log() override; + Log(const Log &log) = delete; Log &operator=(const Log &log) = delete; /** - * @brief Set log remove callback. - * @param[in] callback log remove callback - */ - void setRemoveCallback(RemoveCallback callback); - - /** - * @brief Unset log remove callback. - */ - void unsetRemoveCallback(); - - /** * @return log id */ - virtual int getId() const override; + int getId() const; /** * @return log name */ - virtual const char *getName() const override; + const char *getName() const; /** * @return log number */ - virtual const char *getNumber() const override; + const char *getNumber() const; /** * @return log name image path */ - virtual const char *getImagePath() const override; + const char *getImagePath() const; /** * @return type of number @@ -138,23 +122,20 @@ namespace Logs * @brief Update contact record */ void updateContactRecord(); + /** * @brief Remove log from database */ void remove(); - /** - * @brief Called when Log is destroyed - */ - void onDestroy(); private: + friend class LogProvider; contacts_record_h getContactRecord(); contacts_record_h m_LogRecord; contacts_record_h m_ContactRecord; LogGroup *m_Group; - RemoveCallback m_OnRemoved; }; } } diff --git a/lib-logs/src/Logs/Details/DetailsView.cpp b/lib-logs/src/Logs/Details/DetailsView.cpp index a1333ee..832d680 100644 --- a/lib-logs/src/Logs/Details/DetailsView.cpp +++ b/lib-logs/src/Logs/Details/DetailsView.cpp @@ -178,7 +178,7 @@ void DetailsView::insertLogDetailItem(Log *log) { LogDetailItem *logItem = new LogDetailItem(log); m_Genlist->insert(logItem, getLastGroupItem(), *getLastGroupItem()->begin()); - log->setRemoveCallback(std::bind(&DetailsView::onLogRemoved, this, logItem)); + log->setDeleteCallback(std::bind(&DetailsView::onLogRemoved, this, logItem)); addSelectItem(logItem); } diff --git a/lib-logs/src/Logs/Model/Log.cpp b/lib-logs/src/Logs/Model/Log.cpp index c11fe54..b41f877 100644 --- a/lib-logs/src/Logs/Model/Log.cpp +++ b/lib-logs/src/Logs/Model/Log.cpp @@ -24,8 +24,7 @@ using namespace Common::Database; using namespace Logs::Model; Log::Log(contacts_record_h record) - : ContactData(TypeLog), - m_LogRecord(record), m_ContactRecord(getContactRecord()), m_Group(nullptr) + : m_LogRecord(record), m_ContactRecord(getContactRecord()), m_Group(nullptr) { } @@ -41,16 +40,6 @@ Log::~Log() } } -void Log::setRemoveCallback(RemoveCallback callback) -{ - m_OnRemoved = std::move(callback); -} - -void Log::unsetRemoveCallback() -{ - m_OnRemoved = nullptr; -} - int Log::getId() const { return getRecordInt(m_LogRecord, _contacts_phone_log.id); @@ -216,10 +205,3 @@ void Log::remove() { contacts_db_delete_record(_contacts_phone_log._uri, getId()); } - -void Log::onDestroy() -{ - if (m_OnRemoved) { - m_OnRemoved(); - } -} diff --git a/lib-logs/src/Logs/Model/LogProvider.cpp b/lib-logs/src/Logs/Model/LogProvider.cpp index 0809e28..695a4ce 100644 --- a/lib-logs/src/Logs/Model/LogProvider.cpp +++ b/lib-logs/src/Logs/Model/LogProvider.cpp @@ -26,7 +26,6 @@ #include using namespace Common::Database; -using namespace Contacts; using namespace Logs::Model; LogProvider::LogProvider() @@ -166,8 +165,8 @@ size_t LogProvider::fillGroupList(LogIterator begin, LogIterator end) } size_t newGroupsCount = 0; - for (auto &&contactData : Utils::makeRange(begin, end)) { - Log *log = static_cast(contactData); + for (auto &&dataItem : Utils::makeRange(begin, end)) { + Log *log = static_cast(dataItem); if (!shouldExist(*log)) { continue; } @@ -229,7 +228,7 @@ LogProvider::LogIterator LogProvider::updateLogs() Log *log = (Log *)(*oldIt); if (id != log->getId()) { - log->onDestroy(); + log->onDeleted(); delete *oldIt; oldIt = m_Logs.erase(oldIt); } else { @@ -240,7 +239,7 @@ LogProvider::LogIterator LogProvider::updateLogs() } while (oldIt != m_Logs.end()) { - ((Log *)*oldIt)->onDestroy(); + ((Log *)*oldIt)->onDeleted(); delete *oldIt; oldIt = m_Logs.erase(oldIt); }