ukui-search/libsearch/searchinterface/result-item.cpp

91 lines
1.7 KiB
C++
Raw Normal View History

2022-06-18 10:46:14 +08:00
#include "result-item.h"
using namespace UkuiSearch;
namespace UkuiSearch {
class ResultItemPrivate
2022-06-18 10:46:14 +08:00
{
friend class ResultItem;
private:
size_t m_searchId = 0;
QString m_itemKey;
SearchResultPropertyMap m_data;
};
2022-06-18 10:46:14 +08:00
}
ResultItem::ResultItem() : d(new ResultItemPrivate())
2022-06-18 10:46:14 +08:00
{
}
ResultItem::ResultItem(const size_t searchId) : d(new ResultItemPrivate())
2022-06-18 10:46:14 +08:00
{
d->m_searchId = searchId;
2022-06-18 10:46:14 +08:00
}
ResultItem::ResultItem(const QString &itemKey) : d(new ResultItemPrivate())
2022-10-21 11:21:35 +08:00
{
d->m_itemKey = itemKey;
2022-10-21 11:21:35 +08:00
}
ResultItem::ResultItem(const size_t searchId, const QString &itemKey, const SearchResultPropertyMap &map) : d(new ResultItemPrivate())
2022-06-18 10:46:14 +08:00
{
d->m_searchId = searchId;
d->m_itemKey = itemKey;
d->m_data = map;
2022-06-18 10:46:14 +08:00
}
void ResultItem::setSearchId(const size_t searchId)
2022-06-18 10:46:14 +08:00
{
d->m_searchId = searchId;
2022-06-18 10:46:14 +08:00
}
2022-10-21 11:21:35 +08:00
void ResultItem::setItemKey(const QString &itemKey)
2022-10-21 11:21:35 +08:00
{
d->m_itemKey = itemKey;
2022-10-21 11:21:35 +08:00
}
size_t ResultItem::getSearchId() const
2022-06-18 10:46:14 +08:00
{
return d->m_searchId;
2022-06-18 10:46:14 +08:00
}
QString ResultItem::getItemKey() const
2022-06-18 10:46:14 +08:00
{
return d->m_itemKey;
2022-06-18 10:46:14 +08:00
}
void ResultItem::setValue(SearchProperty::SearchResultProperty property, const QVariant &value)
2022-06-18 10:46:14 +08:00
{
d->m_data.insert(property, value);
2022-06-18 10:46:14 +08:00
}
QVariant ResultItem::getValue(SearchProperty::SearchResultProperty property) const
2022-06-18 10:46:14 +08:00
{
return d->m_data.value(property);
2022-06-18 10:46:14 +08:00
}
SearchResultPropertyMap ResultItem::getAllValue() const
2022-10-21 11:21:35 +08:00
{
return d->m_data;
2022-10-21 11:21:35 +08:00
}
2022-06-18 10:46:14 +08:00
ResultItem::~ResultItem()
{
2022-10-21 11:21:35 +08:00
if (d)
delete d;
d = nullptr;
}
ResultItem::ResultItem(const ResultItem &item): d(new ResultItemPrivate(*item.d))
2022-10-21 11:21:35 +08:00
{
2022-06-18 10:46:14 +08:00
}
2023-04-19 15:14:36 +08:00
ResultItem &ResultItem::operator=(const ResultItem &other)
{
*d = *other.d;
return *this;
}
ResultItem &ResultItem::operator=(ResultItem &&other) Q_DECL_NOEXCEPT
{
d = other.d;
other.d = nullptr;
return *this;
}