#define COLUMN_IMAGE_MEMO_ID "image_memo_id"
#define COLUMN_REMOVED_IMAGE_ID "removed_image_id"
+#define COLUMN_THUMBNAIL_INFO "thumbnail_info"
#define COLUMN_ALL_IMAGE_PATH "all_image_path"
#define IMAGES_SEPARATOR ","
#include "Common/Model/Colors.h"
#include "Common/Model/Image.h"
#include "Common/Model/SoundRecord.h"
+#include "Common/Model/Thumbnail.h"
#include "Model/DataItem.h"
#include <list>
const ImageList &getImagesToRemove() const;
/**
- * @brief Get thumbnail index.
- * @return Thumbnail index if success, otherwise empty string.
+ * @brief Get thumbnail.
+ * @return Thumbnail.
*/
- const char *getThumbnail() const;
+ const Thumbnail &getThumbnail() const;
/**
* @return First image.
*/
int addImage(std::string image);
- /**
- * @brief Add thumbnail to Memo.
- * @param[in] image Image path.
- */
- void setThumbnail(std::string image);
-
/**
* @brief Add sound record to Memo.
*/
const Image *getImage(int index) const;
void addSoundToRemove(SoundRecord sound);
void addImageToRemove(Image image);
+ void setThumbnail(Thumbnail thumbnail);
long long m_Id;
time_t m_Time;
ColorId m_Color;
ImageList m_ImagesToRemove;
ImageList m_Images;
- std::string m_Thumbnail;
+ Thumbnail m_Thumbnail;
SoundRecordList m_SoundRecords;
SoundRecordList m_SoundRecordsToRemove;
bool m_IsPinned;
static void setMemoColumn(Memo *memo, result_set_cursor cursor, int column);
static void setMemoTextColumn(Memo *memo, result_set_cursor cursor, int column, char *columnName);
static void setMemoIntColumn(Memo *memo, result_set_cursor cursor, int column, char *columnName);
+ static void setMemoThumbnail(Memo *memo, std::string thumbnail);
static void setMemoImages(Memo *memo, std::string images);
static void setMemoImages(Memo *memo, bundle *data);
--- /dev/null
+/*
+ * 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_THUMBNAIL_H
+#define COMMON_MODEL_THUMBNAIL_H
+
+#include <string>
+#include <tizen.h>
+
+namespace Common
+{
+ namespace Model
+ {
+ class EXPORT_API Thumbnail
+ {
+ public:
+ Thumbnail();
+
+ /**
+ * @brief Create thumbnail.
+ * @param[in] id thumbnail id
+ * @param[in] path thumbnail path.
+ */
+ Thumbnail(int id, std::string path);
+
+ bool operator==(const Thumbnail &other);
+ bool operator!=(const Thumbnail &other);
+
+ /**
+ * @return Thumbnail id.
+ */
+ int getId() const;
+
+ /**
+ * @return Thumbnail path.
+ */
+ const std::string &getPath() const;
+
+ private:
+ int m_Id;
+ std::string m_Path;
+ };
+ }
+};
+
+#endif /* COMMON_MODEL_THUMBNAIL_H */
Evas_Object *image = elm_image_add(layout);
elm_image_aspect_fixed_set(image, EINA_FALSE);
- elm_image_file_set(image, m_Memo.getThumbnail(), nullptr);
+ elm_image_file_set(image, m_Memo.getThumbnail().getPath().c_str(), nullptr);
elm_object_part_content_set(layout, PART_IMAGE, image);
return layout;
return m_ImagesToRemove;
}
-const char *Memo::getThumbnail() const
+const Thumbnail &Memo::getThumbnail() const
{
- return m_Thumbnail.c_str();
+ return m_Thumbnail;
}
const Image *Memo::getFirstImage() const
return index;
}
-void Memo::setThumbnail(std::string image)
-{
- m_Thumbnail = std::move(image);
-}
-
void Memo::addSoundRecord()
{
if (!m_SoundRecords.empty()) {
m_SoundRecords = std::move(memo->m_SoundRecords);
changes |= ChangeSound;
}
- if (strcmp(getThumbnail(), memo->getThumbnail()) != 0) {
+ if (m_Thumbnail != memo->m_Thumbnail) {
setThumbnail(memo->getThumbnail());
changes |= ChangedThumbnail;
}
{
m_ImagesToRemove.push_back(std::move(image));
}
+
+void Memo::setThumbnail(Thumbnail thumbnail)
+{
+ m_Thumbnail = std::move(thumbnail);
+}
namespace
{
- const std::string thumbnailDir = std::string(getDataDir()).append("thumbnails/");
- const std::string soundDir = std::string(getDataDir()).append("sounds/");
- const std::string imageDir = std::string(getDataDir()).append("images/");
+ const std::string thumbnailDir = std::string(getDataDir()).append("thumbnails");
+ const std::string soundDir = std::string(getDataDir()).append("sounds");
+ const std::string imageDir = std::string(getDataDir()).append("images");
}
Memo *MemoBuilder::createMemo(result_set_cursor cursor)
memo->setTitle(std::move(value));
} else if (strcmp(columnName, COLUMN_ALL_IMAGE_PATH) == 0) {
setMemoImages(memo, std::move(value));
- } else if (strcmp(columnName, COLUMN_THUMBNAIL_PATH) == 0) {
- memo->setThumbnail(Common::getFilePath(thumbnailDir, value));
+ } else if (strcmp(columnName, COLUMN_THUMBNAIL_INFO) == 0) {
+ setMemoThumbnail(memo, std::move(value));
} else if (strcmp(columnName, COLUMN_SOUND_PATH) == 0) {
memo->addSoundRecord(SoundRecord(Common::getFilePath(soundDir, value)));
} else {
}
}
+void MemoBuilder::setMemoThumbnail(Memo *memo, std::string thumbnail)
+{
+ char *thumbnailName = nullptr;
+ char *str = strtok_r(&thumbnail[0], ",", &thumbnailName);
+ int thumbnailId = strtol(str, nullptr, 10);
+
+ memo->setThumbnail(Thumbnail(thumbnailId, getFilePath(thumbnailDir, thumbnailName)));
+}
+
void MemoBuilder::setMemoImages(Memo *memo, std::string images)
{
int imageId = 0;
--- /dev/null
+/*
+ * 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/Thumbnail.h"
+
+using namespace Common::Model;
+
+Thumbnail::Thumbnail()
+ : m_Id(0)
+{
+}
+
+Thumbnail::Thumbnail(int id, std::string path)
+ : m_Id(id),
+ m_Path(std::move(path))
+{
+}
+
+bool Thumbnail::operator==(const Thumbnail &other)
+{
+ return (m_Id == other.m_Id && m_Path == other.m_Path);
+}
+
+bool Thumbnail::operator!=(const Thumbnail &other)
+{
+ return !(*this == other);
+}
+
+int Thumbnail::getId() const
+{
+ return m_Id;
+}
+
+const std::string &Thumbnail::getPath() const
+{
+ return m_Path;
+}
COLUMN_MEMO_COLOR ", "
COLUMN_MEMO_PINNED ", "
COLUMN_MEMO_TIME ", "
- COLUMN_THUMBNAIL_PATH ", "
TABLE_SOUNDS "." COLUMN_SOUND_PATH ", "
+ "(" COLUMN_THUMBNAIL_ID " || '" IMAGES_SEPARATOR "' || " COLUMN_THUMBNAIL_PATH ") AS " COLUMN_THUMBNAIL_INFO ", "
"GROUP_CONCAT((" COLUMN_IMAGE_ID " || '" IMAGES_SEPARATOR "' || " COLUMN_IMAGE_INDEX " || '" IMAGES_SEPARATOR "' || " COLUMN_IMAGE_PATH "), '"
IMAGES_SEPARATOR "' ) AS " COLUMN_ALL_IMAGE_PATH
" FROM " TABLE_MEMOS
COLUMN_MEMO_COLOR ", "
COLUMN_MEMO_PINNED ", "
COLUMN_MEMO_TIME ", "
- COLUMN_THUMBNAIL_PATH ", "
TABLE_SOUNDS "." COLUMN_SOUND_PATH ", "
+ "(" COLUMN_THUMBNAIL_ID " || '" IMAGES_SEPARATOR "' || " COLUMN_THUMBNAIL_PATH ") AS " COLUMN_THUMBNAIL_INFO ", "
"GROUP_CONCAT((" COLUMN_IMAGE_ID " || '" IMAGES_SEPARATOR "' || " COLUMN_IMAGE_INDEX " || '" IMAGES_SEPARATOR "' || " COLUMN_IMAGE_PATH "), '"
IMAGES_SEPARATOR "' ) AS " COLUMN_ALL_IMAGE_PATH
" FROM " TABLE_MEMOS