aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-04-16 22:26:44 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-05 08:37:31 +0000
commit5ef5f1bb9eb282a122906d375e90632c6dcfcb35 (patch)
tree808088835d3507d61ddf330ed48340df2d905e9b /src/qml
parent13ec9ab3b898a67403ce0031c4cfdc74d95d5560 (diff)
Move the target property index into the common base class
This unifies some more code between the different binding classes Change-Id: I891dc9358cf9598a0c1e21df8a62d6f8a4193985 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/qqmlabstractbinding_p.h3
-rw-r--r--src/qml/qml/qqmlbinding.cpp15
-rw-r--r--src/qml/qml/qqmlbinding_p.h3
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding.cpp7
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding_p.h2
5 files changed, 8 insertions, 22 deletions
diff --git a/src/qml/qml/qqmlabstractbinding_p.h b/src/qml/qml/qqmlabstractbinding_p.h
index aa76c9aeba..ccf525ef38 100644
--- a/src/qml/qml/qqmlabstractbinding_p.h
+++ b/src/qml/qml/qqmlabstractbinding_p.h
@@ -73,7 +73,7 @@ public:
// Should return the encoded property index for the binding. Should return this value
// even if the binding is not enabled or added to an object.
// Encoding is: coreIndex | (valueTypeIndex << 16)
- virtual int targetPropertyIndex() const = 0;
+ int targetPropertyIndex() const { return m_targetIndex; }
// Should return the object for the binding. Should return this object even if the
// binding is not enabled or added to the object.
@@ -124,6 +124,7 @@ private:
protected:
QFlagPointer<QObject> m_target;
+ int m_targetIndex;
};
QQmlAbstractBinding::Pointer
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index ec9ac912b5..0f22bf4521 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -270,11 +270,6 @@ QString QQmlBinding::expression() const
return v->toQStringNoThrow();
}
-int QQmlBinding::targetPropertyIndex() const
-{
- return m_index;
-}
-
void QQmlBinding::setTarget(const QQmlProperty &prop)
{
setTarget(prop.object(), QQmlPropertyPrivate::get(prop)->core);
@@ -286,7 +281,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core)
QQmlPropertyData pd = core;
if (!object) {
- m_index = -1;
+ m_targetIndex = -1;
return;
}
@@ -298,7 +293,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core)
int aValueTypeIndex;
if (!vme->aliasTarget(coreIndex, &object, &coreIndex, &aValueTypeIndex)) {
m_target = 0;
- m_index = -1;
+ m_targetIndex = -1;
return;
}
if (valueTypeIndex == -1)
@@ -307,7 +302,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core)
QQmlData *data = QQmlData::get(object, false);
if (!data || !data->propertyCache) {
m_target = 0;
- m_index = -1;
+ m_targetIndex = -1;
return;
}
QQmlPropertyData *propertyData = data->propertyCache->property(coreIndex);
@@ -325,7 +320,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core)
pd.valueTypeCoreIndex = valueTypeIndex;
}
}
- m_index = pd.encodedIndex();
+ m_targetIndex = pd.encodedIndex();
QQmlData *data = QQmlData::get(*m_target, true);
if (!data->propertyCache) {
@@ -337,7 +332,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core)
QQmlPropertyData QQmlBinding::getPropertyData() const
{
int coreIndex;
- int valueTypeIndex = QQmlPropertyData::decodeValueTypePropertyIndex(m_index, &coreIndex);
+ int valueTypeIndex = QQmlPropertyData::decodeValueTypePropertyIndex(m_targetIndex, &coreIndex);
QQmlData *data = QQmlData::get(*m_target, false);
Q_ASSERT(data && data->propertyCache);
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index 69d434ab25..18f60a2b39 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -84,7 +84,6 @@ public:
// Inherited from QQmlAbstractBinding
virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags flags = QQmlPropertyPrivate::DontRemoveBinding);
virtual QString expression() const;
- virtual int targetPropertyIndex() const;
void update(QQmlPropertyPrivate::WriteFlags flags = QQmlPropertyPrivate::DontRemoveBinding);
typedef int Identifier;
@@ -105,8 +104,6 @@ private:
inline bool enabledFlag() const;
inline void setEnabledFlag(bool);
QQmlPropertyData getPropertyData() const;
-
- int m_index;
};
bool QQmlBinding::updatingFlag() const
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding.cpp b/src/qml/qml/qqmlvaluetypeproxybinding.cpp
index a12699facf..bf6a7d6045 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding.cpp
+++ b/src/qml/qml/qqmlvaluetypeproxybinding.cpp
@@ -37,10 +37,10 @@ QT_BEGIN_NAMESPACE
QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, int index)
: QQmlAbstractBinding(ValueTypeProxy),
- m_targetIndex(index),
m_bindings(0)
{
m_target = o;
+ m_targetIndex = index;
}
QQmlValueTypeProxyBinding::~QQmlValueTypeProxyBinding()
@@ -104,9 +104,4 @@ void QQmlValueTypeProxyBinding::removeBindings(quint32 mask)
}
}
-int QQmlValueTypeProxyBinding::targetPropertyIndex() const
-{
- return m_targetIndex;
-}
-
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding_p.h b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
index 6e618375d9..f6d9c0abc1 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding_p.h
+++ b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
@@ -58,14 +58,12 @@ public:
void removeBindings(quint32 mask);
virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags);
- virtual int targetPropertyIndex() const;
protected:
~QQmlValueTypeProxyBinding();
private:
friend class QQmlAbstractBinding;
- int m_targetIndex;
QQmlAbstractBinding *m_bindings;
};