QSqlTableModelPrivate: deduplicate field stripping logic
Change-Id: Ic969a192644e84d78558da0f19e588033e4af43d Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
This commit is contained in:
parent
7e4232f10a
commit
1247683d40
@ -299,9 +299,7 @@ void QSqlRelationalTableModelPrivate::revertCachedRow(int row)
|
||||
|
||||
int QSqlRelationalTableModelPrivate::nameToIndex(const QString &name) const
|
||||
{
|
||||
QString fieldname = name;
|
||||
if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName))
|
||||
fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
|
||||
QString fieldname = strippedFieldName(name);
|
||||
int idx = baseRec.indexOf(fieldname);
|
||||
if (idx == -1) {
|
||||
// If the name is an alias we can find it here.
|
||||
|
@ -67,11 +67,16 @@ QSqlRecord QSqlTableModelPrivate::record(const QVector<QVariant> &values) const
|
||||
}
|
||||
|
||||
int QSqlTableModelPrivate::nameToIndex(const QString &name) const
|
||||
{
|
||||
return rec.indexOf(strippedFieldName(name));
|
||||
}
|
||||
|
||||
QString QSqlTableModelPrivate::strippedFieldName(const QString &name) const
|
||||
{
|
||||
QString fieldname = name;
|
||||
if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName))
|
||||
fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
|
||||
return rec.indexOf(fieldname);
|
||||
return fieldname;
|
||||
}
|
||||
|
||||
void QSqlTableModelPrivate::initRecordAndPrimaryIndex()
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
const QSqlRecord &rec, const QSqlRecord &whereValues);
|
||||
virtual void revertCachedRow(int row);
|
||||
virtual int nameToIndex(const QString &name) const;
|
||||
QString strippedFieldName(const QString &name) const;
|
||||
void initRecordAndPrimaryIndex();
|
||||
|
||||
QSqlDatabase db;
|
||||
|
Loading…
Reference in New Issue
Block a user