summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqlquerymodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QSqlQueryModel: memoize roleNames()Marc Mutz2025-03-201-1/+2
| | | | | | | | | | | | | | | The return value of this function is constant and some users (QML?) may call this function often, so memoize the result of the function instead of re-creating the QHash on every call. Amends 40206a9f6d7635bb19305d1c8d74908808e3529e. Not picking to Qt 5, because I'm unsure about the state of magic statics there, and I don't want to take out the Q_GLOBAL_STATIC sledgehammer. Pick-to: 6.9 6.8 6.5 Change-Id: I8311e93ea16982c82e8312e1e104d95ed062fe6b Reviewed-by: Edward Welbourne <[email protected]>
* QSqlQueryModel: restore RVO in data()Marc Mutz2025-03-171-4/+3
| | | | | | | | | | | | | | | | | The return of a default-constructed QVariant 'v' from three branches invites NRVO, but most compilers won't let it kick in, because there are two return statements that don't return 'v'. Return an rvalue from each branch, so RVO is guaranteed (since C++17) to kick in. Amends the start of the public history. Picking back all the way, since it's risk-free. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I495885bee3ebba63c9e52640903c792011c1dee2 Reviewed-by: Christian Ehrlicher <[email protected]>
* QSqlQuery: complete the deprecation/removal of its copiesGiuseppe D'Angelo2025-02-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSqlQuery has been made movable in Qt 6.2 (14f9f00fdb2dc428610c08e3d9d03e38e9602166). The pre-existing copy operations have been deprecated, but not removed, in order to preserve SC/BC. This left us with two issues: 1) Whether or not to keep the deprecated copies in Qt 7. The answer is no: the copy operations are impossible to implement in a way consistent with value semantics (the state of the DB driver can't be copied in general). Therefore, mark the related APIs as to-be-removed, and not just deprecated. 2) While we no longer copy QSqlQuery from Qt code directly, QMetaType still detects the presence of the copy constructor and extracts it, triggering the deprecation warning. Rather than unconditionally suppressing the warning (which will hide any similar issue we might have in the future), add a local workaround that raises a runtime warning if QSqlQuery is copied through QMetaType, while not raising the deprecation warning when building Qt itself. [ChangeLog][QtSql][QSqlQuery] Copying a QSqlQuery object via QMetaType now raises a runtime warning. Note that copy operations for QSqlQuery objects have already been deprecated since Qt 6.2, and are planned to be removed in Qt 7. Fixes: QTBUG-132752 Task-number: QTBUG-91766 Pick-to: 6.9 Change-Id: I48714ad53ec706a5e4e055c45a1c05f372382940 Reviewed-by: Marc Mutz <[email protected]>
* QSqlQueryModel: add new function to refresh the model dataChristian Ehrlicher2024-12-201-18/+5
| | | | | | | | | | | | | | This function re-executes the query used by QSqlQueryModel and refreshes the data from the database. The query must not use bound values as these values are not preserved. [ChangeLog][QtSql][QSqlQueryModel] Added refresh() to refresh the model data from the database. Pick-to: 6.9 Task-number: QTBUG-123603 Change-Id: I3f1d779e07b88565abe825c31cfc4d7d1b2312c4 Reviewed-by: Volker Hilsheimer <[email protected]>
* QSqlQueryModel: New method to re-execute the current queryDheerendra Purohit2024-11-201-0/+29
| | | | | | | | | | | Add refreshQuery() and refreshQuery(const QSqlDatabase &db) to refresh the model data. [ChangeLog][QtSql][QSqlQueryModel] Added refreshQuery() and refreshQuery(const QSqlDatabase &db) to refresh the model data. Fixes: QTBUG-123603 Change-Id: I6738006dd8ca2fc82f3b4ad88b663c7b353a09f6 Reviewed-by: Christian Ehrlicher <[email protected]>
* SQL/models: use qsizetype/range-base for loops where possibleChristian Ehrlicher2024-05-231-4/+3
| | | | | | | | Replace some 'native' for loops with range-base for loops or use qsiztype instead int, mark some helper functions as const. Change-Id: Ib3f368d6c07bc170ab4ed7cbf28181a226dbeac5 Reviewed-by: Axel Spoerl <[email protected]>
* SQL: remove outdated \since tagsChristian Ehrlicher2024-01-211-7/+0
| | | | | | | | There is no need to know if a function was added in Qt4 or earlier so remove all \since 4.x tags Change-Id: I5cf4e89a3e30c13fac076f1ae7abb33a625e366c Reviewed-by: Kai Köhne <[email protected]>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* Make QSqlQueryModel::query() return a reference to the const QSqlQueryIvan Solovev2022-08-101-5/+2
| | | | | | | | | | | | | | | Returning QSqlQuery instance by value does not make much sense, because it cannot be copied correctly. Also, its copy constructor and copy-assignment operators are deprecated from Qt 6.2. [ChangeLog][Potentially Source-Incompatible Changes][QSqlQueryModel] QSqlQueryModel::query() now returns a reference to the const QSqlQuery object associated with the model. Task-number: QTBUG-105048 Change-Id: I04a2aa377b17d770d2a9855040f8c730190484d8 Reviewed-by: Marc Mutz <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* QSqlQueryModel: guard the definition of deprecated methodIvan Solovev2022-08-101-1/+2
| | | | | | | | | | | | | ... to prevent compilation errors when built with QT_DISABLE_DEPRECATED_BEFORE >= 0x060200 This commit amends 14f9f00fdb2dc428610c08e3d9d03e38e9602166 Task-number: QTBUG-105048 Pick-to: 6.4 6.3 6.2 Change-Id: I33c586508353ccb4c0af3f5da0cdaf9abe9f590e Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Giuseppe D'Angelo <[email protected]>
* 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 <[email protected]> Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Jörg Bornemann <[email protected]>
* QtSql: includemocsMarc Mutz2022-04-281-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: Id758d672710ba998595824645e3e16e00537781d Reviewed-by: Thiago Macieira <[email protected]>
* Sql: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-191-2/+3
| | | | | | Task-number: QTBUG-98434 Change-Id: Ie12ca82fd912617eabe4f602c08914f12878cb32 Reviewed-by: Volker Hilsheimer <[email protected]>
* Doc: Ensure deprecated APIs in Qt Sql are documented as suchNico Vertriest2021-07-221-2/+1
| | | | | | | | | Added \deprecated + [version_since] where needed Fixes: QTBUG-94585 Pick-to: 6.2 6.1 Change-Id: Id6d1fee1bbb6f8194e90a494673edef34530482b Reviewed-by: Andy Shaw <[email protected]>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-1/+1
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <[email protected]>
* QSqlQuery: make it a move only typeGiuseppe D'Angelo2021-03-211-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSqlQuery is a broken value class. Copying one object would mean copying database state (the result set, the cursor position, etc.) which isn't generally available for all database drivers. For that reason, the current implementation does not honor value semantics -- modifying a QSqlQuery object has visible side effects on its existing copies (!). The correct solution is to accept that QSqlQuery is a move only type, not a value type. Add move semantics to it, and deprecate its copies. (We can't just *remove* copies in Qt 6 due to SC/BC constraints). [ChangeLog][QtSql][QSqlQuery] QSqlQuery copy operations have been deprecated. QSqlQuery copy semantics cannot be implemented correctly, as it's not generally possible to copy a result set of a query when copying the corresponding QSqlQuery object. This resulted in modifications on a QSqlQuery having visible (and unintended) side effects on its copies. Instead, treat QSqlQuery as a move-only type. Fixes: QTBUG-91766 Change-Id: Iabd3aa605332a5c15c524303418bf17a21ed520b Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* Doc: make Qt Sql snippets compilableNico Vertriest2020-03-201-1/+1
| | | | | | | Task-number: QTBUG-81496 Change-Id: Id6206e9179c2e8157c99e777a3de35bd83d49e34 Reviewed-by: Topi Reiniö <[email protected]> Reviewed-by: Paul Wicking <[email protected]>
* Doc: Fix QSql*Model snippetsSze Howe Koh2020-01-191-2/+2
| | | | | | | | | | - QSqlQueryModel docs contained a snippet about QSqlTableModel. - Snippet #25 was about QSqlTableModel, but it was previously unused. - This patch ensures that snippet code matches the corresponding text descriptions. Change-Id: I2a5ffbe0978ef9b8d0b027db59647b824e52d214 Reviewed-by: Samuel Gaist <[email protected]>
* Fix some qdoc warnings for 5.10Friedemann Kleint2017-07-251-1/+1
| | | | | | | | | | | | | | | | src/corelib/io/qfiledevice.cpp:741: warning: Can't link to 'setFileName()' src/corelib/io/qfiledevice.cpp:772: warning: Can't link to 'setFileName()' src/corelib/io/qfiledevice.cpp:790: warning: No such parameter 'time' in QFileDevice::setFileTime() src/corelib/io/qfiledevice.cpp:790: warning: Undocumented parameter 'fileTime' in QFileDevice::setFileTime() src/corelib/io/qfileinfo.cpp:1344: warning: Can't link to 'FileTime' src/corelib/kernel/qcoreapplication.cpp:2007: warning: Can't link to 'isTranslatorInstalled()' src/gui/opengl/qopenglextrafunctions.h:468: warning: No documentation for 'QOpenGLExtraFunctions::glBlendBarrier(void )' src/gui/opengl/qopenglextrafunctions.h:494: warning: No documentation for 'QOpenGLExtraFunctions::glGetGraphicsResetStatus(void )' src/gui/opengl/qopenglextrafunctions.h:475: warning: No documentation for 'QOpenGLExtraFunctions::glPopDebugGroup(void )' src/sql/models/qsqlquerymodel.cpp:217: warning: Unknown command '\override' Change-Id: Ide0ce911f6faf964fda8f32fac433da7d2cb11de Reviewed-by: Thiago Macieira <[email protected]>
* Modify QSqlQueryModel roleNamesJesus Fernandez2017-05-261-0/+24
| | | | | | | | | | | | | | | QSqlQueryModel::roleNames was exposing the default QAbstractItemModel roles. Only "display" role makes sense because it's a read-only model and it is not providing any other data information. [ChangeLog][Important Behavior Changes] The names of the roles returned by QSqlQueryModel::roleNames now only include a name for the Qt::DisplayRole. Previously all the roles names of QSqlQueryModel were returned. Task-number: QTBUG-60857 Change-Id: Ib18aa0e7083a828648767d700c5af05b6aa84f4f Reviewed-by: Andy Shaw <[email protected]>
* 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 <[email protected]>
* QSqlQueryModel::clear(): Call begin/endResetModel().Friedemann Kleint2015-11-191-0/+2
| | | | | | | | | Call begin/endResetModel() in QSqlQueryModel and all derived classes. Task-number: QTBUG-49404 Change-Id: I11492d6386efb4c945c246a6379aaa6ca4502a25 Reviewed-by: Mark Brand <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-4/+4
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <[email protected]> Reviewed-by: Jerome Pasion <[email protected]>
* fix QSqlTableModel::headerData() for empty query with inserted rowMark Brand2013-02-061-10/+11
| | | | | | | | | | | | | | QSqlQueryModel::headerData() relied on virtual indexInQuery() to detect whether the requested column at row 0 mapped to an index in the query. This failed when row 0 was a pending insert managed by QSqlTableModel, and therefore not in the query. The only thing that matters here is the column. Task-number: QTBUG-29108 Change-Id: I3e0ae85ba223e444781ec8033386d394bb44f0e8 Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Mark Brand <[email protected]>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <[email protected]>
* doc: Fix a few doc errors for QtSQLTor Arne Vestbø2012-10-121-1/+1
| | | | | | | | | | | The examples include path already contains 'sql', so we can't prefix the includes with 'sql' as well. Changing the include path to also include the parent examples directory is not an option, as qdoc will then try to generate output for example single example. Change-Id: Ifae07af86e60e6105a0625f29fbd6bc8f73b2550 Reviewed-by: Martin Smith <[email protected]> Reviewed-by: Frederik Gladhorn <[email protected]>
* 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 <[email protected]> Reviewed-by: Sergio Ahumada <[email protected]>
* sql: Include own headers firstSergio Ahumada2012-09-191-2/+1
| | | | | | | | cpp files should include their own headers first (but below config.h) Change-Id: I225bc0f09988167ae7f938f7f21a77d05a3d191b Reviewed-by: Caroline Chao <[email protected]> Reviewed-by: Mark Brand <[email protected]>
* QSqlQueryModel: suppress insert and remove signals while resettingMark Brand2012-08-301-4/+74
| | | | | | | | | | There is no need to emit signals for inserting and removing rows and columns while resetting the model. Suppress these signals in such a way that subclasses can benefit without worrying about it. Change-Id: I04447c87173be54a7323b97608cdd40ae245b80b Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Olivier Goffart <[email protected]>
* QSqlQueryModel: fix nested beginResetModel/endResetModelMark Brand2012-08-301-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up to 83c9ebbd6692cde99ee692e6549c591100f12545. Consider the case where calls to the reset methods on the same object are nested as in the following sequence: 1. beginResetModel() 2. beginResetModel() 3. endResetModel() 4. endResetModel() In such cases, only the outermost calls, i.e., 1) and 4), should emit signals. After 83c9ebbd6692cde99ee692e6549c591100f12545, 1) and 3) emitted the signals, which is wrong. This is corrected by keeping track of the nesting level. Such sequences can come about when a base class calls the begin/end methods between the calls made by the subclass. QSqlTableModel::select() is an example of this. Test included. Change-Id: Ia62b45cb1abaab00a32bb8357de4a958bcff83e5 Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Olivier Goffart <[email protected]>
* docs: remove \reimp from non-virtual methodsMark Brand2012-08-301-2/+2
| | | | | | | It seems we need \internal in this case. Change-Id: I3f290bb0d22f9f3b5d04d27b13a7ef8961b2dd6c Reviewed-by: Olivier Goffart <[email protected]>
* documentation: grammar nitpickMark Brand2012-08-291-3/+3
| | | | | | Change-Id: Ibf16731f04f2c53adeff1b8b1fcc6f1555e3613d Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Bill King <[email protected]>
* Doc: Fix most qdoc errors in QtSql.Casper van Donderen2012-04-281-6/+6
| | | | | | | | | - Move 2 images from qtdoc. - Add "make docs" command for qtsql - Fix qdoc command usage errors. Change-Id: Id2f0548d09ed8f77b2317863d443c19d1cccdd83 Reviewed-by: Lars Knoll <[email protected]>
* QSqlQueryModel::setQuery() don't use deprecated reset()Mark Brand2012-04-231-37/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the method attempted to reset only as a last resort. Now reset() is deprecated and resetting must happen between emitting modelAboutToBeReset() and modelReset(). Since this suffices in all cases to notify views that they must reinterrogate the model, it is no longer necessary to signal explicitly row removals and insertions within the scope of the reset. Additionally, fetchMore() is now called within the scope of the reset so insert signals do not have to be emitted here either. This improved handling of resetting in QSqlQueryModel also allows the cache in QSqlTableModel to be cleared directly at select(). This change may actually allow views to operate more efficiently since they no longer have to react to separate row removal and insert signals. Views can avoid pointless deallocation and reallocation by considering row count only after the reset is finished. The cost is that the columns and horizontal headers must be considered in the view at each setQuery() call. In any case, it is not clear that trying to be smart about this in the model justifies additional complexity. Tests had to be adjusted where they expected explicit row removal and insert signals. Change-Id: I4f7eac1419824361d7d9bdcc6a87092b33e80d7a Task-Id: QTBUG-25419 Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Olivier Goffart <[email protected]> Reviewed-by: Honglei Zhang <[email protected]>
* QSqlQueryModel::fetchMore() documentation fixMark Brand2012-04-231-1/+1
| | | | | | Change-Id: If046e674abad9c2dcff934a2fdd80d4133e1f4ad Reviewed-by: Andy Shaw <[email protected]> Reviewed-by: Mark Brand <[email protected]>
* Fix crash when an invalid filter is setHonglei Zhang2012-03-301-1/+2
| | | | | | | | | | | | | QSqlTableModel::headerData() generates a crash if an invalid filter is set. QSqlQueryModel::indexInQuery() should check the index value before applied to d->colOffsets[]. QSqlQueryModel::initRecordAndPrimaryIndex() is updated to sync the size of rec and colOffsets. Task-number: QTBUG-23879 Change-Id: Ic9f88bb288592aa6fb3c1415cc818632dadaab56 Reviewed-by: Michael Goddard <[email protected]> Reviewed-by: Mark Brand <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <[email protected]>
* 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/+600
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