TizenRefApp-7895 Memo detail view isn't closed if opened from widget 86/116686/10
authorAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Mon, 27 Feb 2017 14:57:12 +0000 (16:57 +0200)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Fri, 3 Mar 2017 13:01:43 +0000 (15:01 +0200)
Integrated DataControlConsumer and DataControlProvider in the application

Change-Id: Ibb61c0bae3e5593ce88446758605de576fcbc928
Signed-off-by: Aleksandr Sapozhnik <a.sapozhnik@samsung.com>
19 files changed:
lib-common/inc/Common/Model/DataConsumer.h [deleted file]
lib-common/inc/Common/Model/MemoBuilder.h
lib-common/inc/Common/Model/MemoConsumer.h [new file with mode: 0644]
lib-common/inc/Common/Model/MemoProvider.h [deleted file]
lib-common/src/Common/Model/DataConsumer.cpp [deleted file]
lib-common/src/Common/Model/MemoBuilder.cpp
lib-common/src/Common/Model/MemoConsumer.cpp [new file with mode: 0644]
lib-common/src/Common/Model/MemoProvider.cpp [deleted file]
memo-app/inc/Input/DetailsView.h
memo-app/inc/Input/InputView.h
memo-app/inc/List/MemoListView.h
memo-app/inc/OperationEditController.h
memo-app/src/Input/DetailsView.cpp
memo-app/src/Input/InputView.cpp
memo-app/src/List/MemoListView.cpp
memo-app/src/OperationEditController.cpp
memo-svc/src/Service/DataProvider.cpp
memo-widget/inc/MemoWidget.h
memo-widget/src/MemoWidget.cpp

diff --git a/lib-common/inc/Common/Model/DataConsumer.h b/lib-common/inc/Common/Model/DataConsumer.h
deleted file mode 100644 (file)
index 8a7a2d5..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * 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 COMMON_MODEL_DATA_CONSUMER_H
-#define COMMON_MODEL_DATA_CONSUMER_H
-
-#include "Model/DataProvider.h"
-
-#include <data_control.h>
-#include <data_control_noti.h>
-
-namespace Common
-{
-       namespace Model
-       {
-               class Memo;
-
-               class EXPORT_API DataConsumer
-               {
-               public:
-
-                       /**
-                        * @brief Get list of memo
-                        * @param[in]    list           list of memos
-                        */
-                       typedef std::function<void(::Model::DataProvider::DataList list)> MemoListReceivedCallback;
-
-                       /**
-                        * @brief Get memo
-                        * @param[in]    memo           Memo
-                        */
-                       typedef std::function<void(::Model::DataItem *memo)> MemoReceivedCallback;
-
-                       /**
-                        * @brief Called when memo data has been changed.
-                        * @param[in]    id             Memo id
-                        * @param[in]    type           Changed type
-                        */
-                       typedef std::function<void(long long id, data_control_data_change_type_e type)> ChangeCallback;
-
-                       /**
-                        * @brief Called on result.
-                        * @param[in]    result         Result is true whether the operation was successful.
-                        */
-                       typedef std::function<void(bool result)> ResultCallback;
-
-                       DataConsumer();
-                       ~DataConsumer();
-
-                       DataConsumer(const DataConsumer &consumer) = delete;
-                       DataConsumer &operator=(const DataConsumer &consumer) = delete;
-
-                       /**
-                        * @brief Add data control callback on data changed.
-                        * @param[in]   callback            Callback that is called when data is change.
-                        */
-                       void setChangeCallback(ChangeCallback callback);
-
-                       /**
-                        * @brief Unset callback on data changed.
-                        */
-                       void unsetChangeCallback();
-
-                       /**
-                        * @brief Set result callback.
-                        * @param[in]   callback            On result callback.
-                        */
-                       void setResultCallback(ResultCallback callback);
-
-                       /**
-                        * @brief Unset result callback.
-                        */
-                       void unsetResultCallback();
-
-                       /**
-                        * @brief Get list of memos asynchronously.
-                        * @param[in]   callback            Callback that is called when memo list is received.
-                        */
-                       void getMemoList(MemoListReceivedCallback callback);
-
-                       /**
-                        * @brief Get memo asynchronously.
-                        * @param[in]   callback            Callback that is called when memo is received.
-                        * @param[in]   id                  Id to find memo.
-                        */
-                       void getMemo(MemoReceivedCallback callback, int id);
-
-                       /**
-                        * @brief Insert Memo content.
-                        * @param[in]   memo            Memo content
-                        * @return Error code.
-                        */
-                       int insertMemo(Memo *memo);
-
-                       /**
-                        * @brief Remove Memo content.
-                        * @param[in]   memo            Memo to remove
-                        * @return Error code.
-                        */
-                       int removeMemo(Memo *memo);
-
-                       /**
-                        * @brief Update Memo.
-                        * @param[in]   memo            Memo to update
-                        * @return Error code.
-                        */
-                       int updateMemo(Memo *memo);
-
-               private:
-                       void onDeleteResponse(int requestId, data_control_h provider,
-                                       bool providerResult, const char *error);
-                       void onUpdateResponse(int requestId, data_control_h provider,
-                                       bool providerResult, const char *error);
-                       void onInsertResponse(int requestId, data_control_h provider,
-                                       long long insertedRowId, bool providerResult, const char *error);
-                       void onSelectResponse(int requestId, data_control_h provider,
-                                       result_set_cursor cursor, bool providerResult, const char *error);
-
-                       void initialize();
-                       Memo *createMemo(result_set_cursor cursor, int columnCount);
-                       void setMemoContent(Memo *memo, result_set_cursor cursor, int column);
-                       void setMemoImages(Memo *memo, char *image);
-                       bundle *prepareBundle(Memo *memo);
-                       void setImageToBundle(bundle *bd, Memo *memo);
-                       void setSoundToBundle(bundle *bd, Memo *memo);
-                       void setThumbnailToBundle(bundle *bd, Memo *memo);
-
-                       void onDataChanged(data_control_h provider, data_control_data_change_type_e type, bundle *data);
-                       void onResult(data_control_h provider, data_control_error_e result, int callback_id);
-
-                       data_control_h m_Provider;
-
-                       int m_Id;
-                       MemoListReceivedCallback m_OnListReceived;
-                       MemoReceivedCallback m_OnMemoReceived;
-                       ChangeCallback m_OnMemoChanged;
-                       ResultCallback m_OnResult;
-
-                       int m_ListRequestId;
-                       int m_MemoRequestId;
-               };
-       }
-}
-
-#endif /* COMMON_MODEL_DATA_CONSUMER_H */
index 2dd7cde674c12b6ccb4f723ef5abf14fec380e4b..75f26584bfbeebaf99b8e3169e76baca9998d473 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef COMMON_MODEL_MEMO_BUILDER_H
 #define COMMON_MODEL_MEMO_BUILDER_H
 
