forked from qt-creator/qt-creator
PythonEditorPlugin: Sprinkle const over code
Change-Id: I01b4b11299bd73f6bae87045deef0328753720a7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user