| 1 | 
   | 
 /** | 
 
 
 
 
 
 
 
 
 
 
 
 | 2 | 
 < | 
  * Copyright (C) 2017 - Fábio Bento (random-guy) | 
 
 
 
 
 
 
 
 
 
 | 2 | 
 > | 
  * Copyright (C) 2017 - 2018 Fábio Bento (fabiobento512) | 
 
 
 
 
 
 
 
 
 
 
 
 | 3 | 
   | 
  * | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 4 | 
   | 
  * This library is distributed under the MIT License. See notice at the end | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 | 
   | 
  * of this file. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 68 | 
   | 
     QDir dir(dirPath); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 69 | 
   | 
     if (!dir.exists()) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 70 | 
   | 
         return true; | 
 
 
 
 
 
 
 
 
 
 
 
 | 71 | 
 < | 
     foreach(const QFileInfo &info, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { | 
 
 
 
 
 
 
 
 
 
 | 71 | 
 > | 
     for(const QFileInfo &info : dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { | 
 
 
 
 
 
 
 
 
 
 
 
 | 72 | 
   | 
         if (info.isDir()) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 | 
   | 
             if (!rmDir(info.filePath())) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 | 
   | 
                 return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 180 | 
   | 
 #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 181 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 182 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 183 | 
 < | 
 bool backupFile(QString file){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 184 | 
 < | 
     return QFile::copy(file,file+".bak"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 183 | 
 > | 
 bool backupFile(const QString &file, QString newFilename){ | 
 
 
 
 
 
 | 184 | 
 > | 
          | 
 
 
 
 
 
 | 185 | 
 > | 
         if(newFilename.isEmpty()){ | 
 
 
 
 
 
 | 186 | 
 > | 
                 newFilename = file; | 
 
 
 
 
 
 | 187 | 
 > | 
         } | 
 
 
 
 
 
 | 188 | 
 > | 
          | 
 
 
 
 
 
 | 189 | 
 > | 
     return QFile::copy(file, newFilename+".bak"); | 
 
 
 
 
 
 
 
 
 
 
 
 | 190 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 191 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 192 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 265 | 
   | 
 #ifdef QT_GUI_LIB | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 266 | 
   | 
 namespace Dialogs { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 267 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 268 | 
 < | 
 void showInfo(const QString &message){ | 
 
 
 
 
 
 
 
 
 
 | 268 | 
 > | 
 void showInfo(const QString &message, const bool richText){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 269 | 
   | 
     QMessageBox msgBox; | 
 
 
 
 
 
 
 
 
 | 270 | 
 + | 
         if(richText){ | 
 
 
 
 
 
 
 
 
 | 271 | 
 + | 
                 msgBox.setTextFormat(Qt::RichText); | 
 
 
 
 
 
 
 
 
 | 272 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 273 | 
   | 
     msgBox.setIcon(QMessageBox::Information); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 274 | 
   | 
     msgBox.setText(message); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 275 | 
   | 
     msgBox.exec(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 276 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 277 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 278 | 
 < | 
 void showRichInfo(const QString &message){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 271 | 
 < | 
     QMessageBox msgBox; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 272 | 
 < | 
     msgBox.setTextFormat(Qt::RichText); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 273 | 
 < | 
     msgBox.setIcon(QMessageBox::Information); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 274 | 
 < | 
     msgBox.setText(message); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 275 | 
 < | 
     msgBox.exec(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 276 | 
 < | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 277 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 278 | 
 < | 
 void showWarning(const QString &message){ | 
 
 
 
 
 
 
 
 
 
 | 278 | 
 > | 
 void showWarning(const QString &message, const bool richText){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 279 | 
   | 
     QMessageBox msgBox; | 
 
 
 
 
 
 
 
 
 | 280 | 
 + | 
         if(richText){ | 
 
 
 
 
 
 
 
 
 | 281 | 
 + | 
                 msgBox.setTextFormat(Qt::RichText); | 
 
 
 
 
 
 
 
 
 | 282 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 283 | 
   | 
     msgBox.setIcon(QMessageBox::Warning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 284 | 
   | 
     msgBox.setText(message); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 285 | 
   | 
     msgBox.exec(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 286 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 287 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 288 | 
 < | 
 void showError(const QString &message){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 286 | 
 < | 
     QMessageBox msgBox; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 287 | 
 < | 
     msgBox.setIcon(QMessageBox::Critical); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 288 | 
 < | 
     msgBox.setText(message); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 289 | 
 < | 
     msgBox.exec(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 290 | 
 < | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 291 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 292 | 
 < | 
 void showRichError(const QString &message){ | 
 
 
 
 
 
 
 
 
 
 | 288 | 
 > | 
 void showError(const QString &message, const bool richText){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 289 | 
   | 
     QMessageBox msgBox; | 
 
 
 
 
 
 
 
 
 | 290 | 
 + | 
         if(richText){ | 
 
 
 
 
 
 
 
 
 | 291 | 
 + | 
                 msgBox.setTextFormat(Qt::RichText); | 
 
 
 
 
 
 
 
 
 | 292 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 293 | 
   | 
     msgBox.setIcon(QMessageBox::Critical); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 294 | 
   | 
     msgBox.setText(message); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 295 | 
   | 
     msgBox.exec(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 332 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 333 | 
   | 
 // Check if any string in the list is empty | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 334 | 
   | 
 bool checkEmptySpaces(QStringList toCheck){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 335 | 
 < | 
     foreach (QString current, toCheck){ | 
 
 
 
 
 
 
 
 
 
 | 335 | 
 > | 
     for (const QString ¤t : toCheck){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 336 | 
   | 
         if(current.trimmed().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 337 | 
   | 
             return true; //There are empty spaces | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 338 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 341 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 342 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 343 | 
   | 
 bool checkIfIntegers(QStringList toCheck){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 344 | 
 < | 
     foreach (QString current, toCheck){ | 
 
 
 
 
 
 
 
 
 
 | 344 | 
 > | 
     for (const QString ¤t : toCheck){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 345 | 
   | 
         if(!isStringInteger(current)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 346 | 
   | 
             return true; // Some aren't valid integers | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 347 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 350 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 351 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 352 | 
   | 
 bool checkIfDoubles(QStringList toCheck){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 353 | 
 < | 
     foreach (QString current, toCheck){ | 
 
 
 
 
 
 
 
 
 
 | 353 | 
 > | 
     for (const QString ¤t : toCheck){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 354 | 
   | 
         if(!isStringDouble(current)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 355 | 
   | 
             return true; // Some aren't valid doubles | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 356 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 531 | 
   | 
 #ifdef QT_GUI_LIB | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 532 | 
   | 
 namespace StatusBar { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 533 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 534 | 
 + | 
 void showInfo(QStatusBar * const statusBar, const QString &message){ | 
 
 
 
 
 
 
 
 
 | 535 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 536 | 
 + | 
     QPalette myPalete = QPalette(); | 
 
 
 
 
 
 
 
 
 | 537 | 
 + | 
     myPalete.setColor( QPalette::WindowText, QColor(0,38,255)); | 
 
 
 
 
 
 
 
 
 | 538 | 
 + | 
     statusBar->setPalette( myPalete ); | 
 
 
 
 
 
 
 
 
 | 539 | 
 + | 
     statusBar->showMessage(message,10000); //display by 10 seconds | 
 
 
 
 
 
 
 
 
 | 540 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 541 | 
 + | 
 } | 
 
 
 
 
 
 
 
 
 | 542 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 543 | 
   | 
 void showError(QStatusBar * const statusBar, const QString &message){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 544 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 545 | 
   | 
     QPalette myPalete = QPalette(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 565 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 566 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 567 | 
   | 
 /** | 
 
 
 
 
 
 
 
 
 
 
 
 | 568 | 
 < | 
  * Copyright (c) 2017 - Fábio Bento (random-guy) | 
 
 
 
 
 
 
 
 
 
 | 568 | 
 > | 
  * Copyright (c) 2017 - 2018 Fábio Bento (fabiobento512) | 
 
 
 
 
 
 
 
 
 
 
 
 | 569 | 
   | 
  * | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 570 | 
   | 
  * Permission is hereby granted, free of charge, to any person | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 571 | 
   | 
  * obtaining a copy of this software and associated documentation |