+#include "Utils/Bundle.h"
+
 #include <data_control.h>
 #include <string>
 
@@ -44,6 +46,14 @@ namespace Common
                         * @return memo.
                         */
                        static Memo *createMemo(bundle *data);
+
+                       /**
+                        * @brief Create bundle from Memo.
+                        * @param[in]   memo   Memo to create bundle from
+                        * @return Bundle containing memo data.
+                        */
+                       static Utils::Bundle createBundle(const Memo &memo);
+
                private:
                        static void setMemoColumn(Memo *memo, result_set_cursor cursor, int column);
                        static void setMemoTextColumn(Memo *memo, result_set_cursor cursor, int column, char *columnName);
@@ -55,6 +65,10 @@ namespace Common
                        static void setMemoImages(Memo *memo, bundle *data);
                        static void setMemoSound(Memo *memo, bundle *data);
                        static void setMemoThumbnail(Memo *memo, bundle *data);
+
+                       static void setMemoImagesToBundle(Utils::Bundle &bundle, const Memo &memo);
+                       static void setMemoSoundsToBundle(Utils::Bundle &bundle, const Memo &memo);
+                       static void setMemoThumbnailToBundle(Utils::Bundle &bundle, const Memo &memo);
                };
        }
 }
diff --git a/lib-common/inc/Common/Model/MemoConsumer.h b/lib-common/inc/Common/Model/MemoConsumer.h
new file mode 100644 (file)
index 0000000..68a5ca3
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 COMMON_MODEL_MEMO_CONSUMER_H
+#define COMMON_MODEL_MEMO_CONSUMER_H
+
+#include "Model/DataControlConsumer.h"
+
+namespace Common
+{
+       namespace Model
+       {
+               class EXPORT_API MemoConsumer : public ::Model::DataControlConsumer
+               {
+               public:
+                       /**
+                        * @return Consumer singleton instance.
+                        */
+                       static MemoConsumer &getInstance();
+
+                       /**
+                        * @see DataControlConsumer::getDataItem()
+                        */
+                       virtual void getDataItem(int id, GetCallback callback) override;
+
+               protected:
+                       /**
+                        * @see DataControlConsumer::createDataItem()
+                        */
+                       virtual ::Model::DataItem *createDataItem(result_set_cursor cursor) override;
+
+                       /**
+                        * @see DataControlConsumer::createBundle()
+                        */
+                       virtual Utils::Bundle createBundle(const ::Model::DataItem &item) override;
+
+               private:
+                       MemoConsumer();
+               };
+       }
+}
+
+#endif /* COMMON_MODEL_MEMO_CONSUMER_H */
diff --git a/lib-common/inc/Common/Model/MemoProvider.h b/lib-common/inc/Common/Model/MemoProvider.h
deleted file mode 100644 (file)
index 1db67a0..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * 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 COMMON_MODEL_MEMO_PROVIDER_H
-#define COMMON_MODEL_MEMO_PROVIDER_H
-
-#include "Common/Model/DataConsumer.h"
-#include "Model/DataProvider.h"
-
-namespace Common
-{
-       namespace Model
-       {
-               class Memo;
-
-               class EXPORT_API MemoProvider : public ::Model::DataProvider
-               {
-               public:
-                       MemoProvider();
-                       ~MemoProvider();
-
-                       MemoProvider(const MemoProvider &provider) = delete;
-                       MemoProvider &operator=(const DataConsumer &provider) = delete;
-
-                       /**
-                        * @brief Set result callback. Is called when a response is received.
-                        * @param[in]   callback            On result callback.
-                        */
-                       void setResultCallback(DataConsumer::ResultCallback callback);
-
-                       /**
-                        * @brief Unset result callback.
-                        */
-                       void unsetResultCallback();
-
-                       /**
-                        * @brief Get memo.
-                        * @param[in]   id             id to find memo.
-                        * @return memo.
-                        */
-                       Memo *getMemo(long long id);
-
-                       /**
-                        * @brief Insert memo.
-                        * @param[in]   memo            Memo to insert.
-                        */
-                       void insertMemo(Memo *memo);
-
-                       /**
-                        * @brief Update memo.
-                        * @param[in]   memo            Memo to update.
-                        */
-                       void updateMemo(Memo *memo);
-
-                       /**
-                        * @brief Delete memo.
-                        * @param[in]   memo             Memo to delete.
-                        */
-                       void deleteMemo(Memo *memo);
-
-               protected:
-                       /**
-                        * @see DataProvider::startInit().
-                        */
-                       virtual void startInit() override;
-
-                       /**
-                        * @see DataProvider::startUpdate().
-                        */
-                       virtual void startUpdate() override;
-
-               private:
-                       struct UpdateInfo
-                       {
-                               long long id;
-                               data_control_data_change_type_e type;
-                       };
-
-                       void onMemoReceived(::Model::DataItem *newItem, long long id, data_control_data_change_type_e type);
-                       void onMemoDataChanged(long long id, data_control_data_change_type_e type);
-
-                       void getMemoFromDB(long long id, data_control_data_change_type_e type);
-
-                       DataConsumer m_Consumer;
-                       std::list<UpdateInfo> m_Updates;
-               };
-       }
-}
-
-#endif /* COMMON_MODEL_MEMO_PROVIDER_H */
diff --git a/lib-common/src/Common/Model/DataConsumer.cpp b/lib-common/src/Common/Model/DataConsumer.cpp
deleted file mode 100644 (file)
index 4b5f152..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * 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 "Common/Model/DataConsumer.h"
-#include "Common/Model/DataBasePath.h"
-#include "Common/Model/Memo.h"
-#include <Common/Model/MemoBuilder.h>
-#include "Common/Model/SoundRecord.h"
-#include "Utils/Callback.h"
-#include "Utils/Logger.h"
-#include "Utils/Range.h"
-
-#include <stdio.h>
-#include <sqlite3.h>
-#include <algorithm>
-
-#define BUFFER_SIZE 100
-#define PROVIDER_ID "http://memo_provider"
-
-using namespace Model;
-using namespace Common::Model;
-
-DataConsumer::DataConsumer()
-       : m_Provider(nullptr)
-{
-       initialize();
-}
-
-DataConsumer::~DataConsumer()
-{
-       data_control_remove_data_change_cb(m_Provider, m_Id);
-       data_control_sql_unregister_response_cb(m_Provider);
-       data_control_sql_destroy(m_Provider);
-}
-
-void DataConsumer::setChangeCallback(ChangeCallback callback)
-{
-       m_OnMemoChanged = std::move(callback);
-}
-
-void DataConsumer::unsetChangeCallback()
-{
-       m_OnMemoChanged = nullptr;
-}
-
-void DataConsumer::setResultCallback(ResultCallback callback)
-{
-       m_OnResult = std::move(callback);
-}
-
-void DataConsumer::unsetResultCallback()
-{
-       m_OnResult = nullptr;
-}
-
-void DataConsumer::getMemoList(MemoListReceivedCallback callback)
-{
-       m_OnListReceived = std::move(callback);
-
-       const char *columnList[] = {COLUMN_MEMO_ID, COLUMN_MEMO_TITLE, COLUMN_MEMO_TEXT, COLUMN_MEMO_PINNED, COLUMN_MEMO_TIME, COLUMN_MEMO_COLOR, COLUMN_THUMBNAIL_PATH};
-       data_control_sql_select(m_Provider, (char **)columnList, Utils::count(columnList), nullptr, nullptr, &m_ListRequestId);
-}
-
-void DataConsumer::getMemo(MemoReceivedCallback callback, int id)
-{
-       m_OnMemoReceived = std::move(callback);
-
-       const char *columnList[] = {COLUMN_MEMO_ID, COLUMN_MEMO_TITLE, COLUMN_MEMO_TEXT, COLUMN_MEMO_PINNED, COLUMN_MEMO_TIME, COLUMN_MEMO_COLOR, COLUMN_THUMBNAIL_PATH};
-
-       char where[BUFFER_SIZE];
-       snprintf(where, sizeof(where), "%s = %d", COLUMN_MEMO_ID, id);
-
-       data_control_sql_select(m_Provider, (char **)columnList, Utils::count(columnList), where, nullptr, &m_MemoRequestId);
-}
-
-int DataConsumer::insertMemo(Memo *memo)
-{
-       bundle *bd = prepareBundle(memo);
-
-       int reqId = 0;
-       int err = data_control_sql_insert(m_Provider, bd, &reqId);
-       WARN_IF_ERR(err, "data_control_sql_insert() failed.");
-       bundle_free(bd);
-
-       return err;
-}
-
-int DataConsumer::removeMemo(Memo *memo)
-{
-       char where[BUFFER_SIZE];
-       snprintf(where, sizeof(where), "%s = %d", COLUMN_MEMO_ID, memo->getId());
-
-       int reqId = 0;
-       int err = data_control_sql_delete(m_Provider, where, &reqId);
-       WARN_IF_ERR(err, "data_control_sql_delete() failed.");
-
-       return err;
-}
-
-int DataConsumer::updateMemo(Memo *memo)
-{
-       bundle *bd = prepareBundle(memo);
-
-       char where[BUFFER_SIZE];
-       snprintf(where, sizeof(where), "%s = %d", COLUMN_MEMO_ID, memo->getId());
-
-       int reqId = 0;
-       int err = data_control_sql_update(m_Provider, bd, where, &reqId);
-       WARN_IF_ERR(err, "data_control_sql_update() failed.");
-
-       bundle_free(bd);
-       return err;
-}
-
-void DataConsumer::onDeleteResponse(int requestId, data_control_h provider, bool providerResult, const char *error)
-{
-       if (m_OnResult) {
-               m_OnResult(providerResult);
-       }
-}
-
-void DataConsumer::onInsertResponse(int requestId, data_control_h provider, long long insertedRowId, bool providerResult, const char *error)
-{
-       if (m_OnResult) {
-               m_OnResult(providerResult);
-       }
-}
-
-void DataConsumer::onUpdateResponse(int requestId, data_control_h provider, bool providerResult, const char *error)
-{
-       if (m_OnResult) {
-               m_OnResult(providerResult);
-       }
-}
-
-void DataConsumer::onSelectResponse(int requestId, data_control_h provider, result_set_cursor cursor, bool providerResult, const char *error)
-{
-       RETM_IF(!providerResult, "onSelectResponse() failed.");
-
-       DataProvider::DataList list;
-
-       int res = data_control_sql_step_first(cursor);
-
-       while (res == DATA_CONTROL_ERROR_NONE) {
-               list.push_back(MemoBuilder::createMemo(cursor));
-               res = data_control_sql_step_next(cursor);
-       }
-
-       if (m_MemoRequestId == requestId && m_OnMemoReceived) {
-               m_OnMemoReceived(std::move(list.back()));
-       } else if (m_ListRequestId == requestId && m_OnListReceived) {
-               m_OnListReceived(std::move(list));
-       }
-}
-
-void DataConsumer::initialize()
-{
-       int ret = data_control_sql_create(&m_Provider);
-       RETM_IF_ERR(ret, "data_control_sql_create() failed.");
-
-       ret = data_control_sql_set_provider_id(m_Provider, PROVIDER_ID);
-       RETM_IF_ERR(ret, "data_control_sql_set_provider_id() failed.");
-
-       ret = data_control_sql_set_data_id(m_Provider, TABLE_MEMOS);
-       RETM_IF_ERR(ret, "data_control_sql_set_data_id() failed.");
-
-       data_control_sql_response_cb cb;
-       cb.delete_cb = makeCallbackWithLastParam(&DataConsumer::onDeleteResponse);
-       cb.insert_cb = makeCallbackWithLastParam(&DataConsumer::onInsertResponse);
-       cb.select_cb = makeCallbackWithLastParam(&DataConsumer::onSelectResponse);
-       cb.update_cb = makeCallbackWithLastParam(&DataConsumer::onUpdateResponse);
-
-       data_control_sql_register_response_cb(m_Provider, &cb, this);
-       data_control_add_data_change_cb(m_Provider, makeCallbackWithLastParam(&DataConsumer::onDataChanged),
-                       this, makeCallbackWithLastParam(&DataConsumer::onResult), this, &m_Id);
-}
-
-bundle *DataConsumer::prepareBundle(Memo *memo)
-{
-       bundle *bd = bundle_create();
-
-       Model::ColorId color = memo->getColor();
-       bool pinned = memo->isPinned();
-       time_t time = memo->getTime();
-
-       bundle_add_str(bd, COLUMN_MEMO_TEXT, memo->getContent().c_str());
-       bundle_add_str(bd, COLUMN_MEMO_TITLE, memo->getTitle().c_str());
-       bundle_add_byte(bd, COLUMN_MEMO_COLOR, &color, sizeof(color));
-       bundle_add_byte(bd, COLUMN_MEMO_PINNED, &pinned, sizeof(pinned));
-       bundle_add_byte(bd, COLUMN_MEMO_TIME, &time, sizeof(time));
-
-       setImageToBundle(bd, memo);
-       setSoundToBundle(bd, memo);
-       setThumbnailToBundle(bd, memo);
-
-       return bd;
-}
-
-void DataConsumer::setImageToBundle(bundle *bd, Memo *memo)
-{
-       std::vector<int> id;
-       std::vector<const char *> images;
-       std::vector<int> index;
-
-       for (auto &&image : memo->getImages()) {
-               id.push_back(image.getId());
-               images.push_back(image.getPath().c_str());
-               index.push_back(image.getIndex());
-       }
-
-       bundle_add_byte(bd, COLUMN_IMAGE_ID, (void **)id.data(), sizeof(id[0]) * id.size());
-       bundle_add_str_array(bd, COLUMN_IMAGE_PATH, (const char **) images.data(), images.size());
-       bundle_add_byte(bd, COLUMN_IMAGE_INDEX, (void **)index.data(), sizeof(index[0]) * index.size());
-
-       std::vector<int> removedId;
-
-       for (auto &&image : memo->getImagesToRemove()) {
-               removedId.push_back(image.getId());
-       }
-
-       bundle_add_byte(bd, COLUMN_REMOVED_IMAGE_ID, (void **) removedId.data(), sizeof(removedId[0]) * removedId.size());
-}
-
-void DataConsumer::setSoundToBundle(bundle *bd, Memo *memo)
-{
-       if (const SoundRecord *soundToRemove = memo->getSoundRecordToRemove()) {
-               bundle_add_str(bd, SOUND_TO_REMOVE, soundToRemove->getPath().c_str());
-       }
-       if (const SoundRecord *soundToSave = memo->getSoundRecord()) {
-               int id = soundToSave->getId();
-               bundle_add_byte(bd, COLUMN_SOUND_ID, &id, sizeof(id));
-               bundle_add_str(bd, SOUND_TO_SAVE, soundToSave->getPath().c_str());
-       }
-}
-
-void DataConsumer::setThumbnailToBundle(bundle *bd, Memo *memo)
-{
-       int id = memo->getThumbnail().getId();
-       bundle_add_byte(bd, COLUMN_THUMBNAIL_ID, &id, sizeof(id));
-}
-
-void DataConsumer::onDataChanged(data_control_h provider, data_control_data_change_type_e type, bundle *data)
-{
-       long long *id = nullptr;
-       bundle_get_byte(data, COLUMN_MEMO_ID, (void **) &id, nullptr);
-
-       if (m_OnMemoChanged) {
-               m_OnMemoChanged(*id, type);
-       }
-}
-
-void DataConsumer::onResult(data_control_h provider, data_control_error_e result, int callback_id)
-{
-       WARN_IF_ERR((tizen_error_e)result, "data_changed_cb() failed.");
-}
index 44032173a952cb68b1654e16f4b7bd597c1f5adf..bcfaebb27c914836a324cc77f77375b417457718 100644 (file)
@@ -84,6 +84,25 @@ Memo *MemoBuilder::createMemo(bundle *data)
        return memo;
 }
 
