Fix some code scanning issues.

QString: Use QChar where appropriate.
This commit is contained in:
Friedemann Kleint
2010-02-01 12:43:56 +01:00
parent d2235489e8
commit 2fd8b2d7ff
54 changed files with 170 additions and 160 deletions

View File

@@ -260,7 +260,7 @@ bool CMakeProject::parseCMakeLists()
foreach(const CMakeTarget &ct, m_targets) {
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith("/fast"))
if (ct.title.endsWith(QLatin1String("/fast")))
continue;
QList<CMakeRunConfiguration *> list = existingRunConfigurations.values(ct.title);
if (!list.isEmpty()) {
@@ -312,7 +312,7 @@ QStringList CMakeProject::targets() const
foreach (const CMakeTarget &ct, m_targets) {
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith("/fast"))
if (ct.title.endsWith(QLatin1String("/fast")))
continue;
results << ct.title;
}
@@ -324,7 +324,7 @@ bool CMakeProject::hasTarget(const QString &title) const
foreach (const CMakeTarget &ct, m_targets) {
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith("/fast"))
if (ct.title.endsWith(QLatin1String("/fast")))
continue;
if (ct.title == title)
return true;
@@ -410,11 +410,12 @@ void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::
ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *rootNode, QString directory)
{
QString relativePath = QDir(QFileInfo(rootNode->path()).path()).relativeFilePath(directory);
QStringList parts = relativePath.split("/", QString::SkipEmptyParts);
QStringList parts = relativePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
ProjectExplorer::FolderNode *parent = rootNode;
QString path = QFileInfo(rootNode->path()).path();
foreach (const QString &part, parts) {
path += "/" + part;
path += QLatin1Char('/');
path += part;
// Find folder in subFolders
bool found = false;
foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) {
@@ -899,12 +900,12 @@ void CMakeCbpParser::parseUnit()
while (!atEnd()) {
readNext();
if (isEndElement()) {
if (!fileName.endsWith(".rule") && !m_processedUnits.contains(fileName)) {
if (!fileName.endsWith(QLatin1String(".rule")) && !m_processedUnits.contains(fileName)) {
// Now check whether we found a virtual element beneath
if (m_parsingCmakeUnit) {
m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false));
} else {
if (fileName.endsWith(".qrc"))
if (fileName.endsWith(QLatin1String(".qrc")))
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ResourceType, false));
else
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));

View File

@@ -292,7 +292,7 @@ void MakeStepConfigWidget::updateDetails()
CMakeBuildConfiguration *bc = m_makeStep->cmakeBuildConfiguration();
ProjectExplorer::ToolChain *tc = bc->toolChain();
if (tc)
m_summaryText = tr("<b>Make:</b> %1 %2").arg(tc->makeCommand(), arguments.join(" "));
m_summaryText = tr("<b>Make:</b> %1 %2").arg(tc->makeCommand(), arguments.join(QString(QLatin1Char(' '))));
else
m_summaryText = tr("<b>Unknown Toolchain</b>");
emit updateSummary();

View File

@@ -67,7 +67,7 @@ class SettingsDatabasePrivate
public:
QString effectiveGroup() const
{
return m_groups.join(QLatin1String("/"));
return m_groups.join(QString(QLatin1Char('/')));
}
QString effectiveKey(const QString &key) const

View File

@@ -129,7 +129,7 @@ void CodePasterProtocol::paste(const QString &text,
data += CGI::encodeURL(username).toLatin1();
http.setHost(hostName);
http.post("/", data);
http.post(QString(QLatin1Char('/')), data);
}
bool CodePasterProtocol::hasSettings() const

View File

@@ -40,7 +40,7 @@ using namespace CPlusPlus;
CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager, Core::EditorManager *editorManager)
: m_modelManager(manager)
{
setShortcutString(".");
setShortcutString(QString(QLatin1Char('.')));
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Declarations |
@@ -64,10 +64,11 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(const QString &
QList<Locator::FilterEntry> goodEntries;
QList<Locator::FilterEntry> betterEntries;
QStringMatcher matcher(entry, Qt::CaseInsensitive);
const QRegExp regexp("*"+entry+"*", Qt::CaseInsensitive, QRegExp::Wildcard);
const QChar asterisk = QLatin1Char('*');
const QRegExp regexp(asterisk + entry + asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
if (!regexp.isValid())
return goodEntries;
bool hasWildcard = (entry.contains('*') || entry.contains('?'));
bool hasWildcard = (entry.contains(asterisk) || entry.contains('?'));
if (m_currentFileName.isEmpty())
return goodEntries;

View File

@@ -34,7 +34,7 @@ using namespace CppTools::Internal;
CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager)
: CppLocatorFilter(manager, editorManager)
{
setShortcutString("m");
setShortcutString(QString(QLatin1Char('m')));
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Functions);

View File

@@ -44,7 +44,7 @@ CppLocatorFilter::CppLocatorFilter(CppModelManager *manager, Core::EditorManager
m_editorManager(editorManager),
m_forceNewSearchList(true)
{
setShortcutString(":");
setShortcutString(QString(QLatin1Char(':')));
setIncludedByDefault(false);
connect(manager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)),
@@ -84,11 +84,12 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(const QString &origEntr
QString entry = trimWildcards(origEntry);
QList<Locator::FilterEntry> goodEntries;
QList<Locator::FilterEntry> betterEntries;
const QChar asterisk = QLatin1Char('*');
QStringMatcher matcher(entry, Qt::CaseInsensitive);
const QRegExp regexp("*"+entry+"*", Qt::CaseInsensitive, QRegExp::Wildcard);
const QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
if (!regexp.isValid())
return goodEntries;
bool hasWildcard = (entry.contains('*') || entry.contains('?'));
bool hasWildcard = (entry.contains(asterisk) || entry.contains('?'));
QMutableMapIterator<QString, Info> it(m_searchList);
while (it.hasNext()) {

View File

@@ -197,7 +197,7 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
}
symbolName = QLatin1String("<anonymous ");
symbolName += type;
symbolName += QLatin1String(">");
symbolName += QLatin1Char('>');
}
return symbolName;
}

View File

@@ -268,7 +268,7 @@ public slots:
void gotoResult(int i)
{
QString needle = QString::number(i) + '^';
QString needle2 = QLatin1String(">") + needle;
QString needle2 = QLatin1Char('>') + needle;
QTextCursor cursor(document());
do {
const QString line = cursor.block().text();

View File

@@ -2207,7 +2207,7 @@ void GdbEngine::attemptBreakpointSynchronization()
// (reloadSourceFiles and reloadBreakList) to be executed
// within the same stop-executecommand-continue cycle.
// Just calling reloadSourceFiles and reloadBreakList doesn't work
// in this case, because a) stopping the executable is asyncronous,
// in this case, because a) stopping the executable is asynchronous,
// b) we wouldn't want to stop-exec-continue twice
m_sourcesListUpdating = true;
GdbCommand cmd;

View File

@@ -255,7 +255,7 @@ QList<StackFrame> StackHandler::frames() const
bool StackHandler::isDebuggingDebuggingHelpers() const
{
for (int i = m_stackFrames.size(); --i >= 0; )
if (m_stackFrames.at(i).function.startsWith("qDumpObjectData"))
if (m_stackFrames.at(i).function.startsWith(QLatin1String("qDumpObjectData")))
return true;
return false;
}

View File

@@ -152,7 +152,7 @@ void WatchData::setValue(const QString &value0)
}
// avoid duplicated information
if (value.startsWith("(") && value.contains(") 0x"))
if (value.startsWith(QLatin1Char('(')) && value.contains(") 0x"))
value = value.mid(value.lastIndexOf(") 0x") + 2);
// doubles are sometimes displayed as "@0x6141378: 1.2".
@@ -171,8 +171,8 @@ void WatchData::setValue(const QString &value0)
// pointer type information is available in the 'type'
// column. No need to duplicate it here.
if (value.startsWith("(" + type + ") 0x"))
value = value.section(" ", -1, -1);
if (value.startsWith(QLatin1Char('(') + type + ") 0x"))
value = value.section(QLatin1Char(' '), -1, -1);
setValueUnneeded();
}
@@ -796,7 +796,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
switch (idx.column()) {
case 0:
if (data.name == QLatin1String("*") && item->parent)
return QLatin1String("*") + item->parent->name;
return QLatin1Char('*') + item->parent->name;
return data.name;
case 1: {
int format = m_handler->m_individualFormats.value(data.iname, -1);

View File

@@ -164,11 +164,11 @@ bool isSkippableFunction(const QString &funcName, const QString &fileName)
if (fileName.endsWith(QLatin1String(".moc")))
return true;
if (funcName.endsWith("::qt_metacall"))
if (funcName.endsWith(QLatin1String("::qt_metacall")))
return true;
if (funcName.endsWith("::d_func"))
if (funcName.endsWith(QLatin1String("::d_func")))
return true;
if (funcName.endsWith("::q_func"))
if (funcName.endsWith(QLatin1String("::q_func")))
return true;
return false;

View File

@@ -2207,7 +2207,7 @@ void FakeVimHandler::Private::handleCommand(const QString &cmd)
static bool isSubstitution(const QString &cmd0, QStringList *result)
{
QString cmd;
if (cmd0.startsWith("substitute"))
if (cmd0.startsWith(QLatin1String("substitute")))
cmd = cmd0.mid(10);
else if (cmd0.startsWith('s') && cmd0.size() > 1
&& !isalpha(cmd0.at(1).unicode()))
@@ -2450,7 +2450,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
} else if (act) {
// non-boolean to show
showBlackMessage(arg + '=' + act->value().toString());
} else if (arg.startsWith("no")
} else if (arg.startsWith(QLatin1String("no"))
&& (act = theFakeVimSettings()->item(arg.mid(2)))) {
// boolean config to be switched off
bool oldValue = act->value().toBool();
@@ -2505,10 +2505,10 @@ void FakeVimHandler::Private::passUnknownSetCommand(const QString &arg)
static void vimPatternToQtPattern(QString *needle, QTextDocument::FindFlags *flags)
{
// FIXME: Rough mapping of a common case
if (needle->startsWith("\\<") && needle->endsWith("\\>"))
if (needle->startsWith(QLatin1String("\\<")) && needle->endsWith(QLatin1String("\\>")))
(*flags) |= QTextDocument::FindWholeWords;
needle->replace("\\<", ""); // start of word
needle->replace("\\>", ""); // end of word
needle->remove(QLatin1String("\\<")); // start of word
needle->remove(QLatin1String("\\>")); // end of word
//qDebug() << "NEEDLE " << needle0 << needle;
}

View File

@@ -231,41 +231,36 @@ QVariant SearchResultTreeModel::data(const SearchResultTextRow *row, int role) c
QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) const
{
QVariant result;
switch (role)
{
#if 0
case Qt::CheckStateRole:
if (file->isUserCheckable())
result = file->checkState();
break;
return QVariant(file->checkState());
#endif
case Qt::BackgroundRole: {
const QColor baseColor = QApplication::palette().base().color();
result = baseColor.darker(105);
return QVariant(baseColor.darker(105));
break;
}
case Qt::DisplayRole:
result = QString(QDir::toNativeSeparators(file->fileName())
+ " (" + QString::number(file->childrenCount()) + ")");
break;
case Qt::DisplayRole: {
QString result = QDir::toNativeSeparators(file->fileName());
result += QLatin1String(" (");
result += QString::number(file->childrenCount());
result += QLatin1Char(')');
return QVariant(result);
}
case ItemDataRoles::FileNameRole:
case Qt::ToolTipRole:
result = QDir::toNativeSeparators(file->fileName());
break;
return QVariant(QDir::toNativeSeparators(file->fileName()));
case ItemDataRoles::ResultLinesCountRole:
result = file->childrenCount();
break;
return QVariant(file->childrenCount());
case ItemDataRoles::TypeRole:
result = "file";
break;
return QVariant(QLatin1String("file"));
default:
result = QVariant();
break;
}
return result;
return QVariant();
}
QVariant SearchResultTreeModel::headerData(int section, Qt::Orientation orientation,

View File

@@ -144,7 +144,7 @@ ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName(const
else if (FolderNode *folder = m_folderByName.value(folderName))
return folder;
FolderNode *folder = new FolderNode(baseDir + "/" + folderName);
FolderNode *folder = new FolderNode(baseDir + QLatin1Char('/') + folderName);
folder->setFolderName(component);
m_folderByName.insert(folderName, folder);

View File

@@ -49,7 +49,7 @@ HelpIndexFilter::HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine):
m_icon(QIcon()) // TODO: Put an icon next to the results
{
setIncludedByDefault(false);
setShortcutString("?");
setShortcutString(QString(QLatin1Char('?')));
connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()),
this, SLOT(updateIndices()));

View File

@@ -590,16 +590,16 @@ void HelpPlugin::extensionsInitialized()
QStringList documentationToRemove;
QStringList filtersToRemove;
const QString &docInternal = QString("com.nokia.qtcreator.%1%2%3")
const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QString filterInternal = QString("Qt Creator %1.%2.%3")
const QString filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QRegExp filterRegExp("Qt Creator \\d*\\.\\d*\\.\\d*");
const QStringList &docs = m_helpEngine->registeredDocumentations();
foreach (const QString &ns, docs) {
if (ns == docInternal) {
assistantInternalDocRegistered = true;
} else if (ns.startsWith("com.nokia.qtcreator.")) {
} else if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))) {
documentationToRemove << ns;
}
}
@@ -663,8 +663,8 @@ void HelpPlugin::extensionsInitialized()
QString addedDocs = m_helpEngine->customValue(QLatin1String("AddedDocs")).toString();
if (!addedDocs.isEmpty()) {
QStringList documentationToAdd = addedDocs.split(";");
foreach (QString item, documentationToAdd)
const QStringList documentationToAdd = addedDocs.split(QLatin1Char(';'));
foreach (const QString &item, documentationToAdd)
m_helpEngine->registerDocumentation(item);
m_helpEngine->removeCustomValue(QLatin1String("AddedDocs"));
}
@@ -984,7 +984,7 @@ void HelpPlugin::openHelpPage(const QString& url)
} else {
// local help not installed, resort to external web help
QString urlPrefix;
if (url.startsWith("qthelp://com.nokia.qtcreator")) {
if (url.startsWith(QLatin1String("qthelp://com.nokia.qtcreator"))) {
urlPrefix = QString::fromLatin1("http://doc.trolltech.com/qtcreator-%1.%2/")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR);
} else {

View File

@@ -225,7 +225,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
QDir::Files|QDir::Hidden,
QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
foreach (const QString &file, fileEntries)
files.append(dir.path()+"/"+file);
files.append(dir.path()+ QLatin1Char('/') +file);
progress += dirProgressMax;
} else {
int subProgress = dirProgressMax/(subDirs.size()+1);
@@ -234,7 +234,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
progressValues.push(selfProgress);
processedValues.push(true);
foreach (const QString &directory, subDirs) {
dirs.push(QDir(dir.path()+"/"+directory));
dirs.push(QDir(dir.path()+ QLatin1Char('/') + directory));
progressValues.push(subProgress);
processedValues.push(false);
}

View File

@@ -40,7 +40,7 @@ using namespace Locator::Internal;
FileSystemFilter::FileSystemFilter(EditorManager *editorManager, LocatorWidget *locatorWidget)
: m_editorManager(editorManager), m_locatorWidget(locatorWidget), m_includeHidden(true)
{
setShortcutString("f");
setShortcutString(QString(QLatin1Char('f')));
setIncludedByDefault(false);
}
@@ -52,13 +52,13 @@ QList<FilterEntry> FileSystemFilter::matchesFor(const QString &entry)
QString directory = entryInfo.path();
QString filePath = entryInfo.filePath();
if (entryInfo.isRelative()) {
if (filePath.startsWith("~/")) {
if (filePath.startsWith(QLatin1String("~/"))) {
directory.replace(0, 1, QDir::homePath());
} else {
IEditor *editor = m_editorManager->currentEditor();
if (editor && !editor->file()->fileName().isEmpty()) {
QFileInfo info(editor->file()->fileName());
directory.prepend(info.absolutePath()+"/");
directory.prepend(info.absolutePath() + QLatin1Char('/'));
}
}
}
@@ -74,7 +74,7 @@ QList<FilterEntry> FileSystemFilter::matchesFor(const QString &entry)
QStringList files = dirInfo.entryList(fileFilter,
QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
foreach (const QString &dir, dirs) {
if (dir != "." && (name.isEmpty() || dir.startsWith(name, Qt::CaseInsensitive))) {
if (dir != QLatin1String(".") && (name.isEmpty() || dir.startsWith(name, Qt::CaseInsensitive))) {
FilterEntry entry(this, dir, dirInfo.filePath(dir));
entry.resolveFileIcon = true;
value.append(entry);
@@ -95,7 +95,9 @@ void FileSystemFilter::accept(FilterEntry selection) const
{
QFileInfo info(selection.internalData.toString());
if (info.isDir()) {
QString value = shortcutString() + " " + QDir::toNativeSeparators(info.absoluteFilePath()+"/");
QString value = shortcutString();
value += QLatin1Char(' ');
value += QDir::toNativeSeparators(info.absoluteFilePath() + QLatin1Char('/'));
m_locatorWidget->show(value, value.length());
return;
}

View File

@@ -375,7 +375,7 @@ void LocatorWidget::showPopup()
QList<ILocatorFilter*> LocatorWidget::filtersFor(const QString &text, QString &searchText)
{
QList<ILocatorFilter*> filters = m_locatorPlugin->filters();
int whiteSpace = text.indexOf(" ");
const int whiteSpace = text.indexOf(QLatin1Char(' '));
QString prefix;
if (whiteSpace >= 0)
prefix = text.left(whiteSpace);
@@ -464,13 +464,13 @@ void LocatorWidget::filterSelected()
if (!currentText.isEmpty()) {
searchText = currentText;
foreach (ILocatorFilter *otherfilter, m_locatorPlugin->filters()) {
if (currentText.startsWith(otherfilter->shortcutString() + " ")) {
if (currentText.startsWith(otherfilter->shortcutString() + QLatin1Char(' '))) {
searchText = currentText.mid(otherfilter->shortcutString().length()+1);
break;
}
}
}
show(filter->shortcutString() + " " + searchText,
show(filter->shortcutString() + QLatin1Char(' ') + searchText,
filter->shortcutString().length() + 1,
searchText.length());
updateCompletionList(m_fileLineEdit->text());

View File

@@ -42,7 +42,7 @@ OpenDocumentsFilter::OpenDocumentsFilter(EditorManager *editorManager) :
this, SLOT(refreshInternally()));
connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
this, SLOT(refreshInternally()));
setShortcutString("o");
setShortcutString(QString(QLatin1Char('o')));
setIncludedByDefault(true);
}

View File

@@ -636,7 +636,7 @@ void PerforcePlugin::startSubmitProject()
QStringList fstatLines = fstatResult.stdOut.split(QLatin1Char('\n'));
QStringList depotFileNames;
foreach (const QString &line, fstatLines) {
if (line.startsWith("... depotFile"))
if (line.startsWith(QLatin1String("... depotFile")))
depotFileNames.append(line.mid(14));
}
if (depotFileNames.isEmpty()) {

View File

@@ -281,8 +281,8 @@ void AbstractProcessStep::taskAdded(const ProjectExplorer::TaskWindow::Task &tas
} else {
// More then one filename, so do a better compare
// Chop of any "../"
while (filePath.startsWith("../"))
filePath = filePath.mid(3);
while (filePath.startsWith(QLatin1String("../")))
filePath.remove(0, 3);
int count = 0;
QString possibleFilePath;
foreach(const QFileInfo &fi, possibleFiles) {

View File

@@ -44,7 +44,7 @@ AllProjectsFilter::AllProjectsFilter(ProjectExplorerPlugin *pe)
{
connect(m_projectExplorer, SIGNAL(fileListChanged()),
this, SLOT(markFilesAsOutOfDate()));
setShortcutString("a");
setShortcutString(QString(QLatin1Char('a')));
setIncludedByDefault(true);
}

View File

@@ -56,7 +56,7 @@ AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, SearchResultWind
QString AllProjectsFind::id() const
{
return "All Projects";
return QLatin1String("All Projects");
}
QString AllProjectsFind::name() const
@@ -128,14 +128,14 @@ QWidget *AllProjectsFind::createConfigWidget()
void AllProjectsFind::writeSettings(QSettings *settings)
{
settings->beginGroup("AllProjectsFind");
settings->beginGroup(QLatin1String("AllProjectsFind"));
writeCommonSettings(settings);
settings->endGroup();
}
void AllProjectsFind::readSettings(QSettings *settings)
{
settings->beginGroup("AllProjectsFind");
readCommonSettings(settings, "*");
settings->beginGroup(QLatin1String("AllProjectsFind"));
readCommonSettings(settings, QString(QLatin1Char('*')));
settings->endGroup();
}

View File

@@ -49,7 +49,7 @@ CurrentProjectFilter::CurrentProjectFilter(ProjectExplorerPlugin *pe)
connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
this, SLOT(currentProjectChanged(ProjectExplorer::Project*)));
setShortcutString("p");
setShortcutString(QString(QLatin1Char('p')));
setIncludedByDefault(false);
}

View File

@@ -56,7 +56,7 @@ CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, SearchResu
QString CurrentProjectFind::id() const
{
return "Current Project";
return QLatin1String("Current Project");
}
QString CurrentProjectFind::name() const
@@ -123,14 +123,14 @@ QWidget *CurrentProjectFind::createConfigWidget()
void CurrentProjectFind::writeSettings(QSettings *settings)
{
settings->beginGroup("CurrentProjectFind");
settings->beginGroup(QLatin1String("CurrentProjectFind"));
writeCommonSettings(settings);
settings->endGroup();
}
void CurrentProjectFind::readSettings(QSettings *settings)
{
settings->beginGroup("CurrentProjectFind");
readCommonSettings(settings, "*");
settings->beginGroup(QLatin1String("CurrentProjectFind"));
readCommonSettings(settings, QString(QLatin1Char('*')));
settings->endGroup();
}

View File

@@ -332,7 +332,7 @@ QString CustomExecutableRunConfiguration::executable() const
Environment env = activeBuildConfiguration()->environment();
exec = env.searchInPath(m_executable);
if (exec.isEmpty())
exec = QDir::cleanPath(workingDirectory() + "/" + m_executable);
exec = QDir::cleanPath(workingDirectory() + QLatin1Char('/') + m_executable);
} else {
exec = m_executable;
}

View File

@@ -42,7 +42,7 @@ QList<EnvironmentItem> EnvironmentItem::fromStringList(QStringList list)
foreach (const QString &string, list) {
int pos = string.indexOf(QLatin1Char('='));
if (pos == -1) {
EnvironmentItem item(string, "");
EnvironmentItem item(string, QString());
item.unset = true;
result.append(item);
} else {
@@ -152,21 +152,21 @@ void Environment::prependOrSet(const QString&key, const QString &value, const QS
void Environment::appendOrSetPath(const QString &value)
{
#ifdef Q_OS_WIN
QString sep = ";";
const QChar sep = QLatin1Char(';');
#else
QString sep = ":";
const QChar sep = QLatin1Char(':');
#endif
appendOrSet("PATH", QDir::toNativeSeparators(value), sep);
appendOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(sep));
}
void Environment::prependOrSetPath(const QString &value)
{
#ifdef Q_OS_WIN
QString sep = ";";
const QChar sep = QLatin1Char(';');
#else
QString sep = ":";
const QChar sep = QLatin1Char(':');
#endif
prependOrSet("PATH", QDir::toNativeSeparators(value), sep);
prependOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(sep));
}
Environment Environment::systemEnvironment()
@@ -209,11 +209,11 @@ QString Environment::searchInPath(QString executable) const
QStringList Environment::path() const
{
#ifdef Q_OS_WIN
QString sep = ";";
const QChar sep = QLatin1Char(';');
#else
QString sep = ":";
const QChar sep = QLatin1Char(':');
#endif
return m_values.value("PATH").split(sep);
return m_values.value(QLatin1String("PATH")).split(sep);
}
QString Environment::value(const QString &key) const
@@ -340,12 +340,15 @@ QStringList Environment::parseCombinedArgString(const QString &program)
QString Environment::joinArgumentList(const QStringList &arguments)
{
QString result;
const QChar doubleQuote = QLatin1Char('"');
foreach (QString arg, arguments) {
if (!result.isEmpty())
result += QLatin1Char(' ');
arg.replace(QLatin1String("\""), QLatin1String("\"\"\""));
if (arg.contains(QLatin1Char(' ')))
arg = "\"" + arg + "\"";
arg.replace(QString(doubleQuote), QLatin1String("\"\"\""));
if (arg.contains(QLatin1Char(' '))) {
arg.insert(0, doubleQuote);
arg += doubleQuote;
}
result += arg;
}
return result;

View File

@@ -270,8 +270,8 @@ void ProcessStepConfigWidget::updateDetails()
m_summaryText = tr("<b>%1</b> %2 %3 %4")
.arg(displayName,
m_step->command(),
m_step->arguments().join(" "),
m_step->enabled() ? "" : tr("(disabled)"));
m_step->arguments().join(QString(QLatin1Char(' '))),
m_step->enabled() ? QString() : tr("(disabled)"));
emit updateSummary();
}
@@ -289,7 +289,7 @@ void ProcessStepConfigWidget::init()
workingDirectory = "$BUILDDIR";
m_ui.workingDirectory->setPath(workingDirectory);
m_ui.commandArgumentsLineEdit->setText(m_step->arguments().join(" "));
m_ui.commandArgumentsLineEdit->setText(m_step->arguments().join(QString(QLatin1Char(' '))));
m_ui.enabledCheckBox->setChecked(m_step->enabled());
m_ui.nameLineEdit->setText(m_step->displayName());
@@ -320,7 +320,7 @@ void ProcessStepConfigWidget::workingDirectoryLineEditTextEdited()
void ProcessStepConfigWidget::commandArgumentsLineEditTextEdited()
{
m_step->setArguments(m_ui.commandArgumentsLineEdit->text().split(" ",
m_step->setArguments(m_ui.commandArgumentsLineEdit->text().split(QLatin1Char(' '),
QString::SkipEmptyParts));
updateDetails();
}

View File

@@ -1167,7 +1167,7 @@ void ProjectExplorerPlugin::restoreSession()
arguments.removeOne(d->m_sessionToRestoreAtStartup);
// Restore latest session or what was passed on the command line
if (d->m_sessionToRestoreAtStartup == QString::null) {
if (d->m_sessionToRestoreAtStartup.isEmpty()) {
d->m_session->createAndLoadNewDefaultSession();
} else {
d->m_session->loadSession(d->m_sessionToRestoreAtStartup);
@@ -1728,6 +1728,7 @@ void ProjectExplorerPlugin::addToRecentProjects(const QString &fileName, const Q
void ProjectExplorerPlugin::updateRecentProjectMenu()
{
typedef QList<QPair<QString, QString> >::const_iterator StringPairListConstIterator;
if (debug)
qDebug() << "ProjectExplorerPlugin::updateRecentProjectMenu";
@@ -1739,12 +1740,10 @@ void ProjectExplorerPlugin::updateRecentProjectMenu()
menu->setEnabled(!d->m_recentProjects.isEmpty());
//projects (ignore sessions, they used to be in this list)
QList<QPair<QString, QString> >::const_iterator it, end;
end = d->m_recentProjects.constEnd();
for (it = d->m_recentProjects.constBegin(); it != end; ++it) {
const StringPairListConstIterator end = d->m_recentProjects.constEnd();
for (StringPairListConstIterator it = d->m_recentProjects.constBegin(); it != end; ++it) {
const QPair<QString, QString> &s = *it;
if (s.first.endsWith(".qws"))
if (s.first.endsWith(QLatin1String(".qws")))
continue;
QAction *action = menu->addAction(s.first);
action->setData(s.first);

View File

@@ -173,7 +173,7 @@ bool SessionFile::load(const QString &fileName)
// We used to write relative paths into the session file
// relative to the session files, and those were stored in the
// config dir
it.setValue(configDir + "/" + file);
it.setValue(configDir + QLatin1Char('/') + file);
}
}
@@ -380,9 +380,9 @@ SessionManager::SessionManager(QObject *parent)
// Move sessions to that directory
foreach (const QString &session, sessions()) {
QFile file(configDir + "/" + session + ".qws");
QFile file(configDir + QLatin1Char('/') + session + QLatin1String(".qws"));
if (file.exists())
if (file.copy(configDir + "/qtcreator/" + session + ".qws"))
if (file.copy(configDir + QLatin1String("/qtcreator/") + session + QLatin1String(".qws")))
file.remove();
}
}

View File

@@ -240,7 +240,7 @@ void TaskModel::addTask(const TaskWindow::Task &task)
QFont font;
QFontMetrics fm(font);
QString filename = task.file;
int pos = filename.lastIndexOf("/");
const int pos = filename.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
filename = task.file.mid(pos +1);
@@ -876,7 +876,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
// Assemble string for the right side
// just filename + linenumer
QString file = index.data(TaskModel::File).toString();
int pos = file.lastIndexOf("/");
const int pos = file.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
file = file.mid(pos +1);
painter->drawText(width + 22 + 4, 2 + opt.rect.top() + fm.ascent(), file);

View File

@@ -179,9 +179,9 @@ QByteArray GccToolChain::predefinedMacros()
// Turn off flag indicating Apple's blocks support
int idx = m_predefinedMacros.indexOf("#define __BLOCKS__ 1");
if (idx != -1) {
idx = m_predefinedMacros.indexOf("1", idx);
idx = m_predefinedMacros.indexOf(QLatin1Char('1'), idx);
m_predefinedMacros[idx] = '0';
}
}-
// Define __strong and __weak (used for Apple's GC extension of C) to be empty
m_predefinedMacros.append("#define __strong\n");
@@ -397,7 +397,7 @@ QByteArray MSVCToolChain::predefinedMacros()
if (!value.isEmpty()) {
value.chop(1); //remove '\n'
}
QByteArray newDefine = "#define " + key + " " + value + '\n';
QByteArray newDefine = "#define " + key + ' ' + value + '\n';
m_predefinedMacros.append(newDefine);
}
}
@@ -543,7 +543,7 @@ void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env)
// Find MSVC path
path += "/";
path += QLatin1Char('/');
// Find Platform name
CeSdkHandler cesdkhandler;

View File

@@ -137,15 +137,18 @@ void GettingStartedWelcomePageWidget::updateExamples(const QString& examplePath,
inExamples = true;
}
if (inExamples && reader.name() == "example") {
QString name = reader.attributes().value(QLatin1String("name")).toString();
QString fn = reader.attributes().value(QLatin1String("filename")).toString();
QString relativeProPath = '/' + dirName + '/' + fn + '/' + fn + ".pro";
const QChar slash = QLatin1Char('/');
const QString name = reader.attributes().value(QLatin1String("name")).toString();
const QString fn = reader.attributes().value(QLatin1String("filename")).toString();
const QString relativeProPath = slash + dirName + slash + fn + slash + fn + QLatin1String(".pro");
QString fileName = examplePath + relativeProPath;
if (!QFile::exists(fileName))
fileName = sourcePath + "/examples" + relativeProPath;
QString helpPath = "qthelp://com.trolltech.qt/qdoc/" + dirName.replace("/", "-") + "-" + fn + ".html";
fileName = sourcePath + QLatin1String("/examples") + relativeProPath;
QString helpPath = QLatin1String("qthelp://com.trolltech.qt/qdoc/") +
dirName.replace(slash, QLatin1Char('-')) +
QLatin1Char('-') + fn + QLatin1String(".html");
ui->examplesComboBox->addItem(" " + name, fileName);
ui->examplesComboBox->addItem(QLatin1String(" ") + name, fileName);
ui->examplesComboBox->setItemData(ui->examplesComboBox->count()-1, helpPath, Qt::UserRole+1);
}
break;

View File

@@ -129,8 +129,8 @@ bool MakeStep::init()
makeCmd = m_makeCmd;
if (!QFileInfo(makeCmd).isAbsolute()) {
// Try to detect command in environment
QString tmp = environment.searchInPath(makeCmd);
if (tmp == QString::null) {
const QString tmp = environment.searchInPath(makeCmd);
if (tmp.isEmpty()) {
emit addOutput(tr("<font color=\"#ff0000\">Could not find make command: %1 "\
"in the build environment</font>").arg(makeCmd));
return false;
@@ -241,8 +241,8 @@ void MakeStepConfigWidget::updateDetails()
if (!QFileInfo(makeCmd).isAbsolute()) {
Environment environment = bc->environment();
// Try to detect command in environment
QString tmp = environment.searchInPath(makeCmd);
if (tmp == QString::null) {
const QString tmp = environment.searchInPath(makeCmd);
if (tmp.isEmpty()) {
m_summaryText = tr("<b>Make Step:</b> %1 not found in the environment.").arg(makeCmd);
emit updateSummary();
return;

View File

@@ -172,8 +172,10 @@ void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuil
QVBoxLayout *importLayout = new QVBoxLayout(importPage);
importLabel = new QLabel(importPage);
QString versionString = version->displayName() + " (" + QDir::toNativeSeparators(version->qmakeCommand()) + ")";
QString buildConfigString = (buildConfig & QtVersion::BuildAll) ? QLatin1String("debug_and_release ") : QLatin1String("");
QString versionString = version->displayName() + QLatin1String(" (") +
QDir::toNativeSeparators(version->qmakeCommand()) +
QLatin1Char(')');
QString buildConfigString = (buildConfig & QtVersion::BuildAll) ? QLatin1String("debug_and_release ") : QString();
buildConfigString.append((buildConfig & QtVersion::DebugBuild) ? QLatin1String("debug") : QLatin1String("release"));
importLabel->setTextFormat(Qt::RichText);
importLabel->setText(tr("Qt Creator has found an already existing build in the source directory.<br><br>"

View File

@@ -45,7 +45,7 @@ QMakeParser::QMakeParser()
void QMakeParser::stdError(const QString &line)
{
QString lne(line.trimmed());
if (lne.startsWith("Project ERROR:")) {
if (lne.startsWith(QLatin1String("Project ERROR:"))) {
const QString description = lne.mid(15);
emit addTask(TaskWindow::Task(TaskWindow::Error,
description,

View File

@@ -496,8 +496,8 @@ void MaemoRunConfiguration::updateSimulatorInformation()
if (m_cachedSimulatorInformationValid)
return;
m_simulator = QString::null;
m_simulatorArgs == QString::null;
m_simulator.clear();
m_simulatorArgs.clear();
m_cachedSimulatorInformationValid = true;
m_simulatorPath = QDir::toNativeSeparators(m_userSimulatorPath);
m_visibleSimulatorParameter = tr("Could not autodetect target simulator, "

View File

@@ -74,7 +74,7 @@ QStringList WINSCWToolChain::systemIncludes() const
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
QString symIncludesValue = env.value("MWCSYM2INCLUDES");
if (!symIncludesValue.isEmpty())
return symIncludesValue.split(";");
return symIncludesValue.split(QLatin1Char(';'));
} else {
QStringList symIncludes = QStringList()
<< "\\MSL\\MSL_C\\MSL_Common\\Include"
@@ -94,7 +94,7 @@ QStringList WINSCWToolChain::systemIncludes() const
void WINSCWToolChain::addToEnvironment(ProjectExplorer::Environment &env)
{
if (!m_carbidePath.isEmpty()) {
env.set("MWCSYM2INCLUDES", systemIncludes().join(";"));
env.set("MWCSYM2INCLUDES", systemIncludes().join(QString(QLatin1Char(';'))));
QStringList symLibraries = QStringList()
<< "\\Win32-x86 Support\\Libraries\\Win32 SDK"
<< "\\Runtime\\Runtime_x86\\Runtime_Win32\\Libs";

View File

@@ -523,13 +523,13 @@ QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &li
// if it is the former we need to get the canonical form
// for the other one we don't need to do anything
if (QFileInfo(parsedSpec).isRelative()) {
if(QFileInfo(directory + "/" + parsedSpec).exists()) {
parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec);
if(QFileInfo(directory + QLatin1Char('/') + parsedSpec).exists()) {
parsedSpec = QDir::cleanPath(directory + QLatin1Char('/') + parsedSpec);
#ifdef Q_OS_WIN
parsedSpec = parsedSpec.toLower();
#endif
} else {
parsedSpec = baseMkspecDir + "/" + parsedSpec;
parsedSpec = baseMkspecDir + QLatin1Char('/') + parsedSpec;
}
}

View File

@@ -1147,13 +1147,13 @@ QStringList Qt4ProFileNode::subDirsPaths(ProFileReader *reader) const
realDir = subDirVar;
QFileInfo info(realDir);
if (!info.isAbsolute()) {
info.setFile(m_projectDir + "/" + realDir);
realDir = m_projectDir + "/" + realDir;
info.setFile(m_projectDir + QLatin1Char('/') + realDir);
realDir = m_projectDir + QLatin1Char('/') + realDir;
}
QString realFile;
if (info.isDir()) {
realFile = QString("%1/%2.pro").arg(realDir, info.fileName());
realFile = QString::fromLatin1("%1/%2.pro").arg(realDir, info.fileName());
} else {
realFile = realDir;
}

View File

@@ -591,7 +591,7 @@ void Qt4Project::updateCodeModel()
//support to access this information
// TODO this is wastefull
// only save it per .pro file, and on beeing asked
// only save it per .pro file, and on being asked
// search for the .pro file that has that file
foreach (FileNode *fileNode, pro->fileNodes()) {
const QString path = fileNode->path();

View File

@@ -651,9 +651,12 @@ void QtOptionsPageWidget::fixQtVersionName(int index)
QRegExp regexp("^(.*)\\((\\d)\\)$");
if (regexp.exactMatch(name)) {
// Already in Name (#) format
name = regexp.cap(1) + "(" + QString().setNum(regexp.cap(2).toInt() + 1) + ")";
name = regexp.cap(1);
name += QLatin1Char('(');
name += QString::number(regexp.cap(2).toInt() + 1);
name += QLatin1Char(')');
} else {
name = name + " (2)";
name += QLatin1String(" (2)");
}
// set new name
m_versions[index]->setDisplayName(name);

View File

@@ -814,12 +814,12 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
QString QtVersionManager::findQMakeLine(const QString &directory)
{
QFile makefile(directory + "/Makefile" );
QFile makefile(directory + QLatin1String("/Makefile" ));
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
QTextStream ts(&makefile);
while (!ts.atEnd()) {
QString line = ts.readLine();
if (line.startsWith("# Command:"))
const QString line = ts.readLine();
if (line.startsWith(QLatin1String("# Command:")))
return line;
}
}
@@ -831,7 +831,7 @@ QString QtVersionManager::trimLine(const QString line)
{
// Actually the first space after #Command: /path/to/qmake
int firstSpace = line.indexOf(" ", 11);
const int firstSpace = line.indexOf(QLatin1Char(' '), 11);
return line.mid(firstSpace).trimmed();
}
@@ -989,8 +989,8 @@ void QtVersion::updateVersionInfo() const
QByteArray output = process.readAllStandardOutput();
QTextStream stream(&output);
while (!stream.atEnd()) {
QString line = stream.readLine();
int index = line.indexOf(":");
const QString line = stream.readLine();
const int index = line.indexOf(QLatin1Char(':'));
if (index != -1)
m_versionInfo.insert(line.left(index), QDir::fromNativeSeparators(line.mid(index+1)));
}
@@ -1379,9 +1379,9 @@ QString QtVersion::invalidReason() const
{
if (isValid())
return QString();
if (qmakeCommand() == QString::null)
if (qmakeCommand().isEmpty())
return QApplication::translate("QtVersion", "No QMake path set");
if (displayName() == QString::null)
if (displayName().isEmpty())
return QApplication::translate("QtVersion", "Qt Version has no name");
if (m_notInstalled)
return QApplication::translate("QtVersion", "Qt Version is not installed, please run make install");

View File

@@ -74,9 +74,9 @@ QStringList BaseFileFind::fileNameFilters() const
{
QStringList filters;
if (m_filterCombo && !m_filterCombo->currentText().isEmpty()) {
QStringList parts = m_filterCombo->currentText().split(",");
const QStringList parts = m_filterCombo->currentText().split(QLatin1Char(','));
foreach (const QString &part, parts) {
QString filter = part.trimmed();
const QString filter = part.trimmed();
if (!filter.isEmpty()) {
filters << filter;
}

View File

@@ -3195,7 +3195,7 @@ void BaseTextEditor::slotCursorPositionChanged()
#if 0
qDebug() << "block" << textCursor().blockNumber()+1
<< "depth:" << TextEditDocumentLayout::braceDepth(textCursor().block())
<< "/" << TextEditDocumentLayout::braceDepth(document()->lastBlock());
<< '/' << TextEditDocumentLayout::braceDepth(document()->lastBlock());
#endif
if (!d->m_contentsChanged && d->m_lastCursorChangeWasInteresting) {
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(editableInterface(), d->m_tempNavigationState);

View File

@@ -42,7 +42,7 @@ using namespace TextEditor::Internal;
LineNumberFilter::LineNumberFilter(QObject *parent)
: ILocatorFilter(parent)
{
setShortcutString("l");
setShortcutString(QString(QLatin1Char('l')));
setIncludedByDefault(true);
}

View File

@@ -157,7 +157,7 @@ public slots:
// Convenience slot for "Delete current file" action. Prompts to
// delete the file via VCSManager.
void promptToDeleteCurrentFile();
// Prompt to initalize version control in a directory, initially
// Prompt to initialize version control in a directory, initially
// pointing to the current project.
void createRepository();