ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/CommonUtils/util.cpp
(Generate patch)

Comparing s10k/CommonUtils/util.cpp (file contents):
Revision 1073 by s10k, Thu Oct 5 17:48:32 2017 UTC vs.
Revision 1109 by s10k, Sat Feb 16 17:23:09 2019 UTC

# Line 1 | Line 1
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.
# Line 68 | Line 68 | bool rmDir(const QString &dirPath)
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;
# Line 180 | Line 180 | QString getAppPath(){
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   }
# Line 260 | Line 265 | const char* boolToCstr(bool currentBoole
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();
# Line 333 | Line 332 | namespace Validation {
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 &current : toCheck){
336          if(current.trimmed().isEmpty()){
337              return true; //There are empty spaces
338          }
# Line 342 | Line 341 | bool checkEmptySpaces(QStringList toChec
341   }
342  
343   bool checkIfIntegers(QStringList toCheck){
344 <    foreach (QString current, toCheck){
344 >    for (const QString &current : toCheck){
345          if(!isStringInteger(current)){
346              return true; // Some aren't valid integers
347          }
# Line 351 | Line 350 | bool checkIfIntegers(QStringList toCheck
350   }
351  
352   bool checkIfDoubles(QStringList toCheck){
353 <    foreach (QString current, toCheck){
353 >    for (const QString &current : toCheck){
354          if(!isStringDouble(current)){
355              return true; // Some aren't valid doubles
356          }
# Line 532 | Line 531 | void deleteSelectedRows(QTableWidget *my
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();
# Line 557 | Line 565 | void showSuccess(QStatusBar * const stat
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

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)