+Utils::Bundle MemoBuilder::createBundle(const Memo &memo)
+{
+       Utils::Bundle bundle;
+
+       bundle.addStr(COLUMN_MEMO_TEXT, memo.getContent().c_str());
+       bundle.addStr(COLUMN_MEMO_TITLE, memo.getTitle().c_str());
+       bundle.addInt(COLUMN_MEMO_COLOR, memo.getColor());
+       bundle.addInt(COLUMN_MEMO_PINNED, memo.isPinned());
+
+       time_t time = memo.getTime();
+       bundle_add_byte(bundle.getBundle(), COLUMN_MEMO_TIME, &time, sizeof(time));
+
+       setMemoImagesToBundle(bundle, memo);
+       setMemoSoundsToBundle(bundle, memo);
+       setMemoThumbnailToBundle(bundle, memo);
+
+       return bundle;
+}
+
 void MemoBuilder::setMemoColumn(Memo *memo, result_set_cursor cursor, int column)
 {
        char columnName[BUFFER_SIZE] = { 0, };
@@ -230,3 +249,46 @@ void MemoBuilder::setMemoThumbnail(Memo *memo, bundle *data)
        bundle_get_byte(data, COLUMN_THUMBNAIL_ID, (void **)&id, nullptr);
        memo->setThumbnail(Thumbnail(*id, ""));
 }
