CMake: Move CMakeProjectManager::findCbpFile to tealeafreader.cpp

That's the the only user of that code.

Change-Id: Iabc6a1fa9a4ad05c467e8ed64386d3185de25f02
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2017-02-25 17:27:00 +01:00
parent 28b6c4f671
commit 8b5b1f1de7
3 changed files with 22 additions and 26 deletions

View File

@@ -173,23 +173,3 @@ QString CMakeManager::mimeType() const
{
return QLatin1String(Constants::CMAKEPROJECTMIMETYPE);
}
QString CMakeManager::findCbpFile(const QDir &directory)
{
// Find the cbp file
// the cbp file is named like the project() command in the CMakeList.txt file
// so this function below could find the wrong cbp file, if the user changes the project()
// 2name
QDateTime t;
QString file;
foreach (const QString &cbpFile , directory.entryList()) {
if (cbpFile.endsWith(QLatin1String(".cbp"))) {
QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile);
if (t.isNull() || fi.lastModified() > t) {
file = directory.path() + QLatin1Char('/') + cbpFile;
t = fi.lastModified();
}
}
}
return file;
}

View File

@@ -29,7 +29,6 @@
QT_BEGIN_NAMESPACE
class QAction;
class QDir;
QT_END_NAMESPACE
namespace CMakeProjectManager {
@@ -46,8 +45,6 @@ public:
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString) override;
QString mimeType() const override;
static QString findCbpFile(const QDir &);
private:
void updateCmakeActions();
void clearCMakeCache(ProjectExplorer::Project *project);

View File

@@ -31,7 +31,6 @@
#include "cmakekitinformation.h"
#include "cmakeparser.h"
#include "cmakeprojectconstants.h"
#include "cmakeprojectmanager.h"
#include "cmakeprojectnodes.h"
#include <coreplugin/documentmanager.h>
@@ -169,9 +168,29 @@ void TeaLeafReader::resetData()
m_files.clear();
}
static QString findCbpFile(const QDir &directory)
{
// Find the cbp file
// the cbp file is named like the project() command in the CMakeList.txt file
// so this function below could find the wrong cbp file, if the user changes the project()
// 2name
QDateTime t;
QString file;
foreach (const QString &cbpFile , directory.entryList()) {
if (cbpFile.endsWith(QLatin1String(".cbp"))) {
QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile);
if (t.isNull() || fi.lastModified() > t) {
file = directory.path() + QLatin1Char('/') + cbpFile;
t = fi.lastModified();
}
}
}
return file;
}
void TeaLeafReader::parse(bool force)
{
const QString cbpFile = CMakeManager::findCbpFile(QDir(m_parameters.buildDirectory.toString()));
const QString cbpFile = findCbpFile(QDir(m_parameters.buildDirectory.toString()));
const QFileInfo cbpFileFi = cbpFile.isEmpty() ? QFileInfo() : QFileInfo(cbpFile);
if (!cbpFileFi.exists()) {
// Initial create:
@@ -385,7 +404,7 @@ void TeaLeafReader::extractData()
// Do not insert topCMake into m_cmakeFiles: The project already watches that!
// Find cbp file
FileName cbpFile = FileName::fromString(CMakeManager::findCbpFile(bldDir.toString()));
FileName cbpFile = FileName::fromString(findCbpFile(bldDir.toString()));
if (cbpFile.isEmpty())
return;
m_cmakeFiles.insert(cbpFile);