2022-06-18 10:46:14 +08:00
|
|
|
#include "result-item.h"
|
|
|
|
using namespace UkuiSearch;
|
2023-03-15 16:39:38 +08:00
|
|
|
namespace UkuiSearch {
|
|
|
|
class ResultItemPrivate
|
2022-06-18 10:46:14 +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;
|
|
|
|
};
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
2023-03-15 16:39:38 +08:00
|
|
|
ResultItem::ResultItem() : d(new ResultItemPrivate())
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
ResultItem::ResultItem(const size_t searchId) : d(new ResultItemPrivate())
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
d->m_searchId = searchId;
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
ResultItem::ResultItem(const QString &itemKey) : d(new ResultItemPrivate())
|
2022-10-21 11:21:35 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
d->m_itemKey = itemKey;
|
2022-10-21 11:21:35 +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-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
d->m_searchId = searchId;
|
|
|
|
d->m_itemKey = itemKey;
|
|
|
|
d->m_data = map;
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
void ResultItem::setSearchId(const size_t searchId)
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
d->m_searchId = searchId;
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
2022-10-21 11:21:35 +08:00
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
void ResultItem::setItemKey(const QString &itemKey)
|
2022-10-21 11:21:35 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
d->m_itemKey = itemKey;
|
2022-10-21 11:21:35 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
size_t ResultItem::getSearchId() const
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
return d->m_searchId;
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
QString ResultItem::getItemKey() const
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
return d->m_itemKey;
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
void ResultItem::setValue(SearchProperty::SearchResultProperty property, const QVariant &value)
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
d->m_data.insert(property, value);
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
QVariant ResultItem::getValue(SearchProperty::SearchResultProperty property) const
|
2022-06-18 10:46:14 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
return d->m_data.value(property);
|
2022-06-18 10:46:14 +08:00
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
SearchResultPropertyMap ResultItem::getAllValue() const
|
2022-10-21 11:21:35 +08:00
|
|
|
{
|
2023-03-15 16:39:38 +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;
|
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
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
|
|
|
}
|