+
+void MemoBuilder::setMemoImagesToBundle(Utils::Bundle &bundle, const Memo &memo)
+{
+       std::vector<int> id;
+       std::vector<const char *> images;
+       std::vector<int> index;
+
+       for (auto &&image : memo.getImages()) {
+               id.push_back(image.getId());
+               images.push_back(image.getPath().c_str());
+               index.push_back(image.getIndex());
+       }
+
+       bundle_add_byte(bundle.getBundle(), COLUMN_IMAGE_ID, (void **)id.data(), sizeof(id[0]) * id.size());
+       bundle_add_str_array(bundle.getBundle(), COLUMN_IMAGE_PATH, (const char **) images.data(), images.size());
+       bundle_add_byte(bundle.getBundle(), COLUMN_IMAGE_INDEX, (void **)index.data(), sizeof(index[0]) * index.size());
+
+       std::vector<int> removedId;
+
+       for (auto &&image : memo.getImagesToRemove()) {
+               removedId.push_back(image.getId());
+       }
+
+       bundle_add_byte(bundle.getBundle(), COLUMN_REMOVED_IMAGE_ID, (void **) removedId.data(), sizeof(removedId[0]) * removedId.size());
+}
+
+void MemoBuilder::setMemoSoundsToBundle(Utils::Bundle &bundle, const Memo &memo)
+{
+       if (const SoundRecord *soundToRemove = memo.getSoundRecordToRemove()) {
+               bundle.addStr(SOUND_TO_REMOVE, soundToRemove->getPath().c_str());
+       }
+       if (const SoundRecord *soundToSave = memo.getSoundRecord()) {
+               int id = soundToSave->getId();
+               bundle.addInt(COLUMN_SOUND_ID, id);
+               bundle.addStr(SOUND_TO_SAVE, soundToSave->getPath().c_str());
+       }
+}
+
+void MemoBuilder::setMemoThumbnailToBundle(Utils::Bundle &bundle, const Memo &memo)
+{
+       int id = memo.getThumbnail().getId();
+       bundle.addInt(COLUMN_THUMBNAIL_ID, id);
+}
diff --git a/lib-common/src/Common/Model/MemoConsumer.cpp b/lib-common/src/Common/Model/MemoConsumer.cpp
new file mode 100644 (file)
index 0000000..bb8209a
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 "Common/Model/MemoConsumer.h"
+
+#include "Common/Model/MemoBuilder.h"
+#include "Common/Model/DataBasePath.h"
+#include "Common/Model/Memo.h"
+
+#define PROVIDER_ID "http://memo_provider"
+
+using namespace Common::Model;
+
+namespace
+{
+       const char *columnList[] = {
+               COLUMN_MEMO_ID,
+               COLUMN_MEMO_TITLE,
+               COLUMN_MEMO_TEXT,
+               COLUMN_MEMO_PINNED,
+               COLUMN_MEMO_TIME,
+               COLUMN_MEMO_COLOR,
+               COLUMN_THUMBNAIL_PATH
+       };
+}
+
+MemoConsumer::MemoConsumer()
+       : DataControlConsumer(PROVIDER_ID, TABLE_MEMOS, columnList)
+{
+}
+
+MemoConsumer &MemoConsumer::getInstance()
+{
+       static MemoConsumer instance;
+       return instance;
+}
+
+void MemoConsumer::getDataItem(int id, GetCallback callback)
+{
+       selectDataItems(std::to_string(id).c_str(), std::move(callback));
+}
+
+::Model::DataItem *MemoConsumer::createDataItem(result_set_cursor cursor)
+{
+       return MemoBuilder::createMemo(cursor);
+}
+
+Utils::Bundle MemoConsumer::createBundle(const ::Model::DataItem &item)
+{
+       return MemoBuilder::createBundle(static_cast<const Memo &>(item));
+}
+
diff --git a/lib-common/src/Common/Model/MemoProvider.cpp b/lib-common/src/Common/Model/MemoProvider.cpp
deleted file mode 100644 (file)
index 461c333..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * 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 "Common/Model/MemoProvider.h"
-#include "Common/Model/Memo.h"
-
-#include "Utils/Logger.h"
-
-
-using namespace Model;
-using namespace Common::Model;
-
-using namespace std::placeholders;
-
-MemoProvider::MemoProvider()
-{
-       m_Consumer.setChangeCallback(std::bind(&MemoProvider::onMemoDataChanged, this, _1, _2));
-}
-
-MemoProvider::~MemoProvider()
-{
-       m_Consumer.unsetChangeCallback();
-}
-
-void MemoProvider::setResultCallback(DataConsumer::ResultCallback callback)
-{
-       m_Consumer.setResultCallback(callback);
-}
-
-void MemoProvider::unsetResultCallback()
-{
-       m_Consumer.unsetResultCallback();
-}
-
-Memo *MemoProvider::getMemo(long long id)
-{
-       for (auto &&dataItem : getDataList()) {
-               auto memo = static_cast<Memo *>(dataItem);
-               if (memo->getId() == id) {
-                       return memo;
-               }
-       }
-
-       return nullptr;
-}
-
-void MemoProvider::insertMemo(Memo *memo)
-{
-       m_Consumer.insertMemo(memo);
-}
-
-void MemoProvider::updateMemo(Memo *memo)
-{
-       m_Consumer.updateMemo(memo);
-}
-
-void MemoProvider::deleteMemo(Memo *memo)
-{
-       m_Consumer.removeMemo(memo);
-}
-
-void MemoProvider::startInit()
-{
-       m_Consumer.getMemoList(std::bind(&MemoProvider::finishInit, this, _1));
-}
-
-void MemoProvider::startUpdate()
-{
-       for (auto it = m_Updates.begin(); it != m_Updates.end();) {
-               if (it->type == DATA_CONTROL_DATA_CHANGE_SQL_DELETE) {
-                       if (Memo *memo = getMemo(it->id)) {
-                               deleteDataItem(*memo);
-                               it = m_Updates.erase(it);
-                               continue;
-                       }
-               } else {
-                       getMemoFromDB(it->id, it->type);
-               }
-
-               ++it;
-       }
-
-       if (m_Updates.empty()) {
-               finishUpdate();
-       }
-}
-
-void MemoProvider::onMemoDataChanged(long long id, data_control_data_change_type_e type)
-{
-       m_Updates.push_back({id, type});
-       update();
-}
-
-void MemoProvider::onMemoReceived(::Model::DataItem *newItem, long long id, data_control_data_change_type_e type)
-{
-       if (type == DATA_CONTROL_DATA_CHANGE_SQL_INSERT) {
-               insertDataItem(newItem);
-
-       } else if (type == DATA_CONTROL_DATA_CHANGE_SQL_UPDATE) {
-               if (Memo *memo = getMemo(id)) {
-                       memo->update(newItem);
-               }
-       }
-
-       for (auto it = m_Updates.begin(); it != m_Updates.end(); ++it) {
-               if (it->id == id) {
-                       m_Updates.erase(it);
-                       break;
-               }
-       }
-
-       if (m_Updates.empty()) {
-               finishUpdate();
-       }
-}
-
-void MemoProvider::getMemoFromDB(long long id, data_control_data_change_type_e type)
-{
-       m_Consumer.getMemo(std::bind(&MemoProvider::onMemoReceived, this, _1, id, type), id);
-}
index 101962c016081efde6bc3995b5d1698e6e8c4fff..0c4f2156280d8940d38ef5b47e7f358c9df18efb 100644 (file)
@@ -33,10 +33,9 @@ namespace Input
                /**
                 * @brief Create Details view.
                 * @param[in]   memo       Memo.
-                * @param[in]   provider   Memo provider.
                 * @see InputView.
                 */
