summaryrefslogtreecommitdiff
path: root/src/plugins/pythoneditor/pythoneditorplugin.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-03-28 09:29:30 +0100
committerEike Ziller <eike.ziller@qt.io>2019-03-28 08:48:31 +0000
commitd408d74f440e8c1d6ac1dfb0eab504766a42911c (patch)
tree6ef158a087de670a3d4f6ef58f6c824ab7a41ab9 /src/plugins/pythoneditor/pythoneditorplugin.cpp
parentae046702b0577d0fb2d9ade2a457e0ff10022f67 (diff)
downloadqt-creator-d408d74f440e8c1d6ac1dfb0eab504766a42911c.tar.gz
PythonEditorPlugin: Sprinkle const over code
Change-Id: I01b4b11299bd73f6bae87045deef0328753720a7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'src/plugins/pythoneditor/pythoneditorplugin.cpp')
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index f3efaedba5..4a9220b86f 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -333,7 +333,7 @@ static QStringList readLines(const Utils::FileName &projectFile)
QTextStream stream(&file);
forever {
- QString line = stream.readLine();
+ const QString line = stream.readLine();
if (line.isNull())
break;
if (visited.contains(line))
@@ -395,7 +395,7 @@ static QStringList readLinesJson(const Utils::FileName &projectFile,
bool PythonProject::saveRawFileList(const QStringList &rawFileList)
{
- bool result = saveRawList(rawFileList, projectFilePath().toString());
+ const bool result = saveRawList(rawFileList, projectFilePath().toString());
// refresh(PythonProject::Files);
return result;
}
@@ -411,19 +411,18 @@ bool PythonProject::saveRawList(const QStringList &rawList, const QString &fileN
stream << filePath << '\n';
saver.setResult(&stream);
}
- bool result = saver.finalize(ICore::mainWindow());
- return result;
+ return saver.finalize(ICore::mainWindow());
}
bool PythonProject::addFiles(const QStringList &filePaths)
{
QStringList newList = m_rawFileList;
- QDir baseDir(projectDirectory().toString());
+ const QDir baseDir(projectDirectory().toString());
foreach (const QString &filePath, filePaths)
newList.append(baseDir.relativeFilePath(filePath));
- bool result = saveRawList(newList, projectFilePath().toString());
+ const bool result = saveRawList(newList, projectFilePath().toString());
refresh();
return result;
@@ -434,7 +433,7 @@ bool PythonProject::removeFiles(const QStringList &filePaths)
QStringList newList = m_rawFileList;
foreach (const QString &filePath, filePaths) {
- QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
+ const QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
if (i != m_rawListEntries.end())
newList.removeOne(i.value());
}
@@ -445,7 +444,7 @@ bool PythonProject::removeFiles(const QStringList &filePaths)
bool PythonProject::setFiles(const QStringList &filePaths)
{
QStringList newList;
- QDir baseDir(projectDirectory().toString());
+ const QDir baseDir(projectDirectory().toString());
foreach (const QString &filePath, filePaths)
newList.append(baseDir.relativeFilePath(filePath));
@@ -456,11 +455,11 @@ bool PythonProject::renameFile(const QString &filePath, const QString &newFilePa
{
QStringList newList = m_rawFileList;
- QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
+ const QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
if (i != m_rawListEntries.end()) {
- int index = newList.indexOf(i.value());
+ const int index = newList.indexOf(i.value());
if (index != -1) {
- QDir baseDir(projectDirectory().toString());
+ const QDir baseDir(projectDirectory().toString());
newList.replace(index, baseDir.relativeFilePath(newFilePath));
}
}
@@ -509,12 +508,13 @@ void PythonProject::refresh(Target *target)
emitParsingStarted();
parseProject();
- QDir baseDir(projectDirectory().toString());
+ const QDir baseDir(projectDirectory().toString());
BuildTargetInfoList appTargets;
auto newRoot = std::make_unique<PythonProjectNode>(this);
for (const QString &f : qAsConst(m_files)) {
const QString displayName = baseDir.relativeFilePath(f);
- FileType fileType = f.endsWith(".pyproject") || f.endsWith(".pyqtc") ? FileType::Project : FileType::Source;
+ const FileType fileType = f.endsWith(".pyproject") || f.endsWith(".pyqtc") ? FileType::Project
+ : FileType::Source;
newRoot->addNestedNode(std::make_unique<PythonFileNode>(FileName::fromString(f),
displayName, fileType));
if (fileType == FileType::Source) {
@@ -617,8 +617,8 @@ QHash<QString, QStringList> sortFilesIntoPaths(const QString &base, const QSet<Q
const QDir baseDir(base);
foreach (const QString &absoluteFileName, files) {
- QFileInfo fileInfo(absoluteFileName);
- FileName absoluteFilePath = FileName::fromString(fileInfo.path());
+ const QFileInfo fileInfo(absoluteFileName);
+ const FileName absoluteFilePath = FileName::fromString(fileInfo.path());
QString relativeFilePath;
if (absoluteFilePath.isChildOf(baseDir)) {