diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2015-07-13 15:12:02 +0200 |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2015-09-23 11:39:11 +0000 |
commit | 08b62bcfd953478396418bfa440eec4013f4c6ad (patch) | |
tree | f66b590a19532ce4982204375ea64f6a94b4a8e0 /src/plugins/cpptools/cpptoolsplugin.cpp | |
parent | 1d9dd67fd39d1a32118935685a811f04a8ac1ce4 (diff) | |
download | qt-creator-08b62bcfd953478396418bfa440eec4013f4c6ad.tar.gz |
CppTools: SwitchHeaderSource file name case sensitivity
Make sure that on Windows the corresponding header /source
file is searched using case insensitive comparisons.
Change-Id: I66b06cd8a7c46b78e8ff24e11803287630f3914b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r-- | src/plugins/cpptools/cpptoolsplugin.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 1719a085f9..f113c5fc62 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -265,7 +265,7 @@ static QStringList findFilesInProject(const QString &name, const QStringList::const_iterator pcend = projectFiles.constEnd(); QStringList candidateList; for (QStringList::const_iterator it = projectFiles.constBegin(); it != pcend; ++it) { - if (it->endsWith(pattern)) + if (it->endsWith(pattern, Utils::HostOsInfo::fileNameCaseSensitivity())) candidateList.append(*it); } return candidateList; @@ -342,12 +342,17 @@ static QStringList baseDirWithAllDirectories(const QDir &baseDir, const QStringL return result; } -static int commonStringLength(const QString &s1, const QString &s2) +static int commonFilePathLength(const QString &s1, const QString &s2) { int length = qMin(s1.length(), s2.length()); for (int i = 0; i < length; ++i) - if (s1[i] != s2[i]) - return i; + if (Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseSensitive) { + if (s1[i] != s2[i]) + return i; + } else { + if (s1[i].toLower() != s2[i].toLower()) + return i; + } return length; } @@ -362,7 +367,7 @@ static QString correspondingHeaderOrSourceInProject(const QFileInfo &fileInfo, const QStringList projectFiles = findFilesInProject(candidateFileName, project); // Find the file having the most common path with fileName foreach (const QString &projectFile, projectFiles) { - int value = commonStringLength(filePath, projectFile); + int value = commonFilePathLength(filePath, projectFile); if (value > compareValue) { compareValue = value; bestFileName = projectFile; |