-               DetailsView(Common::Model::Memo memo, Common::Model::MemoProvider *provider);
+               explicit DetailsView(Common::Model::Memo memo);
                virtual ~DetailsView() override;
 
        private:
@@ -51,7 +50,7 @@ namespace Input
                virtual bool onBackPressed() override;
                virtual void onMenuPressed() override;
                virtual void onFavIconChanged() override;
-               virtual void onResult(bool result) override;
+               virtual void onResult(bool isSuccess, int id) override;
 
                void onEdit();
                void onDelete();
index e23680ef98d707248a2b44affbac9961c6e9e502..0b0efd828edcd9dce5ac97ebf0024fdd3f9ef3df 100644 (file)
 
 #include <vector>
 
-namespace Common
-{
-       namespace Model
-       {
-               class MemoProvider;
-       }
-}
-
 namespace Input
 {
        class TitleField;
@@ -50,9 +42,8 @@ namespace Input
                /**
                 * @brief Create Input view.
                 * @param[in]   memo       Memo.
-                * @param[in]   provider   Memo provider.
                 */
-               InputView(Common::Model::Memo memo, Common::Model::MemoProvider *provider);
+               explicit InputView(Common::Model::Memo memo);
                virtual ~InputView() override;
 
        protected:
@@ -64,13 +55,12 @@ namespace Input
                virtual void onNavigation(bool isCurrent) override;
                virtual void onRotationChanged(int degree) override;
                virtual void onFavIconChanged() {};
-               virtual void onResult(bool result);
+               virtual void onResult(bool isSuccess, int id);
 
                InputBox *getInputBox() const;
                TitleField *getTitleField() const;
                RecordField *getRecordField() const;
                Common::Model::Memo &getMemo();
-               Common::Model::MemoProvider *getProvider() const;
 
        private:
                Evas_Object *createLayout(Evas_Object *parent, const char *layoutName);
@@ -108,7 +98,6 @@ namespace Input
                RecordField *m_RecordField;
                Common::Model::Memo m_InitialMemo;
                Common::Model::Memo m_Memo;
-               Common::Model::MemoProvider *m_Provider;
                AttachPanel m_AttachPanel;
        };
 }
