Skip to content

Commit 74734ea

Browse files
committed
Use nullptr instead of NULL or 0
1 parent 78e6b5f commit 74734ea

32 files changed

+190
-190
lines changed

src/club.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const int COLUMN_COUNT = 3;
3939

4040
// ### Club ###
4141

42-
Club::Club(const QString& _name) : name(_name), country(NULL), province(NULL)
42+
Club::Club(const QString& _name) : name(_name), country(nullptr), province(nullptr)
4343
{
4444
}
4545
Club::~Club()
@@ -117,8 +117,8 @@ bool ClubDB::loadFromFile()
117117
if (stream.name() == "Club")
118118
{
119119
Club* new_club = new Club(stream.attributes().value("name").toString());
120-
Location* country = NULL;
121-
Location* province = NULL;
120+
Location* country = nullptr;
121+
Location* province = nullptr;
122122

123123
QStringRef ref = stream.attributes().value("country");
124124
if (!ref.isEmpty())
@@ -165,7 +165,7 @@ Club* ClubDB::getByID(int id)
165165

166166
std::map<int, Club*>::iterator id_it = id_map.find(id);
167167
if (id_it == id_map.end())
168-
return NULL;
168+
return nullptr;
169169
else
170170
return id_it->second;
171171
}
@@ -190,7 +190,7 @@ Club* ClubDB::findClub(const QString& name)
190190
return clubs[i];
191191
}
192192

193-
return NULL;
193+
return nullptr;
194194
}
195195
void ClubDB::findSimilarClubs(QString name, std::vector< Club* >& out)
196196
{
@@ -210,7 +210,7 @@ Club* ClubDB::findClubAt(Location* location, Club* exclude)
210210
return clubs[i];
211211
}
212212

213-
return NULL;
213+
return nullptr;
214214
}
215215
QString ClubDB::getUnusedName(const QString& desiredName)
216216
{
@@ -230,7 +230,7 @@ QString ClubDB::getUnusedName(const QString& desiredName)
230230

231231
void ClubDB::addClub(Club* club, bool setNewID)
232232
{
233-
assert(findClub(club->getName()) == NULL && "Tried to add a club whose name is already used by another club!");
233+
assert(findClub(club->getName()) == nullptr && "Tried to add a club whose name is already used by another club!");
234234

235235
int row = static_cast<int>(clubs.size());
236236
int count = 1;
@@ -271,7 +271,7 @@ Club* ClubDB::getItem(const QModelIndex& index) const
271271
return item;
272272
}
273273

274-
return NULL;
274+
return nullptr;
275275
}
276276

277277
int ClubDB::rowCount(const QModelIndex& parent) const
@@ -395,7 +395,7 @@ ClubTable::ClubTable()
395395
}
396396
ClubTable::~ClubTable()
397397
{
398-
setModel(NULL);
398+
setModel(nullptr);
399399
delete sortedModel;
400400
}
401401

src/club.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ Q_OBJECT
7171
void mergeClubs(Club* src, Club* dest);
7272

