CQtDeployer/Deploy/libinfo.cpp

157 lines
3.3 KiB
C++
Raw Normal View History

2019-09-23 16:46:57 +03:00
/*
2022-03-09 17:56:42 +03:00
* Copyright (C) 2018-2022 QuasarApp.
2019-09-23 16:46:57 +03:00
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
2019-04-05 14:23:42 +03:00
#include "libinfo.h"
2019-12-20 17:25:20 +03:00
#include "pathutils.h"
2019-04-05 14:23:42 +03:00
bool operator ==(const LibInfo &left, const LibInfo &right) {
return left.fullPath() == right.fullPath();
}
bool operator <=(const LibInfo &left, const LibInfo &right){
return !operator>(left, right);
}
bool operator >=(const LibInfo &left, const LibInfo &right) {
return !operator<(left, right);
}
bool operator <(const LibInfo &left, const LibInfo &right){
2021-04-21 13:08:18 +03:00
return left._priority < right._priority;
2019-04-05 14:23:42 +03:00
}
bool operator >(const LibInfo &left, const LibInfo &right) {
2021-04-21 13:08:18 +03:00
return left._priority > right._priority;
2019-04-05 14:23:42 +03:00
}
const QSet<LibInfo> &LibInfo::getAllDep() const {
2021-04-21 13:08:18 +03:00
return _allDep;
2019-04-05 14:23:42 +03:00
}
Platform LibInfo::getPlatform() const {
2021-04-21 13:08:18 +03:00
return _platform;
2019-04-05 14:23:42 +03:00
}
void LibInfo::setPlatform(const Platform &value) {
2021-04-21 13:08:18 +03:00
_platform = value;
2019-04-05 14:23:42 +03:00
}
QString LibInfo::getName() const {
2021-04-21 13:08:18 +03:00
return _name;
2019-04-05 14:23:42 +03:00
}
void LibInfo::setName(const QString &value) {
2021-04-21 13:08:18 +03:00
_name = value;
2019-04-05 14:23:42 +03:00
}
QString LibInfo::getPath() const {
2021-04-21 13:08:18 +03:00
return _path;
2019-04-05 14:23:42 +03:00
}
void LibInfo::setPath(const QString &value) {
2021-04-21 13:08:18 +03:00
_path = value;
2019-04-05 14:23:42 +03:00
}
void LibInfo::addDependncies(const QString &value) {
2021-04-21 13:08:18 +03:00
_dependncies.insert(value);
2019-04-05 14:23:42 +03:00
}
2019-12-23 21:55:15 +03:00
void LibInfo::addDependncies(const QSet<QString> &value) {
2021-04-21 13:08:18 +03:00
_dependncies += value;
2019-12-23 21:55:15 +03:00
}
2019-04-05 14:23:42 +03:00
void LibInfo::removeDependncies(const QString &value) {
2021-04-21 13:08:18 +03:00
_dependncies.remove(value);
2019-04-05 14:23:42 +03:00
}
QSet<QString> LibInfo::getDependncies() const {
2021-04-21 13:08:18 +03:00
return _dependncies;
2019-04-05 14:23:42 +03:00
}
void LibInfo::setDependncies(const QSet<QString> &value) {
2021-04-21 13:08:18 +03:00
_dependncies = value;
2019-04-05 14:23:42 +03:00
}
2019-08-24 17:56:42 +03:00
LibPriority LibInfo::getPriority() const {
2021-04-21 13:08:18 +03:00
return _priority;
2019-04-05 14:23:42 +03:00
}
2019-08-24 17:56:42 +03:00
void LibInfo::setPriority(const LibPriority &value) {
2021-04-21 13:08:18 +03:00
_priority = value;
2019-04-05 14:23:42 +03:00
}
2019-09-22 16:46:07 +03:00
QString LibInfo::getQtPath() const
{
2021-04-21 13:08:18 +03:00
return _qtPath;
2019-09-22 16:46:07 +03:00
}
void LibInfo::setQtPath(const QString &value)
{
2021-04-21 13:08:18 +03:00
_qtPath = value;
2019-09-22 16:46:07 +03:00
}
2019-12-24 11:46:11 +03:00
WinAPI LibInfo::getWinApi() const {
return _winApi;
}
void LibInfo::setWinApi(WinAPI winApi) {
_winApi = winApi;
}
2020-11-05 12:57:41 +03:00
QtMajorVersion LibInfo::isDependetOfQt() const {
2021-04-21 13:08:18 +03:00
for (const auto& i : _dependncies) {
2021-05-24 18:35:22 +03:00
if (QtMajorVersion result = DeployCore::isQtLibName(i)) {
2020-11-05 12:57:41 +03:00
return result;
2020-01-28 13:51:00 +03:00
}
}
2020-11-05 12:57:41 +03:00
return QtMajorVersion::NoQt;
2020-01-28 13:51:00 +03:00
}
2021-11-10 11:37:55 +03:00
QString LibInfo::toString() const {
2021-11-10 11:50:00 +03:00
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList dependenciesList = _dependncies.toList();
#else
2021-11-10 11:37:55 +03:00
QStringList dependenciesList{_dependncies.begin(), _dependncies.end()};
2021-11-10 11:50:00 +03:00
#endif
2021-11-10 11:37:55 +03:00
return QString("LibInfo: path: '%0', name: '%1', qtPath: '%2', platform: '%3', dependencies: '%4'").
arg(_path,
_name,
_qtPath,
DeployCore::platformToString(_platform),
dependenciesList.join(", "));
}
2019-04-05 14:23:42 +03:00
QString LibInfo::fullPath() const {
2021-04-21 13:08:18 +03:00
return _path + "/" + _name;
2019-04-05 14:23:42 +03:00
}
void LibInfo::clear() {
2021-04-21 13:08:18 +03:00
_path = "";
_name = "";
_qtPath = "";
_platform = Platform::UnknownPlatform;
_dependncies.clear();
_allDep.clear();
2019-04-05 14:23:42 +03:00
}
bool LibInfo::isValid() const {
2021-04-21 13:08:18 +03:00
return _platform != Platform::UnknownPlatform &&
_name.size() && _path.size();
2019-04-05 14:23:42 +03:00
}
bool LibInfo::isScaned() const {
2021-04-21 13:08:18 +03:00
return _allDep.size();
}
2019-04-05 14:23:42 +03:00
uint qHash(const LibInfo &info) {
return qHash(info.fullPath());
}