index 112e61f182099f244a0a5381e13b120751813c86..91840dc59fe258d7a6b67192a5df3c7751f76c81 100644 (file)
 #ifndef LIST_MEMO_LIST_VIEW_H
 #define LIST_MEMO_LIST_VIEW_H
 
-#include "Common/Model/MemoProvider.h"
-
-#include "Ux/SelectView.h"
+#include "Model/DataControlProvider.h"
 #include "Model/SearchProvider.h"
+#include "Ux/SelectView.h"
 
 namespace Ui
 {
@@ -83,7 +82,7 @@ namespace List
                Evas_Object   *m_AddButton;
                bool           m_IsSearching;
 
-               Common::Model::MemoProvider m_DataProvider;
+               Model::DataControlProvider m_DataProvider;
                Model::SearchProvider m_SearchProvider;
        };
 }
index 6fdd1183c7b5e0dec6274341610acd256d88749e..0ba93746185f834a636ba889abe311c31cdb46c7 100644 (file)
 #define OPERATION_EDIT_CONTROLLER_H
 
 #include "App/OperationController.h"
-#include "Common/Model/MemoProvider.h"
 
 class OperationEditController : public App::OperationController
 {
 private:
        virtual void onRequest(const char *operation, app_control_h request) override;
-
-       Common::Model::MemoProvider m_Provider;
 };
 
 #endif /* OPERATION_EDIT_CONTROLLER_H */
index 51cdbe8988ac3b4266d3d10e325d26898b52a4fe..19631cc034bface18bdf08bc888645029a8d5f04 100644 (file)
@@ -17,7 +17,7 @@
 #include "Input/DetailsView.h"
 #include "Input/TitleField.h"
 
-#include "Common/Model/MemoProvider.h"
+#include "Common/Model/MemoConsumer.h"
 #include "Common/Model/ShareTool.h"
 
 #include "App/AppControlRequest.h"
@@ -37,8 +37,8 @@ using namespace Utils;
 #define DATETIME_FORMAT_24 "%x %R"
 #define DATETIME_FORMAT_12 "%x %I:%M %p"
 
