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

91 lines
1.7 KiB
C++
Raw Normal View History

2021-12-28 15:56:41 +08:00
#include "result-item.h"
using namespace UkuiSearch;
namespace UkuiSearch {
class ResultItemPrivate
2021-12-31 17:38:02 +08:00
{
friend class ResultItem;
private:
size_t m_searchId = 0;
QString m_itemKey;
SearchResultPropertyMap m_data;
};
2021-12-31 17:38:02 +08:00
}
ResultItem::ResultItem() : d(new ResultItemPrivate())
2022-01-11 16:20:40 +08:00
{
}
ResultItem::ResultItem(const size_t searchId) : d(new ResultItemPrivate())
2022-01-11 16:20:40 +08:00
{
d->m_searchId = searchId;
2022-01-11 16:20:40 +08:00
}
ResultItem::ResultItem(const QString &itemKey) : d(new ResultItemPrivate())
{
d->m_itemKey = itemKey;
}
ResultItem::ResultItem(const size_t searchId, const QString &itemKey, const SearchResultPropertyMap &map) : d(new ResultItemPrivate())
{
d->m_searchId = searchId;
d->m_itemKey = itemKey;
d->m_data = map;
}
void ResultItem::setSearchId(const size_t searchId)
{
d->m_searchId = searchId;
}
void ResultItem::setItemKey(const QString &itemKey)
{
d->m_itemKey = itemKey;
}
size_t ResultItem::getSearchId() const
2022-01-11 16:20:40 +08:00
{
return d->m_searchId;
2022-01-11 16:20:40 +08:00
}
QString ResultItem::getItemKey() const
2021-12-28 15:56:41 +08:00
{
return d->m_itemKey;
2021-12-28 15:56:41 +08:00
}
void ResultItem::setValue(SearchProperty::SearchResultProperty property, const QVariant &value)
{
d->m_data.insert(property, value);
}
QVariant ResultItem::getValue(SearchProperty::SearchResultProperty property) const
{
return d->m_data.value(property);
}
SearchResultPropertyMap ResultItem::getAllValue() const
{
return d->m_data;
}
2021-12-28 15:56:41 +08:00
ResultItem::~ResultItem()
{
if (d)
delete d;
d = nullptr;
}
ResultItem::ResultItem(const ResultItem &item): d(new ResultItemPrivate(*item.d))
{
2021-12-28 15:56:41 +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;
}