ukui-search/libsearch/searchinterface/search-result-property-info...

116 lines
3.8 KiB
C++
Raw Normal View History

#include "search-result-property-info.h"
#include <QMetaType>
#include <QVariant>
using namespace UkuiSearch;
class UkuiSearch::SearchResultPropertyInfoPrivate
{
public:
SearchProperty::SearchResultProperty m_property;
QString m_name;
QString m_displayName;
QMetaType::Type m_valueType;
};
SearchResultPropertyInfo::SearchResultPropertyInfo():d(new SearchResultPropertyInfoPrivate)
{
d->m_property = SearchProperty::SearchResultProperty::Invalid;
d->m_name = QStringLiteral("Invalid");
d->m_valueType = QMetaType::UnknownType;
}
SearchResultPropertyInfo::SearchResultPropertyInfo(SearchProperty::SearchResultProperty property): d(new SearchResultPropertyInfoPrivate)
{
d->m_property = property;
switch (property) {
case SearchProperty::SearchResultProperty::FilePath:
d->m_name = QStringLiteral("FilePath");
d->m_displayName = tr("file path");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::FileName:
d->m_name = QStringLiteral("FileName");
d->m_displayName = tr("file name");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::FileIconName:
d->m_name = QStringLiteral("FileIconName");
d->m_displayName = tr("file icon name");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::ModifiedTime:
d->m_name = QStringLiteral("ModifiedTime");
d->m_displayName = tr("modified time");
d->m_valueType = QMetaType::QDateTime;
break;
case SearchProperty::SearchResultProperty::ApplicationDesktopPath:
d->m_name = QStringLiteral("ApplicationDesktopPath");
d->m_displayName = tr("application desktop file path");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::ApplicationLocalName:
d->m_name = QStringLiteral("ApplicationLocalName");
d->m_displayName = tr("application local name");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::ApplicationIconName:
d->m_name = QStringLiteral("ApplicationIconName");
d->m_displayName = tr("application icon name");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::ApplicationDescription:
d->m_name = QStringLiteral("ApplicationDescription");
d->m_displayName = tr("application description");
d->m_valueType = QMetaType::QString;
break;
case SearchProperty::SearchResultProperty::IsOnlineApplication:
d->m_name = QStringLiteral("IsOnlineApplication");
d->m_displayName = tr("is online application");
d->m_valueType = QMetaType::Int;
break;
case SearchProperty::SearchResultProperty::ApplicationPkgName:
d->m_name = QStringLiteral("ApplicationPkgName");
d->m_displayName = tr("application package name");
d->m_valueType = QMetaType::QString;
break;
}
}
SearchResultPropertyInfo::SearchResultPropertyInfo(const SearchResultPropertyInfo &other): d(new SearchResultPropertyInfoPrivate(*other.d))
{
}
SearchResultPropertyInfo &UkuiSearch::SearchResultPropertyInfo::operator=(const SearchResultPropertyInfo &rhs)
{
*d = *rhs.d;
return *this;
}
bool SearchResultPropertyInfo::operator==(const SearchResultPropertyInfo &rhs) const
{
return d->m_name == rhs.d->m_name && d->m_displayName == rhs.d->m_displayName &&
d->m_property == rhs.d->m_property;
}
SearchProperty::SearchResultProperty UkuiSearch::SearchResultPropertyInfo::property() const
{
return d->m_property;
}
QString SearchResultPropertyInfo::name() const
{
return d->m_name;
}
QString SearchResultPropertyInfo::displayName() const
{
return d->m_displayName;
}