From dbb09cd4fb0dd3bd048af63a7e606e9d6d4aa737 Mon Sep 17 00:00:00 2001 From: aziesemer Date: Mon, 25 Mar 2019 15:04:40 -0400 Subject: [PATCH] Code refactoring to used QT when comparing version --- src/Updater.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Updater.cpp b/src/Updater.cpp index bfd4b91..4d1f7d6 100644 --- a/src/Updater.cpp +++ b/src/Updater.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "Updater.h" #include "Downloader.h" @@ -456,21 +457,5 @@ void Updater::setUpdateAvailable (const bool available) */ bool Updater::compare (const QString& x, const QString& y) { - QStringList versionsX = x.split ("."); - QStringList versionsY = y.split ("."); - - int count = qMin (versionsX.count(), versionsY.count()); - - for (int i = 0; i < count; ++i) { - int a = QString (versionsX.at (i)).toInt(); - int b = QString (versionsY.at (i)).toInt(); - - if (a > b) - return true; - - else if (b > a) - return false; - } - - return versionsY.count() < versionsX.count(); + return QVersionNumber::fromString(x) > QVersionNumber::fromString(y); }