forked from openkylin/ukui-search
79 lines
1.5 KiB
C++
79 lines
1.5 KiB
C++
#include "result-item.h"
|
|
using namespace UkuiSearch;
|
|
namespace UkuiSearch {
|
|
class ResultItemPrivate
|
|
{
|
|
friend class ResultItem;
|
|
private:
|
|
size_t m_searchId = 0;
|
|
QString m_itemKey;
|
|
SearchResultPropertyMap m_data;
|
|
};
|
|
}
|
|
ResultItem::ResultItem() : d(new ResultItemPrivate())
|
|
{
|
|
}
|
|
|
|
ResultItem::ResultItem(const size_t searchId) : d(new ResultItemPrivate())
|
|
{
|
|
d->m_searchId = searchId;
|
|
}
|
|
|
|
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
|
|
{
|
|
return d->m_searchId;
|
|
}
|
|
|
|
QString ResultItem::getItemKey() const
|
|
{
|
|
return d->m_itemKey;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
ResultItem::~ResultItem()
|
|
{
|
|
if (d)
|
|
delete d;
|
|
d = nullptr;
|
|
}
|
|
|
|
ResultItem::ResultItem(const ResultItem &item): d(new ResultItemPrivate(*item.d))
|
|
{
|
|
}
|