Use QString::toLatin1() rather than ::toAscii()

The toAscii (and fromAscii) are removed from Qt5 in favor of Latin1.
This commit is contained in:
Ben Boeckel 2013-11-24 21:19:20 +01:00 committed by Felix Geyer
parent 03e4b2d13c
commit 66b3d22041
7 changed files with 16 additions and 16 deletions

View File

@ -141,7 +141,7 @@ QString imageReaderFilter()
}
}
formatsStringList.append("*." + QString::fromAscii(format).toLower());
formatsStringList.append("*." + QString::fromLatin1(format).toLower());
}
return formatsStringList.join(" ");

View File

@ -42,12 +42,12 @@ Uuid Uuid::random()
QString Uuid::toBase64() const
{
return QString::fromAscii(m_data.toBase64());
return QString::fromLatin1(m_data.toBase64());
}
QString Uuid::toHex() const
{
return QString::fromAscii(m_data.toHex());
return QString::fromLatin1(m_data.toHex());
}
QByteArray Uuid::toByteArray() const
@ -85,7 +85,7 @@ bool Uuid::operator!=(const Uuid& other) const
Uuid Uuid::fromBase64(const QString& str)
{
QByteArray data = QByteArray::fromBase64(str.toAscii());
QByteArray data = QByteArray::fromBase64(str.toLatin1());
return Uuid(data);
}

View File

@ -779,7 +779,7 @@ void KeePass2XmlReader::parseEntryString(Entry* entry)
if (isProtected && !value.isEmpty()) {
if (m_randomStream) {
value = QString::fromUtf8(m_randomStream->process(QByteArray::fromBase64(value.toAscii())));
value = QString::fromUtf8(m_randomStream->process(QByteArray::fromBase64(value.toLatin1())));
}
else {
raiseError("Unable to decrypt entry string");
@ -1053,7 +1053,7 @@ Uuid KeePass2XmlReader::readUuid()
QByteArray KeePass2XmlReader::readBinary()
{
return QByteArray::fromBase64(readString().toAscii());
return QByteArray::fromBase64(readString().toLatin1());
}
QByteArray KeePass2XmlReader::readCompressedBinary()

View File

@ -192,7 +192,7 @@ void KeePass2XmlWriter::writeBinaries()
}
if (!data.isEmpty()) {
m_xml.writeCharacters(QString::fromAscii(data.toBase64()));
m_xml.writeCharacters(QString::fromLatin1(data.toBase64()));
}
m_xml.writeEndElement();
}
@ -341,7 +341,7 @@ void KeePass2XmlWriter::writeEntry(const Entry* entry)
if (m_randomStream) {
m_xml.writeAttribute("Protected", "True");
QByteArray rawData = m_randomStream->process(entry->attributes()->value(key).toUtf8());
value = QString::fromAscii(rawData.toBase64());
value = QString::fromLatin1(rawData.toBase64());
}
else {
m_xml.writeAttribute("ProtectInMemory", "True");
@ -485,7 +485,7 @@ void KeePass2XmlWriter::writeUuid(const QString& qualifiedName, const Entry* ent
void KeePass2XmlWriter::writeBinary(const QString& qualifiedName, const QByteArray& ba)
{
writeString(qualifiedName, QString::fromAscii(ba.toBase64()));
writeString(qualifiedName, QString::fromLatin1(ba.toBase64()));
}
void KeePass2XmlWriter::writeColor(const QString& qualifiedName, const QColor& color)

View File

@ -122,7 +122,7 @@ void FileKey::create(QIODevice* device)
xmlWriter.writeStartElement("Key");
QByteArray data = randomGen()->randomArray(32);
xmlWriter.writeTextElement("Data", QString::fromAscii(data.toBase64()));
xmlWriter.writeTextElement("Data", QString::fromLatin1(data.toBase64()));
xmlWriter.writeEndElement();
@ -211,7 +211,7 @@ QByteArray FileKey::loadXmlKey(QXmlStreamReader& xmlReader)
while (!xmlReader.error() && xmlReader.readNextStartElement()) {
if (xmlReader.name() == "Data") {
// TODO: do we need to enforce a specific data.size()?
data = QByteArray::fromBase64(xmlReader.readElementText().toAscii());
data = QByteArray::fromBase64(xmlReader.readElementText().toLatin1());
}
}

View File

@ -37,13 +37,13 @@ void TestCryptoHash::test()
QCOMPARE(cryptoHash1.result(),
QByteArray::fromHex("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
QByteArray source2 = QString("KeePassX").toAscii();
QByteArray source2 = QString("KeePassX").toLatin1();
QByteArray result2 = CryptoHash::hash(source2, CryptoHash::Sha256);
QCOMPARE(result2, QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
CryptoHash cryptoHash3(CryptoHash::Sha256);
cryptoHash3.addData(QString("KeePa").toAscii());
cryptoHash3.addData(QString("ssX").toAscii());
cryptoHash3.addData(QString("KeePa").toLatin1());
cryptoHash3.addData(QString("ssX").toLatin1());
QCOMPARE(cryptoHash3.result(),
QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
}

View File

@ -33,7 +33,7 @@ namespace QTest {
char* toString(const Uuid& uuid)
{
QByteArray ba = "Uuid(";
ba += uuid.toBase64().toAscii().constData();
ba += uuid.toBase64().toLatin1().constData();
ba += ")";
return qstrdup(ba.constData());
}
@ -296,7 +296,7 @@ void TestKeePass2XmlReader::testEntry2()
QVERIFY(attrs.isEmpty());
QCOMPARE(entry->attachments()->keys().size(), 1);
QCOMPARE(QString::fromAscii(entry->attachments()->value("myattach.txt")), QString("abcdefghijk"));
QCOMPARE(QString::fromLatin1(entry->attachments()->value("myattach.txt")), QString("abcdefghijk"));
QCOMPARE(entry->autoTypeEnabled(), true);
QCOMPARE(entry->autoTypeObfuscation(), 1);