Skip to content

Commit

Permalink
Fix build issues on older versions of Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
SverrirValgeirsson committed Apr 1, 2021
1 parent 3ca673e commit 16fa5ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* Fixed a bug where the check for new version would basically always find a new version
* Fixed bug introduced in 2.20 with automatically adding due: or t: when using rec:
* Fixed building issues for older versions of Qt5


New in 2.20
Expand Down
10 changes: 10 additions & 0 deletions def.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#ifndef DEF_H
#define DEF_H

/* Workaround for the Qt::endl not existing before 5.14.something */
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#define endline endl
#else
#define endline Qt::endl
#endif



// Defaults and definitions for settings
#define DEFAULT_HOTKEY "Ctrl+Alt+t"
#define DEFAULT_HOTKEY_ENABLE false
Expand Down
6 changes: 3 additions & 3 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MainWindow::MainWindow(QWidget *parent) :
if(QCoreApplication::arguments().contains("-portable")){
QSettings::setDefaultFormat(QSettings::IniFormat);
QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,QDir::currentPath());
qDebug()<<"Setting ini file path to: "<<QDir::currentPath()<<Qt::endl;
qDebug()<<"Setting ini file path to: "<<QDir::currentPath()<<endline;
}

hotkey = new UGlobalHotkeys();
Expand Down Expand Up @@ -161,7 +161,7 @@ MainWindow::MainWindow(QWidget *parent) :
QDate lastCheck = QDate::fromString(last_check,"yyyy-MM-dd");
QDate nextCheck = lastCheck.addDays(7);

qDebug()<<"Last update check date: "<<last_check<<" and next is "<<nextCheck.toString("yyyy-MM-dd")<<Qt::endl;
qDebug()<<"Last update check date: "<<last_check<<" and next is "<<nextCheck.toString("yyyy-MM-dd")<<endline;
int daysToNextcheck = QDate::currentDate().daysTo(nextCheck);
if(daysToNextcheck<0){
QString URL = VERSION_URL;
Expand Down Expand Up @@ -612,7 +612,7 @@ void MainWindow::requestReceived(QNetworkReply* reply){
replyText = reply->readAll();
double latest_version = replyText.toDouble();
double this_version = QString(VER).toDouble();
qDebug()<<"Checked version - Latest: "<<latest_version<<" this version "<<this_version<<Qt::endl;
qDebug()<<"Checked version - Latest: "<<latest_version<<" this version "<<this_version<<endline;
if(latest_version>this_version || forced_check_version){
if(latest_version > this_version){
ui->lbl_newVersion->show();
Expand Down
22 changes: 11 additions & 11 deletions todotxt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ todotxt::todotxt()

undoDir = new QTemporaryDir();
if(!undoDir->isValid()){
qDebug()<<"Could not create undo dir"<<Qt::endl;
qDebug()<<"Could not create undo dir"<<endline;
} else {
qDebug()<<"Created undo dir at "<<undoDir->path()<<Qt::endl;
qDebug()<<"Created undo dir at "<<undoDir->path()<<endline;
}
}

Expand Down Expand Up @@ -312,8 +312,8 @@ QString todotxt::getRelativeDate(QString shortform,QDate d){


void todotxt::restoreFiles(QString namePrefix){
qDebug()<<"Restoring: "<<namePrefix<<Qt::endl;
qDebug()<<"Pointer: "<<undoPointer<<Qt::endl;
qDebug()<<"Restoring: "<<namePrefix<<endline;
qDebug()<<"Pointer: "<<undoPointer<<endline;
// Copy back files from the undo
QString newtodo = namePrefix+TODOFILE;
QString newdone = namePrefix+DONEFILE;
Expand Down Expand Up @@ -413,14 +413,14 @@ void todotxt::cleanupUndoDir()
QStringList files = directory.entryList(QDir::Files);
QDateTime expirationTime = QDateTime::currentDateTime();
expirationTime = expirationTime.addDays(-14);
qDebug()<<"Checking for undo files to cleanup..."<<Qt::endl;
qDebug()<<"Checking for undo files to cleanup..."<<endline;
foreach(QString filename, files) {
auto finfo = QFileInfo(directory.filePath(filename));
QDateTime created = finfo.birthTime();
if(expirationTime.daysTo(created)<0 || !created.isValid()){
//qDebug()<<"We should remove file (but wont now)"<<filename<<Qt::endl;
//qDebug()<<"We should remove file (but wont now)"<<filename<<endline;
if(!QFile::remove(directory.filePath(filename))){
qDebug()<<"Failed to remove: "<<filename<<Qt::endl;
qDebug()<<"Failed to remove: "<<filename<<endline;
}
}
}
Expand All @@ -441,14 +441,14 @@ bool todotxt::checkNeedForUndo(){
slurp(todofile,todo);
slurp(undofile,lastUndo);
if(todo.size()!=lastUndo.size()){
qDebug()<<"Sizes differ: "<<todofile<<" vs "<<undofile<<Qt::endl;
qDebug()<<"Sizes differ: "<<todofile<<" vs "<<undofile<<endline;
return true;
}

// We got this far, we have to go trhough the files line by line
for(int i=0;i<(int) todo.size();i++){
if(todo[i] != lastUndo[i]){
qDebug()<<todo[i]<<" != "<<lastUndo[i]<<Qt::endl;
qDebug()<<todo[i]<<" != "<<lastUndo[i]<<endline;
return true;
}
}
Expand Down Expand Up @@ -480,8 +480,8 @@ void todotxt::saveToUndo()
QFile::copy(getDeletedFilePath(),newdeleted);

undoBuffer.push_back(namePrefix);
qDebug()<<"Added to undoBuffer: "<<namePrefix<<Qt::endl;
qDebug()<<"Buffer is now: "<<undoBuffer.size()<<Qt::endl;
qDebug()<<"Added to undoBuffer: "<<namePrefix<<endline;
qDebug()<<"Buffer is now: "<<undoBuffer.size()<<endline;
}

}
Expand Down

0 comments on commit 16fa5ea

Please sign in to comment.