Commit a1c1d7d2 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Thomas Hartmann

QmlDesigner: Trivial QT_NO_CAST_FROM_ASCII fixes

This are the "trivial" low risk fixes for QT_NO_CAST_FROM_ASCII
in the Qt Quick Designer.

Change-Id: Ife1542a61abbd1b323cecea46854d95de252f2bb
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent d31e77be
......@@ -146,7 +146,7 @@ void Exception::createWarning() const
*/
QString Exception::description() const
{
return QString("file: %1, function: %2, line: %3").arg(m_file, m_function, QString::number(m_line));
return QString(QStringLiteral("file: %1, function: %2, line: %3")).arg(m_file, m_function, QString::number(m_line));
}
/*!
......
......@@ -56,7 +56,7 @@ InvalidArgumentException::InvalidArgumentException(int line,
QString InvalidArgumentException::description() const
{
if (function() == "createNode")
if (function() == QLatin1String("createNode"))
return QCoreApplication::translate("QmlDesigner::InvalidArgumentException", "Failed to create item of type %1").arg(m_argument);
return Exception::description();
......@@ -67,7 +67,7 @@ QString InvalidArgumentException::description() const
*/
QString InvalidArgumentException::type() const
{
return "InvalidArgumentException";
return QLatin1String("InvalidArgumentException");
}
/*!
......
......@@ -62,7 +62,7 @@ InvalidIdException::InvalidIdException(int line,
QString InvalidIdException::type() const
{
return "InvalidIdException";
return QLatin1String("InvalidIdException");
}
QString InvalidIdException::description() const
......
......@@ -57,7 +57,7 @@ InvalidMetaInfoException::InvalidMetaInfoException(int line,
*/
QString InvalidMetaInfoException::type() const
{
return "InvalidMetaInfoException";
return QLatin1String("InvalidMetaInfoException");
}
}
......@@ -57,7 +57,7 @@ InvalidModelNodeException::InvalidModelNodeException(int line,
*/
QString InvalidModelNodeException::type() const
{
return "InvalidModelNodeException";
return QLatin1String("InvalidModelNodeException");
}
}
......@@ -58,7 +58,7 @@ InvalidModelStateException::InvalidModelStateException(int line,
*/
QString InvalidModelStateException::type() const
{
return "InvalidModelStateException";
return QLatin1String("InvalidModelStateException");
}
} // namespace QmlDesigner
......@@ -57,7 +57,7 @@ InvalidPropertyException::InvalidPropertyException(int line,
*/
QString InvalidPropertyException::type() const
{
return "InvalidPropertyException";
return QLatin1String("InvalidPropertyException");
}
/*!
......
......@@ -58,7 +58,7 @@ InvalidQmlSourceException::InvalidQmlSourceException(int line,
*/
QString InvalidQmlSourceException::type() const
{
return "InvalidQmlSourceException";
return QLatin1String("InvalidQmlSourceException");
}
QString InvalidQmlSourceException::description() const
......
......@@ -56,6 +56,6 @@ Returns the type of this exception as a string.
*/
QString InvalidReparentingException::type() const
{
return "InvalidReparentingException";
return QLatin1String("InvalidReparentingException");
}
} // namespace QmlDesigner
......@@ -57,7 +57,7 @@ InvalidSlideIndexException::InvalidSlideIndexException(int line,
*/
QString InvalidSlideIndexException::type() const
{
return "InvalidSlideIndexException";
return QLatin1String("InvalidSlideIndexException");
}
} // namespace QmlDesigner
......@@ -41,6 +41,6 @@ NotImplementedException::NotImplementedException(int line,
QString NotImplementedException::type() const
{
return "NotImplementedException";
return QLatin1String("NotImplementedException");
}
}
......@@ -57,7 +57,7 @@ Returns the type of this exception as a string.
*/
QString RemoveBaseStateException::type() const
{
return "RemoveBaseStateException";
return QLatin1String("RemoveBaseStateException");
}
} // namespace QmlDesigner
......@@ -44,7 +44,7 @@ RewritingException::RewritingException(int line,
QString RewritingException::type() const
{
return "RewritingException";
return QLatin1String("RewritingException");
}
QString RewritingException::description() const
......
......@@ -92,7 +92,7 @@ static bool hasQtQuick1(NodeInstanceView *nodeInstanceView)
{
if (nodeInstanceView && nodeInstanceView->model()) {
foreach (const Import &import ,nodeInstanceView->model()->imports()) {
if (import.url() == "QtQuick" && import.version().toDouble() < 2.0)
if (import.url() == QLatin1String("QtQuick") && import.version().toDouble() < 2.0)
return true;
}
}
......
......@@ -203,7 +203,7 @@ MetaInfoReader::ParserSate MetaInfoReader::readQmlSourceElement(const QString &n
void MetaInfoReader::readTypeProperty(const QString &name, const QVariant &value)
{
if (name == "name") {
if (name == QLatin1String("name")) {
m_currentClassName = value.toString().toUtf8();
if (!m_qualication.isEmpty()) //prepend qualification
m_currentClassName = m_qualication + "." + m_currentClassName;
......@@ -266,10 +266,10 @@ void MetaInfoReader::setVersion(const QString &versionNumber)
if (!versionNumber.isEmpty()) {
int val;
bool ok;
if (versionNumber.contains('.')) {
val = versionNumber.split('.').first().toInt(&ok);
if (versionNumber.contains(QLatin1Char('.'))) {
val = versionNumber.split(QLatin1Char('.')).first().toInt(&ok);
major = ok ? val : major;
val = versionNumber.split('.').last().toInt(&ok);
val = versionNumber.split(QLatin1Char('.')).last().toInt(&ok);
minor = ok ? val : minor;
} else {
val = versionNumber.toInt(&ok);
......
......@@ -84,7 +84,7 @@ static inline bool checkIfDerivedFromItem(const QString &fileName)
QmlJS::Document::MutablePtr document =
QmlJS::Document::create(fileName.isEmpty() ?
QStringLiteral("<internal>") : fileName, QmlJS::Dialect::Qml);
document->setSource(source);
document->setSource(QString::fromUtf8(source));
document->parseQml();
......@@ -113,7 +113,7 @@ static inline bool checkIfDerivedFromItem(const QString &fileName)
QList<const QmlJS::ObjectValue *> prototypes = QmlJS::PrototypeIterator(objectValue, context).all();
foreach (const QmlJS::ObjectValue *prototype, prototypes) {
if (prototype->className() == "Item")
if (prototype->className() == QLatin1String("Item"))
return true;
}
......@@ -193,7 +193,7 @@ void SubComponentManager::parseDirectories()
parseDirectory(dirInfo.canonicalFilePath());
foreach (const QString &subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) {
parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8());
parseDirectory(dirInfo.canonicalFilePath() + QLatin1String("/") + subDir, true, subDir.toUtf8());
}
}
......@@ -232,10 +232,10 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
if (!model() || !model()->rewriterView())
return;
QDir designerDir(canonicalDirPath + Constants::QML_DESIGNER_SUBFOLDER);
QDir designerDir(canonicalDirPath + QLatin1String(Constants::QML_DESIGNER_SUBFOLDER));
if (designerDir.exists()) {
QStringList filter;
filter << "*.metainfo";
filter << QLatin1String("*.metainfo");
designerDir.setNameFilters(filter);
QStringList metaFiles = designerDir.entryList(QDir::Files);
......@@ -303,7 +303,7 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
continue;
}
// oldFileInfo > newFileInfo
parseFile(newFileInfo.filePath(), addToLibrary, qualification);
parseFile(newFileInfo.filePath(), addToLibrary, QString::fromLatin1(qualification));
++newIter;
}
......@@ -314,7 +314,7 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
}
while (newIter != newList.constEnd()) {
parseFile(newIter->filePath(), addToLibrary, qualification);
parseFile(newIter->filePath(), addToLibrary, QString::fromLatin1(qualification));
if (debug)
qDebug() << "m_watcher.addPath(" << newIter->filePath() << ')';
++newIter;
......@@ -359,7 +359,7 @@ void SubComponentManager::unregisterQmlFile(const QFileInfo &fileInfo, const QSt
{
QString componentName = fileInfo.baseName();
if (!qualifier.isEmpty())
componentName = qualifier + '.' + componentName;
componentName = qualifier + QLatin1Char('.') + componentName;
}
......@@ -380,7 +380,7 @@ void SubComponentManager::registerQmlFile(const QFileInfo &fileInfo, const QStri
fixedQualifier = qualifier;
if (qualifier.right(1) == QStringLiteral("."))
fixedQualifier.chop(1); //remove last char if it is a dot
componentName = fixedQualifier + '.' + componentName;
componentName = fixedQualifier + QLatin1Char('.') + componentName;
}
if (debug)
......@@ -391,7 +391,7 @@ void SubComponentManager::registerQmlFile(const QFileInfo &fileInfo, const QStri
ItemLibraryEntry itemLibraryEntry;
itemLibraryEntry.setType(componentName.toUtf8(), -1, -1);
itemLibraryEntry.setName(baseComponentName);
itemLibraryEntry.setCategory("QML Components");
itemLibraryEntry.setCategory(QLatin1String("QML Components"));
if (!qualifier.isEmpty()) {
itemLibraryEntry.setRequiredImport(fixedQualifier);
}
......
......@@ -102,11 +102,11 @@ QString ComponentTextModifier::text() const
QString txt(m_originalModifier->text());
const int leader = m_componentStartOffset - m_rootStartOffset;
txt.replace(m_rootStartOffset, leader, QString(leader, ' '));
txt.replace(m_rootStartOffset, leader, QString(leader, QLatin1Char(' ')));
const int textLength = txt.size();
const int trailer = textLength - m_componentEndOffset;
txt.replace(m_componentEndOffset, trailer, QString(trailer, ' '));
txt.replace(m_componentEndOffset, trailer, QString(trailer, QLatin1Char(' ')));
return txt;
}
......
......@@ -76,17 +76,17 @@ QString Import::toString(bool skipAlias) const
QString result;
if (isFileImport())
result += '"' + file() + '"';
result += QLatin1Char('"') + file() + QLatin1Char('"');
else if (isLibraryImport())
result += url();
else
return QString();
if (hasVersion())
result += ' ' + version();
result += QLatin1Char(' ') + version();
if (hasAlias() && !skipAlias)
result += " as " + alias();
result += QLatin1String(" as ") + alias();
return result;
}
......
......@@ -149,7 +149,7 @@ QString ModelNode::validId()
static bool idIsQmlKeyWord(const QString& id)
{
QStringList keywords;
keywords << "import" << "as";
keywords << QLatin1String("import") << QLatin1String("as");
return keywords.contains(id);
}
......@@ -589,7 +589,7 @@ void ModelNode::removeProperty(const PropertyName &name) const
if (!isValid())
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
model()->d->checkPropertyName(name);
model()->d->checkPropertyName(QString::fromLatin1(name));
if (internalNode()->hasProperty(name))
model()->d->removeProperty(internalNode()->property(name));
......@@ -1028,9 +1028,9 @@ QString ModelNode::convertTypeToImportAlias() const
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (model()->rewriterView())
return model()->rewriterView()->convertTypeToImportAlias(type());
return model()->rewriterView()->convertTypeToImportAlias(QString::fromLatin1(type()));
return type();
return QString::fromLatin1(type());
}
ModelNode::NodeSourceType ModelNode::nodeSourceType() const
......
......@@ -198,7 +198,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
newQmlItemNode = QmlItemNode(view->createModelNode("QtQuick.Image", metaInfo.majorVersion(), metaInfo.minorVersion(), propertyPairList));
parentproperty.reparentHere(newQmlItemNode);
newQmlItemNode.setId(view->generateNewId("image"));
newQmlItemNode.setId(view->generateNewId(QLatin1String("image")));
if (!view->currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
......
......@@ -191,7 +191,7 @@ bool QmlObjectNode::isTranslatableText(const PropertyName &name) const
if (modelNode().metaInfo().isValid() && modelNode().metaInfo().hasProperty(name))
if (modelNode().metaInfo().propertyTypeName(name) == "QString" || modelNode().metaInfo().propertyTypeName(name) == "string") {
if (modelNode().hasBindingProperty(name)) {
static QRegExp regularExpressionPatter("qsTr\\((\".*\")\\)");
static QRegExp regularExpressionPatter(QLatin1String("qsTr\\((\".*\")\\)"));
return regularExpressionPatter.exactMatch(modelNode().bindingProperty(name).expression());
}
......@@ -204,7 +204,7 @@ bool QmlObjectNode::isTranslatableText(const PropertyName &name) const
QString QmlObjectNode::stripedTranslatableText(const PropertyName &name) const
{
if (modelNode().hasBindingProperty(name)) {
static QRegExp regularExpressionPatter("qsTr\\(\"(.*)\"\\)");
static QRegExp regularExpressionPatter(QLatin1String("qsTr\\(\"(.*)\"\\)"));
if (regularExpressionPatter.exactMatch(modelNode().bindingProperty(name).expression()))
return regularExpressionPatter.cap(1);
} else {
......@@ -417,7 +417,7 @@ QVariant QmlObjectNode::instanceValue(const ModelNode &modelNode, const Property
QString QmlObjectNode::generateTranslatableText(const QString &text)
{
return QString("qsTr(\"%1\")").arg(text);
return QString(QStringLiteral("qsTr(\"%1\")")).arg(text);
}
TypeName QmlObjectNode::instanceType(const PropertyName &name) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment