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