summaryrefslogtreecommitdiffstats
path: root/src/sql
Commit message (Collapse)AuthorAgeFilesLines
* Remove use of Q_BROKEN_DEBUG_STREAM.Stephen Kelly2012-02-221-6/+0
| | | | | | | | No supported compiler defines it, and it was not used consistently so it didn't work anyway. Change-Id: Icc9e911e22daaedaee3d9316c15d19be26cd2e72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Ensure that QSqlDatabase::database() is still thread-safeAndy Shaw2012-02-171-4/+1
| | | | | | | | | | | | | | | | QSqlDatabase::database() is documented to be thread-safe and when the driver is queried for the numericalPrecisionPolicy set then it can comprimise the thread-safety. Since the driver itself (if one is set) will be queried for the numericalPrecisionPolicy when numericalPrecisionPolicy() is called on the QSqlDatabase then we can have it fallback to the default instead rather than taking the driver's own setting. Task-number: QTBUG-13423 (cherry picked from commit e7e9fca6c0cd1d0869029fc6e9d7605234ee5bb2) Change-Id: Ie7e9fca6c0cd1d0869029fc6e9d7605234ee5bb2 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::indexInQuery(): fix for inserted rowsMark Brand2012-02-151-0/+3
| | | | | | | | Should return invalid QModelIndex since inserted row does not map to query. Change-Id: Ib1d15cf4198a7063717fb3f3b594b2b1d8a54dfe Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlRelationalTableModelPrivate: simplify field name translationMark Brand2012-02-151-9/+6
| | | | | | | | | | | | It's not appropriate to use indexInQuery() here. First of all, the row might be an inserted row, and thus not be in the query. The intent was probably to get the column position in the query, but this is certainly not row dependent. Furthermore, if there are inserted or removed columns, these are managed within QSqlQueryModel. Change-Id: I89668655b263747a5b849136404112e911722b3d Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::submitAll(): avoid resubmiting successful changesMark Brand2012-02-152-2/+20
| | | | | | | | | | | | | | Consider what happens the 1st change succeeds and the 2nd fails. No select will be done. When submitAll() is called again, the 1st will still seem to be pending. It will fail or have unexpected effects if the primary values were changed. The solution is to avoid resubmitting successful changes. We leave them in the cache so they stay visible. Submitted changes cannot be reverted of course. Change-Id: Ibf400555effa1c3801d02f8713b4b69856ede23a Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: do not store primaryValues in change cacheMark Brand2012-02-152-13/+7
| | | | | | | They can be generated on demand regardless of edit strategy. Change-Id: I1e1853e93cc453f1486b65ce577f00141b9c5c47 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::primaryValues(): take care of row mappingMark Brand2012-02-151-18/+13
| | | | | | | | | There is no reason for the caller to be concerned with this. primaryValues() now takes advantage of the fact that QSqlQueryModel uses indexInQuery which was recently made virtual. Change-Id: I7d856ee05f55c3199fd17c618e559320d0582989 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::commitAll(): replace row removal hackMark Brand2012-02-151-1/+13
| | | | | | | | | | | | | | | | | | | The purpose of the hack was to fool QSqlQueryModel into signaling the removal of extra rows via rowsRemoved(). The extra rows are the inserted rows generated by QSqlTableModel. While it is important to signal the removal of all the rows before requerying after committing changes, there is a cleaner way. The table model should remove its rows before the query model removes its rows. Iterating backwards avoids having to decrement row numbers above ones being removed. Expected test results have been adjusted for these changes. Change-Id: I0e8aa81f5e7b8fea5922f5ffd1cfb4a932313a10 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: deduplicate and optimize counting of insertsMark Brand2012-02-152-14/+18
| | | | | | | | | Reading STL iteration code is painful enough if you only have to do it once. Thiago suggested remembering the end iterator for performance. Change-Id: Ic2cdc480f591932ea420e692a4d2796d49f05313 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSql*Model: make indexInQuery() virtualMark Brand2012-02-152-18/+10
| | | | | | | | | Qt 5 seems like an excellent opportunity to simplify logic and separate concerns by making indexInQuery() virtual. Note that this wasn't my idea, but was mentioned in a helpful comment. Change-Id: Ie29ead110def45297c32de3ce6d07a8eefb08d8c Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::primaryValues(): make constMark Brand2012-02-142-2/+2
| | | | | Change-Id: I6d53beb2b177dc5c71c74755f2fb602ab87502c0 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::insertRecord(): clean up after failed setRecord()Mark Brand2012-02-091-1/+4
| | | | | Change-Id: Ic9f314144bd3ccf4b59b9cb3f0d79f8d6f97a824 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::setRecord(): improve handling of field mappingMark Brand2012-02-091-12/+22
| | | | | | | | | | -Only use fields where generated flag is set to true. -Require all fields to map correctly. If fields don't map, that is a sign of a programming or user error. Change-Id: Ie8474393005de6c9926b4e46985d62b194eafde2 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::insertRecord(): correct documentationMark Brand2012-02-091-3/+3
| | | | | Change-Id: I35680f842a650493cf530c0b74894e2b45aa3c6e Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Introduce Q_DECLARE_OPAQUE_POINTERJoão Abecasis2012-02-094-40/+10
| | | | | | | | | | | | To hide the IsPointerToTypeDerivedFromQObject monstruosity :-) Documentation for Q_DECLARE_METATYPE and qRegisterMetaType was updated to mention requirements on registered types and how they can be circumvented for pointer types with the new macro. Change-Id: If83b037a8e2f28761eb903525e87008107298801 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* QSqlTableModel::setRecord(): emit dataChanged() consistentlyMark Brand2012-02-081-10/+5
| | | | | | | | | | | | | | | Previously, if any fields in the supplied record could not be matched with a column in the target table, dataChanged() was supressed for all columns for OnManualSubmit. This is not good because it prevents other views from noticing the fields that *do* change. It's simplest and probably more efficient just to emit dataChanged() once for the whole row. Fewer signals need to be processed and in typical cases much or all of the row is likely to be changed anyway. Change-Id: Ib56bf9a18e51b9cb85771acefcb2bf26e295a54e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::setRecord(): do not try to detect value changesMark Brand2012-02-081-9/+2
| | | | | | | | | | | | | | | | | | | | | | | In an apparent attempt to be economical with emitting dataChanged() and submitting SQL to the databse, setRecord() compares each field value of the record with the old value, taking action only when a difference is detected. Several complaints against this code are: -The comparision does not work on float type. -It is really up to the application and database to decide this. The model should make few assumptions. The application has the option to omit fields from the record that should be ignored. -The current behavior seems to assume that the "old" values are the current state of the database, but the database may have changed since the model was last refreshed. -The code compares the value from record(), which probably corresponds to the EditRole, with the DisplayRole value from data(). Change-Id: I11477c185eb411d442144dc682893d0df12d03d5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::setData(): submit() instead of updateRowInTable()Mark Brand2012-02-081-10/+3
| | | | | | | | | | Use submit() instead of calling updatRowInTable(). The effect is exactly the same. Submit() invokes submitAll() which invokes updateRowInTable(). The cache is purged and select() is called only on success. Change-Id: I3de9a3d6acf802ee6594d034a9e261e53637995d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::setData(): call dataChanged() before select()Mark Brand2012-02-081-2/+1
| | | | | | | | | Emit dataChanged() before a possible new select instead of after. The select reinserts all the rows, emitting signals for that, so there isn't any point to dataChanged() afterwards. Change-Id: I698a0d385f97104891343d94cc27e4ecf3a7233c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel: do not suppress dataChanged() on inserted recordMark Brand2012-02-082-18/+16
| | | | | | | | | | | | | | | | | | | Affects setData() and setRecord(). Previously dataChanged() was suppressed when editing an inserted record, except for OnManualSubmit. The motivation was probably to allow setData() to be used while handling primeInsert(). Suppressing dataChanged() is not a good idea since views other than the one which made the change will not know of the change. It is a terrible idea to call setData() or setRecord() while handling primeInsert(), so this is now expressly forbidden. setData() and setRecord() now do nothing and return false if called while rows are being inserted. Change-Id: I96738c09a6268704c5626d95b72bfb46378e3242 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::setRecord(): use submit for OnFieldChangeMark Brand2012-02-081-1/+1
| | | | | | | submitAll() is supposed to be for OnManualSubmit. Change-Id: Id0335fe731669bd24e1da72ab4724f88d6f1d905 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::removeRows(): require valid full range of rowsMark Brand2012-02-071-13/+20
| | | | | | | | | | | | | | | If an invalid range of rows is specified, it's likely to be a programming or user error. The old behavior of ignoring out of range rows seems dangerous and complicates the code. Also implement the documented behavior of returning false if changes are unsuccessful for OnFieldChange and OnRowChange. Previously the return value of submit() was ignored. Updated and improved documentation. Change-Id: Iaaf51c6d9a0c8c06fd5d186b4b88358fbeab9936 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::removeRows(): don't emit extra beforeDeleteMark Brand2012-02-071-8/+0
| | | | | | | | Qt 5 seems like a welcome opportunity to stop emitting this spurious beforeDelete signal. Change-Id: Ib8628343ca9b8fdd85c154a206c7e2bf2c4c9dc1 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModelPrivate::ModifiedRow guard private dataMark Brand2012-02-073-47/+53
| | | | | | | | | | | | | | | | Even though ModifiedRow is not part of the public API, guarding its data helps make clear the intended patterns of use. "op" and "primaryValues" are read-only after construction. setValue() encourages maintainers to let ModifiedRow manage the "generated" flags of the record. The primeInsert() signal still exposes the actual record, including the "generated" flags, which is the justification for recRef(). Change-Id: I16d1610a8f9233af78b90662b08706b48ea19c41 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModelPrivate: deduplicate field stripping logicMark Brand2012-02-073-4/+8
| | | | | Change-Id: Ic969a192644e84d78558da0f19e588033e4af43d Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* reduce cost of checking cache for data() and headerData()Mark Brand2012-02-051-22/+27
| | | | | | | Assume requested row is usually not cached. Change-Id: I7727b431cc3841528aa6390400b93b1218773e65 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::setData(): comment historical idiosyncraciesMark Brand2012-02-051-0/+14
| | | | | Change-Id: I5c4782e18dc7a471dc294a4146db04f1efd3ed2e Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* refactor QSqlTableModel::setData()Mark Brand2012-02-051-38/+20
| | | | | | | | | | | | | -move logic out of switch statement -clear cache more clearly for OnFieldChange -call setValue() in one place instead of two -eliminate extra return path Existing idiosyncracies have been kept for the time being. Change-Id: Ia4c5a5fd3e374b53e3c4d870f2ee9d37b5090917 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* refactor QSqlTableModel::setRecord()Mark Brand2012-02-051-40/+37
| | | | | | | | | | | | | | | | | | -Do not use setData() We're using ModifiedRow now so it makes sense to buffer the changes and submit the row at once. This improves readability and encourages further haromonization of the editing strategies. -No longer need temporary change to OnRowChange Previously, the strategy was temporarily changed from OnFieldChange to OnRowChange in order to obtain the desired behavior from setData(). Now, since we don't use setData(), we can program the desired behavior here and don't need this trick. -Comment historical idiosyncracies/bugs Change-Id: I6d9e2a69e1571a74c630ad1392e15b60fc0ad3f2 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* merge private and public QSqlTableModel::setRecord()Mark Brand2012-02-052-33/+22
| | | | | Change-Id: I409bd32f85224db64363688d63fc372d1beaa0d3 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* ModifiedRow: use for all edit strategiesMark Brand2012-02-053-255/+139
| | | | | | | | | | | | Previously ModifiedRow was used only for OnManualSubmit and a seperate buffer and utility methods were used for OnFieldChange and OnRowChange. Also, initialization of the edit buffer is done by ModifiedRow instead of a helper function. Change-Id: I3316498e5bb10c416138ca14c3a7f8b143c8e544 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Handle the 'real' datatype correctly in the SQLite driverAndy Shaw2012-02-031-0/+1
| | | | | | | | | | | | | | | The 'real' datatype should be seen as a QVariant::Double type and not as a QVariant::String type otherwise it does not get presented correctly when using a non Qt application to access it. Test is included for QSqlQuery. Task-number: QTBUG-16373 Change-Id: Ie323ce49eb95e4d6bb4c3814ba9a957a63f4b259 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com> (cherry picked from commit b23631015c23a49e3b4d296ea0a6266bfce3d4f1) Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Various documentation fixes ported from Qt 4.8Teemu Katajisto2012-02-021-2/+3
| | | | | | | | | | | | | | | Selected fixes for qtbase from 4.8 commit 3826203f744a2147bebf5f088de0d524156f59fd Task-number: QTBUG-9466 Task-number: QTBUG-7924 Task-number: QTBUG-20355 Task-number: QTBUG-19367 Task-number: QTBUG-14554 Change-Id: I551251dd8a87d7dd837e5927050ffd14bce9a97c Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* SQL driver implementation to signal notification sourcesTorben Dannhauer2012-02-014-6/+24
| | | | | | | | | | | Implements the new notification signal in all QSql drivers which use notifcation. In qt5 only ibase and psql have a notification implementation. PSQL differentiates correctly between 'SelfSource' and 'OtherSource' whereas ibase only signals 'UnknownSource' as a default implementation. Change-Id: Ifcaa139b7a980ed852cf817b3f93284609360ca7 Reviewed-by: Torben Dannhauer <torben@dannhauer.info> Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Interface definition to provide notifications with a source information.Torben Dannhauer2012-02-012-0/+13
| | | | | | | | To differentiate between signals of different sources types, this submission adds an enum and extra signal to provide it. Change-Id: Iad711739c41894e9c74d83072c50ae17edc695f2 Reviewed-by: Torben Dannhauer <torben@dannhauer.info> Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Revert "Put the generated <module>version.h into build tree"Bradley T. Hughes2012-02-011-1/+1
| | | | | | | | | After discussion with Liang, I'm reverting it as he requested. This change put every header into the SYNCQT.HEADER_FILES twice for in-source builds, and the qtMODULEversion.h header did not include a path component. This reverts commit 2fbc45b58bba860abf67fb28aa1319c9f4ededaf Change-Id: Ie84cef19193ce5e49072f1f67a41140d9d2673b8 Reviewed-by: Liang Qi <liang.qi@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-3051-51/+51
| | | | | | | | | | 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>
* Put the generated <module>version.h into build treeLiang Qi2012-01-281-1/+1
| | | | | | | | | It was put in source tree before. Task-number: QTBUG-20439 Change-Id: Ib52d9c2e83ae375aad259ddc74138bbc728b3ed0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* improvements to ModifiedRowMark Brand2012-01-272-16/+19
| | | | | | | | | -remove unnecessary explicit copy constructor -explicitly inline constructor -more convenient initialization Change-Id: I78b275ef9d5413f95278a044345e42303dc35624 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* use nameToIndex() instead of duplicating codeMark Brand2012-01-272-6/+7
| | | | | Change-Id: If55541aa8a2345f90984d8b82bee0c3ebb01a605 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* fix identation and styleMark Brand2012-01-272-2/+3
| | | | | | Change-Id: I18e9e752e8dc0cf980f424264f274177b98a98be Reviewed-by: Yunqiao Yin <charles.yin@nokia.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-2514-14/+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>
* Fix a compile error in qsql_sqlite2.cppLars Knoll2012-01-251-0/+8
| | | | | | | | | The compile error got introduced due to the change in QMetaType requiring fully defined types for pointers. Change-Id: I6383ff5923fc1d5bd3c1161e2823e83f2a06a99e Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Store the is-a QObject fact with the metatype declaration.Stephen Kelly2012-01-243-0/+34
| | | | | | | | | | | | | | This is a source incompatible change for Q_DECLARE_METATYPE(T*), which now requires T to be fully defined. The consequences of this are: * Forward declared types can no longer be declared as a metatype. (though this is a very uncommon thing to do). There is a trivial workaround where necessary. Change-Id: Id74c40088b8c0b466fcd7c55abd616f69acc82c8 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove Symbian specific code from QtSql.Xizhi Zhu2012-01-232-13/+0
| | | | | Change-Id: I3fc538862c7334914ec9e4331ef2d3db5c699ea9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-2351-51/+51
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Rename all our interfaces from com.trolltech to org.qt-projectLars Knoll2012-01-191-1/+1
| | | | | | Change-Id: I6db7211fcf6b24bd75e360645bbb2fdf1ef8a8bc Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Fix compilation of Qt itself with QT_NO_DEBUG_STREAMDavid Faure2012-01-121-2/+2
| | | | | | | Change-Id: I07087dff0f109347ea80434f17eeb7cc1c13114c Reviewed-by: Jonas Gastal <jgastal@profusion.mobi> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Fix documentation.Frederik Gladhorn2012-01-061-2/+2
| | | | | Change-Id: Id54263f408e29ed3b9d06712e39759485a42b869 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-0551-51/+51
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>