7373
Club* getItem(const QModelIndex &index) const;
74-
bool containsName(const QString& name, Club* exclude = NULL);
74+
bool containsName(const QString& name, Club* exclude = nullptr);
7575
Club* findClub(const QString& name);
76-
Club* findClubAt(Location* location, Club* exclude = NULL);
76+
Club* findClubAt(Location* location, Club* exclude = nullptr);
7777
void findSimilarClubs(QString name, std::vector<Club*>& out);
7878
inline void clubChanged(QModelIndex index)
7979
{

src/clubDialog.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ ClubDialog::ClubDialog(Club* _club, QWidget* parent) : QDialog(parent, Qt::Windo
7777
nameEdit->setText(club->getName());
7878
nameEdit->selectAll();
7979
setLocationText();
80-
if (club->getProvince() != NULL)
80+
if (club->getProvince() != nullptr)
8181
selectLocation(club->getProvince());
82-
else if (club->getCountry() != NULL)
82+
else if (club->getCountry() != nullptr)
8383
selectLocation(club->getCountry());
8484

8585
updateActions();
@@ -134,7 +134,7 @@ void ClubDialog::setLocationText()
134134

135135
if (club->getProvince())
136136
{
137-
assert((club->getCountry() != NULL) && "Province set for a club, but no country!");
137+
assert((club->getCountry() != nullptr) && "Province set for a club, but no country!");
138138
text += club->getProvince()->getName() + ", " + club->getCountry()->getName() + "</b>";
139139
}
140140
else if (club->getCountry())
@@ -150,9 +150,9 @@ void ClubDialog::locationSelected()
150150

151151
QModelIndex index = locationView->selectionModel()->currentIndex();
152152
if (!index.isValid())
153-
club->setLocation(NULL, NULL);
153+
club->setLocation(nullptr, nullptr);
154154
else if (index.parent() == QModelIndex())
155-
club->setLocation(locationDB.getItem(locationDB.getSortModel()->mapToSource(index)), NULL);
155+
club->setLocation(locationDB.getItem(locationDB.getSortModel()->mapToSource(index)), nullptr);
156156
else
157157
club->setLocation(locationDB.getItem(locationDB.getSortModel()->mapToSource(index.parent())), locationDB.getItem(locationDB.getSortModel()->mapToSource(index)));
158158

@@ -245,7 +245,7 @@ void ClubDialog::removeLocationClicked()
245245
QAbstractItemModel* model = locationView->model();
246246
Location* index_location = locationDB.getItem(locationDB.getSortModel()->mapToSource(index));
247247

248-
if (clubDB.findClubAt(index_location, club) != NULL)
248+
if (clubDB.findClubAt(index_location, club) != nullptr)
249249
{
250250
QMessageBox::warning(this, APP_NAME, tr("The location %1 you want to delete is still referenced by at least one club. You must delete the references first!").arg(index_location->getName()));
251251
return;
@@ -254,7 +254,7 @@ void ClubDialog::removeLocationClicked()
254254
for (int i = 0; i < num_children; ++i)
255255
{
256256
Location* sub_location = index_location->getChild(i);
257-
if (clubDB.findClubAt(sub_location, club) != NULL)
257+
if (clubDB.findClubAt(sub_location, club) != nullptr)
258258
{
259259
QMessageBox::warning(this, APP_NAME, tr("The sub-location %1 you want to delete is still referenced by at least one club. You must delete the references first!").arg(sub_location->getName()));
260260
return;

src/clubDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ClubDialog : public QDialog
3737
Q_OBJECT
3838
public:
3939

40-
ClubDialog(Club* _club, QWidget* parent = NULL);
40+
ClubDialog(Club* _club, QWidget* parent = nullptr);
4141
~ClubDialog();
4242

4343
// Overridden methods

src/comboBoxDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ComboBoxDelegate : public QItemDelegate
2828
Q_OBJECT
2929
public:
3030

31-
ComboBoxDelegate(QAbstractItemModel* _model, int _model_column, QObject *parent = 0);
31+
ComboBoxDelegate(QAbstractItemModel* _model, int _model_column, QObject* parent = nullptr);
3232

3333
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
3434
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;

src/csvFile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
CSVFile::CSVFile(const QString& path, const QChar _separator, const QChar _stringDelimiter, bool escape_minus)
3131
{
32-
stream = NULL;
32+
stream = nullptr;
3333
file = new QFile(path);
3434

3535
error = NoError;
@@ -39,8 +39,8 @@ CSVFile::CSVFile(const QString& path, const QChar _separator, const QChar _strin
3939
}
4040
CSVFile::CSVFile(QString* string, const QChar _separator, const QChar _stringDelimiter, bool escape_minus)
4141
{
42-
stream = NULL;
43-
file = NULL;
42+
stream = nullptr;
43+
file = nullptr;
4444
this->string = string;
4545

4646
error = NoError;
@@ -141,7 +141,7 @@ std::vector< int >* CSVFile::getColumnVector(const QString& name)
141141
{
142142
ColumnMap::iterator it = columnMap.find(name);
143143
if (it == columnMap.end())
144-
return NULL;
144+
return nullptr;
145145
else
146146
return &it->second;
147147
}

src/csvFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CSVFile
5454
~CSVFile();
5555

5656
/// Shows a dialog with options for separator and delimiter characters and escaping of -
57-
bool showExportDialog(QWidget* parent = NULL);
57+
bool showExportDialog(QWidget* parent = nullptr);
5858

5959
/// Opens the file and reads the first line (the column names) if the file is opened for reading
6060
bool open(bool for_reading);

src/event.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
Event::Event()
2929
{
30-
resultList = NULL;
30+
resultList = nullptr;
3131
}
3232
Event::~Event()
3333
{
@@ -67,7 +67,7 @@ Category* Event::findCategory(const QString& name)
6767
if (categories[i]->name.compare(name, Qt::CaseSensitive) == 0)
6868
return categories[i];
6969
}
70-
return NULL;
70+
return nullptr;
7171
}
7272
int Event::getNumCategories()
7373
{

src/layout.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Layout::Layout(const QString& filename) : filename(filename)
3131
// set defaults
3232
has_background_color = false;
3333
background_color = Qt::white;
34-
background_image = NULL;
35-
background_image_cache = NULL;
34+
background_image = nullptr;
35+
background_image_cache = nullptr;
3636
owns_background_image = false;
3737
aspect = 4 / 3.0f;
3838
}
@@ -42,7 +42,7 @@ Layout::Layout(const Layout& other)
4242
has_background_color = other.has_background_color;
4343
background_color = other.background_color;
4444
background_image = other.background_image;
45-
background_image_cache = NULL;
45+
background_image_cache = nullptr;
4646
owns_background_image = false;
4747

4848
for (std::map<QString, Rect*>::const_iterator it = other.rects.begin(); it != other.rects.end(); ++it)
@@ -71,12 +71,12 @@ Layout::~Layout()
7171
Layout::Point* Layout::getPointByID(const QString& id)
7272
{
7373
std::map<QString, Point*>::iterator it = points.find(id);
74-
return (it == points.end()) ? NULL : it->second;
74+
return (it == points.end()) ? nullptr : it->second;
7575
}
7676
Layout::Rect* Layout::getRectByID(const QString& id)
7777
{
7878
std::map<QString, Rect*>::iterator it = rects.find(id);
79-
return (it == rects.end()) ? NULL : it->second;
79+
return (it == rects.end()) ? nullptr : it->second;
8080
}
8181

8282
QFont Layout::qFontFromFont(Layout::Font* font_data, int display_height)
@@ -156,7 +156,7 @@ bool Layout::loadFromFile()
156156
QFile file("my layouts/" + filename + ".xml");
157157
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
158158
{
159-
QMessageBox::warning(NULL, tr("Error"), tr("Could not load layout: %1 because the file could not be opened!").arg(filename));
159+
QMessageBox::warning(nullptr, tr("Error"), tr("Could not load layout: %1 because the file could not be opened!").arg(filename));
160160
return false;
161161
}
162162

@@ -296,8 +296,8 @@ Layout::Font* Layout::getFont(const QString& name)
296296
std::map<QString, Font*>::iterator it = fonts.find(name);
297297
if (it == fonts.end())
298298
{
299-
QMessageBox::warning(NULL, tr("Error while loading layout"), tr("Cannot find font %1!").arg(name));
300-
return NULL;
299+
QMessageBox::warning(nullptr, tr("Error while loading layout"), tr("Cannot find font %1!").arg(name));
300+
return nullptr;
301301
}
302302

303303
return it->second;
@@ -321,15 +321,15 @@ LayoutDB::LayoutDB()
321321
QStringList myLayouts = dir.entryList(nameFilters, QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDir::Name);
322322

323323
for (int i = 0; i < myLayouts.size(); ++i)
324-
layouts.insert(myLayouts.at(i).left(myLayouts.at(i).size() - 4), NULL);
324+
layouts.insert(myLayouts.at(i).left(myLayouts.at(i).size() - 4), nullptr);
325325

326326
// TODO: dir watcher
327327
}
328328
Layout* LayoutDB::getOrLoadLayout(const QString& name, QWidget* dialogParent)
329329
{
330330
Layouts::iterator it = layouts.find(name);
331331
if (it == layouts.end())
332-
return NULL;
332+
return nullptr;
333333

334334
if (*it)
335335
return *it;
@@ -339,7 +339,7 @@ Layout* LayoutDB::getOrLoadLayout(const QString& name, QWidget* dialogParent)
339339
if (!loadedLayout->loadFromFile())
340340
{
341341
delete loadedLayout;
342-
return NULL;
342+
return nullptr;
343343
}
344344
layouts.insert(name, loadedLayout);
345345

src/layout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class LayoutDB
106106
typedef QMap<QString, Layout*> Layouts;
107107

108108
/// Returns the layout with the given name; loads it if it is not loaded yet.
109-
/// Returns NULL if there was an error loading it.
109+
/// Returns nullptr if there was an error loading it.
110110
Layout* getOrLoadLayout(const QString& name, QWidget* dialogParent);
111111

112112
inline Layouts::iterator begin() {return layouts.begin();}
@@ -124,7 +124,7 @@ class LayoutDB
124124

125125
LayoutDB();
126126

127-
/// The value can be NULL if the layout is not loaded yet
127+
/// The value can be nullptr if the layout is not loaded yet
128128
Layouts layouts;
129129
};
130130

0 commit comments

Comments
 (0)