summaryrefslogtreecommitdiffstats
path: root/src/sql
Commit message (Collapse)AuthorAgeFilesLines
* QSqlTableModel::data(): use cached values when availableMark Brand2012-03-061-23/+3
| | | | | | | | | | Simplify logic. If the record is in the cache, even untouched values should be there. This is also necessary for getting the most up-to-date values between submitting and the next select. Change-Id: I8578d96229797ce9fb0d07fe456301358f2be071 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel: derive primary values from database valuesMark Brand2012-03-062-10/+13
| | | | | | | | | | | Primary values are used to map a row in the model to a row in the database table. It is critically important between submitting a change and the following select (which refreshes the query) to have updated primary values. Otherwise, if the change affected the primary values, additional changes before select will misbehave. Change-Id: I5d08dd70ac5d3f06cd9d3186a439f4c80a037c2d Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: mirror database values in change cacheMark Brand2012-03-062-7/+11
| | | | | | | | | | | Between submitting and the next select, these values will be more up-to-date than those that could be obtained from the query. This will be useful for constructing primary values and reverting changes made after submitting. Change-Id: I8317617f3e7043ad0b79b333731c55fb88aef171 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel: remove unnecessary parameter from setSubmitted()Mark Brand2012-03-062-2/+2
| | | | | Change-Id: I6d23788163ffd6ba7a8f01ed40910d861ff92703 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* Remove the usage of deprecated qdoc macros.Casper van Donderen2012-03-024-120/+120
| | | | | | | | | | | QDoc now has support for Doxygen style commands for italics, bold and list items. This change applies that change in QDoc to the actual documentation. Task-number: QTBUG-24578 Change-Id: I519bf9c29b14092e3ab6067612f42bf749eeedf5 Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QSqlTableModel: unify code for cache-clearing before selectMark Brand2012-02-281-19/+12
| | | | | | | | | | The code in submitAll() had the same goal as the code in select, so it has been unified. The new code in select() avoids sending lots of dataChanged() signals for rows that are going to be removed by QSqlQueryModel anyway. Change-Id: Ic22e038223720185e47ed0cc573147745ecc8fc9 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::isDirty(): simplify and improve logicMark Brand2012-02-281-17/+8
| | | | | Change-Id: Ic1332befa9078a94f872e38ff779e5b4cec7c100 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Clean up some Q_WS_WINDebao Zhang2012-02-241-2/+2
| | | | | | | | Q_WS_WIN does not exist any more. Change-Id: Icb7f542cfcd4d21e994f246ff665583cb6b57610 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* QSqlTableModel: rename parameter to avoid name clash with methodMark Brand2012-02-231-5/+5
| | | | | Change-Id: Ib8fa6b0ca71ffdd9f1f8416c448b5c830988ed08 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* QSqlTableModel: avoid extra QMap lookupMark Brand2012-02-231-7/+5
| | | | | | | | | The consensus on #qt-labs seems to be that there is little or no point in checking with contains() before using value(), even if the map does not contain the key in most cases. Change-Id: I34740a91d5c3af65e20937a5ae3b4bab32406440 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* fix styleMark Brand2012-02-231-2/+1
| | | | | Change-Id: I8ad0b4d15484662be7b38daa797a688727377c88 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* QSqlTableModel: document edit strategy behaviorMark Brand2012-02-231-2/+14
| | | | | Change-Id: Ib674288e950837aa343cf1206ed081386b1fff0d Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* improve documentation language styleMark Brand2012-02-231-1/+1
| | | | | Change-Id: Ic7daa90fff764578bd8122986a73c2ea6280e784 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* 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>