-DetailsView::DetailsView(Memo memo, MemoProvider *provider)
-       : InputView(memo, provider)
+DetailsView::DetailsView(Memo memo)
+       : InputView(std::move(memo))
        , m_Mode(ModeDetails)
 {
 }
@@ -81,14 +81,14 @@ void DetailsView::onMenuPressed()
 void DetailsView::onFavIconChanged()
 {
        if (m_Mode == ModeDetails) {
-               getProvider()->updateMemo(&getMemo());
+               MemoConsumer::getInstance().updateDataItem(getMemo());
        }
 }
 
-void DetailsView::onResult(bool result)
+void DetailsView::onResult(bool isSuccess, int id)
 {
        if (m_Mode == ModeInput) {
-               InputView::onResult(result);
+               InputView::onResult(isSuccess, id);
        }
 }
 
@@ -106,7 +106,7 @@ void DetailsView::onDelete()
 
        popup->addButton("IDS_MEMO_BUTTON_CANCEL_ABB2");
        popup->addButton("IDS_MEMO_BUTTON_DELETE_ABB4", [this] {
-               getProvider()->deleteMemo(&getMemo());
+               MemoConsumer::getInstance().deleteDataItem(getMemo().getId());
                notification_status_message_post(_("IDS_MEMO_POP_DELETED"));
                getPage()->close();
                return true;
@@ -141,7 +141,7 @@ void DetailsView::onCheckChanged()
 {
        getMemo().setContent(getInputBox()->getContent());
        getMemo().setTime(getCurrentTime());
-       getProvider()->updateMemo(&getMemo());
+       MemoConsumer::getInstance().updateDataItem(getMemo());
 }
 
 void DetailsView::setMode(Mode mode)
index df701b713c97c7137c6029d31663ebda5863d043..ded42e46337a6fb382087333e58e9ad81fdf570f 100644 (file)
@@ -20,7 +20,7 @@
 #include "Input/ColorSelector.h"
 #include "Input/TitleField.h"
 
-#include "Common/Model/MemoProvider.h"
+#include "Common/Model/MemoConsumer.h"
 #include "Common/Model/SoundRecord.h"
 #include "Common/SoundManager.h"
 
@@ -50,7 +50,7 @@ namespace
        const std::string layoutFilePath = App::getResourcePath(INPUT_LAYOUT_EDJ);
 }
 
-InputView::InputView(Memo memo, MemoProvider *provider)
+InputView::InputView(Memo memo)
        : m_DoneButton(nullptr)
        , m_InputBox(nullptr)
        , m_Bg(nullptr)
@@ -58,14 +58,11 @@ InputView::InputView(Memo memo, MemoProvider *provider)
        , m_RecordField(nullptr)
        , m_InitialMemo(memo)
        , m_Memo(std::move(memo))
-       , m_Provider(provider)
 {
-       m_Provider->setResultCallback(std::bind(&InputView::onResult, this, _1));
 }
 
 InputView::~InputView()
 {
-       m_Provider->unsetResultCallback();
 }
 
 Evas_Object *InputView::onCreate(Evas_Object *parent)
@@ -161,9 +158,9 @@ void InputView::onRotationChanged(int degree)
        }
 }
 
-void InputView::onResult(bool result)
+void InputView::onResult(bool isSuccess, int id)
 {
-       if (result) {
+       if (isSuccess) {
                getPage()->close();
        }
 }
@@ -188,11 +185,6 @@ Common::Model::Memo &InputView::getMemo()
        return m_Memo;
 }
 
-Common::Model::MemoProvider *InputView::getProvider() const
-{
-       return m_Provider;
-}
-
 Evas_Object *InputView::createLayout(Evas_Object *parent, const char *layoutName)
 {
        Evas_Object *layout = elm_layout_add(parent);
@@ -273,11 +265,7 @@ void InputView::onDonePressed(Evas_Object *button, void *eventInfo)
        m_Memo.setContent(m_InputBox->getContent());
        getMemo().setTime(getCurrentTime());
 
-       if (m_Memo.isNew()) {
-               m_Provider->insertMemo(&m_Memo);
-       } else {
-               m_Provider->updateMemo(&m_Memo);
-       }
+       MemoConsumer::getInstance().saveDataItem(m_Memo, std::bind(&InputView::onResult, this, _1, _2));
 }
 
 void InputView::onCancelPressed(Evas_Object *button, void *eventInfo)
index 302f3f52aa0f2b26f7fe2e8e7a384f358ffed45f..7a89faf8e3a6711fba843b0374fc2665599c9a20 100644 (file)
@@ -18,6 +18,8 @@
 #include "List/MemoComparator.h"
 #include "List/MemoSearchItem.h"
 #include "List/SearchBar.h"
+
+#include "Common/Model/MemoConsumer.h"
 #include "Input/DetailsView.h"
 
 #include "App/Path.h"
@@ -49,7 +51,7 @@ using namespace std::placeholders;
 MemoListView::MemoListView()
        : m_Bg(nullptr), m_Content(nullptr), m_Gengrid(nullptr),
          m_SearchBar(nullptr), m_AddButton(nullptr),
