Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
* Use `nullptr` instead of alternatives
* Fix initialization order of object variables in constructors
  • Loading branch information
RobertKrajewski committed Oct 18, 2020
1 parent 29fc038 commit e9868eb
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion include/autoclosedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AutoCloseDialog : public QDialog
Q_OBJECT

public:
explicit AutoCloseDialog(QWidget *parent = 0);
explicit AutoCloseDialog(QWidget *parent = nullptr);
~AutoCloseDialog();

private:
Expand Down
2 changes: 1 addition & 1 deletion include/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Browser : public QWidget
Q_OBJECT

public:
explicit Browser(QWidget *parent = 0);
explicit Browser(QWidget *parent = nullptr);
~Browser();
void init(Options *options);
void loadSettings();
Expand Down
2 changes: 1 addition & 1 deletion include/filedownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FileDownloader : public QDialog

public:
explicit FileDownloader(int itemNumber,
QWidget *parent= 0);
QWidget *parent= nullptr);
~FileDownloader();
int startNextDownload(QString, QString, QString, QUrl, int, int, int time);

Expand Down
2 changes: 1 addition & 1 deletion include/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Info : public QDialog
Q_OBJECT

public:
explicit Info(QWidget *parent = 0);
explicit Info(QWidget *parent = nullptr);
~Info();

private:
Expand Down
2 changes: 1 addition & 1 deletion include/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Logger : public QWidget
Q_OBJECT

public:
explicit Logger(QWidget *parent = 0);
explicit Logger(QWidget *parent = nullptr);
~Logger();

void saveSettings();
Expand Down
2 changes: 1 addition & 1 deletion include/login.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Login: public QObject
Q_OBJECT

public:
explicit Login(QWidget *parent = 0);
explicit Login(QWidget *parent = nullptr);

bool isRefreshTokenAvailable() { return !refreshToken.isEmpty(); }
void init();
Expand Down
2 changes: 1 addition & 1 deletion include/logindialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LoginDialog : public QDialog
Q_OBJECT

public:
explicit LoginDialog(QWidget *parent = 0);
explicit LoginDialog(QWidget *parent = nullptr);
~LoginDialog();

public slots:
Expand Down
2 changes: 1 addition & 1 deletion include/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class message : public QDialog
Q_OBJECT

public:
explicit message(QWidget *parent = 0);
explicit message(QWidget *parent = nullptr);
~message();

private:
Expand Down
2 changes: 1 addition & 1 deletion include/mymainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MyMainWindow : public QMainWindow
Q_OBJECT

public:
explicit MyMainWindow(QWidget *parent = 0);
explicit MyMainWindow(QWidget *parent = nullptr);
void closeEvent(QCloseEvent * event);

private slots:
Expand Down
2 changes: 1 addition & 1 deletion include/mysortfilterproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MySortFilterProxyModel : public QSortFilterProxyModel
Q_OBJECT

public:
MySortFilterProxyModel(QObject *parent = 0);
MySortFilterProxyModel(QObject *parent = nullptr);

public slots:
QDate filterMinimumDate() const { return minDate; }
Expand Down
2 changes: 1 addition & 1 deletion include/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Options : public QWidget
Q_OBJECT

public:
explicit Options(QWidget *parent = 0);
explicit Options(QWidget *parent = nullptr);
~Options();
void loadSettings();
void saveSettings();
Expand Down
4 changes: 2 additions & 2 deletions include/structureelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum MyItemType
courseItem = 1001,
directoryItem = 1002,
fileItem = 1003,
messageItem = 1004,
messageItem = 1004
};

enum MyItemDataRole
Expand All @@ -48,7 +48,7 @@ enum MyItemDataRole
topicRole = 39,
authorRole = 40,
typeEXRole = 41,
systemEXRole = 42,
systemEXRole = 42
};

enum synchroniseStatus
Expand Down
2 changes: 1 addition & 1 deletion include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Utils : public QObject

static void checkAllFilesIfSynchronised(QList<Structureelement *> items, QString downloadDirectory);
private:
explicit Utils(QObject *parent = 0);
explicit Utils(QObject *parent = nullptr);

};

Expand Down
10 changes: 5 additions & 5 deletions src/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void Browser::on_removeSelectionPushButton_clicked()
// Holen der ausgewählten Dateien
QModelIndexList selectedElementsIndexList = proxy->mapSelectionToSource(ui->dataTreeView->selectionModel()->selection()).indexes();
// Iteration über alle Elemente
Structureelement *parentElement = 0;
Structureelement *parentElement = nullptr;
QModelIndexList::Iterator iteratorEnd = selectedElementsIndexList.end();

