summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-05 08:10:50 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-06 09:06:16 (GMT)
commit7b5e37cab738804d47b78582aa3d0f3bb6933e70 (patch)
tree4acaf0f2b2785965d32787312002aa34f99c57fb
parent13833beb641289c45faed337848d37280195aadc (diff)
downloadQt-7b5e37cab738804d47b78582aa3d0f3bb6933e70.zip
Qt-7b5e37cab738804d47b78582aa3d0f3bb6933e70.tar.gz
Qt-7b5e37cab738804d47b78582aa3d0f3bb6933e70.tar.bz2
Deprecate qVariantValue qVariantCanConvert qVariantFromValue qVariantSetValue
The template member equivalent should be used instead. qVariantFromValue and qVariantSetValue does not have the QT_DEPRECATED macro, as they have template specialisation which is not possible to acheive as member function. So they are called by the non-deprecated implementation. Rev-by: dev mailing list
-rw-r--r--src/corelib/kernel/qvariant.cpp16
-rw-r--r--src/corelib/kernel/qvariant.h24
2 files changed, 19 insertions, 21 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index bbfbce8..feb85ce 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1076,7 +1076,7 @@ static void streamDebug(QDebug dbg, const QVariant &v)
dbg.nospace() << v.toFloat();
break;
case QMetaType::QObjectStar:
- dbg.nospace() << qVariantValue<QObject *>(v);
+ dbg.nospace() << qvariant_cast<QObject *>(v);
break;
case QVariant::Double:
dbg.nospace() << v.toDouble();
@@ -1237,7 +1237,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
conversion functions to data types defined in QtGui, such as
QColor, QImage, and QPixmap. In other words, there is no \c
toColor() function. Instead, you can use the QVariant::value() or
- the qVariantValue() template function. For example:
+ the qvariant_cast() template function. For example:
\snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 2
@@ -1352,12 +1352,12 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
Note that you have to pass the address of the variable you want stored.
- Usually, you never have to use this constructor, use qVariantFromValue()
+ Usually, you never have to use this constructor, use QVariant::fromValue()
instead to construct variants from the pointer types represented by
\c QMetaType::VoidStar, \c QMetaType::QObjectStar and
\c QMetaType::QWidgetStar.
- \sa qVariantFromValue(), Type
+ \sa QVariant::fromValue(), Type
*/
/*!
@@ -3116,6 +3116,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
/*!
\fn QVariant qVariantFromValue(const T &value)
\relates QVariant
+ \obsolete
Returns a variant containing a copy of the given \a value
with template type \c{T}.
@@ -3136,6 +3137,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
/*! \fn void qVariantSetValue(QVariant &variant, const T &value)
\relates QVariant
+ \obsolete
Sets the contents of the given \a variant to a copy of the
\a value with the specified template type \c{T}.
@@ -3155,13 +3157,14 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Returns the given \a value converted to the template type \c{T}.
- This function is equivalent to qVariantValue().
+ This function is equivalent to QVariant::value().
- \sa qVariantValue(), QVariant::value()
+ \sa QVariant::value()
*/
/*! \fn T qVariantValue(const QVariant &value)
\relates QVariant
+ \obsolete
Returns the given \a value converted to the template type \c{T}.
@@ -3177,6 +3180,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
/*! \fn bool qVariantCanConvert(const QVariant &value)
\relates QVariant
+ \obsolete
Returns true if the given \a value can be converted to the
template type specified; otherwise returns false.
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 73b00e9..432b708 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -86,14 +86,8 @@ class QVariantComparisonHelper;
template <typename T>
inline QVariant qVariantFromValue(const T &);
-template <typename T>
-inline void qVariantSetValue(QVariant &, const T &);
-
-template<typename T>
-inline T qVariantValue(const QVariant &);
-
template<typename T>
-inline bool qVariantCanConvert(const QVariant &);
+inline T qvariant_cast(const QVariant &);
class Q_CORE_EXPORT QVariant
{
@@ -330,7 +324,7 @@ class Q_CORE_EXPORT QVariant
template<typename T>
inline T value() const
- { return qVariantValue<T>(*this); }
+ { return qvariant_cast<T>(*this); }
template<typename T>
static inline QVariant fromValue(const T &value)
@@ -338,7 +332,7 @@ class Q_CORE_EXPORT QVariant
template<typename T>
bool canConvert() const
- { return qVariantCanConvert<T>(*this); }
+ { return canConvert(Type(qMetaTypeId<T>())); }
public:
#ifndef qdoc
@@ -588,16 +582,16 @@ template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
return v;
}
+#ifdef QT_DEPRECATED
template<typename T>
-inline T qVariantValue(const QVariant &variant)
+inline QT_DEPRECATED T qVariantValue(const QVariant &variant)
{ return qvariant_cast<T>(variant); }
template<typename T>
-inline bool qVariantCanConvert(const QVariant &variant)
-{
- return variant.canConvert(static_cast<QVariant::Type>(
- qMetaTypeId<T>(static_cast<T *>(0))));
-}
+inline QT_DEPRECATED bool qVariantCanConvert(const QVariant &variant)
+{ return variant.canConvert<T>(); }
+#endif
+
#endif
Q_DECLARE_SHARED(QVariant)
Q_DECLARE_TYPEINFO(QVariant, Q_MOVABLE_TYPE);