89 lines
2.5 KiB
C++
89 lines
2.5 KiB
C++
/*
|
|
*
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#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}});
|
|
}
|
|
}
|