Const'ify, use nullptr

This commit is contained in:
Laurent Montel 2017-12-25 18:41:50 +01:00
parent f78eee320c
commit d1949d9149
14 changed files with 28 additions and 30 deletions

View File

@ -127,7 +127,7 @@ void Calendar::setDays(int days)
} }
} }
int Calendar::weeks() int Calendar::weeks() const
{ {
return m_weeks; return m_weeks;
} }
@ -141,7 +141,7 @@ void Calendar::setWeeks(int weeks)
} }
} }
int Calendar::firstDayOfWeek() int Calendar::firstDayOfWeek() const
{ {
// QML has Sunday as 0, so we need to accomodate here // QML has Sunday as 0, so we need to accomodate here
return m_firstDayOfWeek == 7 ? 0 : m_firstDayOfWeek; return m_firstDayOfWeek == 7 ? 0 : m_firstDayOfWeek;

View File

@ -156,11 +156,11 @@ public:
void setDays(int days); void setDays(int days);
// Weeks // Weeks
int weeks(); int weeks() const;
void setWeeks(int weeks); void setWeeks(int weeks);
// Start day // Start day
int firstDayOfWeek(); int firstDayOfWeek() const;
void setFirstDayOfWeek(int day); void setFirstDayOfWeek(int day);
// Error message // Error message

View File

@ -29,7 +29,7 @@
DaysModel::DaysModel(QObject *parent) : DaysModel::DaysModel(QObject *parent) :
QAbstractListModel(parent), QAbstractListModel(parent),
m_pluginsManager(0), m_pluginsManager(nullptr),
m_lastRequestedEventsStartDate(QDate()), m_lastRequestedEventsStartDate(QDate()),
m_agendaNeedsUpdate(false) m_agendaNeedsUpdate(false)
{ {

View File

@ -70,8 +70,8 @@ private Q_SLOTS:
private: private:
QModelIndex indexForDate(const QDate &date); QModelIndex indexForDate(const QDate &date);
EventPluginsManager *m_pluginsManager; EventPluginsManager *m_pluginsManager = nullptr;
QList<DayData> *m_data; QList<DayData> *m_data = nullptr;
QList<QObject*> m_qmlData; QList<QObject*> m_qmlData;
QDate m_lastRequestedAgendaDate; QDate m_lastRequestedAgendaDate;
QList<CalendarEvents::CalendarEventsPlugin*> m_eventPlugins; QList<CalendarEvents::CalendarEventsPlugin*> m_eventPlugins;

View File

@ -67,7 +67,7 @@ private:
void loadPlugin(const QString &absolutePath); void loadPlugin(const QString &absolutePath);
friend class EventPluginsModel; friend class EventPluginsModel;
EventPluginsModel *m_model; EventPluginsModel *m_model = nullptr;
QList<CalendarEvents::CalendarEventsPlugin*> m_plugins; QList<CalendarEvents::CalendarEventsPlugin*> m_plugins;
struct PluginData { struct PluginData {
QString name; QString name;

View File

@ -94,7 +94,7 @@ void ColorScope::setParentScope(ColorScope* parentScope)
ColorScope *ColorScope::findParentScope() ColorScope *ColorScope::findParentScope()
{ {
QObject *p = 0; QObject *p = nullptr;
if (m_parent) { if (m_parent) {
QQuickItem *gp = qobject_cast<QQuickItem *>(m_parent); QQuickItem *gp = qobject_cast<QQuickItem *>(m_parent);
if (gp) { if (gp) {
@ -106,7 +106,7 @@ ColorScope *ColorScope::findParentScope()
if (!p || !m_parent) { if (!p || !m_parent) {
setParentScope(nullptr); setParentScope(nullptr);
return 0; return nullptr;
} }
ColorScope *c = qobject_cast<ColorScope *>(p); ColorScope *c = qobject_cast<ColorScope *>(p);

View File

@ -151,7 +151,7 @@ void SortFilterModel::setFilterCallback(const QJSValue& callback)
m_filterCallback = callback; m_filterCallback = callback;
invalidateFilter(); invalidateFilter();
emit filterCallbackChanged(callback); Q_EMIT filterCallbackChanged(callback);
} }
void SortFilterModel::setFilterRole(const QString &role) void SortFilterModel::setFilterRole(const QString &role)

View File

@ -28,9 +28,7 @@ DataSource::DataSource(QObject *parent)
: QObject(parent), : QObject(parent),
m_ready(false), m_ready(false),
m_interval(0), m_interval(0),
m_intervalAlignment(Plasma::Types::NoAlignment), m_intervalAlignment(Plasma::Types::NoAlignment)
m_dataEngine(0),
m_dataEngineConsumer(0)
{ {
m_models = new QQmlPropertyMap(this); m_models = new QQmlPropertyMap(this);
m_data = new QQmlPropertyMap(this); m_data = new QQmlPropertyMap(this);
@ -104,7 +102,7 @@ void DataSource::setEngine(const QString &e)
m_dataEngine->disconnect(this); m_dataEngine->disconnect(this);
// Deleting the consumer triggers the reference counting // Deleting the consumer triggers the reference counting
delete m_dataEngineConsumer; delete m_dataEngineConsumer;
m_dataEngineConsumer = 0; m_dataEngineConsumer = nullptr;
} }
/* /*
@ -222,7 +220,7 @@ QObject *DataSource::serviceForSource(const QString &source)
if (!m_services.contains(source)) { if (!m_services.contains(source)) {
Plasma::Service *service = m_dataEngine->serviceForSource(source); Plasma::Service *service = m_dataEngine->serviceForSource(source);
if (!service) { if (!service) {
return 0; return nullptr;
} }
m_services[source] = service; m_services[source] = service;
} }

View File

@ -185,10 +185,10 @@ private:
int m_interval; int m_interval;
Plasma::Types::IntervalAlignment m_intervalAlignment; Plasma::Types::IntervalAlignment m_intervalAlignment;
QString m_engine; QString m_engine;
QQmlPropertyMap *m_data; QQmlPropertyMap *m_data = nullptr;
QQmlPropertyMap *m_models; QQmlPropertyMap *m_models = nullptr;
Plasma::DataEngine *m_dataEngine; Plasma::DataEngine *m_dataEngine = nullptr;
Plasma::DataEngineConsumer *m_dataEngineConsumer; Plasma::DataEngineConsumer *m_dataEngineConsumer = nullptr;
QStringList m_sources; QStringList m_sources;
QStringList m_connectedSources; QStringList m_connectedSources;
QStringList m_oldSources; QStringList m_oldSources;

View File

@ -25,8 +25,8 @@
struct FadingMaterialState struct FadingMaterialState
{ {
QSGTexture *source; QSGTexture *source = nullptr;
QSGTexture *target; QSGTexture *target = nullptr;
qreal progress; qreal progress;
}; };
@ -41,7 +41,7 @@ public:
void initialize() Q_DECL_OVERRIDE; void initialize() Q_DECL_OVERRIDE;
private: private:
QOpenGLFunctions *glFuncs = 0; QOpenGLFunctions *glFuncs = nullptr;
int m_progressId = 0; int m_progressId = 0;
}; };

View File

@ -30,7 +30,7 @@
#include <kwindoweffects.h> #include <kwindoweffects.h>
#include <KDirWatch> #include <KDirWatch>
ToolTipDialog *ToolTip::s_dialog = 0; ToolTipDialog *ToolTip::s_dialog = nullptr;
int ToolTip::s_dialogUsers = 0; int ToolTip::s_dialogUsers = 0;
ToolTip::ToolTip(QQuickItem *parent) ToolTip::ToolTip(QQuickItem *parent)
@ -70,7 +70,7 @@ ToolTip::~ToolTip()
if (s_dialogUsers == 0) { if (s_dialogUsers == 0) {
delete s_dialog; delete s_dialog;
s_dialog = 0; s_dialog = nullptr;
} }
} }

View File

@ -55,7 +55,7 @@ QQmlEngine *EngineBookKeeping::engine() const
//for components creation, any engine will do, as long is valid //for components creation, any engine will do, as long is valid
if (m_engines.isEmpty()) { if (m_engines.isEmpty()) {
qWarning() << "No engines found, this should never happen"; qWarning() << "No engines found, this should never happen";
return 0; return nullptr;
} else { } else {
return *m_engines.constBegin(); return *m_engines.constBegin();
} }

View File

@ -37,7 +37,7 @@ QMenuProxy::QMenuProxy(QObject *parent)
m_placement(Plasma::Types::LeftPosedTopAlignedPopup) m_placement(Plasma::Types::LeftPosedTopAlignedPopup)
{ {
if (qobject_cast<QApplication *>(QCoreApplication::instance())) { if (qobject_cast<QApplication *>(QCoreApplication::instance())) {
m_menu = new QMenu(0); m_menu = new QMenu(nullptr);
// Breeze and Oxygen have rounded corners on menus. They set this attribute in polish() // Breeze and Oxygen have rounded corners on menus. They set this attribute in polish()
// but at that time the underlying surface has already been created where setting this // but at that time the underlying surface has already been created where setting this
// flag makes no difference anymore (Bug 385311) // flag makes no difference anymore (Bug 385311)
@ -91,7 +91,7 @@ void QMenuProxy::setVisualParent(QObject *parent)
//if the old parent was a QAction, disconnect the menu from it //if the old parent was a QAction, disconnect the menu from it
QAction *action = qobject_cast<QAction *>(m_visualParent.data()); QAction *action = qobject_cast<QAction *>(m_visualParent.data());
if (action) { if (action) {
action->setMenu(0); action->setMenu(nullptr);
m_menu->clear(); m_menu->clear();
} }
//if parent is a QAction, become a submenu //if parent is a QAction, become a submenu
@ -336,7 +336,7 @@ void QMenuProxy::open(int x, int y)
openInternal(pos.toPoint()); openInternal(pos.toPoint());
} }
Q_INVOKABLE void QMenuProxy::openRelative() void QMenuProxy::openRelative()
{ {
QQuickItem *parentItem = nullptr; QQuickItem *parentItem = nullptr;

View File

@ -126,7 +126,7 @@ Applet::Applet(QObject *parentObject, const QVariantList &args)
} }
Applet::Applet(const QString &packagePath, uint appletId) Applet::Applet(const QString &packagePath, uint appletId)
: QObject(0), : QObject(nullptr),
d(new AppletPrivate(appletMetadataForDirectory(packagePath), appletId, this)) d(new AppletPrivate(appletMetadataForDirectory(packagePath), appletId, this))
{ {
d->init(packagePath); d->init(packagePath);