Change remaining uses of {to,from}Ascii to {to,from}Latin1 [QtSql]

This operation should be a no-op anyway, since at this point in time,
the fromAscii and toAscii functions simply call their fromLatin1 and
toLatin1 counterparts.

Task-number: QTBUG-21872
Change-Id: Icb3ab0e1f4f3173563f3de36115b5457cf1ba856
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
Thiago Macieira 2012-05-02 16:32:26 +02:00 committed by Qt by Nokia
parent ec360d7ad9
commit 8f32994b50
6 changed files with 25 additions and 25 deletions

View File

@ -760,7 +760,7 @@ bool QDB2Result::exec()
break;
}
default: {
QByteArray ba = values.at(i).toString().toAscii();
QByteArray ba = values.at(i).toString().toLatin1();
int len = ba.length() + 1;
if (*ind != SQL_NULL_DATA)
*ind = ba.length();
@ -836,7 +836,7 @@ bool QDB2Result::exec()
values[i] = QString((const QChar *)tmpStorage.takeFirst().constData());
break;
default: {
values[i] = QString::fromAscii(tmpStorage.takeFirst().constData());
values[i] = QString::fromLatin1(tmpStorage.takeFirst().constData());
break; }
}
if (indicators[i] == SQL_NULL_DATA)

View File

@ -1342,8 +1342,8 @@ QSqlRecord QIBaseResult::record() const
q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG "
"FROM RDB$RELATION_FIELDS a, RDB$FIELDS b "
"WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE "
"AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' "
"AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' "));
"AND a.RDB$RELATION_NAME = '") + QString::fromLatin1(v.relname, v.relname_length).toUpper() + QLatin1String("' "
"AND a.RDB$FIELD_NAME = '") + QString::fromLatin1(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' "));
if(q.first()) {
if(v.sqlscale < 0) {
f.setLength(q.value(0).toInt());

View File

@ -353,7 +353,7 @@ QVariant QPSQLResult::data(int i)
case QVariant::Bool:
return QVariant((bool)(val[0] == 't'));
case QVariant::String:
return d->driver->isUtf8 ? QString::fromUtf8(val) : QString::fromAscii(val);
return d->driver->isUtf8 ? QString::fromUtf8(val) : QString::fromLatin1(val);
case QVariant::LongLong:
if (val[0] == '-')
return QString::fromLatin1(val).toLongLong();
@ -366,7 +366,7 @@ QVariant QPSQLResult::data(int i)
if (numericalPrecisionPolicy() != QSql::HighPrecision) {
QVariant retval;
bool convert;
double dbl=QString::fromAscii(val).toDouble(&convert);
double dbl=QString::fromLatin1(val).toDouble(&convert);
if (numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
retval = (qlonglong)dbl;
else if (numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
@ -377,9 +377,9 @@ QVariant QPSQLResult::data(int i)
return QVariant();
return retval;
}
return QString::fromAscii(val);
return QString::fromLatin1(val);
}
return QString::fromAscii(val).toDouble();
return QString::fromLatin1(val).toDouble();
case QVariant::Date:
if (val[0] == '\0') {
return QVariant(QDate());
@ -685,7 +685,7 @@ QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion()
PGresult* result = exec("select version()");
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
QString val = QString::fromAscii(PQgetvalue(result, 0, 0));
QString val = QString::fromLatin1(PQgetvalue(result, 0, 0));
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)"));
rx.setMinimal(true); // enforce non-greedy RegExp
@ -1380,7 +1380,7 @@ void QPSQLDriver::_q_handleNotification(int)
QString payload;
#if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 70400
if (notify->extra)
payload = d->isUtf8 ? QString::fromUtf8(notify->extra) : QString::fromAscii(notify->extra);
payload = d->isUtf8 ? QString::fromUtf8(notify->extra) : QString::fromLatin1(notify->extra);
#endif
emit notification(name);
QSqlDriver::NotificationSource source = (notify->be_pid == PQbackendPID(d->connection)) ? QSqlDriver::SelfSource : QSqlDriver::OtherSource;

View File

@ -149,7 +149,7 @@ void QSQLite2ResultPrivate::finalize()
int res = sqlite_finalize(currentMachine, &err);
if (err) {
q->setLastError(QSqlError(QCoreApplication::translate("QSQLite2Result",
"Unable to fetch results"), QString::fromAscii(err),
"Unable to fetch results"), QString::fromLatin1(err),
QSqlError::StatementError, res));
sqlite_freemem(err);
}
@ -172,14 +172,14 @@ void QSQLite2ResultPrivate::init(const char **cnames, int numCols)
const char* fieldName = lastDot ? lastDot + 1 : cnames[i];
//remove quotations around the field name if any
QString fieldStr = QString::fromAscii(fieldName);
QString fieldStr = QString::fromLatin1(fieldName);
QLatin1Char quote('\"');
if ( fieldStr.length() > 2 && fieldStr.startsWith(quote) && fieldStr.endsWith(quote)) {
fieldStr = fieldStr.mid(1);
fieldStr.chop(1);
}
rInf.append(QSqlField(fieldStr,
nameToType(QString::fromAscii(cnames[i+numCols]))));
nameToType(QString::fromLatin1(cnames[i+numCols]))));
}
}
@ -231,7 +231,7 @@ bool QSQLite2ResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int
if (idx < 0 && !initialFetch)
return true;
for (i = 0; i < colNum; ++i)
values[i + idx] = utf8 ? QString::fromUtf8(fvals[i]) : QString::fromAscii(fvals[i]);
values[i + idx] = utf8 ? QString::fromUtf8(fvals[i]) : QString::fromLatin1(fvals[i]);
return true;
case SQLITE_DONE:
if (rInf.isEmpty())
@ -293,13 +293,13 @@ bool QSQLite2Result::reset (const QString& query)
char *err = 0;
int res = sqlite_compile(d->access,
d->utf8 ? query.toUtf8().constData()
: query.toAscii().constData(),
: query.toLatin1().constData(),
&(d->currentTail),
&(d->currentMachine),
&err);
if (res != SQLITE_OK || err) {
setLastError(QSqlError(QCoreApplication::translate("QSQLite2Result",
"Unable to execute statement"), QString::fromAscii(err),
"Unable to execute statement"), QString::fromLatin1(err),
QSqlError::StatementError, res));
sqlite_freemem(err);
}
@ -399,7 +399,7 @@ bool QSQLite2Driver::open(const QString & db, const QString &, const QString &,
char* err = 0;
d->access = sqlite_open(QFile::encodeName(db), 0, &err);
if (err) {
setLastError(QSqlError(tr("Error opening database"), QString::fromAscii(err),
setLastError(QSqlError(tr("Error opening database"), QString::fromLatin1(err),
QSqlError::ConnectionError));
sqlite_freemem(err);
err = 0;
@ -441,7 +441,7 @@ bool QSQLite2Driver::beginTransaction()
return true;
setLastError(QSqlError(tr("Unable to begin transaction"),
QString::fromAscii(err), QSqlError::TransactionError, res));
QString::fromLatin1(err), QSqlError::TransactionError, res));
sqlite_freemem(err);
return false;
}
@ -458,7 +458,7 @@ bool QSQLite2Driver::commitTransaction()
return true;
setLastError(QSqlError(tr("Unable to commit transaction"),
QString::fromAscii(err), QSqlError::TransactionError, res));
QString::fromLatin1(err), QSqlError::TransactionError, res));
sqlite_freemem(err);
return false;
}
@ -475,7 +475,7 @@ bool QSQLite2Driver::rollbackTransaction()
return true;
setLastError(QSqlError(tr("Unable to rollback transaction"),
QString::fromAscii(err), QSqlError::TransactionError, res));
QString::fromLatin1(err), QSqlError::TransactionError, res));
sqlite_freemem(err);
return false;
}

