File indexing completed on 2024-09-08 09:41:01
0001 /* 0002 SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "private/packagejobthread_p.h" 0008 0009 #include "package.h" 0010 0011 #include <QVector> 0012 0013 namespace KPackage 0014 { 0015 bool isVersionNewer(const QString &version1, const QString &version2) 0016 { 0017 if (version1 == version2) { 0018 return false; 0019 } 0020 0021 const auto versionChunks = QVector<QString>::fromList(version2.split(QLatin1Char('.'))); 0022 const auto oldVersionChunks = QVector<QString>::fromList(version1.split(QLatin1Char('.'))); 0023 const int length = qMin(versionChunks.size(), oldVersionChunks.size()); 0024 0025 for (int i = 0; i < length; ++i) { 0026 if (versionChunks[i] != oldVersionChunks[i]) { 0027 return versionChunks[i] > oldVersionChunks[i]; 0028 } 0029 } 0030 0031 return versionChunks.size() > oldVersionChunks.size(); 0032 } 0033 0034 } // namespace KPackage