summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqltablemodel_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Use QList instead of QVector in sqlJarek Kobus2020-06-251-1/+1
| | | | | | Task-number: QTBUG-84469 Change-Id: I942aec7d949331a52d7f12fa2725d8d9707f605f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* More nullptr usage in headersKevin Funk2019-03-141-1/+1
| | | | | | | | | | | Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Initialize the QSqlQuery to be invalid when creating a sql modelAndy Shaw2018-08-281-1/+1
| | | | | | | | | | | | | | | When QSqlQueryModel or QSqlTableModel is created it will create a QSqlQuery which defaults to using the default QSqlDatabase connection. If this connection belongs to another thread then it will throw a warning as this is not safe to use. Since the QSqlQuery is always recreated when a query is set, the instance which is a member of the class can effectively be invalid until a new one is set. Task-number: QTBUG-69213 Change-Id: I68a5dd59fe62788f531d59a0680da11b118ee383 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Sql: Add a feature for the SQL item modelsUlf Hermann2018-02-201-0/+2
| | | | | | | | ... and make sure we can build if it's switched off. Change-Id: I9565a2ce632a861a99e1276f3edf4f0d094b5451 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QSqlTableModel: avoid copying QSqlRecord instancesDavid Faure2017-08-101-1/+1
| | | | | | | | | | | | | | Profiling a large model showed that QSqlRecord was being copied and destroyed from a few places, due to use of QMap<int, ModifiedRow>::value() where ModifiedRow has two QSqlRecord members. This can easily be avoided (in the common case with no modified rows) by using constFind() instead. My testcase (iterating over a model with 126936 rows) went from 1266 ms to 896 ms. Change-Id: I04e98b5573ef24165bf6cff19946e5bedd0fb0ba Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Unbreak ubsan developer-buildMarc Mutz2017-02-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | Clang 3.8's undefined-behavior sanitizer checks that the declared type of the object is a base class of the dynamic type of the object on each access to a member of a class type. It therefore requires the typeinfo for these types, which for polymorphic types is emitted in the TU where the vtable is emitted, too. QDBusConnectionPrivate is a polymorphic non-exported class, so this failed at link-time. Ditto for the other case. Fix by autotest-exporting the classes. Also, where applicable, de-inline the dtors, so the vtable (and typeinfo) are pinned to one TU, and the ctor, just because it's the correct thing to do. Change-Id: I991f81f88d2a48e85d94d9f3ac61473c0b7056d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qtsqlglobal.h and qtsqlglobal_p.hLars Knoll2016-07-031-0/+1
| | | | | | | | | | | | | | The new modular configuration system requires one global header per module, that is included by all other files in this module. QtSql already had such a header, but its name (qsql.h) was not in line with what's being used in all other modules. So add a qtsqlglobal.h header, deprecate qsql.h and turn it into a a forwarding header to that new global header file. Change-Id: Ibaeb95b008cf08ba062cbfe8a3f4d3bf79294390 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QSqlTableModel: expose methods for getting primary valuesMark Brand2013-04-021-3/+1
| | | | | | | These methods are very useful in subclasses. Change-Id: Ifdfee9d90cbdad97f349e46b587582f1d9e7cd7a Reviewed-by: Andy Shaw <andy.shaw@digia.com>
* QSqlTableModel: support refreshing inserted rows with auto columnsMark Brand2013-02-061-0/+1
| | | | | | | | | | | | | | | | | | Previously, selectRow() did not work after INSERTing a new row into a table with an automatically populated column. It did not work because the model did not know the primary values for the new row. Newly inserted rows were therefore not refreshed in OnFieldChange and OnRowChange edit strategies. This change provides support for the typical simple case where a single column is populated by the database and can be retrieved with QSqlQuery::lastInsertId(). Task-Number: QTBUG-29102 Change-Id: Ibf0f0ac8661185bde57034ddf40c2178bece4778 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Lukas Geyer <lgeyer@gmx.at> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* fix #includesMark Brand2012-10-021-1/+2
| | | | | | Change-Id: Ia33d7ef08e43bad95d57823e37757a09e53493b9 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QSqlTableModel::selectRow(): fix failure on uncached rowsMark Brand2012-09-241-6/+2
| | | | | | | | | | | | | | | | | | | | This method was originally intended for refreshing rows after submitting changes. It should also work for refreshing rows that are unchanged (i.e., not cached), but did not because constructing the primary values depended on the cache. As a consequence, the WHERE clause for the query was not created. Fixed by deriving primary values for uncached rows from the query record. Note that the cache is still authoritative for rows it holds. This is important because the prmary values there may differ from the original query record due to changes to columns of the primary key. Includes new test. Change-Id: I41cca2cbf26019d4b495ffa6d876e2b55ec57803 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* 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>
* QSql*Model: add SQL syntax helperMark Brand2012-03-221-0/+5
| | | | | Change-Id: Ia53e30d7a2f2bb5b4f76c32fcf0fe526d1e4ab51 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel bugfix: consider uncached rows submittedMark Brand2012-03-151-0/+2
| | | | | Change-Id: I7ec0529b88fd8e3ae0cf8dadfcb5899579e52745 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel: long live selectRow()!Mark Brand2012-03-071-0/+14
| | | | | Change-Id: If26dbcc8a1e8ef1376ef7a688c946ce5270e5706 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: handle changes between submit and selectMark Brand2012-03-071-7/+40
| | | | | | | | | | | | | | | | | | | | Once an insert has been submitted, the cached record behaves like an update. For row bookkeeping, we still have to remember that it was originally inserted and is not in the query rows. Between submitting a delete and selecting, we remove the values from the deleted record. This causes a blank row to be displayed. Read-only flag is set for cells in deleted row. Reverting between submit and select means going back to the last submitted values. When removing rows, it's better to process from highest row numbers to lowest. This avoids complications with higher rows shifting down when lower rows are removed. Change-Id: I8752fa11f7a1b88f2a71b9e03a020ac37e62487f Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel: derive primary values from database valuesMark Brand2012-03-061-0/+12
| | | | | | | | | | | 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-061-4/+8
| | | | | | | | | | | 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-061-1/+1
| | | | | Change-Id: I6d23788163ffd6ba7a8f01ed40910d861ff92703 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel::submitAll(): avoid resubmiting successful changesMark Brand2012-02-151-1/+4
| | | | | | | | | | | | | | 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-151-4/+2
| | | | | | | They can be generated on demand regardless of edit strategy. Change-Id: I1e1853e93cc453f1486b65ce577f00141b9c5c47 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: deduplicate and optimize counting of insertsMark Brand2012-02-151-0/+1
| | | | | | | | | 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>
* QSqlTableModel::primaryValues(): make constMark Brand2012-02-141-1/+1
| | | | | Change-Id: I6d53beb2b177dc5c71c74755f2fb602ab87502c0 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: do not suppress dataChanged() on inserted recordMark Brand2012-02-081-1/+3
| | | | | | | | | | | | | | | | | | | 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>
* QSqlTableModelPrivate::ModifiedRow guard private dataMark Brand2012-02-071-9/+15
| | | | | | | | | | | | | | | | 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-071-0/+1
| | | | | Change-Id: Ic969a192644e84d78558da0f19e588033e4af43d Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* merge private and public QSqlTableModel::setRecord()Mark Brand2012-02-051-1/+0
| | | | | Change-Id: I409bd32f85224db64363688d63fc372d1beaa0d3 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* ModifiedRow: use for all edit strategiesMark Brand2012-02-051-10/+6
| | | | | | | | | | | | 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>
* 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>
* improvements to ModifiedRowMark Brand2012-01-271-2/+7
| | | | | | | | | -remove unnecessary explicit copy constructor -explicitly inline constructor -more convenient initialization Change-Id: I78b275ef9d5413f95278a044345e42303dc35624 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* fix identation and styleMark Brand2012-01-271-1/+1
| | | | | | Change-Id: I18e9e752e8dc0cf980f424264f274177b98a98be Reviewed-by: Yunqiao Yin <charles.yin@nokia.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* 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>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+120
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12