View File

@ -185,11 +185,11 @@ static int CS_PUBLIC qTdsMsgHandler (DBPROCESS* dbproc,
if (severity > 0) {
QString errMsg = QString::fromLatin1("%1 (Msg %2, Level %3, State %4, Server %5, Line %6)")
.arg(QString::fromAscii(msgtext))
.arg(QString::fromLatin1(msgtext))
.arg(msgno)
.arg(severity)
.arg(msgstate)
.arg(QString::fromAscii(srvname))
.arg(QString::fromLatin1(srvname))
.arg(line);
p->addErrorMsg(errMsg);
if (severity > 10) {
@ -435,7 +435,7 @@ bool QTDSResult::reset (const QString& query)
for (int i = 0; i < numCols; ++i) {
int dbType = dbcoltype(d->dbproc, i+1);
QVariant::Type vType = qDecodeTDSType(dbType);
QSqlField f(QString::fromAscii(dbcolname(d->dbproc, i+1)), vType);
QSqlField f(QString::fromLatin1(dbcolname(d->dbproc, i+1)), vType);
f.setSqlType(dbType);
f.setLength(dbcollen(d->dbproc, i+1));
d->rec.append(f);

View File

@ -2712,11 +2712,11 @@ void tst_QSqlQuery::blobsPreparedQuery()
QVERIFY_SQL( q, exec( QString( "CREATE TABLE %1(id INTEGER, data %2)" ).arg( tableName ).arg( typeName ) ) );
q.prepare( QString( "INSERT INTO %1(id, data) VALUES(:id, :data)" ).arg( tableName ) );
q.bindValue( ":id", 1 );
q.bindValue( ":data", shortBLOB.toAscii() );
q.bindValue( ":data", shortBLOB.toLatin1() );
QVERIFY_SQL( q, exec() );
q.bindValue( ":id", 2 );
q.bindValue( ":data", longerBLOB.toAscii() );
q.bindValue( ":data", longerBLOB.toLatin1() );
QVERIFY_SQL( q, exec() );
// Two executions and result sets