// qvariant.sip generated by MetaSIP on Mon Oct 24 12:34:00 2011 // // This file is part of the QtCore Python extension module. // // Copyright (c) 2011 Riverbank Computing Limited // // This file is part of PyQt. // // This file may be used under the terms of the GNU General Public // License versions 2.0 or 3.0 as published by the Free Software // Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 // included in the packaging of this file. Alternatively you may (at // your option) use any later version of the GNU General Public // License if such license has been publicly approved by Riverbank // Computing Limited (or its successors, if any) and the KDE Free Qt // Foundation. In addition, as a special exception, Riverbank gives you // certain additional rights. These rights are described in the Riverbank // GPL Exception version 1.1, which can be found in the file // GPL_EXCEPTION.txt in this package. // // If you are unsure which license is appropriate for your use, please // contact the sales department at sales@riverbankcomputing.com. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. %ModuleCode #include %End class QVariant /AllowNone,API=QVariant: - 2/ { %TypeHeaderCode #include %End %ConvertToTypeCode if (sipIsErr == NULL) // We can convert everything to a QVariant. return 1; // If it is already a QVariant then just return it. if (Py_TYPE(sipPy) == sipTypeAsPyTypeObject(sipType_QVariant)) { *sipCppPtr = reinterpret_cast(sipConvertToType(sipPy, sipType_QVariant, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); return 0; } // Convert it to a QVariant. QVariant var = qpycore_PyObject_AsQVariant(sipPy, sipIsErr); if (*sipIsErr) return 0; *sipCppPtr = new QVariant(var); return sipGetState(sipTransferObj); %End public: enum Type { Invalid, Bool, Int, UInt, LongLong, ULongLong, Double, Char, Map, List, String, StringList, ByteArray, BitArray, Date, Time, DateTime, Url, Locale, Rect, RectF, Size, SizeF, Line, LineF, Point, PointF, RegExp, Font, Pixmap, Brush, Color, Palette, Icon, Image, Polygon, Region, Bitmap, Cursor, SizePolicy, KeySequence, Pen, TextLength, TextFormat, %If (Qt_4_2_0 -) Matrix, %End %If (Qt_4_3_0 -) Transform, %End %If (Qt_4_5_0 -) Hash, %End %If (Qt_4_6_0 -) Matrix4x4, %End %If (Qt_4_6_0 -) Vector2D, %End %If (Qt_4_6_0 -) Vector3D, %End %If (Qt_4_6_0 -) Vector4D, %End %If (Qt_4_6_0 -) Quaternion, %End %If (Qt_4_7_0 -) EasingCurve, %End UserType, }; QVariant(); QVariant(QVariant::Type type /Constrained/); QVariant(int typeOrUserType, const void *copy); QVariant(const QVariant &other); QVariant(SIP_PYOBJECT); %MethodCode int is_err = 0; QVariant var = qpycore_PyObject_AsQVariant(a0, &is_err); if (is_err) sipCpp = 0; else sipCpp = new QVariant(var); %End ~QVariant(); static QVariant fromList(const QList &list); %MethodCode // We don't implement this as a Python ctor to allow an empty Python list to be // handled as a Python object. sipRes = new QVariant(*a0); %End static QVariant fromMap(const QMap &map); %MethodCode // We don't implement this as a Python ctor to allow an empty Python dictionary // to be handled as a Python object. sipRes = new QVariant(*a0); %End QVariant::Type type() const; int userType() const; const char *typeName() const; bool canConvert(QVariant::Type t) const; bool convert(QVariant::Type t); bool isValid() const; bool isNull() const; void clear(); void detach(); bool isDetached() const; int toInt(bool *ok = 0) const; uint toUInt(bool *ok = 0) const; qlonglong toLongLong(bool *ok = 0) const; qulonglong toULongLong(bool *ok = 0) const; bool toBool() const; double toDouble(bool *ok = 0) const; QByteArray toByteArray() const; QBitArray toBitArray() const; QString toString() const; QStringList toStringList() const; QChar toChar() const; QDate toDate() const; QTime toTime() const; QDateTime toDateTime() const; QList toList() const; QMap toMap() const; %If (Qt_4_5_0 -) QHash toHash() const; %End QPoint toPoint() const; QPointF toPointF() const; QSize toSize() const; QSizeF toSizeF() const; QLine toLine() const; QLineF toLineF() const; QRect toRect() const; QRectF toRectF() const; QUrl toUrl() const; QLocale toLocale() const; QRegExp toRegExp() const; SIP_PYOBJECT toPyObject() const; %MethodCode sipRes = qpycore_PyObject_FromQVariant(*sipCpp); %End void load(QDataStream &ds); void save(QDataStream &ds) const; static const char *typeToName(QVariant::Type type); static QVariant::Type nameToType(const char *name); void *data(); bool operator==(const QVariant &v) const; bool operator!=(const QVariant &v) const; %If (Qt_4_6_0 -) float toFloat(bool *ok = 0) const; %End %If (Qt_4_6_0 -) qreal toReal(bool *ok = 0) const; %End %If (Qt_4_7_0 -) QEasingCurve toEasingCurve() const; %End }; typedef QList QVariantList /DocType="Py_v3:list-of-object"/; // class QVariant /AllowNone,API=QVariant:2 -,DocType="object"/ %MappedType QVariant /AllowNone,API=QVariant:2 -,DocType="object"/ { %TypeHeaderCode #include %End %ConvertToTypeCode if (!sipIsErr) // We can always convert to a QVariant. return 1; // If it is a null QVariant then just return it. if (Py_TYPE(sipPy) == sipTypeAsPyTypeObject(sipType_QPyNullVariant)) { *sipCppPtr = reinterpret_cast( sipConvertToType(sipPy, sipType_QPyNullVariant, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); return 0; } QVariant var = qpycore_PyObject_AsQVariant(sipPy, sipIsErr); if (*sipIsErr) return 0; *sipCppPtr = new QVariant(var); return sipGetState(sipTransferObj); %End %ConvertFromTypeCode return qpycore_PyObject_FromQVariant(*sipCpp); %End // The following must match the v1 API. enum Type { Invalid, Bool, Int, UInt, LongLong, ULongLong, Double, Char, Map, List, String, StringList, ByteArray, BitArray, Date, Time, DateTime, Url, Locale, Rect, RectF, Size, SizeF, Line, LineF, Point, PointF, RegExp, Font, Pixmap, Brush, Color, Palette, Icon, Image, Polygon, Region, Bitmap, Cursor, SizePolicy, KeySequence, Pen, TextLength, TextFormat, %If (Qt_4_2_0 -) Matrix, %End %If (Qt_4_3_0 -) Transform, %End %If (Qt_4_5_0 -) Hash, %End %If (Qt_4_6_0 -) Matrix4x4, %End %If (Qt_4_6_0 -) Vector2D, %End %If (Qt_4_6_0 -) Vector3D, %End %If (Qt_4_6_0 -) Vector4D, %End %If (Qt_4_6_0 -) Quaternion, %End %If (Qt_4_7_0 -) EasingCurve, %End UserType, }; static const char *typeToName(QVariant::Type type); static QVariant::Type nameToType(const char *name); }; %If (Qt_4_5_0 -) typedef QHash QVariantHash /DocType="Py_v3:dict-of-str-object"/; %End QDataStream &operator>>(QDataStream &s, QVariant &p /Constrained/) /API=QVariant: - 2/; typedef QMap QVariantMap /DocType="Py_v3:dict-of-str-object"/; QDataStream &operator<<(QDataStream &s, const QVariant &p /Constrained/) /API=QVariant: - 2/; QDataStream &operator>>(QDataStream &s, QVariant::Type &p /Constrained,In/); QDataStream &operator<<(QDataStream &s, const QVariant::Type p /Constrained/); %If (Qt_4_3_0 -) void qSwap(QVariant &value1, QVariant &value2) /API=QVariant: - 2/; %End // QList is implemented as a Python list. %MappedType QList /DocType="list-of-QVariant.Type"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. for (int i = 0; i < sipCpp->size(); ++i) { QVariant::Type e = sipCpp->at(i); PyObject *eobj; if ((eobj = sipConvertFromEnum(e, sipType_QVariant_Type)) == NULL) { Py_DECREF(l); return NULL; } PyList_SET_ITEM(l, i, eobj); } return l; %End %ConvertToTypeCode // Check the type if that is all that is required. if (sipIsErr == NULL) { if (!PyList_Check(sipPy)) return 0; for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i) if (!sipCanConvertToEnum(PyList_GET_ITEM(sipPy, i), sipType_QVariant_Type)) return 0; return 1; } QList *ql = new QList; for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i) { long l = SIPLong_AsLong(PyList_GET_ITEM(sipPy, i)); ql->append(static_cast(l)); } *sipCppPtr = ql; return sipGetState(sipTransferObj); %End };