-         m_IsSearching(false),
+         m_IsSearching(false), m_DataProvider(MemoConsumer::getInstance()),
          m_SearchProvider(m_DataProvider, MemoComparator())
 {
        setStrings({
@@ -184,7 +186,8 @@ void MemoListView::onDeleteSelected()
 
        setSelectCallback([this](SelectResults results) {
                for (auto &&result : results) {
-                       m_DataProvider.deleteMemo((Memo *) result.value.data);
+                       Memo *memo = static_cast<Memo *>(result.value.data);
+                       MemoConsumer::getInstance().deleteDataItem(memo->getId());
                }
 
                onDeleteFinished();
@@ -269,7 +272,7 @@ Evas_Object *MemoListView::createAddButton(Evas_Object *parent)
        elm_object_part_content_set(floatButton, "button1", button);
        evas_object_smart_callback_add(button, "clicked", [](void *data, Evas_Object *, void *) {
                auto view = (MemoListView *) data;
-               view->getNavigator()->navigateTo(new Input::InputView(Memo(), &view->m_DataProvider));
+               view->getNavigator()->navigateTo(new Input::InputView(Memo()));
        }, this);
 
        Evas_Object *image = elm_image_add(button);
@@ -361,7 +364,7 @@ MemoSearchItem *MemoListView::createItem(DataItem &dataItem)
        auto memoItem = new MemoSearchItem(searchData);
        memoItem->setSelectCallback([this, &memo] {
                if (getSelectMode() == SelectNone) {
-                       getNavigator()->navigateTo(new Input::DetailsView(memo, &m_DataProvider));
+                       getNavigator()->navigateTo(new Input::DetailsView(memo));
                }
        });
 
index 7de6883fccb1e5bcc71a772b7861ca6298b76081..f39b6559680da1535d409e85a9feb5f788053129 100644 (file)
  */
 
 #include "OperationEditController.h"
-#include "Input/DetailsView.h"
 
 #include "App/AppControlRequest.h"
+#include "Common/Model/MemoConsumer.h"
+#include "Input/DetailsView.h"
 #include "Ui/Navigator.h"
 
 using namespace Common::Model;
@@ -25,23 +26,30 @@ using namespace Common::Model;
 void OperationEditController::onRequest(const char *operation, app_control_h request)
 {
        int id = App::getIntExtraData(request, APP_CONTROL_DATA_ID);
-       m_Provider.initialize([this, id] {
-               Ui::View *view = nullptr;
+       MemoConsumer::getInstance().getDataItem(id, [this](MemoConsumer::DataList dataList) {
+               Memo *memo = nullptr;
+               if (!dataList.empty()) {
+                       memo = static_cast<Memo *>(dataList.front());
+               }
 
+               Ui::View *view = nullptr;
                char *operation = nullptr;
                app_control_get_operation(getRequest(), &operation);
                if (operation) {
-                       Memo *memo = id > 0 ? m_Provider.getMemo(id) : nullptr;
                        if (strcmp(operation, APP_CONTROL_OPERATION_VIEW) == 0) {
                                if (memo) {
-                                       view = new Input::DetailsView(*memo, &m_Provider);
+                                       view = new Input::DetailsView(*memo);
                                }
                        } else {
-                               view = new Input::InputView(memo ? *memo : Memo(), &m_Provider);
+                               view = new Input::InputView(memo ? *memo : Memo());
                        }
                        free(operation);
                }
 
+               for (auto &&item : dataList) {
+                       delete item;
+               }
+
                if (view) {
                        getNavigator()->navigateTo(view);
                } else {
index ac7d5f0f1218a092959f816179de251a7c0499fc..54c3ba8dfad3593ab5a0ffe9e92851a79b83f646 100644 (file)
@@ -207,8 +207,7 @@ void DataProvider::onInsertRequest(int requestId, data_control_h provider, bundl
 
 void DataProvider::onUpdateRequest(int requestId, data_control_h provider, bundle *updateData, const char *where)
 {
-       int memoId = 0;
-       sscanf(where, COLUMN_MEMO_ID " = %d", &memoId);
+       int memoId = std::stoi(where);
        setSuccessCallback([requestId, this] (int memoId) {
                notify(memoId, DATA_CONTROL_DATA_CHANGE_SQL_UPDATE);
                data_control_provider_send_update_result(requestId);
@@ -225,9 +224,7 @@ void DataProvider::onUpdateRequest(int requestId, data_control_h provider, bundl
 
 void DataProvider::onDeleteRequest(int requestId, data_control_h provider, const char *where)
 {
-       int memoId = 0;
-       sscanf(where, COLUMN_MEMO_ID " = %d", &memoId);
-
+       int memoId = std::stoi(where);
        DeleteStatement statement;
        if (statement.execute(m_Db, requestId, memoId)) {
                notify(memoId, DATA_CONTROL_DATA_CHANGE_SQL_DELETE);
@@ -241,7 +238,7 @@ void DataProvider::onSelectRequest(int requestId, data_control_h provider, const
        sqlite3_stmt *sqlStmt = nullptr;
        int id = 0;
        if (where) {
-               sscanf(where, COLUMN_MEMO_ID " = %d", &id);
+               id = std::stoi(where);
        }
 
        int err = sqlite3_prepare_v2(m_Db, where ? selectStmt : selectAllStmt, -1, &sqlStmt, nullptr);
index 15350e5f5fc1a5dc3ce26bfc1d56be50f668bde5..4247811ce4cc241f8c1ef107cfd539944ab33d54 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <Elementary.h>
 #include "App/Widget.h"
-#include "Common/Model/MemoProvider.h"
+#include "Model/DataControlProvider.h"
 
 namespace Ui
 {
@@ -28,6 +28,11 @@ namespace Ui
 
 namespace Common
 {
+       namespace Model
+       {
+               class Memo;
+       }
+
        class MemoItem;
 }
 
@@ -57,7 +62,7 @@ private:
        Ui::Gengrid *m_Gengrid;
 
        bool m_IsEmpty;
-       Common::Model::MemoProvider m_Provider;
+       Model::DataControlProvider m_Provider;
 };
 
 #endif /* MEMO_WIDGET_H */
index 18bd4bf0ab57a60a6862e9f134954497cfa51144..d7be8d1cda27145ec6c7bc41b653f74489db7fa7 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "MemoWidget.h"
 #include "Common/Model/Memo.h"
+#include "Common/Model/MemoConsumer.h"
 #include "Common/MemoItem.h"
 
 #include "App/AppControl.h"
@@ -40,7 +41,8 @@ using namespace Common::Model;
 using namespace std::placeholders;
 
 MemoWidget::MemoWidget()
-       : m_Layout(nullptr), m_Gengrid(nullptr), m_IsEmpty(false)
+       : m_Layout(nullptr), m_Gengrid(nullptr), m_IsEmpty(false),
+         m_Provider(MemoConsumer::getInstance())
 {
 }