summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/drivers/db2/qsql_db2.cpp4
-rw-r--r--src/sql/drivers/db2/qsql_db2.h4
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp8
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.h4
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp4
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.h4
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp4
-rw-r--r--src/sql/drivers/oci/qsql_oci.h4
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp4
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.h4
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp22
-rw-r--r--src/sql/drivers/psql/qsql_psql.h4
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp16
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.h4
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.pri2
-rw-r--r--src/sql/drivers/sqlite2/qsql_sqlite2.cpp12
-rw-r--r--src/sql/drivers/sqlite2/qsql_sqlite2.h4
-rw-r--r--src/sql/drivers/tds/qsql_tds.cpp16
-rw-r--r--src/sql/drivers/tds/qsql_tds.h4
-rw-r--r--src/sql/kernel/qsql.h5
-rw-r--r--src/sql/kernel/qsql.qdoc4
-rw-r--r--src/sql/kernel/qsqlcachedresult.cpp4
-rw-r--r--src/sql/kernel/qsqlcachedresult_p.h4
-rw-r--r--src/sql/kernel/qsqldatabase.cpp4
-rw-r--r--src/sql/kernel/qsqldatabase.h5
-rw-r--r--src/sql/kernel/qsqldriver.cpp25
-rw-r--r--src/sql/kernel/qsqldriver.h8
-rw-r--r--src/sql/kernel/qsqldriverplugin.cpp4
-rw-r--r--src/sql/kernel/qsqldriverplugin.h7
-rw-r--r--src/sql/kernel/qsqlerror.cpp4
-rw-r--r--src/sql/kernel/qsqlerror.h5
-rw-r--r--src/sql/kernel/qsqlfield.cpp4
-rw-r--r--src/sql/kernel/qsqlfield.h5
-rw-r--r--src/sql/kernel/qsqlindex.cpp4
-rw-r--r--src/sql/kernel/qsqlindex.h5
-rw-r--r--src/sql/kernel/qsqlnulldriver_p.h4
-rw-r--r--src/sql/kernel/qsqlquery.cpp4
-rw-r--r--src/sql/kernel/qsqlquery.h5
-rw-r--r--src/sql/kernel/qsqlrecord.cpp9
-rw-r--r--src/sql/kernel/qsqlrecord.h5
-rw-r--r--src/sql/kernel/qsqlresult.cpp4
-rw-r--r--src/sql/kernel/qsqlresult.h5
-rw-r--r--src/sql/models/qsqlquerymodel.cpp4
-rw-r--r--src/sql/models/qsqlquerymodel.h5
-rw-r--r--src/sql/models/qsqlquerymodel_p.h4
-rw-r--r--src/sql/models/qsqlrelationaldelegate.cpp4
-rw-r--r--src/sql/models/qsqlrelationaldelegate.h5
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp43
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.h5
-rw-r--r--src/sql/models/qsqltablemodel.cpp487
-rw-r--r--src/sql/models/qsqltablemodel.h5
-rw-r--r--src/sql/models/qsqltablemodel_p.h30
-rw-r--r--src/sql/sql.pro11
53 files changed, 394 insertions, 470 deletions
diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp
index f8a803568e..6b7ccc5c83 100644
--- a/src/sql/drivers/db2/qsql_db2.cpp
+++ b/src/sql/drivers/db2/qsql_db2.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/db2/qsql_db2.h b/src/sql/drivers/db2/qsql_db2.h
index 4982aba776..a2462a3435 100644
--- a/src/sql/drivers/db2/qsql_db2.h
+++ b/src/sql/drivers/db2/qsql_db2.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index 3d08649de9..1109dfd62a 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -1845,8 +1845,10 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer)
isc_event_counts(counts, eBuffer->bufferLength, eBuffer->eventBuffer, eBuffer->resultBuffer);
if (counts[0]) {
- if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed)
+ if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed) {
emit notification(i.key());
+ emit notification(i.key(), QSqlDriver::UnknownSource);
+ }
else if (eBuffer->subscriptionState == QIBaseEventBuffer::Starting)
eBuffer->subscriptionState = QIBaseEventBuffer::Subscribed;
diff --git a/src/sql/drivers/ibase/qsql_ibase.h b/src/sql/drivers/ibase/qsql_ibase.h
index cd8d302db5..cda9112d7c 100644
--- a/src/sql/drivers/ibase/qsql_ibase.h
+++ b/src/sql/drivers/ibase/qsql_ibase.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index b0d8d04d1e..3048748a20 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/mysql/qsql_mysql.h b/src/sql/drivers/mysql/qsql_mysql.h
index 632d29305b..01f4a52cd2 100644
--- a/src/sql/drivers/mysql/qsql_mysql.h
+++ b/src/sql/drivers/mysql/qsql_mysql.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index 9b4f887421..1e001f77b2 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/oci/qsql_oci.h b/src/sql/drivers/oci/qsql_oci.h
index 5b82829221..9e97c84a7f 100644
--- a/src/sql/drivers/oci/qsql_oci.h
+++ b/src/sql/drivers/oci/qsql_oci.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index f0d66ea872..40cd2e6f75 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h
index c28ebce535..0741ad4491 100644
--- a/src/sql/drivers/odbc/qsql_odbc.h
+++ b/src/sql/drivers/odbc/qsql_odbc.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 55d8cc6146..e3533581ba 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -107,7 +107,18 @@
template <typename T>
inline void PQfreemem(T *t, int = 0) { free(t); }
+QT_BEGIN_NAMESPACE namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<PGconn*> {
+ enum { Value = false };
+};
+} QT_END_NAMESPACE
Q_DECLARE_METATYPE(PGconn*)
+
+QT_BEGIN_NAMESPACE namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<PGresult*> {
+ enum { Value = false };
+};
+} QT_END_NAMESPACE
Q_DECLARE_METATYPE(PGresult*)
QT_BEGIN_NAMESPACE
@@ -1359,8 +1370,13 @@ void QPSQLDriver::_q_handleNotification(int)
PGnotify *notify = 0;
while((notify = PQnotifies(d->connection)) != 0) {
QString name(QLatin1String(notify->relname));
- if (d->seid.contains(name))
+ if (d->seid.contains(name)) {
emit notification(name);
+ if (notify->be_pid == PQbackendPID(d->connection))
+ emit notification(name, QSqlDriver::SelfSource);
+ else
+ emit notification(name, QSqlDriver::OtherSource);
+ }
else
qWarning("QPSQLDriver: received notification for '%s' which isn't subscribed to.",
qPrintable(name));
diff --git a/src/sql/drivers/psql/qsql_psql.h b/src/sql/drivers/psql/qsql_psql.h
index 16a40463fb..94871b4c99 100644
--- a/src/sql/drivers/psql/qsql_psql.h
+++ b/src/sql/drivers/psql/qsql_psql.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index d7ec53c451..962fc97dfc 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -59,7 +59,18 @@
#include <sqlite3.h>
+QT_BEGIN_NAMESPACE namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<sqlite3*> {
+ enum { Value = false };
+};
+} QT_END_NAMESPACE
Q_DECLARE_METATYPE(sqlite3*)
+
+QT_BEGIN_NAMESPACE namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<sqlite3_stmt*> {
+ enum { Value = false };
+};
+} QT_END_NAMESPACE
Q_DECLARE_METATYPE(sqlite3_stmt*)
QT_BEGIN_NAMESPACE
@@ -84,6 +95,7 @@ static QVariant::Type qGetColumnType(const QString &tpName)
return QVariant::Int;
if (typeName == QLatin1String("double")
|| typeName == QLatin1String("float")
+ || typeName == QLatin1String("real")
|| typeName.startsWith(QLatin1String("numeric")))
return QVariant::Double;
if (typeName == QLatin1String("blob"))
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.h b/src/sql/drivers/sqlite/qsql_sqlite.h
index eac90b1e47..8232be0ebc 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.h
+++ b/src/sql/drivers/sqlite/qsql_sqlite.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.pri b/src/sql/drivers/sqlite/qsql_sqlite.pri
index 78a4e49979..7ad5936e25 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.pri
+++ b/src/sql/drivers/sqlite/qsql_sqlite.pri
@@ -1,8 +1,6 @@
HEADERS += $$PWD/qsql_sqlite.h
SOURCES += $$PWD/qsql_sqlite.cpp
-symbian:include($$QT_SOURCE_TREE/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri)
-
!system-sqlite:!contains(LIBS, .*sqlite3.*) {
include($$PWD/../../../3rdparty/sqlite.pri)
} else {
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
index d69acc15a6..46127923bf 100644
--- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
+++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -60,6 +60,14 @@
typedef struct sqlite_vm sqlite_vm;
+QT_BEGIN_NAMESPACE namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<sqlite_vm*> {
+ enum { Value = false };
+};
+template <> struct IsPointerToTypeDerivedFromQObject<sqlite*> {
+ enum { Value = false };
+};
+} QT_END_NAMESPACE
Q_DECLARE_METATYPE(sqlite_vm*)
Q_DECLARE_METATYPE(sqlite*)
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.h b/src/sql/drivers/sqlite2/qsql_sqlite2.h
index 6372495a54..4df870f3ae 100644
--- a/src/sql/drivers/sqlite2/qsql_sqlite2.h
+++ b/src/sql/drivers/sqlite2/qsql_sqlite2.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp
index c97d96beb8..2a97a3c392 100644
--- a/src/sql/drivers/tds/qsql_tds.cpp
+++ b/src/sql/drivers/tds/qsql_tds.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -127,6 +127,18 @@ QT_BEGIN_NAMESPACE
#define CS_PUBLIC
#endif
+namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<LOGINREC*> {
+ enum { Value = false };
+};
+}
+
+namespace QtPrivate {
+template <> struct IsPointerToTypeDerivedFromQObject<DBPROCESS*> {
+ enum { Value = false };
+};
+}
+
QSqlError qMakeError(const QString& err, QSqlError::ErrorType type, int errNo = -1)
{
return QSqlError(QLatin1String("QTDS: ") + err, QString(), type, errNo);
diff --git a/src/sql/drivers/tds/qsql_tds.h b/src/sql/drivers/tds/qsql_tds.h
index d14d1b6cf7..c2301df817 100644
--- a/src/sql/drivers/tds/qsql_tds.h
+++ b/src/sql/drivers/tds/qsql_tds.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsql.h b/src/sql/kernel/qsql.h
index 54c9a684f6..e8f4d9eab1 100644
--- a/src/sql/kernel/qsql.h
+++ b/src/sql/kernel/qsql.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
namespace QSql
{
diff --git a/src/sql/kernel/qsql.qdoc b/src/sql/kernel/qsql.qdoc
index a935acb661..0762fa977e 100644
--- a/src/sql/kernel/qsql.qdoc
+++ b/src/sql/kernel/qsql.qdoc
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -21,6 +20,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp
index a2ae24a2f4..1971a2935d 100644
--- a/src/sql/kernel/qsqlcachedresult.cpp
+++ b/src/sql/kernel/qsqlcachedresult.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h
index c2e4aeb2be..9feaa54999 100644
--- a/src/sql/kernel/qsqlcachedresult_p.h
+++ b/src/sql/kernel/qsqlcachedresult_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 7ba3c24999..d260588dd5 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqldatabase.h b/src/sql/kernel/qsqldatabase.h
index 9dfbd43ed2..57c55ee675 100644
--- a/src/sql/kernel/qsqldatabase.h
+++ b/src/sql/kernel/qsqldatabase.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlError;
class QSqlDriver;
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index 3b64bb10cb..861cd4ad0f 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -131,6 +131,17 @@ QSqlDriver::~QSqlDriver()
*/
/*!
+ \since 5.0
+
+ \fn QSqlDriver::notification(const QString &name, NotificationSource source)
+
+ This signal is emitted when the database posts an event notification
+ that the driver subscribes to. \a name identifies the event notification, \a source indicates the signal source.
+
+ \sa subscribeToNotification()
+*/
+
+/*!
\fn bool QSqlDriver::open(const QString &db, const QString &user, const QString& password,
const QString &host, int port, const QString &options)
@@ -238,6 +249,16 @@ bool QSqlDriver::isOpenError() const
*/
/*!
+ \enum QSqlDriver::NotificationSource
+
+ This enum contains a list of SQL notification sources.
+
+ \value UnknownSource The notification source is unknown
+ \value SelfSource The notification source is this connection
+ \value OtherSource The notification source is another connection
+*/
+
+/*!
\fn bool QSqlDriver::hasFeature(DriverFeature feature) const
Returns true if the driver supports feature \a feature; otherwise
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index 446cdf4df6..5fd74411db 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,7 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlDatabase;
class QSqlDriverPrivate;
@@ -79,6 +78,8 @@ public:
enum IdentifierType { FieldName, TableName };
+ enum NotificationSource { UnknownSource, SelfSource, OtherSource };
+
explicit QSqlDriver(QObject *parent=0);
~QSqlDriver();
virtual bool isOpen() const;
@@ -121,6 +122,7 @@ public:
Q_SIGNALS:
void notification(const QString &name);
+ void notification(const QString &name, NotificationSource source);
protected:
virtual void setOpen(bool o);
diff --git a/src/sql/kernel/qsqldriverplugin.cpp b/src/sql/kernel/qsqldriverplugin.cpp
index 0f98ce3196..ea28ba2aa1 100644
--- a/src/sql/kernel/qsqldriverplugin.cpp
+++ b/src/sql/kernel/qsqldriverplugin.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqldriverplugin.h b/src/sql/kernel/qsqldriverplugin.h
index 13ffd1e409..96dcec0313 100644
--- a/src/sql/kernel/qsqldriverplugin.h
+++ b/src/sql/kernel/qsqldriverplugin.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlDriver;
@@ -58,7 +57,7 @@ struct Q_SQL_EXPORT QSqlDriverFactoryInterface : public QFactoryInterface
virtual QSqlDriver *create(const QString &name) = 0;
};
-#define QSqlDriverFactoryInterface_iid "com.trolltech.Qt.QSqlDriverFactoryInterface"
+#define QSqlDriverFactoryInterface_iid "org.qt-project.Qt.QSqlDriverFactoryInterface"
Q_DECLARE_INTERFACE(QSqlDriverFactoryInterface, QSqlDriverFactoryInterface_iid)
class Q_SQL_EXPORT QSqlDriverPlugin : public QObject, public QSqlDriverFactoryInterface
diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp
index 8a8d2c318a..79c7ee02c2 100644
--- a/src/sql/kernel/qsqlerror.cpp
+++ b/src/sql/kernel/qsqlerror.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlerror.h b/src/sql/kernel/qsqlerror.h
index 11ebf5a615..528eb482af 100644
--- a/src/sql/kernel/qsqlerror.h
+++ b/src/sql/kernel/qsqlerror.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class Q_SQL_EXPORT QSqlError
{
diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp
index dca9e169fa..5d01df1b8e 100644
--- a/src/sql/kernel/qsqlfield.cpp
+++ b/src/sql/kernel/qsqlfield.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlfield.h b/src/sql/kernel/qsqlfield.h
index 3188b18a4a..58dce8b271 100644
--- a/src/sql/kernel/qsqlfield.h
+++ b/src/sql/kernel/qsqlfield.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlFieldPrivate;
diff --git a/src/sql/kernel/qsqlindex.cpp b/src/sql/kernel/qsqlindex.cpp
index ad66e814ef..c695471cb2 100644
--- a/src/sql/kernel/qsqlindex.cpp
+++ b/src/sql/kernel/qsqlindex.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlindex.h b/src/sql/kernel/qsqlindex.h
index 328a8716e2..e3e55b690e 100644
--- a/src/sql/kernel/qsqlindex.h
+++ b/src/sql/kernel/qsqlindex.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class Q_SQL_EXPORT QSqlIndex : public QSqlRecord
{
diff --git a/src/sql/kernel/qsqlnulldriver_p.h b/src/sql/kernel/qsqlnulldriver_p.h
index 9de9c5641b..b44fe97730 100644
--- a/src/sql/kernel/qsqlnulldriver_p.h
+++ b/src/sql/kernel/qsqlnulldriver_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 4b65ef1d8b..3e6712b27e 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlquery.h b/src/sql/kernel/qsqlquery.h
index 2791784374..930bb25abf 100644
--- a/src/sql/kernel/qsqlquery.h
+++ b/src/sql/kernel/qsqlquery.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QVariant;
class QSqlDriver;
diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp
index 18dd9fbc80..93ef58914b 100644
--- a/src/sql/kernel/qsqlrecord.cpp
+++ b/src/sql/kernel/qsqlrecord.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -243,8 +243,9 @@ int QSqlRecord::indexOf(const QString& name) const
}
/*!
- Returns the field at position \a index. If the position is out of
- range, an empty field is returned.
+ Returns the field at position \a index. If the \a index
+ is out of range, function returns
+ a \l{default-constructed value}.
*/
QSqlField QSqlRecord::field(int index) const
{
diff --git a/src/sql/kernel/qsqlrecord.h b/src/sql/kernel/qsqlrecord.h
index 52168255d2..839c6ef898 100644
--- a/src/sql/kernel/qsqlrecord.h
+++ b/src/sql/kernel/qsqlrecord.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlField;
class QStringList;
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp
index de348c99f5..16df1b8b06 100644
--- a/src/sql/kernel/qsqlresult.cpp
+++ b/src/sql/kernel/qsqlresult.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h
index 07780937a6..162451c6dd 100644
--- a/src/sql/kernel/qsqlresult.h
+++ b/src/sql/kernel/qsqlresult.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QString;
class QSqlRecord;
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index a740071d33..341804f1ae 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/models/qsqlquerymodel.h b/src/sql/models/qsqlquerymodel.h
index 75ae2a5eff..7db973b0d4 100644
--- a/src/sql/models/qsqlquerymodel.h
+++ b/src/sql/models/qsqlquerymodel.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlQueryModelPrivate;
class QSqlError;
diff --git a/src/sql/models/qsqlquerymodel_p.h b/src/sql/models/qsqlquerymodel_p.h
index c25d3c98a0..b5eb60c57d 100644
--- a/src/sql/models/qsqlquerymodel_p.h
+++ b/src/sql/models/qsqlquerymodel_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/models/qsqlrelationaldelegate.cpp b/src/sql/models/qsqlrelationaldelegate.cpp
index aaba25d06a..79e026fe57 100644
--- a/src/sql/models/qsqlrelationaldelegate.cpp
+++ b/src/sql/models/qsqlrelationaldelegate.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/sql/models/qsqlrelationaldelegate.h b/src/sql/models/qsqlrelationaldelegate.h
index 60e56ff99d..eb679a7c48 100644
--- a/src/sql/models/qsqlrelationaldelegate.h
+++ b/src/sql/models/qsqlrelationaldelegate.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,7 +53,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlRelationalDelegate: public QItemDelegate
{
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index 6b0ed06ac4..e12976ef24 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -265,7 +265,6 @@ public:
mutable QVector<QRelation> relations;
QSqlRecord baseRec; // the record without relations
void clearChanges();
- void clearEditBuffer();
void clearCache();
void revertCachedRow(int row);
@@ -303,13 +302,12 @@ int QSqlRelationalTableModelPrivate::nameToIndex(const QString &name) const
QString fieldname = name;
if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName))
fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
- return baseRec.indexOf(fieldname);
-}
-
-void QSqlRelationalTableModelPrivate::clearEditBuffer()
-{
- editBuffer = baseRec;
- clearGenerated(editBuffer);
+ int idx = baseRec.indexOf(fieldname);
+ if (idx == -1) {
+ // If the name is an alias we can find it here.
+ idx = QSqlTableModelPrivate::nameToIndex(name);
+ }
+ return idx;
}
/*!
@@ -440,23 +438,16 @@ QVariant QSqlRelationalTableModel::data(const QModelIndex &index, int role) cons
//when the value at index has been changed or added.
//At an unmodified index, the underlying model will
//already have the correct display value.
- QVariant v;
- switch (d->strategy) {
- case OnFieldChange:
- break;
- case OnRowChange:
- if ((index.row() == d->editIndex || index.row() == d->insertIndex)
- && d->editBuffer.isGenerated(index.column()))
- v = d->editBuffer.value(index.column());
- break;
- case OnManualSubmit:
- const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
- if (row.op != QSqlTableModelPrivate::None && row.rec.isGenerated(index.column()))
- v = row.rec.value(index.column());
- break;
+ if (d->strategy != OnFieldChange) {
+ const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
+ if (row.op != QSqlTableModelPrivate::None && row.rec.isGenerated(index.column())) {
+ if (d->strategy == OnManualSubmit || row.op != QSqlTableModelPrivate::Delete) {
+ QVariant v = row.rec.value(index.column());
+ if (v.isValid())
+ return relation.dictionary[v.toString()];
+ }
+ }
}
- if (v.isValid())
- return relation.dictionary[v.toString()];
}
return QSqlTableModel::data(index, role);
}
diff --git a/src/sql/models/qsqlrelationaltablemodel.h b/src/sql/models/qsqlrelationaltablemodel.h
index decdc08216..141fc221ed 100644
--- a/src/sql/models/qsqlrelationaltablemodel.h
+++ b/src/sql/models/qsqlrelationaltablemodel.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class Q_SQL_EXPORT QSqlRelation
{
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index d2b9427287..ff32533440 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,36 +66,6 @@ QSqlRecord QSqlTableModelPrivate::record(const QVector<QVariant> &values) const
return r;
}
-/*! \internal
- Set a record for OnFieldChange and OnRowChange.
-*/
-bool QSqlTableModelPrivate::setRecord(int row, const QSqlRecord &record)
-{
- Q_Q(QSqlTableModel);
- bool isOk = true;
-
- QSqlTableModel::EditStrategy oldStrategy = strategy;
-
- // FieldChange strategy makes no sense when setting an entire row
- if (strategy == QSqlTableModel::OnFieldChange)
- strategy = QSqlTableModel::OnRowChange;
- for (int i = 0; i < record.count(); ++i) {
- int idx = nameToIndex(record.fieldName(i));
- if (idx == -1)
- continue;
- QModelIndex cIndex = q->createIndex(row, idx);
- QVariant value = record.value(i);
- QVariant oldValue = q->data(cIndex);
- if (oldValue.isNull() || oldValue != value)
- isOk &= q->setData(cIndex, value, Qt::EditRole);
- }
- if (isOk && oldStrategy == QSqlTableModel::OnFieldChange)
- q->submitAll();
- strategy = oldStrategy;
-
- return isOk;
-}
-
int QSqlTableModelPrivate::nameToIndex(const QString &name) const
{
QString fieldname = name;
@@ -112,52 +82,21 @@ void QSqlTableModelPrivate::initRecordAndPrimaryIndex()
void QSqlTableModelPrivate::clear()
{
- editIndex = -1;
sortColumn = -1;
sortOrder = Qt::AscendingOrder;
tableName.clear();
editQuery.clear();
- editBuffer.clear();
cache.clear();
primaryIndex.clear();
rec.clear();
filter.clear();
}
-void QSqlTableModelPrivate::revertInsertedRow()
-{
- Q_Q(QSqlTableModel);
- if (insertIndex == -1)
- return;
-
- q->beginRemoveRows(QModelIndex(), insertIndex, insertIndex);
- insertIndex = -1;
- q->endRemoveRows();
-}
-
-void QSqlTableModelPrivate::clearEditBuffer()
-{
- editBuffer = rec;
- clearGenerated(editBuffer);
-}
-
void QSqlTableModelPrivate::clearCache()
{
cache.clear();
}
-void QSqlTableModelPrivate::clearGenerated(QSqlRecord &rec)
-{
- for (int i = rec.count() - 1; i >= 0; i--)
- rec.setGenerated(i, false);
-}
-
-void QSqlTableModelPrivate::setGeneratedValue(QSqlRecord &rec, int c, QVariant v)
-{
- rec.setValue(c, v);
- rec.setGenerated(c, true);
-}
-
void QSqlTableModelPrivate::revertCachedRow(int row)
{
Q_Q(QSqlTableModel);
@@ -444,26 +383,28 @@ QVariant QSqlTableModel::data(const QModelIndex &index, int role) const
// to handle the insertedRows
QModelIndex item = indexInQuery(index);
- switch (d->strategy) {
- case OnFieldChange:
- case OnRowChange:
- if (index.row() == d->insertIndex) {
- if (item.column() < 0 || item.column() >= d->rec.count())
- return QVariant();
- return d->editBuffer.value(index.column());
- }
- if (d->editIndex == item.row()) {
- if (d->editBuffer.isGenerated(item.column()))
- return d->editBuffer.value(item.column());
- }
- break;
- case OnManualSubmit:
- if (d->cache.contains(index.row())) {
- const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
- if (row.rec.isGenerated(item.column()) || row.op == QSqlTableModelPrivate::Insert)
+ if (d->cache.contains(index.row())) {
+ const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
+
+ switch (d->strategy) {
+ case OnFieldChange:
+ case OnRowChange:
+ if (row.op == QSqlTableModelPrivate::Insert) {
+ if (item.column() < 0 || item.column() >= row.rec.count())
+ return QVariant();
return row.rec.value(item.column());
+ } else if (row.op == QSqlTableModelPrivate::Update) {
+ if (row.rec.isGenerated(item.column()))
+ return row.rec.value(item.column());
+ }
+ break;
+ case OnManualSubmit:
+ if (row.op == QSqlTableModelPrivate::Insert
+ || (row.op != QSqlTableModelPrivate::None
+ && row.rec.isGenerated(item.column())))
+ return row.rec.value(item.column());
+ break;
}
- break;
}
// We need to handle row mapping here, but not column mapping
@@ -477,19 +418,12 @@ QVariant QSqlTableModel::headerData(int section, Qt::Orientation orientation, in
{
Q_D(const QSqlTableModel);
if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
- switch (d->strategy) {
- case OnFieldChange:
- case OnRowChange:
- if (d->insertIndex == section)
- return QLatin1String("*");
- break;
- case OnManualSubmit:
- QSqlTableModelPrivate::Op op = d->cache.value(section).op;
+ if (d->cache.contains(section)) {
+ const QSqlTableModelPrivate::Op op = d->cache.value(section).op;
if (op == QSqlTableModelPrivate::Insert)
return QLatin1String("*");
else if (op == QSqlTableModelPrivate::Delete)
return QLatin1String("!");
- break;
}
}
return QSqlQueryModel::headerData(section, orientation, role);
@@ -511,8 +445,11 @@ bool QSqlTableModel::isDirty(const QModelIndex &index) const
switch (d->strategy) {
case OnFieldChange:
return false;
- case OnRowChange:
- return index.row() == d->editIndex && d->editBuffer.isGenerated(index.column());
+ case OnRowChange: {
+ const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
+ return row.op == QSqlTableModelPrivate::Update
+ && row.rec.isGenerated(index.column());
+ }
case OnManualSubmit: {
const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
return row.op == QSqlTableModelPrivate::Insert
@@ -543,46 +480,47 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
if (!index.isValid() || index.column() >= d->rec.count() || index.row() >= rowCount())
return false;
+ if (d->strategy == OnFieldChange && d->cache.value(index.row()).op != QSqlTableModelPrivate::Insert) {
+ d->cache.clear();
+ } else if (d->strategy == OnRowChange && !d->cache.isEmpty() && !d->cache.contains(index.row())) {
+ submit();
+ d->cache.clear();
+ }
+
+ QSqlTableModelPrivate::ModifiedRow &row = d->cache[index.row()];
+
+ if (row.op == QSqlTableModelPrivate::None) {
+ row = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update,
+ d->rec,
+ d->primaryValues(indexInQuery(index).row()));
+ }
+
+ row.setValue(index.column(), value);
+
bool isOk = true;
- switch (d->strategy) {
- case OnFieldChange: {
- if (index.row() == d->insertIndex) {
- QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
- return true;
- }
- d->clearEditBuffer();
- QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
- isOk = updateRowInTable(index.row(), d->editBuffer);
+ if (d->strategy == OnFieldChange && row.op != QSqlTableModelPrivate::Insert) {
+ // historical bug: bad style to call updateRowInTable.
+ // Should call submit(), but maybe the author wanted to avoid
+ // clearing the cache on failure.
+ isOk = updateRowInTable(index.row(), row.rec);
if (isOk)
select();
- emit dataChanged(index, index);
- break; }
- case OnRowChange:
- if (index.row() == d->insertIndex) {
- QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
- return true;
- }
- if (d->editIndex != index.row()) {
- if (d->editIndex != -1)
- submit();
- d->clearEditBuffer();
- }
- QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
- d->editIndex = index.row();
- emit dataChanged(index, index);
- break;
- case OnManualSubmit: {
- QSqlTableModelPrivate::ModifiedRow &row = d->cache[index.row()];
- if (row.op == QSqlTableModelPrivate::None) {
- row.op = QSqlTableModelPrivate::Update;
- row.rec = d->rec;
- QSqlTableModelPrivate::clearGenerated(row.rec);
- row.primaryValues = d->primaryValues(indexInQuery(index).row());
- }
- QSqlTableModelPrivate::setGeneratedValue(row.rec, index.column(), value);
- emit dataChanged(index, index);
- break; }
}
+
+ // historical bug: dataChanged() is suppressed for OnFieldChange and OnRowChange
+ // when operating on an "insert" record. This is to accomodate
+ // applications that call setData() while handling primeInsert().
+ // Otherwise dataChanged() would be emitted between beginInsert()
+ // and endInsert().
+ // The price of this workaround is that, although the view making
+ // the change will already display the new value, other views connected
+ // to the model probably will not.
+ // It's not clear why OnManualSubmit is excluded from this workaround.
+ // Calling setData() while handling primeInsert() is arguably very wrong anyway.
+ // primeInsert() provides a ref to the record for settings values.
+ if (d->strategy == OnManualSubmit || row.op != QSqlTableModelPrivate::Insert)
+ emit dataChanged(index, index);
+
return isOk;
}
@@ -727,52 +665,29 @@ bool QSqlTableModel::submitAll()
{
Q_D(QSqlTableModel);
- switch (d->strategy) {
- case OnFieldChange:
- if (d->insertIndex == -1)
- return true;
- // else fall through
- case OnRowChange:
- if (d->editBuffer.isEmpty())
- return true;
- if (d->insertIndex != -1) {
- if (!insertRowIntoTable(d->editBuffer))
+ for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
+ it != d->cache.constEnd(); ++it) {
+ switch (it.value().op) {
+ case QSqlTableModelPrivate::Insert:
+ if (!insertRowIntoTable(it.value().rec))
return false;
d->bottom = d->bottom.sibling(d->bottom.row() + 1, d->bottom.column());
- } else {
- if (!updateRowInTable(d->editIndex, d->editBuffer))
+ break;
+ case QSqlTableModelPrivate::Update:
+ if (!updateRowInTable(it.key(), it.value().rec))
return false;
+ break;
+ case QSqlTableModelPrivate::Delete:
+ if (!deleteRowFromTable(it.key()))
+ return false;
+ break;
+ case QSqlTableModelPrivate::None:
+ Q_ASSERT_X(false, "QSqlTableModel::submitAll()", "Invalid cache operation");
+ break;
}
- d->clearEditBuffer();
- d->editIndex = -1;
- d->insertIndex = -1;
- return select();
- case OnManualSubmit:
- for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
- it != d->cache.constEnd(); ++it) {
- switch (it.value().op) {
- case QSqlTableModelPrivate::Insert:
- if (!insertRowIntoTable(it.value().rec))
- return false;
- d->bottom = d->bottom.sibling(d->bottom.row() + 1, d->bottom.column());
- break;
- case QSqlTableModelPrivate::Update:
- if (!updateRowInTable(it.key(), it.value().rec))
- return false;
- break;
- case QSqlTableModelPrivate::Delete:
- if (!deleteRowFromTable(it.key()))
- return false;
- break;
- case QSqlTableModelPrivate::None:
- Q_ASSERT_X(false, "QSqlTableModel::submitAll()", "Invalid cache operation");
- break;
- }
- }
- d->clearCache();
- return select();
}
- return false;
+ d->clearCache();
+ return select();
}
/*!
@@ -872,20 +787,9 @@ QSqlTableModel::EditStrategy QSqlTableModel::editStrategy() const
void QSqlTableModel::revertAll()
{
Q_D(QSqlTableModel);
- switch (d->strategy) {
- case OnFieldChange:
- break;
- case OnRowChange:
- if (d->editIndex != -1)
- revertRow(d->editIndex);
- else if (d->insertIndex != -1)
- revertRow(d->insertIndex);
- break;
- case OnManualSubmit:
- while (!d->cache.isEmpty())
- revertRow(d->cache.constBegin().key());
- break;
- }
+
+ while (!d->cache.isEmpty())
+ revertRow(d->cache.constBegin().key());
}
/*!
@@ -899,23 +803,7 @@ void QSqlTableModel::revertRow(int row)
return;
Q_D(QSqlTableModel);
- switch (d->strategy) {
- case OnFieldChange:
- break;
- case OnRowChange: {
- if (d->editIndex == row) {
- d->editBuffer.clear();
- int oldIndex = d->editIndex;
- d->editIndex = -1;
- emit dataChanged(createIndex(oldIndex, 0), createIndex(oldIndex, columnCount()));
- } else if (d->insertIndex == row) {
- d->revertInsertedRow();
- }
- break; }
- case OnManualSubmit:
- d->revertCachedRow(row);
- break;
- }
+ d->revertCachedRow(row);
}
/*!
@@ -1097,36 +985,37 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
if (parent.isValid() || row < 0 || count <= 0)
return false;
+ int initialRowCount = rowCount();
+
int i;
- switch (d->strategy) {
- case OnFieldChange:
- case OnRowChange:
- for (i = 0; i < count; ++i) {
- if (row + i == d->insertIndex)
- d->revertInsertedRow();
- else if (!deleteRowFromTable(row + i))
- return false;
- }
- select();
- break;
- case OnManualSubmit:
- for (i = 0; i < count; ++i) {
- int idx = row + i;
- if (idx >= rowCount())
- return false;
- if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) {
- revertRow(idx);
- // Reverting a row means all the other cache entries have been adjusted downwards
- // so fake this by adjusting row
- --row;
- } else {
- d->cache[idx].op = QSqlTableModelPrivate::Delete;
- d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row());
+ for (i = 0; i < count && row + i < rowCount(); ++i) {
+ int idx = row + i;
+ if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) {
+ revertRow(idx);
+ // Reverting a row means all the other cache entries have been adjusted downwards
+ // so fake this by adjusting row
+ --row;
+ } else {
+ d->cache[idx] = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Delete,
+ QSqlRecord(),
+ d->primaryValues(indexInQuery(createIndex(idx, 0)).row()));
+ if (d->strategy == OnManualSubmit)
emit headerDataChanged(Qt::Vertical, idx, idx);
- }
}
- break;
}
+
+ if (d->strategy != OnManualSubmit && i > 0)
+ submit();
+
+ // historical bug: emit beforeDelete for 1st row beyond end
+ if (d->strategy != OnManualSubmit) {
+ if (row + count > initialRowCount)
+ emit beforeDelete(qMax(initialRowCount, row));
+ }
+
+ if (i < count)
+ return false;
+
return true;
}
@@ -1153,36 +1042,30 @@ bool QSqlTableModel::insertRows(int row, int count, const QModelIndex &parent)
if (row < 0 || count <= 0 || row > rowCount() || parent.isValid())
return false;
- switch (d->strategy) {
- case OnFieldChange:
- case OnRowChange:
- if (count != 1)
- return false;
- beginInsertRows(parent, row, row);
- d->insertIndex = row;
- // ### apply dangling changes...
- d->clearEditBuffer();
- emit primeInsert(row, d->editBuffer);
- break;
- case OnManualSubmit:
- beginInsertRows(parent, row, row + count - 1);
- if (!d->cache.isEmpty()) {
- QMap<int, QSqlTableModelPrivate::ModifiedRow>::Iterator it = d->cache.end();
- while (it != d->cache.begin() && (--it).key() >= row) {
- int oldKey = it.key();
- const QSqlTableModelPrivate::ModifiedRow oldValue = it.value();
- d->cache.erase(it);
- it = d->cache.insert(oldKey + count, oldValue);
- }
- }
+ if (d->strategy != OnManualSubmit && count != 1)
+ return false;
- for (int i = 0; i < count; ++i) {
- d->cache[row + i] = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Insert,
- d->rec);
- emit primeInsert(row + i, d->cache[row + i].rec);
+ beginInsertRows(parent, row, row + count - 1);
+
+ if (d->strategy != OnManualSubmit)
+ d->cache.empty();
+
+ if (!d->cache.isEmpty()) {
+ QMap<int, QSqlTableModelPrivate::ModifiedRow>::Iterator it = d->cache.end();
+ while (it != d->cache.begin() && (--it).key() >= row) {
+ int oldKey = it.key();
+ const QSqlTableModelPrivate::ModifiedRow oldValue = it.value();
+ d->cache.erase(it);
+ it = d->cache.insert(oldKey + count, oldValue);
}
- break;
}
+
+ for (int i = 0; i < count; ++i) {
+ d->cache[row + i] = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Insert,
+ d->rec);
+ emit primeInsert(row + i, d->cache[row + i].rec);
+ }
+
endInsertRows();
return true;
}
@@ -1220,14 +1103,10 @@ int QSqlTableModel::rowCount(const QModelIndex &parent) const
return 0;
int rc = QSqlQueryModel::rowCount();
- if (d->strategy == OnManualSubmit) {
- for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
- it != d->cache.constEnd(); ++it) {
- if (it.value().op == QSqlTableModelPrivate::Insert)
- ++rc;
- }
- } else if (d->insertIndex >= 0) {
- ++rc;
+ for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
+ it != d->cache.constEnd(); ++it) {
+ if (it.value().op == QSqlTableModelPrivate::Insert)
+ ++rc;
}
return rc;
}
@@ -1248,20 +1127,14 @@ QModelIndex QSqlTableModel::indexInQuery(const QModelIndex &item) const
{
Q_D(const QSqlTableModel);
const QModelIndex it = QSqlQueryModel::indexInQuery(item); // this adjusts columns only
- if (d->strategy == OnManualSubmit) {
- int rowOffset = 0;
- QSqlTableModelPrivate::CacheMap::ConstIterator i = d->cache.constBegin();
- while (i != d->cache.constEnd() && i.key() <= it.row()) {
- if (i.value().op == QSqlTableModelPrivate::Insert)
- ++rowOffset;
- ++i;
- }
- return createIndex(it.row() - rowOffset, it.column(), it.internalPointer());
- } else {
- if (d->insertIndex >= 0 && it.row() >= d->insertIndex)
- return createIndex(it.row() - 1, it.column(), it.internalPointer());
+ int rowOffset = 0;
+ QSqlTableModelPrivate::CacheMap::ConstIterator i = d->cache.constBegin();
+ while (i != d->cache.constEnd() && i.key() <= it.row()) {
+ if (i.value().op == QSqlTableModelPrivate::Insert)
+ ++rowOffset;
+ ++i;
}
- return it;
+ return createIndex(it.row() - rowOffset, it.column(), it.internalPointer());
}
/*!
@@ -1331,37 +1204,49 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
if (row >= rowCount())
return false;
+ if (d->strategy == OnFieldChange && d->cache.value(row).op != QSqlTableModelPrivate::Insert)
+ d->cache.clear();
+ else if (d->strategy == OnRowChange && !d->cache.isEmpty() && !d->cache.contains(row))
+ submit();
+
+ QSqlTableModelPrivate::ModifiedRow &mrow = d->cache[row];
+ if (mrow.op == QSqlTableModelPrivate::None)
+ mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update,
+ d->rec,
+ d->primaryValues(indexInQuery(createIndex(row, 0)).row()));
+
bool isOk = true;
- switch (d->strategy) {
- case OnFieldChange:
- case OnRowChange:
- return d->setRecord(row, record);
- case OnManualSubmit: {
- QSqlTableModelPrivate::ModifiedRow &mrow = d->cache[row];
- if (mrow.op == QSqlTableModelPrivate::None) {
- mrow.op = QSqlTableModelPrivate::Update;
- mrow.rec = d->rec;
- QSqlTableModelPrivate::clearGenerated(mrow.rec);
- mrow.primaryValues = d->primaryValues(indexInQuery(createIndex(row, 0)).row());
- }
- QString fieldName;
- for (int i = 0; i < record.count(); ++i) {
- fieldName = record.fieldName(i);
- if (d->db.driver()->isIdentifierEscaped(fieldName, QSqlDriver::FieldName))
- fieldName = d->db.driver()->stripDelimiters(fieldName, QSqlDriver::FieldName);
- int idx = mrow.rec.indexOf(fieldName);
- if (idx == -1) {
- isOk = false;
- } else {
- QSqlTableModelPrivate::setGeneratedValue(mrow.rec, idx, record.value(i));
+ for (int i = 0; i < record.count(); ++i) {
+ int idx = d->nameToIndex(record.fieldName(i));
+ if (idx == -1) {
+ isOk = false;
+ } else if (d->strategy != OnManualSubmit) {
+ // historical bug: this could all be simple like OnManualSubmit, but isn't
+ const QModelIndex cIndex = createIndex(row, idx);
+ // historical bug: comparing EditRole with DisplayRole values here
+ const QVariant oldValue = data(cIndex);
+ const QVariant value = record.value(i);
+ // historical bug: it's a bad idea to check for change here
+ // historical bug: should test oldValue.isNull() != value.isNull()
+ if (oldValue.isNull() || oldValue != value) {
+ // historical bug: dataChanged() is suppressed for Insert. See also setData().
+ mrow.setValue(idx, record.value(i));
+ if (mrow.op != QSqlTableModelPrivate::Insert)
+ emit dataChanged(cIndex, cIndex);
}
+ } else {
+ mrow.setValue(idx, record.value(i));
}
-
- if (isOk)
- emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
- return isOk; }
}
- return false;
+
+ if (d->strategy == OnManualSubmit && isOk)
+ emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
+ else if (d->strategy == OnFieldChange)
+ return submitAll();
+ else if (d->strategy == OnManualSubmit)
+ return isOk;
+
+ return true;
}
QT_END_NAMESPACE
diff --git a/src/sql/models/qsqltablemodel.h b/src/sql/models/qsqltablemodel.h
index d40e591238..38e92200c7 100644
--- a/src/sql/models/qsqltablemodel.h
+++ b/src/sql/models/qsqltablemodel.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Sql)
class QSqlTableModelPrivate;
class QSqlRecord;
diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h
index 9275712cee..56fd839a0c 100644
--- a/src/sql/models/qsqltablemodel_p.h
+++ b/src/sql/models/qsqltablemodel_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -64,29 +64,22 @@ class QSqlTableModelPrivate: public QSqlQueryModelPrivate
public:
QSqlTableModelPrivate()
- : editIndex(-1), insertIndex(-1), sortColumn(-1),
+ : sortColumn(-1),
sortOrder(Qt::AscendingOrder),
strategy(QSqlTableModel::OnRowChange)
{}
void clear();
QSqlRecord primaryValues(int index);
- virtual void clearEditBuffer();
virtual void clearCache();
- static void clearGenerated(QSqlRecord &rec);
- static void setGeneratedValue(QSqlRecord &rec, int c, QVariant v);
QSqlRecord record(const QVector<QVariant> &values) const;
bool exec(const QString &stmt, bool prepStatement,
const QSqlRecord &rec, const QSqlRecord &whereValues);
virtual void revertCachedRow(int row);
- void revertInsertedRow();
- bool setRecord(int row, const QSqlRecord &record);
virtual int nameToIndex(const QString &name) const;
void initRecordAndPrimaryIndex();
QSqlDatabase db;
- int editIndex;
- int insertIndex;
int sortColumn;
Qt::SortOrder sortOrder;
@@ -102,15 +95,22 @@ public:
struct ModifiedRow
{
- ModifiedRow(Op o = None, const QSqlRecord &r = QSqlRecord()): op(o), rec(r) { clearGenerated(rec);}
- ModifiedRow(const ModifiedRow &other): op(other.op), rec(other.rec), primaryValues(other.primaryValues) {}
+ inline ModifiedRow(Op o = None, const QSqlRecord &r = QSqlRecord(), const QSqlRecord &pVals = QSqlRecord())
+ : op(o), rec(r), primaryValues(pVals)
+ {
+ for (int i = rec.count() - 1; i >= 0; --i)
+ rec.setGenerated(i, false);
+ }
+ inline void setValue(int c, const QVariant &v)
+ {
+ rec.setValue(c, v);
+ rec.setGenerated(c, true);
+ }
Op op;
QSqlRecord rec;
- QSqlRecord primaryValues;
+ QSqlRecord primaryValues;
};
- QSqlRecord editBuffer;
-
typedef QMap<int, ModifiedRow> CacheMap;
CacheMap cache;
};
diff --git a/src/sql/sql.pro b/src/sql/sql.pro
index 445946e07c..dbeed14386 100644
--- a/src/sql/sql.pro
+++ b/src/sql/sql.pro
@@ -24,14 +24,3 @@ SQL_P = sql
include(kernel/kernel.pri)
include(drivers/drivers.pri)
include(models/models.pri)
-
-symbian: {
- TARGET.UID3=0x2001E61D
-
- # Problems using data exports from this DLL mean that we can't page it on releases that don't support
- # data exports (currently that's any release before Symbian^3)
- pagingBlock = "$${LITERAL_HASH}ifndef SYMBIAN_DLL_DATA_EXPORTS_SUPPORTED" \
- "UNPAGED" \
- "$${LITERAL_HASH}endif"
- MMP_RULES += pagingBlock
-}