Changeset 1095 for s10k


Ignore:
Timestamp:
Dec 30, 2017, 3:30:28 PM (7 years ago)
Author:
s10k
Message:

Small code refactoring

Location:
s10k/CommonUtils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • s10k/CommonUtils/util.cpp

    r1073 r1095  
    6969    if (!dir.exists())
    7070        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)) {
    7272        if (info.isDir()) {
    7373            if (!rmDir(info.filePath()))
     
    181181}
    182182
    183 bool backupFile(QString file){
    184     return QFile::copy(file,file+".bak");
     183bool backupFile(const QString &file, QString newFilename){
     184       
     185        if(newFilename.isEmpty()){
     186                newFilename = file;
     187        }
     188       
     189    return QFile::copy(file, newFilename+".bak");
    185190}
    186191
     
    334339// Check if any string in the list is empty
    335340bool checkEmptySpaces(QStringList toCheck){
    336     foreach (QString current, toCheck){
     341    for (const QString &current : toCheck){
    337342        if(current.trimmed().isEmpty()){
    338343            return true; //There are empty spaces
     
    343348
    344349bool checkIfIntegers(QStringList toCheck){
    345     foreach (QString current, toCheck){
     350    for (const QString &current : toCheck){
    346351        if(!isStringInteger(current)){
    347352            return true; // Some aren't valid integers
     
    352357
    353358bool checkIfDoubles(QStringList toCheck){
    354     foreach (QString current, toCheck){
     359    for (const QString &current : toCheck){
    355360        if(!isStringDouble(current)){
    356361            return true; // Some aren't valid doubles
  • s10k/CommonUtils/util.h

    r1073 r1095  
    6565QString getAppPath();
    6666
    67 bool backupFile(QString file);
     67bool backupFile(const QString &file, QString newFilename="");
    6868
    6969}
Note: See TracChangeset for help on using the changeset viewer.