summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqlrelationaltablemodel.cpp
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2011-07-06 17:08:50 +0200
committerQt by Nokia <qt-info@nokia.com>2012-01-27 22:48:12 +0100
commit7785227214cdabfb07ff7e425e1f41aa86fb5faf (patch)
tree7dec0ff7111236da35114a6a3856b16072bec64f /src/sql/models/qsqlrelationaltablemodel.cpp
parent42d1cf0bbe89999c0fb5684400caf933420b28d7 (diff)
use nameToIndex() instead of duplicating code
Change-Id: If55541aa8a2345f90984d8b82bee0c3ebb01a605 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/sql/models/qsqlrelationaltablemodel.cpp')
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index df7cf1eb3b..a21c051dd5 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -303,7 +303,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);
+ 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;
}
void QSqlRelationalTableModelPrivate::clearEditBuffer()