diff options
Diffstat (limited to 'src/libs/kdtools')
-rw-r--r-- | src/libs/kdtools/localpackagehub.cpp | 9 | ||||
-rw-r--r-- | src/libs/kdtools/localpackagehub.h | 4 | ||||
-rw-r--r-- | src/libs/kdtools/updatefinder.cpp | 56 |
3 files changed, 53 insertions, 16 deletions
diff --git a/src/libs/kdtools/localpackagehub.cpp b/src/libs/kdtools/localpackagehub.cpp index 6ac3da803..11ff36a88 100644 --- a/src/libs/kdtools/localpackagehub.cpp +++ b/src/libs/kdtools/localpackagehub.cpp @@ -322,7 +322,8 @@ void LocalPackageHub::addPackage(const QString &name, bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, - bool checkable) + bool checkable, + bool expandedByDefault) { // TODO: This somewhat unexpected, remove? if (d->m_packageInfoMap.contains(name)) { @@ -343,6 +344,7 @@ void LocalPackageHub::addPackage(const QString &name, info.virtualComp = virtualComp; info.uncompressedSize = uncompressedSize; info.checkable = checkable; + info.expandedByDefault = expandedByDefault; d->m_packageInfoMap.insert(name, info); } d->modified = true; @@ -416,6 +418,8 @@ void LocalPackageHub::writeToDisk() addTextChildHelper(&package, QLatin1String("Virtual"), QLatin1String("true")); if (info.checkable) addTextChildHelper(&package, QLatin1String("Checkable"), QLatin1String("true")); + if (info.expandedByDefault) + addTextChildHelper(&package, QLatin1String("ExpandedByDefault"), QLatin1String("true")); root.appendChild(package); } @@ -444,6 +448,7 @@ void LocalPackageHub::PackagesInfoData::addPackageFrom(const QDomElement &packag info.forcedInstallation = false; info.virtualComp = false; info.checkable = false; + info.expandedByDefault = false; for (int i = 0; i < childNodes.count(); i++) { QDomNode childNode = childNodes.item(i); QDomElement childNodeE = childNode.toElement(); @@ -478,6 +483,8 @@ void LocalPackageHub::PackagesInfoData::addPackageFrom(const QDomElement &packag info.installDate = QDate::fromString(childNodeE.text(), Qt::ISODate); else if (childNodeE.tagName() == QLatin1String("Checkable")) info.checkable = childNodeE.text().toLower() == QLatin1String("true") ? true : false; + else if (childNodeE.tagName() == QLatin1String("ExpandedByDefault")) + info.expandedByDefault = childNodeE.text().toLower() == QLatin1String("true") ? true : false; } m_packageInfoMap.insert(info.name, info); } diff --git a/src/libs/kdtools/localpackagehub.h b/src/libs/kdtools/localpackagehub.h index f5c7b7623..7a067e73e 100644 --- a/src/libs/kdtools/localpackagehub.h +++ b/src/libs/kdtools/localpackagehub.h @@ -53,6 +53,7 @@ struct KDTOOLS_EXPORT LocalPackage bool virtualComp; quint64 uncompressedSize; bool checkable; + bool expandedByDefault; }; class KDTOOLS_EXPORT LocalPackageHub @@ -104,7 +105,8 @@ public: bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, - bool checkable); + bool checkable, + bool expandedByDefault); bool removePackage(const QString &pkgName); void refresh(); diff --git a/src/libs/kdtools/updatefinder.cpp b/src/libs/kdtools/updatefinder.cpp index ec1be8a4e..b64f922c3 100644 --- a/src/libs/kdtools/updatefinder.cpp +++ b/src/libs/kdtools/updatefinder.cpp @@ -590,34 +590,62 @@ int KDUpdater::compareVersion(const QString &v1, const QString &v2) if (v1 == v2) return 0; - // Split version numbers across "." - const QStringList v1_comps = v1.split(QRegExp(QLatin1String( "\\.|-"))); - const QStringList v2_comps = v2.split(QRegExp(QLatin1String( "\\.|-"))); + // Split version components across ".", "-" or "_" + QStringList v1_comps = v1.split(QRegExp(QLatin1String( "\\.|-|_"))); + QStringList v2_comps = v2.split(QRegExp(QLatin1String( "\\.|-|_"))); // Check each component of the version int index = 0; while (true) { - if (index == v1_comps.count() && index < v2_comps.count()) - return -1; - if (index < v1_comps.count() && index == v2_comps.count()) - return +1; + bool v1_ok = false; + bool v2_ok = false; + + if (index == v1_comps.count() && index < v2_comps.count()) { + v2_comps.at(index).toInt(&v2_ok); + return v2_ok ? -1 : +1; + } + if (index < v1_comps.count() && index == v2_comps.count()) { + v1_comps.at(index).toInt(&v1_ok); + return v1_ok ? +1 : -1; + } if (index >= v1_comps.count() || index >= v2_comps.count()) break; - bool v1_ok, v2_ok; - int v1_comp = v1_comps[index].toInt(&v1_ok); - int v2_comp = v2_comps[index].toInt(&v2_ok); + int v1_comp = v1_comps.at(index).toInt(&v1_ok); + int v2_comp = v2_comps.at(index).toInt(&v2_ok); if (!v1_ok) { - if (v1_comps[index] == QLatin1String("x")) + if (v1_comps.at(index) == QLatin1String("x")) return 0; } if (!v2_ok) { - if (v2_comps[index] == QLatin1String("x")) + if (v2_comps.at(index) == QLatin1String("x")) return 0; } - if (!v1_ok && !v2_ok) - return v1_comps[index].compare(v2_comps[index]); + if (!v1_ok && !v2_ok) { + // try remove equal start + int i = 0; + while (i < v1_comps.at(index).size() + && i < v2_comps.at(index).size() + && v1_comps.at(index).at(i) == v2_comps.at(index).at(i)) { + ++i; + } + if (i > 0) { + v1_comps[index] = v1_comps.at(index).mid(i); + v2_comps[index] = v2_comps.at(index).mid(i); + // compare again + continue; + } + } + if (!v1_ok || !v2_ok) { + int res = v1_comps.at(index).compare(v2_comps.at(index)); + if (res == 0) { + // v1_comps.at(index) == v2_comps(index) + ++index; + continue; + } + return res > 0 ? +1 : -1; + } if (v1_comp < v2_comp) return -1; |