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;
}
@ -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
return m_firstDayOfWeek == 7 ? 0 : m_firstDayOfWeek;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@
#include <kwindoweffects.h>
#include <KDirWatch>
ToolTipDialog *ToolTip::s_dialog = 0;
ToolTipDialog *ToolTip::s_dialog = nullptr;
int ToolTip::s_dialogUsers = 0;
ToolTip::ToolTip(QQuickItem *parent)
@ -70,7 +70,7 @@ ToolTip::~ToolTip()
if (s_dialogUsers == 0) {
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
if (m_engines.isEmpty()) {
qWarning() << "No engines found, this should never happen";
return 0;
return nullptr;
} else {
return *m_engines.constBegin();
}

View File

@ -37,7 +37,7 @@ QMenuProxy::QMenuProxy(QObject *parent)
m_placement(Plasma::Types::LeftPosedTopAlignedPopup)
{
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()
// but at that time the underlying surface has already been created where setting this
// 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
QAction *action = qobject_cast<QAction *>(m_visualParent.data());
if (action) {
action->setMenu(0);
action->setMenu(nullptr);
m_menu->clear();
}
//if parent is a QAction, become a submenu
@ -336,7 +336,7 @@ void QMenuProxy::open(int x, int y)
openInternal(pos.toPoint());
}
Q_INVOKABLE void QMenuProxy::openRelative()
void QMenuProxy::openRelative()
{
QQuickItem *parentItem = nullptr;

View File

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