1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
|
// qvariant.sip generated by MetaSIP on Sun Jun 24 12:29:12 2012
//
// This file is part of the QtCore Python extension module.
//
// Copyright (c) 2012 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// 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 <qvariant.h>
%End
class QVariant /AllowNone,API=QVariant: - 2/
{
%TypeHeaderCode
#include <qvariant.h>
%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<QVariant *>(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
%If (Qt_5_0_0 -)
Uuid,
%End
%If (Qt_5_0_0 -)
ModelIndex,
%End
%If (Qt_5_0_0 -)
PolygonF,
%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<QVariant> &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<QString, QVariant> &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;
%If (Qt_5_0_0 -)
bool canConvert(int targetTypeId) const;
%End
%If (- Qt_5_0_0)
bool canConvert(QVariant::Type t) const;
%End
%If (Qt_5_0_0 -)
bool convert(int targetTypeId);
%End
%If (- Qt_5_0_0)
bool convert(QVariant::Type t);
%End
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<QVariant> toList() const;
QMap<QString, QVariant> toMap() const;
%If (Qt_4_5_0 -)
QHash<QString, QVariant> 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;
%If (Qt_5_0_0 -)
static const char *typeToName(int typeId);
%End
%If (- Qt_5_0_0)
static const char *typeToName(QVariant::Type type);
%End
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
%If (Qt_4_8_0 -)
void swap(QVariant &other);
%End
};
typedef QList<QVariant> 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 <qvariant.h>
%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<QVariant *>(
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
%If (Qt_5_0_0 -)
Uuid,
%End
%If (Qt_5_0_0 -)
ModelIndex,
%End
%If (Qt_5_0_0 -)
PolygonF,
%End
UserType,
};
%If (Qt_5_0_0 -)
static const char *typeToName(int typeId);
%End
%If (- Qt_5_0_0)
static const char *typeToName(QVariant::Type type);
%End
static QVariant::Type nameToType(const char *name);
};
%If (Qt_4_5_0 -)
typedef QHash<QString, QVariant> QVariantHash /DocType="Py_v3:dict-of-str-object"/;
%End
QDataStream &operator>>(QDataStream &s, QVariant &p /Constrained/) /API=QVariant: - 2/;
typedef QMap<QString, QVariant> 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<QVariant::Type> is implemented as a Python list.
%MappedType QList<QVariant::Type> /DocType="list-of-QVariant.Type"/
{
%TypeHeaderCode
#include <qvariant.h>
%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<QVariant::Type> *ql = new QList<QVariant::Type>;
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<QVariant::Type>(l));
}
*sipCppPtr = ql;
return sipGetState(sipTransferObj);
%End
};
|