summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/rbutilqt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/rbutilqt.cpp')
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp62
1 files changed, 8 insertions, 54 deletions
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 274efb46af..98c1024f60 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -1269,6 +1269,7 @@ void RbUtilQt::checkUpdate(void)
1269 if(RbSettings::value(RbSettings::CacheOffline).toBool()) 1269 if(RbSettings::value(RbSettings::CacheOffline).toBool())
1270 update->setCache(true); 1270 update->setCache(true);
1271 1271
1272 ui.statusbar->showMessage(tr("Checking for update ..."));
1272 update->getFile(QUrl(url)); 1273 update->getFile(QUrl(url));
1273} 1274}
1274 1275
@@ -1290,7 +1291,7 @@ void RbUtilQt::downloadUpdateDone(bool error)
1290 } 1291 }
1291 qDebug() << "[Checkupdate] " << rbutilList; 1292 qDebug() << "[Checkupdate] " << rbutilList;
1292 1293
1293 QString newVersion =""; 1294 QString newVersion = "";
1294 //check if there is a binary with higher version in this list 1295 //check if there is a binary with higher version in this list
1295 for(int i=0; i < rbutilList.size(); i++) 1296 for(int i=0; i < rbutilList.size(); i++)
1296 { 1297 {
@@ -1306,9 +1307,9 @@ void RbUtilQt::downloadUpdateDone(bool error)
1306#endif 1307#endif
1307#endif 1308#endif
1308 //check if it is newer, and remember newest 1309 //check if it is newer, and remember newest
1309 if(newerVersion(VERSION,rbutilList.at(i))) 1310 if(Utils::compareVersionStrings(VERSION, rbutilList.at(i)) == 1)
1310 { 1311 {
1311 if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i))) 1312 if(Utils::compareVersionStrings(newVersion, rbutilList.at(i)) == 1)
1312 { 1313 {
1313 newVersion = rbutilList.at(i); 1314 newVersion = rbutilList.at(i);
1314 } 1315 }
@@ -1331,58 +1332,11 @@ void RbUtilQt::downloadUpdateDone(bool error)
1331 QMessageBox::information(this,tr("RockboxUtility Update available"), 1332 QMessageBox::information(this,tr("RockboxUtility Update available"),
1332 tr("<b>New RockboxUtility Version available.</b> <br><br>" 1333 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1333 "Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) ); 1334 "Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) );
1335 ui.statusbar->showMessage(tr("New version of Rockbox Utility available."));
1336 }
1337 else {
1338 ui.statusbar->showMessage(tr("Rockbox Utility is up to date."), 5000);
1334 } 1339 }
1335 } 1340 }
1336} 1341}
1337 1342
1338bool RbUtilQt::newerVersion(QString versionOld,QString versionNew)
1339{
1340 QRegExp chars("\\d*(\\D)");
1341
1342 //strip non-number from beginning
1343 versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d")));
1344 versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d")));
1345
1346 // split versions by "."
1347 QStringList versionListOld = versionOld.split(".");
1348 QStringList versionListNew = versionNew.split(".");
1349
1350 QStringListIterator iteratorOld(versionListOld);
1351 QStringListIterator iteratorNew(versionListNew);
1352
1353 //check every section
1354 while(iteratorOld.hasNext() && iteratorNew.hasNext())
1355 {
1356 QString newPart = iteratorNew.next();
1357 QString oldPart = iteratorOld.next();
1358 QString newPartChar = "", oldPartChar = "";
1359 int newPartInt = 0, oldPartInt =0;
1360
1361 //convert to int, if it contains chars, put into seperated variable
1362 if(newPart.contains(chars))
1363 {
1364 newPartChar = chars.cap(1);
1365 newPart = newPart.remove(newPartChar);
1366 }
1367 newPartInt = newPart.toInt();
1368 //convert to int, if it contains chars, put into seperated variable
1369 if(oldPart.contains(chars))
1370 {
1371 oldPartChar = chars.cap(1);
1372 oldPart = oldPart.remove(oldPartChar);
1373 }
1374 oldPartInt = oldPart.toInt();
1375
1376 if(newPartInt > oldPartInt) // this section int is higher -> true
1377 return true;
1378 else if(newPartInt < oldPartInt) //this section int is lower -> false
1379 return false;
1380 else if(newPartChar > oldPartChar) //ints are the same, chars is higher -> true
1381 return true;
1382 else if(newPartChar < oldPartChar) //ints are the same, chars is lower -> false
1383 return false;
1384 //all the same, next section
1385 }
1386 // all the same -> false
1387 return false;
1388}