summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.h
Commit message (Collapse)AuthorAgeFilesLines
* MetaType: de-inline the container iterables.Stephen Kelly2013-09-201-148/+60
| | | | | | | | This means the *Iterables and corresponding const_iterators need to be exported. Change-Id: Ic93283616bda96e0d7752b0e881bf0230a5c2146 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MetaType: Add assignment operator to the container iterators.Stephen Kelly2013-09-191-0/+20
| | | | | Change-Id: Ib4f2197a0ab6bd41c91de667cd3087fb40e44097 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MetaType: Fix memory leak of QAtomicInt.Stephen Kelly2013-09-171-0/+2
| | | | | Change-Id: I04c87c4caeb96c820c4d332a803cb2824fea5891 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MetaType: Fix operator{++,--}(int) with the type-erased const_iterators.Stephen Kelly2013-09-171-4/+4
| | | | | | | | | | Similar to commit 8b062418 (MetaType: Fix operator{+,-}(int) with the type-erased const_iterators., 2013-09-11), explicitly create a copy of the iterator and intialise it. Change-Id: I8b9edef40ca00c826f72768cba4a0992e55371f8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MetaType: Fix operator{+,-}(int) with the type-erased const_iterators.Stephen Kelly2013-09-131-4/+4
| | | | | | | | Make sure we don't modify the lhs. Instead copy it and advance the copy. Change-Id: I3440e8e175bfc299f8f83b816faca54fa3f79e43 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QVariant: Make it possible to extract a QObject* from a wrapper without ↵Stephen Kelly2013-09-051-1/+3
| | | | | | | conversion. Change-Id: I3a054d87d12e08d72dd4c77b6d467dc63f9a2231 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Core: QDebug and comparison operator support metatypes.Christoph Schleifenbaum2013-05-271-0/+9
| | | | | | | | This patch adds a way to enable operator<, operator== and operator<< into QDebug for QVariants with custom types. Change-Id: I3d12d891bd7252ad2b8f1de69bced354800a1f29 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Make it possible to access QPair and std::pair elements from a QVariant.Stephen Kelly2013-05-201-0/+26
| | | | | Change-Id: I9dc73748073d0d1e43bdadbce73339dfcc1bc647 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Add container access functionality for associative containers in QVariant.Stephen Kelly2013-05-201-0/+142
| | | | | Change-Id: I4763a4c157e52918a0a68cba63624c0649aca235 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Add QVariantList extraction from a QVariant with a sequential container.Stephen Kelly2013-05-081-0/+16
| | | | | Change-Id: Id9fac7bf47ed3fbb385222b25941215ac24b8b88 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Add QVariant container iteration API.Stephen Kelly2013-05-081-2/+92
| | | | | | | | | | | | | | | | | | A new set of classes is introduced for iterating over the contents of a container within a QVariant without knowing the exact type of the container, but with the guarantee that the element type within the container is a metatype. The implementation of the iterable interface uses the stl-compatible container API so that we can also iterate over stl containers, or any other container which also conforms to stl norms. This enables the functionality in the bug report. Task-number: QTBUG-23566 Change-Id: I92a2f3458516de201b8f0e470982c4d030e8ac8b Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Core: Support for converting user defined QVariant types.Christoph Schleifenbaum2013-05-081-5/+3
| | | | | | | | | | | | | | | | | This patchs allows the user to convert defined QMetaType types like MyType to be converted by using e.g. QVariant::toString(), mapping to MyType::toString(). Also all the other QVariant::toXYZ() methods are supported so far. The patch adds static methods QMetaType::registerConverter supporting: - implicit convertion - conversion using member method of source type - conversion using unary functor Change-Id: I4f1db83d9c78bcc9df5c42f82f95cce0480cdcc3 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* qMetaTypeId(): deprecate the dummy parameter.Olivier Goffart2013-02-081-3/+3
| | | | | | | | | | | | | | It was there because of MSVC6 compatibility. It is not removed, because some code used to do qMetaTypeId(&myVariable); This was not a documented feature anyway, so it should not be user visible. Change-Id: I55327d7e73e67a6bb741817741d530d5a650291a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-221-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsavefile_p.h src/corelib/tools/qregularexpression.cpp src/gui/util/qvalidator.cpp src/gui/util/qvalidator.h Change-Id: I58fdf0358bd86e2fad5d9ad0556f3d3f1f535825
| * Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | | | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge branch 'stable' into devSergio Ahumada2013-01-091-2/+2
|\| | | | | | | Change-Id: I7f0dab6bdb1f3cc1d3e6c30166ff6db9dfae37e9
| * Replace macro qdoc with Q_QDOCDebao Zhang2013-01-081-2/+2
| | | | | | | | | | | | | | | | Both qdoc and Q_QDOC are used in source code, which looks not good. Change-Id: I4f3a71670278b0758d92bfa5db086a07e1b1acfd Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* | Rename QRegularExpression-related feature defs to QT_NO_REGULAREXPRESSIONGiuseppe D'Angelo2013-01-071-9/+11
|/ | | | | | | | | | | | QRegExp and QRegularExpression are totally independent, therefore using two different defines is the right thing to do. Also, document the new define in qfeatures.{txt,h}. Change-Id: Ice4826ea543f4b22f1cc27bf31ed6e043d0c43b0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Delete the QVariant ctors taking global Qt enum values.Stephen Kelly2012-10-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They have unexpected results in Qt 5 (the Qt::GlobalColor one works as expected in Qt 4, but was removed in Qt 5): QVariant v = QVariant(Qt::red); qDebug() << v; // QVariant(int, 7) v = Qt::red; qDebug() << v; // QVariant(int, 7) The correct way is to use: QVariant v = QVariant::fromValue(QColor(Qt::red)); The deleted constructors are the ones for which there is a class with an implicit constructor taking the enum, and that class is a built-in metatype. QLocale::Language and QKeySequence::StandardKey would also fit the description, but I can't include the header for QKeySequence as it is in QtGui, and I don't want to include the qlocale header in qvariant.h. Putting a QLocale::Language is probably very uncommon anyway. The QTextFormat test is doing the wrong thing, but the result isn't being tested. Added new tests which fail before the patch. Change-Id: Ia38a0784990f4d40ff7457a86daf58aabd4964eb Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QVariant: prevent QVariant(QMetaType::Type) from compilingMarc Mutz2012-09-071-0/+7
| | | | | | | | Reported-by: Stephen Chu <stephen@ju-ju.com> Change-Id: I298973174ff10f4462f04f3358c974c04dfd3383 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Stephen Chu <stephen@ju-ju.com>
* De-inline QVariant(float)Harald Fernengel2012-08-231-1/+1
| | | | | | | | | All QVariant constructors are not inline, so change QVariant(float) as well. This allows for refactoring of QVariant during lifetime of Qt 5 without breaking QVariant(float) case. Change-Id: Icd1fc331a1ef8a2872be811aa7d1160406038f06 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Speed up construction of basic QVariantsHarald Fernengel2012-08-151-1/+8
| | | | | | | | | | | | | | | | | Instead of first creating an initialized Private struct, then overwrite the member variables, we added an internal constructor that initializes the private struct sanely. In the new (inlined, internal) constructor, both the MSB bits in the bitfield are 0, and since the value of internal meta-type ID is so low that the two MSB bits should never be set, the compiler can (hopefully) optimize away the bit-fiddling initialization of the bit-field. Callgrind shows about 33% speed-up in e.g. QVariant::QVariant(int) Change-Id: I706773a71c0d8dcbe119ad15411578b81892deb5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Implement implicit constructors for built-in classes.Stephen Kelly2012-07-271-0/+12
| | | | | | Change-Id: I6b0b104bc1da3252d014615c50b81830de42e722 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Q_DECLARE_SHARED: mark the type movableMarc Mutz2012-07-101-1/+0
| | | | | | | | | | All implicitly shared classes are by definition movable, so this patch adds Q_DECLARE_TYPEINFO(Type, Q_MOVABLE_TYPE) to Q_DECLARE_SHARED. Change-Id: Idf8989ae1a7ed6d1ac13fccb7eaef7395a875350 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Replace `const QLatin1String &` with `QLatin1String` where appropriateKonstantin Ritt2012-05-251-1/+1
| | | | | | | Task-Id: QTBUG-24502 Change-Id: I360dee4dc68c165de0631ce4cf34e76fd873080e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move QIcon metatype handlers back to QtGuiOlivier Goffart2012-05-181-1/+1
| | | | | | | | | | | QIcon has been moved back from QWidget to QtGui, so the QIcon QVariant and QMetaType handler can now be moved back to QtGui. Also we can give back QIcon its old number, allowing to get rid of some compatibility hack when unstreaming QVariant Change-Id: I439d5c2987c06ecd619f394407850f678164afb8 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Implement the move constructor for containers.Olivier Goffart2012-05-111-0/+2
| | | | | | | | | | | | | | | This changes all the containers that uses QtPrivate::RefCount (QMap already had one), and QVariant In Qt 4.8, it was pointless to have the move constructor because we did not have quick way to re-initialize a null container. (shared_null still needed to be refcounted) But now that we have RefCount, and that the shared_null do not have reference count, we can implement a fast move constructor that do not generate code to increment the reference count. Change-Id: I2bc3c6ae96983f08aa7b1c7cb98d44a89255160b Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Introduce a new built-in type: signed char.Jędrzej Nowacki2012-05-081-0/+1
| | | | | | | | | | | | C++ distinguish between "char", "signed char" and "unsigned char", they are three independent types. Fix QVariant behavior on ARM. On ARM "char" may mean "unsigned char", but we depends on the sign during a numerical conversions. Change-Id: I610ce3fb88ed5964b67f3ae442d264fe16b2d261 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QVariant constructor taking Qt::GlobalColor.Jędrzej Nowacki2012-04-191-1/+0
| | | | | | | | The constructor is wrong, it creates instance of QVariant encapsulating a QColor instance. QVariant should not implicitly convert data, never. Change-Id: Idc794ecdecb42d8b53fee3f993bf51ddd43f595d Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Disable QUrl support in QVariant in bootstrapped modeThiago Macieira2012-03-241-2/+2
| | | | | | | | | | The only use of QUrl in qmake, moc, uic and rcc is due to QVariant's internals, so let's disable it. This means those binaries are now probably a lot smaller since the parsing and IDNA code don't need to be present. Change-Id: Ie156b0817d119b2ba5d3dcb9712a9fea2ee7d4a1 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* QRegularExpression: QMetaType and QVariant supportGiuseppe D'Angelo2012-03-141-3/+11
| | | | | | | | | Removed the Q_DECLARE_METATYPE in favour of first-class support inside QMetaType and QVariant. Change-Id: I904236822bfab967dc0fbd4d4cc2bcb68c741adc Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Introduce QMetaType::UnknownType.Jędrzej Nowacki2012-03-021-1/+1
| | | | | | | | | | | | | | | | | QMetaType::Void was ambiguous, it was pointing to a valid type (void) and in the same time it was signaling errors in QMetaType. There was no clean way to check if returned type was valid void or some unregistered type. This feature will be used by new QMetaObject revision which will store type ids instead of type names. So it will be easy to distinguish between: void mySlot(); MyUnregisteredType mySlot(); Change-Id: I73ff097f75585a95e12df74d50c6f3141153e771 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Cleanup usage of QVariant::Type.Jędrzej Nowacki2012-02-271-9/+9
| | | | | | | | | QVariant::Type is marked as obsolete. It is not possible to get rid of it completely, in a source compatible way, but at least we can remove it safely from a method arguments list. Change-Id: I26b58099bfa6d32f3a583a8ae0047f0bb36bcd0d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QT_ASCII_CAST_WARN_CONSTRUCTORStephen Kelly2012-02-231-1/+1
| | | | | | | GCC version < 3 which it was created for is not supported anymore. Change-Id: I0b4df4c99600cacbaafbf0bc4270cd4978600956 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* replace 'const QChar &' with 'QChar ' where appropriateKonstantin Ritt2012-02-211-1/+1
| | | | | | | | | as QChar is actually an ushort and there is no point in taking its address. Merge-request: 69 Change-Id: Idcc9d621e5627514ade006aa12a789a88929d48b Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Treat pointers to QObject derived types in QVariant specially.Stephen Kelly2012-02-081-10/+62
| | | | | | | | | | | | | | | | It is possible to do this for example: QVariant v = QVariant::fromValue<MyCustomQObject*>(); QObject *object = v.value<QObject*>(); This means that if a QVariant contains a pointer to a QObject derived type, third parties can extract a QObject* and use its properties without knowing the concrete type. This is a source compatible change. Change-Id: Iee9a9437e99cc2f40d1a4bfea47275482ef7161f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Align QVariant::UserType and QMetaType::UserJędrzej Nowacki2012-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | There is no point in keeping separate values which should mean the same. QVariant::UserType was used also to construct a valid, null QVariant, containing an instance of unknown custom type. The concept was strange and useless as there was no operation that could be done on such QVariant. Therefore it was dropped. Please note that the patch slightly changes behavior of different functions accepting a type id as parameter. Before QVariant::UserType was an invalid type from QMetaType perspective (id 127 was not assigned to any built-in type), but QMetaType::User points to the first registered custom type. Change-Id: I5c7d541a9affdcdacf53a4eda2272bdafaa87b71 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Andrew Stanley-Jones <andrew.stanley-jones@nokia.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
* Remove many deprecated methodsLars Knoll2012-01-311-1/+1
| | | | | | | | | | Remove methods that have been marked as deprecated before Qt 4.6. Keep others, but inline them where possible and mark them as QT_DEPRECATED_SINCE(5, 0). Change-Id: If881821ae095f054b31cc13464f19e2007c20ed7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fix visibility of QVariant functions.Jędrzej Nowacki2012-01-181-1/+1
| | | | | | | | | | Change "Refactor QVariant handlers." 08863b6fdaa8383e2274826db3ec42c4d4f11576 changed visibility of two methods; QVariant::create and QVariant::cmp. These methods are internal for Qt usage, but there is no need for breaking a dependent code. Change-Id: Ic3a7f95dea5fa3e697f0686ae5d32dade24f14df Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Add QModelIndex as a built-in metatype.Stephen Kelly2012-01-111-0/+1
| | | | | Change-Id: Ib87cfff8b4baee78189f3df5e20d2e1a00d690e1 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Reimplement QVariant to QDebug streaming.Jędrzej Nowacki2012-01-101-0/+1
| | | | | | | New implementation fixes some commented code marked as FIXME. Change-Id: If8f5bebedd65bcf8f839d804c2022ca79ef82ddf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* C++11 delete some contructors which are not wanted.Stephen Kelly2012-01-101-2/+2
| | | | | | | Change-Id: I844a0872e81f1824928814edb8d21c0b6384283d Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Registered QUuid in the metatype system as a builtin type.Denis Dzyubenko2012-01-051-0/+1
| | | | | | | Change-Id: I6be6129d9f6bf468ba8a5805cfa0f6f79199afb3 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Prasanth Ullattil <prasanth.ullattil@nokia.com>
* Refactor QVariant handlers.Jędrzej Nowacki2012-01-041-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | QVariant implementation is based on delegation to a handler. The handler has rather simple construction, it is a set of function that implements a switch statement over known types and redirects calls to a right method of an encapsulated types instance. Unfortunately after qt modularization project, it is not easy to use types directly from different modules, as they can be undefined or completely unaccessible. Which means that each module has to implement own handler to cooperate correctly with QVariant. We can suspect that list of modules known to QVariant will grow and it is not limited to GUI, Widgets and Core, therefore it would be nice to have an unified, from performance and source code point of view, way of working with handlers. This patch is an attempt to cleanup handlers. Keynotes: - Each handler is working only on types defined in the same module - Core handler implements handling of primitive types too - Custom types have an own handler - Each handler is independent which means that dispatch between handlers is done on QVariant level - Handlers might be registered / unregistered using same interface Change-Id: Ib096df65e2c4ce464bc7a684aade5af7d1264c24 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>