Commit 34933799 authored by Friedemann Kleint's avatar Friedemann Kleint

TextEditor: Compile with QT_NO_CAST_FROM_ASCII.

Change-Id: I8fa683c4f68d6e3d3a3eb95acf2f54f8c56b87b7
Reviewed-by: default avatarLeandro Melo <leandro.melo@nokia.com>
parent f85df655
......@@ -140,9 +140,11 @@ public:
if (str.isEmpty())
return str;
int first = 0, last = str.size()-1;
while (first < str.size() && (str.at(first) == '*' || str.at(first) == '?'))
const QChar asterisk = QLatin1Char('*');
const QChar question = QLatin1Char('?');
while (first < str.size() && (str.at(first) == asterisk || str.at(first) == question))
++first;
while (last >= 0 && (str.at(last) == '*' || str.at(last) == '?'))
while (last >= 0 && (str.at(last) == asterisk || str.at(last) == question))
--last;
if (first > last)
return QString();
......
......@@ -160,7 +160,7 @@ void BaseFileFind::runSearch(Find::SearchResult *search)
Core::FutureProgress *progress =
Core::ICore::instance()->progressManager()->addTask(watcher->future(),
tr("Search"),
Constants::TASK_SEARCH);
QLatin1String(Constants::TASK_SEARCH));
progress->setWidget(label);
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
}
......@@ -240,15 +240,15 @@ QWidget *BaseFileFind::createPatternWidget()
void BaseFileFind::writeCommonSettings(QSettings *settings)
{
settings->setValue("filters", m_filterStrings.stringList());
settings->setValue(QLatin1String("filters"), m_filterStrings.stringList());
if (m_filterCombo)
settings->setValue("currentFilter", m_filterCombo->currentText());
settings->setValue(QLatin1String("currentFilter"), m_filterCombo->currentText());
}
void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaultFilter)
{
QStringList filters = settings->value("filters").toStringList();
m_filterSetting = settings->value("currentFilter").toString();
QStringList filters = settings->value(QLatin1String("filters")).toStringList();
m_filterSetting = settings->value(QLatin1String("currentFilter")).toString();
if (filters.isEmpty())
filters << defaultFilter;
if (m_filterSetting.isEmpty())
......
......@@ -461,7 +461,7 @@ bool BaseTextDocument::open(QString *errorString, const QString &fileName, const
QFutureInterface<void> interface;
interface.setProgressRange(0, chunks);
Core::ICore::instance()->progressManager()->addTask(
interface.future(), tr("Opening file"), Constants::TASK_OPEN_FILE);
interface.future(), tr("Opening file"), QLatin1String(Constants::TASK_OPEN_FILE));
interface.reportStarted();
d->m_document->setUndoRedoEnabled(false);
QTextCursor c(d->m_document);
......
......@@ -190,10 +190,10 @@ TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCurs
cursor->clearSelection();
cursor->setPosition(openParenParag.position() + openParen.pos, QTextCursor::KeepAnchor);
if ((c == '}' && openParen.chr != '{') ||
(c == ')' && openParen.chr != '(') ||
(c == ']' && openParen.chr != '[') ||
(c == '-' && openParen.chr != '+'))
if ((c == QLatin1Char('}') && openParen.chr != QLatin1Char('{')) ||
(c == QLatin1Char(')') && openParen.chr != QLatin1Char('(')) ||
(c == QLatin1Char(']') && openParen.chr != QLatin1Char('[')) ||
(c == QLatin1Char('-') && openParen.chr != QLatin1Char('+')))
return Mismatch;
return Match;
......
......@@ -1005,7 +1005,7 @@ void BaseTextEditorWidget::joinLines()
QString cutLine = cursor.selectedText();
// Collapse leading whitespaces to one or insert whitespace
cutLine.replace(QRegExp("^\\s*"), " ");
cutLine.replace(QRegExp(QLatin1String("^\\s*")), QLatin1String(" "));
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
......@@ -5396,7 +5396,7 @@ void BaseTextEditorWidget::format()
void BaseTextEditorWidget::rewrapParagraph()
{
const int paragraphWidth = displaySettings().m_wrapColumn;
const QRegExp anyLettersOrNumbers = QRegExp("\\w");
const QRegExp anyLettersOrNumbers = QRegExp(QLatin1String("\\w"));
const int tabSize = tabSettings().m_tabSize;
QTextCursor cursor = textCursor();
......@@ -5604,7 +5604,7 @@ void BaseTextEditorWidget::setTabSettings(const TabSettings &ts)
// Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it
// to be set as an int. A work around is to access directly the QTextOption.
qreal charWidth = QFontMetricsF(font()).width(QChar(' '));
qreal charWidth = QFontMetricsF(font()).width(QLatin1Char(' '));
QTextOption option = document()->defaultTextOption();
option.setTabStop(charWidth * ts.m_tabSize);
document()->setDefaultTextOption(option);
......
......@@ -96,7 +96,7 @@ BehaviorSettingsPage::BehaviorSettingsPage(const BehaviorSettingsPageParameters
// global tab preferences for all other languages
d->m_codeStyle = new SimpleCodeStylePreferences(this);
d->m_codeStyle->setDisplayName(tr("Global", "Settings"));
d->m_codeStyle->setId(Constants::GLOBAL_SETTINGS_ID);
d->m_codeStyle->setId(QLatin1String(Constants::GLOBAL_SETTINGS_ID));
// default pool for all other languages
d->m_defaultCodeStylePool = new CodeStylePool(0, this); // Any language
......
......@@ -70,7 +70,7 @@ BehaviorSettingsWidget::BehaviorSettingsWidget(QWidget *parent)
std::rotate(mibs.begin(), firstNonNegative, mibs.end());
foreach (int mib, mibs) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
QString compoundName = codec->name();
QString compoundName = QLatin1String(codec->name());
foreach (const QByteArray &alias, codec->aliases()) {
compoundName += QLatin1String(" / ");
compoundName += QString::fromLatin1(alias);
......
......@@ -58,7 +58,7 @@ FindInCurrentFile::FindInCurrentFile()
QString FindInCurrentFile::id() const
{
return "Current File";
return QLatin1String("Current File");
}
QString FindInCurrentFile::displayName() const
......@@ -134,14 +134,14 @@ QWidget *FindInCurrentFile::createConfigWidget()
void FindInCurrentFile::writeSettings(QSettings *settings)
{
settings->beginGroup("FindInCurrentFile");
settings->beginGroup(QLatin1String("FindInCurrentFile"));
writeCommonSettings(settings);
settings->endGroup();
}
void FindInCurrentFile::readSettings(QSettings *settings)
{
settings->beginGroup("FindInCurrentFile");
readCommonSettings(settings, "*.cpp,*.h");
settings->beginGroup(QLatin1String("FindInCurrentFile"));
readCommonSettings(settings, QLatin1String("*.cpp,*.h"));
settings->endGroup();
}
......@@ -54,7 +54,7 @@ FindInFiles::FindInFiles()
QString FindInFiles::id() const
{
return "Files on Disk";
return QLatin1String("Files on Disk");
}
QString FindInFiles::displayName() const
......@@ -83,15 +83,16 @@ QVariant FindInFiles::additionalParameters() const
QString FindInFiles::label() const
{
const QChar slash = QLatin1Char('/');
const QStringList &nonEmptyComponents = QDir::cleanPath(
QFileInfo(QDir::fromNativeSeparators(m_directory->currentText())).absoluteFilePath())
.split(QLatin1Char('/'), QString::SkipEmptyParts);
return tr("Directory '%1':").arg(nonEmptyComponents.isEmpty() ? "/" : nonEmptyComponents.last());
.split(slash, QString::SkipEmptyParts);
return tr("Directory '%1':").arg(nonEmptyComponents.isEmpty() ? QString(slash) : nonEmptyComponents.last());
}
QString FindInFiles::toolTip() const
{
// %3 is filled by BaseFileFind::runNewSearch
//: %3 is filled by BaseFileFind::runNewSearch
return tr("Path: %1\nFilter: %2\n%3")
.arg(QDir::toNativeSeparators(QFileInfo(m_directory->currentText()).absoluteFilePath()))
.arg(fileNameFilters().join(QLatin1String(",")));
......@@ -150,20 +151,20 @@ void FindInFiles::openFileBrowser()
void FindInFiles::writeSettings(QSettings *settings)
{
settings->beginGroup("FindInFiles");
settings->beginGroup(QLatin1String("FindInFiles"));
writeCommonSettings(settings);
settings->setValue("directories", m_directoryStrings.stringList());
settings->setValue(QLatin1String("directories"), m_directoryStrings.stringList());
if (m_directory)
settings->setValue("currentDirectory", m_directory->currentText());
settings->setValue(QLatin1String("currentDirectory"), m_directory->currentText());
settings->endGroup();
}
void FindInFiles::readSettings(QSettings *settings)
{
settings->beginGroup("FindInFiles");
readCommonSettings(settings, "*.cpp,*.h");
m_directoryStrings.setStringList(settings->value("directories").toStringList());
m_directorySetting = settings->value("currentDirectory").toString();
settings->beginGroup(QLatin1String("FindInFiles"));
readCommonSettings(settings, QLatin1String("*.cpp,*.h"));
m_directoryStrings.setStringList(settings->value(QLatin1String("directories")).toStringList());
m_directorySetting = settings->value(QLatin1String("currentDirectory")).toString();
settings->endGroup();
syncComboWithSettings(m_directory, m_directorySetting);
}
......
......@@ -339,7 +339,7 @@ QString FontSettings::defaultFixedFontFamily()
{
static QString rc;
if (rc.isEmpty()) {
QFont f(DEFAULT_FONT_FAMILY);
QFont f = QFont(QLatin1String(DEFAULT_FONT_FAMILY));
f.setStyleHint(QFont::TypeWriter);
rc = f.family();
}
......
......@@ -321,7 +321,7 @@ void Manager::registerMimeTypes()
Core::ICore::instance()->progressManager()->addTask(future,
tr("Registering definitions"),
Constants::TASK_REGISTER_DEFINITIONS);
QLatin1String(Constants::TASK_REGISTER_DEFINITIONS));
} else {
m_hasQueuedRegistration = true;
m_registeringWatcher.cancel();
......@@ -457,7 +457,7 @@ void Manager::downloadDefinitions(const QList<QUrl> &urls, const QString &savePa
m_downloadWatcher.setFuture(future);
Core::ICore::instance()->progressManager()->addTask(future,
tr("Downloading definitions"),
Constants::TASK_DOWNLOAD_DEFINITIONS);
QLatin1String(Constants::TASK_DOWNLOAD_DEFINITIONS));
}
void Manager::downloadDefinitionsFinished()
......
......@@ -99,7 +99,7 @@ QString HelpItem::extractContent(bool extended) const
helpLinks.insert(m_helpId, m_helpId);
}
foreach (const QUrl &url, helpLinks) {
const QByteArray &html = Core::HelpManager::instance()->fileData(url);
const QString html = QString::fromUtf8(Core::HelpManager::instance()->fileData(url));
switch (m_category) {
case Brief:
contents = htmlExtractor.getClassOrNamespaceBrief(html, m_docMark);
......
......@@ -69,7 +69,7 @@ void LineNumberFilter::accept(FilterEntry selection) const
editorManager->addCurrentPositionToNavigationHistory();
editor->gotoLine(selection.internalData.toInt());
editor->widget()->setFocus();
Core::ModeManager::instance()->activateModeType(Core::Constants::MODE_EDIT_TYPE);
Core::ModeManager::instance()->activateModeType(QLatin1String(Core::Constants::MODE_EDIT_TYPE));
}
}
......
......@@ -53,7 +53,7 @@ public:
explicit LineNumberFilter(QObject *parent = 0);
QString displayName() const { return tr("Line in Current Document"); }
QString id() const { return "Line in current document"; }
QString id() const { return QLatin1String("Line in current document"); }
Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::High; }
QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
void accept(Locator::FilterEntry selection) const;
......
......@@ -95,13 +95,17 @@ QToolButton *OutlineWidgetStack::filterButton()
return m_filterButton;
}
static inline QString outLineKey(int position)
{
return QLatin1String("Outline.") + QString::number(position) + QLatin1String(".SyncWithEditor");
}
void OutlineWidgetStack::restoreSettings(int position)
{
m_position = position; // save it so that we can save/restore in updateCurrentEditor
QSettings *settings = Core::ICore::instance()->settings();
const bool toggleSync = settings->value("Outline."+ QString::number(position) + ".SyncWithEditor",
true).toBool();
const bool toggleSync = settings->value(outLineKey(position), true).toBool();
toggleSyncButton()->setChecked(toggleSync);
if (IOutlineWidget *outlineWidget = qobject_cast<IOutlineWidget*>(currentWidget())) {
......@@ -114,8 +118,7 @@ void OutlineWidgetStack::saveSettings(int position)
Q_ASSERT(position == m_position);
QSettings *settings = Core::ICore::instance()->settings();
settings->setValue("Outline."+QString::number(position)+".SyncWithEditor",
toggleSyncButton()->isEnabled());
settings->setValue(outLineKey(position), toggleSyncButton()->isEnabled());
if (IOutlineWidget *outlineWidget = qobject_cast<IOutlineWidget*>(currentWidget())) {
outlineWidget->saveSettings(position);
......
......@@ -231,8 +231,8 @@ QString PlainTextEditorWidget::findDefinitionId(const Core::MimeType &mimeType,
void PlainTextEditorWidget::acceptMissingSyntaxDefinitionInfo()
{
Core::ICore::instance()->showOptionsDialog(Constants::TEXT_EDITOR_SETTINGS_CATEGORY,
Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS);
Core::ICore::instance()->showOptionsDialog(QLatin1String(Constants::TEXT_EDITOR_SETTINGS_CATEGORY),
QLatin1String(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS));
}
void PlainTextEditorWidget::ignoreMissingSyntaxDefinitionInfo()
......
......@@ -99,12 +99,13 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
if (!file)
return;
PlainTextEditorWidget *textEditor = static_cast<PlainTextEditorWidget *>(editorEditable->editorWidget());
const QString infoSyntaxDefinition = QLatin1String(Constants::INFO_SYNTAX_DEFINITION);
if (textEditor->isMissingSyntaxDefinition() &&
!textEditor->ignoreMissingSyntaxDefinition() &&
TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) {
if (file->hasHighlightWarning())
return;
Core::InfoBarEntry info(Constants::INFO_SYNTAX_DEFINITION,
Core::InfoBarEntry info(infoSyntaxDefinition,
tr("A highlight definition was not found for this file. "
"Would you like to try to find one?"));
info.setCustomButtonInfo(tr("Show highlighter options..."),
......@@ -116,7 +117,7 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
}
if (!file->hasHighlightWarning())
return;
file->infoBar()->removeInfo(Constants::INFO_SYNTAX_DEFINITION);
file->infoBar()->removeInfo(infoSyntaxDefinition);
file->setHighlightWarning(false);
}
}
......
......@@ -35,7 +35,7 @@
using namespace TextEditor;
static const char *settingsSuffixKey = "TabPreferences";
static const char settingsSuffixKey[] = "TabPreferences";
SimpleCodeStylePreferences::SimpleCodeStylePreferences(QObject *parent)
......@@ -56,7 +56,7 @@ void SimpleCodeStylePreferences::setValue(const QVariant &value)
QString SimpleCodeStylePreferences::settingsSuffix() const
{
return settingsSuffixKey;
return QLatin1String(settingsSuffixKey);
}
......@@ -76,6 +76,6 @@ QList<BasicProposalItem *> SnippetAssistCollector::collect() const
{
QList<BasicProposalItem *> snippets;
appendSnippets(&snippets, m_groupId, m_icon, m_order);
appendSnippets(&snippets, Constants::TEXT_SNIPPET_GROUP_ID, m_icon, m_order);
appendSnippets(&snippets, QLatin1String(Constants::TEXT_SNIPPET_GROUP_ID), m_icon, m_order);
return snippets;
}
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