forked from openkylin/ukui-search
70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
|
#include "application-info-storage.h"
|
||
|
#include <QMap>
|
||
|
using namespace UkuiSearch;
|
||
|
namespace UkuiSearch {
|
||
|
class ApplicationInfoStoragePrivate
|
||
|
{
|
||
|
friend class ApplicationInfoStorage;
|
||
|
private:
|
||
|
Properties m_properties;
|
||
|
ApplicationInfoMap m_data;
|
||
|
};
|
||
|
}
|
||
|
ApplicationInfoStorage::ApplicationInfoStorage(): d(new ApplicationInfoStoragePrivate)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ApplicationInfoStorage::ApplicationInfoStorage(Properties properties): d(new ApplicationInfoStoragePrivate)
|
||
|
{
|
||
|
d->m_properties = properties;
|
||
|
}
|
||
|
|
||
|
ApplicationInfoStorage::ApplicationInfoStorage(const ApplicationInfoStorage &other): d(new ApplicationInfoStoragePrivate(*other.d))
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ApplicationInfoStorage::~ApplicationInfoStorage()
|
||
|
{
|
||
|
if(d) {
|
||
|
delete d;
|
||
|
d = nullptr;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ApplicationInfoStorage &ApplicationInfoStorage::operator=(const ApplicationInfoStorage &rhs)
|
||
|
{
|
||
|
*d = *rhs.d;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
QStringList ApplicationInfoStorage::applicationKeys() const
|
||
|
{
|
||
|
return d->m_data.keys();
|
||
|
}
|
||
|
|
||
|
Properties &ApplicationInfoStorage::applicationInfoKeys() const
|
||
|
{
|
||
|
return d->m_properties;
|
||
|
}
|
||
|
|
||
|
QVariant ApplicationInfoStorage::ApplicationInfo(const QString &desktopFile, ApplicationProperty::Property property)
|
||
|
{
|
||
|
return d->m_data.value(desktopFile).value(property);
|
||
|
}
|
||
|
|
||
|
ApplicationInfoMap &ApplicationInfoStorage::allData()
|
||
|
{
|
||
|
return d->m_data;
|
||
|
}
|
||
|
|
||
|
void ApplicationInfoStorage::addData(const QString &desktopFile, ApplicationProperty::Property property, const QVariant &value)
|
||
|
{
|
||
|
if(d->m_data.contains(desktopFile)) {
|
||
|
QMap<ApplicationProperty::Property, QVariant> info = d->m_data.value(desktopFile);
|
||
|
info.insert(property, value);
|
||
|
d->m_data.insert(desktopFile, info);
|
||
|
} else {
|
||
|
d->m_data.insert(desktopFile, QMap<ApplicationProperty::Property, QVariant>{{property, value}});
|
||
|
}
|
||
|
}
|