Commit be443b8e authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Friedemann Kleint

CppTools: Compile with QT_NO_CAST_FROM_ASCII

Change-Id: I31a6117c2b4be3f8603c16a9f98b6937a0b9aeb2
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
parent f0ef96ef
......@@ -509,9 +509,9 @@ bool CheckSymbols::visit(SimpleDeclarationAST *ast)
// Add a diagnostic message if non-virtual function has override/final marker
if ((_usages.back().kind != SemanticInfo::VirtualMethodUse)) {
if (funTy->isOverride())
warning(declrIdNameAST, "Only virtual methods can be marked `override'");
warning(declrIdNameAST, QCoreApplication::translate("CPlusplus::CheckSymbols", "Only virtual methods can be marked `override'"));
else if (funTy->isFinal())
warning(declrIdNameAST, "Only virtual methods can be marked `final'");
warning(declrIdNameAST, QCoreApplication::translate("CPlusPlus::CheckSymbols", "Only virtual methods can be marked `final'"));
}
}
}
......@@ -713,7 +713,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
}
const unsigned length = tokenAt(name->lastToken() - 1).end() - tokenAt(name->firstToken()).begin();
warning(line, column, QCoreApplication::translate("CheckUndefinedSymbols", "Expected a namespace-name"), length);
warning(line, column, QCoreApplication::translate("CPlusPlus::CheckSymbols", "Expected a namespace-name"), length);
}
bool CheckSymbols::hasVirtualDestructor(Class *klass) const
......@@ -1288,9 +1288,9 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
// Add a diagnostic message if argument count does not match
if (matchType == Match_TooFewArgs)
warning(line, column, "Too few arguments", length);
warning(line, column, QCoreApplication::translate("CplusPlus::CheckSymbols", "Too few arguments"), length);
else if (matchType == Match_TooManyArgs)
warning(line, column, "Too many arguments", length);
warning(line, column, QCoreApplication::translate("CPlusPlus::CheckSymbols", "Too many arguments"), length);
const Use use(line, column, length, kind);
addUse(use);
......
......@@ -35,7 +35,7 @@ using namespace CppTools::Internal;
CppClassesFilter::CppClassesFilter(CppModelManager *manager)
: CppLocatorFilter(manager)
{
setShortcutString("c");
setShortcutString(QLatin1String("c"));
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Classes);
......
......@@ -96,7 +96,7 @@ void CppCodeStylePreferences::slotCurrentValueChanged(const QVariant &value)
QString CppCodeStylePreferences::settingsSuffix() const
{
return settingsSuffixKey;
return QLatin1String(settingsSuffixKey);
}
void CppCodeStylePreferences::toMap(const QString &prefix, QVariantMap *map) const
......
......@@ -98,7 +98,7 @@ Core::Id CppCodeStylePreferencesFactory::languageId()
QString CppCodeStylePreferencesFactory::displayName()
{
return Constants::CPP_SETTINGS_NAME;
return QString::fromUtf8(Constants::CPP_SETTINGS_NAME);
}
TextEditor::ICodeStylePreferences *CppCodeStylePreferencesFactory::createCodeStyle() const
......
......@@ -216,9 +216,8 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
m_previews << m_ui->previewTextEditGeneral << m_ui->previewTextEditContent
<< m_ui->previewTextEditBraces << m_ui->previewTextEditSwitch
<< m_ui->previewTextEditPadding;
for (int i = 0; i < m_previews.size(); ++i) {
m_previews[i]->setPlainText(defaultCodeStyleSnippets[i]);
}
for (int i = 0; i < m_previews.size(); ++i)
m_previews[i]->setPlainText(QLatin1String(defaultCodeStyleSnippets[i]));
TextEditor::TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
decorateEditors(textEditorSettings->fontSettings());
......@@ -513,17 +512,17 @@ void CppCodeStyleSettingsPage::apply()
if (originalCppCodeStylePreferences->codeStyleSettings() != m_pageCppCodeStylePreferences->codeStyleSettings()) {
originalCppCodeStylePreferences->setCodeStyleSettings(m_pageCppCodeStylePreferences->codeStyleSettings());
if (s)
originalCppCodeStylePreferences->toSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
originalCppCodeStylePreferences->toSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s);
}
if (originalCppCodeStylePreferences->tabSettings() != m_pageCppCodeStylePreferences->tabSettings()) {
originalCppCodeStylePreferences->setTabSettings(m_pageCppCodeStylePreferences->tabSettings());
if (s)
originalCppCodeStylePreferences->toSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
originalCppCodeStylePreferences->toSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s);
}
if (originalCppCodeStylePreferences->currentDelegate() != m_pageCppCodeStylePreferences->currentDelegate()) {
originalCppCodeStylePreferences->setCurrentDelegate(m_pageCppCodeStylePreferences->currentDelegate());
if (s)
originalCppCodeStylePreferences->toSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
originalCppCodeStylePreferences->toSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s);
}
}
}
......
......@@ -412,9 +412,9 @@ QString CppFunctionHintModel::text(int index) const
QString hintText;
hintText += Qt::escape(prettyMethod.left(begin));
hintText += "<b>";
hintText += QLatin1String("<b>");
hintText += Qt::escape(prettyMethod.mid(begin, end - begin));
hintText += "</b>";
hintText += QLatin1String("</b>");
hintText += Qt::escape(prettyMethod.mid(end));
return hintText;
}
......@@ -648,7 +648,7 @@ Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
CppCompletionAssistProcessor::CppCompletionAssistProcessor()
: m_startPosition(-1)
, m_objcEnabled(true)
, m_snippetCollector(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID,
, m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID),
QIcon(QLatin1String(":/texteditor/images/snippet.png")))
, preprocessorCompletions(QStringList()
<< QLatin1String("define")
......@@ -1130,7 +1130,7 @@ void CppCompletionAssistProcessor::completeObjCMsgSend(CPlusPlus::ClassOrNamespa
if (i > 0)
text += QLatin1Char(' ');
Symbol *arg = method->argumentAt(i);
text += selectorName->nameAt(i)->identifier()->chars();
text += QString::fromUtf8(selectorName->nameAt(i)->identifier()->chars());
text += QLatin1Char(':');
text += TextEditor::Snippet::kVariableDelimiter;
text += QLatin1Char('(');
......@@ -1140,7 +1140,7 @@ void CppCompletionAssistProcessor::completeObjCMsgSend(CPlusPlus::ClassOrNamespa
text += TextEditor::Snippet::kVariableDelimiter;
}
} else {
text = selectorName->identifier()->chars();
text = QString::fromUtf8(selectorName->identifier()->chars());
}
data = text;
......@@ -1237,7 +1237,7 @@ bool CppCompletionAssistProcessor::objcKeywordsWanted() const
QString fileName = document->fileName();
const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase();
return mdb->findByFile(fileName).type() == CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE;
return mdb->findByFile(fileName).type() == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE);
}
int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName,
......@@ -1863,7 +1863,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
int lineStartToken = bs.startOfLine(startToken);
// make sure the required tokens are actually available
bs.LA(startToken - lineStartToken);
QString possibleDecl = bs.mid(lineStartToken).trimmed().append("();");
QString possibleDecl = bs.mid(lineStartToken).trimmed().append(QLatin1String("();"));
Document::Ptr doc = Document::create(QLatin1String("<completion>"));
doc->setUtf8Source(possibleDecl.toLatin1());
......
......@@ -68,7 +68,7 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
QRegExp regexp(asterisk + entry + asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
if (!regexp.isValid())
return goodEntries;
bool hasWildcard = (entry.contains(asterisk) || entry.contains('?'));
bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?')));
if (m_currentFileName.isEmpty())
return goodEntries;
......
......@@ -297,7 +297,7 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search)
Core::ProgressManager *progressManager = Core::ICore::progressManager();
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
CppTools::Constants::TASK_SEARCH);
QLatin1String(CppTools::Constants::TASK_SEARCH));
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
......@@ -410,7 +410,7 @@ namespace {
class SymbolFinder : public SymbolVisitor
{
public:
SymbolFinder(const QStringList &uid) : m_uid(uid), m_index(0), m_result(0) { }
SymbolFinder(const QList<QByteArray> &uid) : m_uid(uid), m_index(0), m_result(0) { }
Symbol *result() const { return m_result; }
bool preVisit(Symbol *symbol)
......@@ -439,7 +439,7 @@ public:
}
private:
QStringList m_uid;
QList<QByteArray> m_uid;
int m_index;
Symbol *m_result;
};
......@@ -461,7 +461,7 @@ bool CppFindReferences::findSymbol(CppFindReferencesParameters *parameters,
doc->check();
// construct id of old symbol
QStringList uid;
QList<QByteArray> uid;
Symbol *current = parameters->symbol;
do {
uid.prepend(idForSymbol(current));
......@@ -649,7 +649,7 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
Find::SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(
tr("C++ Macro Usages:"),
QString(),
macro.name(),
QString::fromUtf8(macro.name()),
replace ? Find::SearchResultWindow::SearchAndReplace
: Find::SearchResultWindow::SearchOnly,
QLatin1String("CppEditor"));
......@@ -683,13 +683,13 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
Core::ProgressManager *progressManager = Core::ICore::progressManager();
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
CppTools::Constants::TASK_SEARCH);
QLatin1String(CppTools::Constants::TASK_SEARCH));
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
void CppFindReferences::renameMacroUses(const Macro &macro, const QString &replacement)
{
const QString textToReplace = replacement.isEmpty() ? macro.name() : replacement;
const QString textToReplace = replacement.isEmpty() ? QString::fromUtf8(macro.name()) : replacement;
findMacroUses(macro, textToReplace, true);
}
......
......@@ -88,7 +88,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
if (!regexp.isValid())
return goodEntries;
bool hasWildcard = (entry.contains(asterisk) || entry.contains('?'));
bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?')));
QHashIterator<QString, QList<ModelItemInfo> > it(m_searchList);
while (it.hasNext()) {
......
......@@ -709,7 +709,7 @@ public:
if (sourceFiles.count() > 1) {
Core::ICore::progressManager()->addTask(result,
QCoreApplication::translate("IndexingSupport", "Parsing"),
CppTools::Constants::TASK_INDEX);
QLatin1String(CppTools::Constants::TASK_INDEX));
}
return result;
......@@ -1052,13 +1052,13 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
QSetIterator<AbstractEditorSupport *> jt(m_addtionalEditorSupport);
while (jt.hasNext()) {
AbstractEditorSupport *es = jt.next();
workingCopy.insert(es->fileName(), es->contents());
workingCopy.insert(es->fileName(), QString::fromUtf8(es->contents()));
}
// add the project configuration file
QByteArray conf(pp_configuration);
conf += definedMacros();
workingCopy.insert(pp_configuration_file, conf);
workingCopy.insert(QLatin1String(pp_configuration_file), QString::fromUtf8(conf));
return workingCopy;
}
......@@ -1124,7 +1124,7 @@ QList<CppModelManager::ProjectPart::Ptr> CppModelManager::projectPart(const QStr
return parts;
//### FIXME: This is a DIRTY hack!
if (fileName.endsWith(".h")) {
if (fileName.endsWith(QLatin1String(".h"))) {
QString cppFile = fileName.mid(0, fileName.length() - 2) + QLatin1String(".cpp");
parts = m_srcToProjectPart.value(cppFile);
if (!parts.isEmpty())
......@@ -1358,7 +1358,7 @@ void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
void CppModelManager::onAboutToUnloadSession()
{
if (Core::ProgressManager *pm = Core::ICore::progressManager()) {
pm->cancelTasks(CppTools::Constants::TASK_INDEX);
pm->cancelTasks(QLatin1String(CppTools::Constants::TASK_INDEX));
}
do {
QMutexLocker locker(&mutex);
......
......@@ -4,8 +4,7 @@ include(../../qtcreatorplugin.pri)
include($$IDE_SOURCE_TREE/src/plugins/locator/locator.pri)
include(cpptools_dependencies.pri)
# DEFINES += QT_NO_CAST_FROM_ASCII
DEFINES += QT_NO_CAST_TO_ASCII
DEFINES += QT_NO_CAST_FROM_ASCII
INCLUDEPATH += .
DEFINES += CPPTOOLS_LIBRARY
HEADERS += completionsettingspage.h \
......
......@@ -16,7 +16,7 @@ QtcPlugin {
Depends { name: "LanguageUtils" }
Depends { name: "cpp" }
cpp.defines: base.concat(["QT_NO_CAST_TO_ASCII"])
cpp.defines: base.concat(["QT_NO_CAST_FROM_ASCII"])
files: [
"ModelManagerInterface.cpp",
......
......@@ -123,7 +123,7 @@ void CppEditorSupport::updateDocumentNow()
_updateDocumentTimer->stop();
QStringList sourceFiles(_textEditor->document()->fileName());
_cachedContents = _textEditor->contents().toUtf8();
_cachedContents = _textEditor->contents();
_documentParser = _modelManager->updateSourceFiles(sourceFiles);
}
}
......
......@@ -102,7 +102,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
d->m_globalCodeStyle = new CppCodeStylePreferences(this);
d->m_globalCodeStyle->setDelegatingPool(pool);
d->m_globalCodeStyle->setDisplayName(tr("Global", "Settings"));
d->m_globalCodeStyle->setId(idKey);
d->m_globalCodeStyle->setId(QLatin1String(idKey));
pool->addCodeStyle(d->m_globalCodeStyle);
textEditorSettings->registerCodeStyle(CppTools::Constants::CPP_SETTINGS_ID, d->m_globalCodeStyle);
......@@ -171,7 +171,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
// load global settings (after built-in settings are added to the pool)
QSettings *s = Core::ICore::settings();
d->m_globalCodeStyle->fromSettings(CppTools::Constants::CPP_SETTINGS_ID, Core::ICore::settings());
d->m_globalCodeStyle->fromSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), Core::ICore::settings());
// legacy handling start (Qt Creator Version < 2.4)
const bool legacyTransformed =
......@@ -214,7 +214,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
// change the current delegate and save
d->m_globalCodeStyle->setCurrentDelegate(oldCreator);
d->m_globalCodeStyle->toSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
d->m_globalCodeStyle->toSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s);
}
// mark old settings as transformed
s->setValue(QLatin1String("CppCodeStyleSettings/LegacyTransformed"), true);
......
......@@ -528,14 +528,14 @@ static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration,
if (!definitionFunction)
return noResult;
Document::Ptr targetDoc = changes.snapshot().document(definition->fileName());
Document::Ptr targetDoc = changes.snapshot().document(QString::fromUtf8(definition->fileName()));
if (!targetDoc)
return noResult;
targetDoc->translationUnit()->getPosition(definitionFunction->endOffset(), &line, &column);
} else {
// we don't have an offset to the start of the function definition, so we need to manually find it...
CppRefactoringFilePtr targetFile = changes.file(definition->fileName());
CppRefactoringFilePtr targetFile = changes.file(QString::fromUtf8(definition->fileName()));
if (!targetFile->isValid())
return noResult;
......@@ -547,7 +547,7 @@ static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration,
targetFile->cppDocument()->translationUnit()->getTokenStartPosition(functionDefinition->firstToken(), &line, &column);
}
return InsertionLocation(definition->fileName(), prefix, suffix, line, column);
return InsertionLocation(QString::fromUtf8(definition->fileName()), prefix, suffix, line, column);
}
QList<InsertionLocation> InsertionPointLocator::methodDefinition(
......
......@@ -207,7 +207,7 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
m_manager->snapshot(), projectFileNames));
Core::FutureProgress *progress = Core::ICore::progressManager()->addTask(watcher->future(),
tr("Searching"),
Find::Constants::TASK_SEARCH);
QLatin1String(Find::Constants::TASK_SEARCH));
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
......@@ -256,17 +256,17 @@ QWidget *SymbolsFindFilter::createConfigWidget()
void SymbolsFindFilter::writeSettings(QSettings *settings)
{
settings->beginGroup(QLatin1String(SETTINGS_GROUP));
settings->setValue(SETTINGS_SYMBOLTYPES, (int)m_symbolsToSearch);
settings->setValue(SETTINGS_SEARCHSCOPE, (int)m_scope);
settings->setValue(QLatin1String(SETTINGS_SYMBOLTYPES), (int)m_symbolsToSearch);
settings->setValue(QLatin1String(SETTINGS_SEARCHSCOPE), (int)m_scope);
settings->endGroup();
}
void SymbolsFindFilter::readSettings(QSettings *settings)
{
settings->beginGroup(QLatin1String(SETTINGS_GROUP));
m_symbolsToSearch = (SearchSymbols::SymbolTypes)settings->value(SETTINGS_SYMBOLTYPES,
m_symbolsToSearch = (SearchSymbols::SymbolTypes)settings->value(QLatin1String(SETTINGS_SYMBOLTYPES),
(int)SearchSymbols::AllTypes).toInt();
m_scope = (SearchScope)settings->value(SETTINGS_SEARCHSCOPE,
m_scope = (SearchScope)settings->value(QLatin1String(SETTINGS_SEARCHSCOPE),
(int)SearchProjectsOnly).toInt();
settings->endGroup();
emit symbolsToSearchChanged();
......@@ -274,7 +274,7 @@ void SymbolsFindFilter::readSettings(QSettings *settings)
void SymbolsFindFilter::onTaskStarted(const QString &type)
{
if (type == CppTools::Constants::TASK_INDEX) {
if (type == QLatin1String(CppTools::Constants::TASK_INDEX)) {
m_enabled = false;
emit enabledChanged(m_enabled);
}
......@@ -282,7 +282,7 @@ void SymbolsFindFilter::onTaskStarted(const QString &type)
void SymbolsFindFilter::onAllTasksFinished(const QString &type)
{
if (type == CppTools::Constants::TASK_INDEX) {
if (type == QLatin1String(CppTools::Constants::TASK_INDEX)) {
m_enabled = true;
emit enabledChanged(m_enabled);
}
......
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