aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/util
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-02-21 10:41:54 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-02-26 07:13:18 +0000
commit499ec43937e926e4f2fa57a9baa455fcb3862262 (patch)
tree206c90d47387f8322b68f5e3db613189397e1af3 /src/qml/util
parent53d1e9ed21d25e65a2f13606af479838f5f21fe7 (diff)
use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/util')
-rw-r--r--src/qml/util/qqmladaptormodel.cpp40
-rw-r--r--src/qml/util/qqmladaptormodel_p.h4
-rw-r--r--src/qml/util/qqmlchangeset.cpp2
-rw-r--r--src/qml/util/qqmlchangeset_p.h2
-rw-r--r--src/qml/util/qqmllistaccessor.cpp2
-rw-r--r--src/qml/util/qqmllistaccessor_p.h2
-rw-r--r--src/qml/util/qqmllistcompositor.cpp2
-rw-r--r--src/qml/util/qqmllistcompositor_p.h36
8 files changed, 45 insertions, 45 deletions
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 7afafec1fe..b4bebb9d5d 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -121,8 +121,8 @@ class VDMModelDelegateDataType
public:
VDMModelDelegateDataType(QQmlAdaptorModel *model)
: model(model)
- , metaObject(0)
- , propertyCache(0)
+ , metaObject(nullptr)
+ , propertyCache(nullptr)
, propertyOffset(0)
, signalOffset(0)
, hasModelData(false)
@@ -176,7 +176,7 @@ public:
const int idx = item->modelIndex();
if (idx >= index && idx < index + count) {
for (int i = 0; i < signalIndexes.count(); ++i)
- QMetaObject::activate(item, signalIndexes.at(i), 0);
+ QMetaObject::activate(item, signalIndexes.at(i), nullptr);
}
}
return changed;
@@ -217,8 +217,8 @@ public:
QV4::ExecutionEngine *v4 = data->v4;
QV4::Scope scope(v4);
QV4::ScopedObject proto(scope, v4->newObject());
- proto->defineAccessorProperty(QStringLiteral("index"), get_index, 0);
- proto->defineAccessorProperty(QStringLiteral("hasModelChildren"), get_hasModelChildren, 0);
+ proto->defineAccessorProperty(QStringLiteral("index"), get_index, nullptr);
+ proto->defineAccessorProperty(QStringLiteral("hasModelChildren"), get_hasModelChildren, nullptr);
QV4::ScopedProperty p(scope);
typedef QHash<QByteArray, int>::const_iterator iterator;
@@ -298,11 +298,11 @@ int QQmlDMCachedModelData::metaCall(QMetaObject::Call call, int id, void **argum
const QMetaObject *meta = metaObject();
if (cachedData.count() > 1) {
cachedData[propertyIndex] = *static_cast<QVariant *>(arguments[0]);
- QMetaObject::activate(this, meta, propertyIndex, 0);
+ QMetaObject::activate(this, meta, propertyIndex, nullptr);
} else if (cachedData.count() == 1) {
cachedData[0] = *static_cast<QVariant *>(arguments[0]);
- QMetaObject::activate(this, meta, 0, 0);
- QMetaObject::activate(this, meta, 1, 0);
+ QMetaObject::activate(this, meta, 0, nullptr);
+ QMetaObject::activate(this, meta, 1, nullptr);
}
} else if (*type->model) {
setValue(type->propertyRoles.at(propertyIndex), *static_cast<QVariant *>(arguments[0]));
@@ -336,7 +336,7 @@ bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx)
const QMetaObject *meta = metaObject();
const int propertyCount = type->propertyRoles.count();
for (int i = 0; i < propertyCount; ++i)
- QMetaObject::activate(this, meta, i, 0);
+ QMetaObject::activate(this, meta, i, nullptr);
return true;
} else {
return false;
@@ -381,11 +381,11 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject
if (!modelData->cachedData.isEmpty()) {
if (modelData->cachedData.count() > 1) {
modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QVariant::Invalid);
- QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, 0);
+ QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, nullptr);
} else if (modelData->cachedData.count() == 1) {
modelData->cachedData[0] = scope.engine->toVariant(argv[0], QVariant::Invalid);
- QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, 0);
- QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, 0);
+ QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, nullptr);
+ QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, nullptr);
}
}
}
@@ -710,7 +710,7 @@ public:
QMetaObjectBuilder builder;
VDMObjectDelegateDataType()
- : metaObject(0)
+ : metaObject(nullptr)
, propertyOffset(0)
, signalOffset(0)
, shared(true)
@@ -720,7 +720,7 @@ public:
VDMObjectDelegateDataType(const VDMObjectDelegateDataType &type)
: QQmlRefCount()
, QQmlAdaptorModel::Accessors()
- , metaObject(0)
+ , metaObject(nullptr)
, propertyOffset(type.propertyOffset)
, signalOffset(type.signalOffset)
, shared(false)
@@ -759,7 +759,7 @@ public:
dataType->initializeMetaType(model);
return index >= 0 && index < model.list.count()
? new QQmlDMObjectData(metaType, dataType, index, qvariant_cast<QObject *>(model.list.at(index)))
- : 0;
+ : nullptr;
}
void initializeMetaType(QQmlAdaptorModel &)
@@ -807,7 +807,7 @@ public:
QMetaObject::metacall(m_data->object, call, id - m_type->propertyOffset + objectPropertyOffset, arguments);
return -1;
} else if (id >= m_type->signalOffset && call == QMetaObject::InvokeMetaMethod) {
- QMetaObject::activate(m_data, this, id - m_type->signalOffset, 0);
+ QMetaObject::activate(m_data, this, id - m_type->signalOffset, nullptr);
return -1;
} else {
return m_data->qt_metacall(call, id, arguments);
@@ -937,10 +937,10 @@ void QQmlAdaptorModel::setModel(const QVariant &variant, QQmlDelegateModel *vdm,
accessors = new VDMObjectDelegateDataType;
} else if (list.type() != QQmlListAccessor::Invalid
&& list.type() != QQmlListAccessor::Instance) { // Null QObject
- setObject(0);
+ setObject(nullptr);
accessors = &qt_vdm_list_accessors;
} else {
- setObject(0);
+ setObject(nullptr);
accessors = &qt_vdm_null_accessors;
}
}
@@ -960,7 +960,7 @@ bool QQmlAdaptorModel::isValid() const
void QQmlAdaptorModel::objectDestroyed(QObject *)
{
- setModel(QVariant(), 0, 0);
+ setModel(QVariant(), nullptr, nullptr);
}
QQmlAdaptorModelEngineData::QQmlAdaptorModelEngineData(QV4::ExecutionEngine *v4)
@@ -968,7 +968,7 @@ QQmlAdaptorModelEngineData::QQmlAdaptorModelEngineData(QV4::ExecutionEngine *v4)
{
QV4::Scope scope(v4);
QV4::ScopedObject proto(scope, v4->newObject());
- proto->defineAccessorProperty(QStringLiteral("index"), get_index, 0);
+ proto->defineAccessorProperty(QStringLiteral("index"), get_index, nullptr);
proto->defineAccessorProperty(QStringLiteral("modelData"),
QQmlDMListAccessorData::get_modelData, QQmlDMListAccessorData::set_modelData);
listItemProto.set(v4, proto);
diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h
index 7bbddcff07..8f773efa20 100644
--- a/src/qml/util/qqmladaptormodel_p.h
+++ b/src/qml/util/qqmladaptormodel_p.h
@@ -74,7 +74,7 @@ public:
inline Accessors() {}
virtual ~Accessors();
virtual int count(const QQmlAdaptorModel &) const { return 0; }
- virtual void cleanup(QQmlAdaptorModel &, QQmlDelegateModel * = 0) const {}
+ virtual void cleanup(QQmlAdaptorModel &, QQmlDelegateModel * = nullptr) const {}
virtual QVariant value(const QQmlAdaptorModel &, int, const QString &) const {
return QVariant(); }
@@ -82,7 +82,7 @@ public:
virtual QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &,
QQmlDelegateModelItemMetaType *,
- int) const { return 0; }
+ int) const { return nullptr; }
virtual bool notify(
const QQmlAdaptorModel &,
diff --git a/src/qml/util/qqmlchangeset.cpp b/src/qml/util/qqmlchangeset.cpp
index 79e3332331..ba876b42e2 100644
--- a/src/qml/util/qqmlchangeset.cpp
+++ b/src/qml/util/qqmlchangeset.cpp
@@ -120,7 +120,7 @@ void QQmlChangeSet::remove(int index, int count)
{
QVector<Change> removes;
removes.append(Change(index, count));
- remove(&removes, 0);
+ remove(&removes, nullptr);
}
/*!
diff --git a/src/qml/util/qqmlchangeset_p.h b/src/qml/util/qqmlchangeset_p.h
index 8e1fa3f9f2..8bc13f1b67 100644
--- a/src/qml/util/qqmlchangeset_p.h
+++ b/src/qml/util/qqmlchangeset_p.h
@@ -119,7 +119,7 @@ public:
void change(int index, int count);
void insert(const QVector<Change> &inserts);
- void remove(const QVector<Change> &removes, QVector<Change> *inserts = 0);
+ void remove(const QVector<Change> &removes, QVector<Change> *inserts = nullptr);
void move(const QVector<Change> &removes, const QVector<Change> &inserts);
void change(const QVector<Change> &changes);
void apply(const QQmlChangeSet &changeSet);
diff --git a/src/qml/util/qqmllistaccessor.cpp b/src/qml/util/qqmllistaccessor.cpp
index 356584abdc..ad55519ad3 100644
--- a/src/qml/util/qqmllistaccessor.cpp
+++ b/src/qml/util/qqmllistaccessor.cpp
@@ -72,7 +72,7 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine)
if (d.userType() == qMetaTypeId<QJSValue>())
d = d.value<QJSValue>().toVariant();
- QQmlEnginePrivate *enginePrivate = engine?QQmlEnginePrivate::get(engine):0;
+ QQmlEnginePrivate *enginePrivate = engine?QQmlEnginePrivate::get(engine):nullptr;
if (!d.isValid()) {
m_type = Invalid;
diff --git a/src/qml/util/qqmllistaccessor_p.h b/src/qml/util/qqmllistaccessor_p.h
index bad5a5803c..bcd079adef 100644
--- a/src/qml/util/qqmllistaccessor_p.h
+++ b/src/qml/util/qqmllistaccessor_p.h
@@ -63,7 +63,7 @@ public:
~QQmlListAccessor();
QVariant list() const;
- void setList(const QVariant &, QQmlEngine * = 0);
+ void setList(const QVariant &, QQmlEngine * = nullptr);
bool isValid() const;
diff --git a/src/qml/util/qqmllistcompositor.cpp b/src/qml/util/qqmllistcompositor.cpp
index 05a4eaac39..8b0b8f48f0 100644
--- a/src/qml/util/qqmllistcompositor.cpp
+++ b/src/qml/util/qqmllistcompositor.cpp
@@ -1253,7 +1253,7 @@ void QQmlListCompositor::listItemsRemoved(
QVector<QQmlChangeSet::Change> removals;
removals.append(QQmlChangeSet::Change(index, count));
- listItemsRemoved(translatedRemovals, list, &removals, 0, 0);
+ listItemsRemoved(translatedRemovals, list, &removals, nullptr, nullptr);
}
/*!
diff --git a/src/qml/util/qqmllistcompositor_p.h b/src/qml/util/qqmllistcompositor_p.h
index 6ae9c47df3..d5723889e1 100644
--- a/src/qml/util/qqmllistcompositor_p.h
+++ b/src/qml/util/qqmllistcompositor_p.h
@@ -87,7 +87,7 @@ public:
class Range
{
public:
- Range() : next(this), previous(this), list(0), index(0), count(0), flags(0) {}
+ Range() : next(this), previous(this), list(nullptr), index(0), count(0), flags(0) {}
Range(Range *next, void *list, int index, int count, uint flags)
: next(next), previous(next->previous), list(list), index(index), count(count), flags(flags) {
next->previous = this; previous->next = this; }
@@ -222,22 +222,22 @@ public:
const iterator &end() { return m_end; }
- void append(void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
- void insert(Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
- iterator insert(iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
+ void append(void *list, int index, int count, uint flags, QVector<Insert> *inserts = nullptr);
+ void insert(Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = nullptr);
+ iterator insert(iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = nullptr);
- void setFlags(Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts = 0);
- void setFlags(iterator from, int count, Group group, uint flags, QVector<Insert> *inserts = 0);
- void setFlags(Group fromGroup, int from, int count, uint flags, QVector<Insert> *inserts = 0) {
+ void setFlags(Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts = nullptr);
+ void setFlags(iterator from, int count, Group group, uint flags, QVector<Insert> *inserts = nullptr);
+ void setFlags(Group fromGroup, int from, int count, uint flags, QVector<Insert> *inserts = nullptr) {
setFlags(fromGroup, from, count, fromGroup, flags, inserts); }
- void setFlags(const iterator from, int count, uint flags, QVector<Insert> *inserts = 0) {
+ void setFlags(const iterator from, int count, uint flags, QVector<Insert> *inserts = nullptr) {
setFlags(from, count, from.group, flags, inserts); }
- void clearFlags(Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removals = 0);
- void clearFlags(iterator from, int count, Group group, uint flags, QVector<Remove> *removals = 0);
- void clearFlags(Group fromGroup, int from, int count, uint flags, QVector<Remove> *removals = 0) {
+ void clearFlags(Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removals = nullptr);
+ void clearFlags(iterator from, int count, Group group, uint flags, QVector<Remove> *removals = nullptr);
+ void clearFlags(Group fromGroup, int from, int count, uint flags, QVector<Remove> *removals = nullptr) {
clearFlags(fromGroup, from, count, fromGroup, flags, removals); }
- void clearFlags(const iterator &from, int count, uint flags, QVector<Remove> *removals = 0) {
+ void clearFlags(const iterator &from, int count, uint flags, QVector<Remove> *removals = nullptr) {
clearFlags(from, count, from.group, flags, removals); }
bool verifyMoveTo(Group fromGroup, int from, Group toGroup, int to, int count, Group group) const;
@@ -249,8 +249,8 @@ public:
int to,
int count,
Group group,
- QVector<Remove> *removals = 0,
- QVector<Insert> *inserts = 0);
+ QVector<Remove> *removals = nullptr,
+ QVector<Insert> *inserts = nullptr);
void clear();
void listItemsInserted(void *list, int index, int count, QVector<Insert> *inserts);
@@ -289,13 +289,13 @@ private:
QVector<Remove> *translatedRemovals,
void *list,
QVector<QQmlChangeSet::Change> *removals,
- QVector<QQmlChangeSet::Change> *insertions = 0,
- QVector<MovedFlags> *movedFlags = 0);
+ QVector<QQmlChangeSet::Change> *insertions = nullptr,
+ QVector<MovedFlags> *movedFlags = nullptr);
void listItemsInserted(
QVector<Insert> *translatedInsertions,
void *list,
const QVector<QQmlChangeSet::Change> &insertions,
- const QVector<MovedFlags> *movedFlags = 0);
+ const QVector<MovedFlags> *movedFlags = nullptr);
void listItemsChanged(
QVector<Change> *translatedChanges,
void *list,
@@ -309,7 +309,7 @@ Q_DECLARE_TYPEINFO(QQmlListCompositor::Remove, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QQmlListCompositor::Insert, Q_PRIMITIVE_TYPE);
inline QQmlListCompositor::iterator::iterator()
- : range(0), offset(0), group(Default), groupCount(0) {}
+ : range(nullptr), offset(0), group(Default), groupCount(0) {}
inline QQmlListCompositor::iterator::iterator(const iterator &it)
: range(it.range)
, offset(it.offset)