for (QModelIndexList::Iterator iterator = selectedElementsIndexList.begin();
Expand All @@ -349,7 +349,7 @@ void Browser::on_removeSelectionPushButton_clicked()

// Hinweis: Nur wenn selectedElement ein Toplevel-Item ist, kann parentElement invisibleRootItem sein
// ist selectedElement ein tieferes Item, ist der oberste Parent 0x00
while ((parentElement != 0) && (parentElement != l2pItemModel->getData()->invisibleRootItem()))
while ((parentElement != nullptr) && (parentElement != l2pItemModel->getData()->invisibleRootItem()))
{
bool siblingsExcluded = true;

Expand Down Expand Up @@ -398,7 +398,7 @@ void Browser::on_addSelectionPushButton_clicked()

// Variablen zur Speicherung von Pointern aus Performancegründen vor
// der Schleife
Structureelement *element = 0;
Structureelement *element = nullptr;
QModelIndexList::Iterator iteratorEnd = selectedElementsIndexList.end();

for (QModelIndexList::Iterator iterator = selectedElementsIndexList.begin();
Expand All @@ -411,7 +411,7 @@ void Browser::on_addSelectionPushButton_clicked()
// Einbinden aller übergeordneter Ordner
Structureelement *parent = element;

while ((parent = (Structureelement *) parent->parent()) != 0)
while ((parent = (Structureelement *) parent->parent()) != nullptr)
{
// Annahme: Wenn ein übergeordnetes Element eingebunden ist, dann sind es auch alle darüber
if (parent->data(includeRole).toBool())
Expand Down Expand Up @@ -593,7 +593,7 @@ void Browser::on_dataTreeView_customContextMenuRequested(const QPoint &pos)

// Überprüfung, ob überhaupt auf ein Element geklickt wurde (oder
// ins Leere)
if (RightClickedItem == 0)
if (RightClickedItem == nullptr)
{
return;
}
Expand Down
7 changes: 3 additions & 4 deletions src/filedownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
#include "qslog/QsLog.h"

FileDownloader::FileDownloader(int itemNumber,
QWidget *parent) :
QWidget *parent) :
QDialog(parent, Qt::FramelessWindowHint),
ui(new Ui::DateiDownloader),
originalModifiedDate(originalModifiedDate),
itemNumber(itemNumber),
manager(new QNetworkAccessManager(this))
manager(new QNetworkAccessManager(this)),
itemNumber(itemNumber)
{
ui->setupUi(this);
ui->retranslateUi(this);
Expand Down
2 changes: 1 addition & 1 deletion src/l2pitemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void L2pItemModel::loadDataFromFile()
void L2pItemModel::saveDataToFile()
{
QDomDocument domDoc;
parseDataToXml(domDoc, data->invisibleRootItem(), NULL);
parseDataToXml(domDoc, data->invisibleRootItem(), nullptr);

#if QT_VERSION >= 0x050400
QString dataPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
Expand Down
2 changes: 1 addition & 1 deletion src/login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define BASEURL QString("https://oauth.campus.rwth-aachen.de/oauth2waitress/oauth2.svc/")

Login::Login(QWidget *parent)
: stopLogin(false), settingsLoaded(false), QObject((QObject*)parent)
: QObject((QObject*)parent), stopLogin(false), settingsLoaded(false)
{
// Automatisch Abbruch des Logins nach 120 Sekunden
stopLoginTimer.setSingleShot(true);
Expand Down
2 changes: 1 addition & 1 deletion src/mymainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


MyMainWindow::MyMainWindow(QWidget *parent):
QMainWindow(parent), ui(new Ui::MyMainWindow), trayIcon(NULL)
QMainWindow(parent), trayIcon(nullptr), ui(new Ui::MyMainWindow)
{
// Sprache installieren
QString locale = QLocale::system().name();
Expand Down
4 changes: 2 additions & 2 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

Options::Options(QWidget *parent) :
QWidget(parent),
login(this),
ui(new Ui::Options)
ui(new Ui::Options),
login(this)
{
ui->setupUi(this);
loginCounter = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ void Parser::parseFiles(QNetworkReply *reply, Structureelement* course)
{
QJsonObject file = element.toObject();
QString filename;
int filesize;
int timestamp;
int filesize = 0;
int timestamp = 0;
QString url;
QStringList urlParts;

Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Structureelement *Utils::getParentCourse(Structureelement *item)
currentItem = dynamic_cast<Structureelement*>(currentItem->parent());
}

return NULL;
return nullptr;
}

QString Utils::getElementLocalPath(Structureelement *item, QString downloadDirectoryPath, bool includeFilname, bool includePrefix)
Expand Down

0 comments on commit e9868eb

Please sign in to comment.