GUI: Added checkbox 'Analyze all Visual Studio configurations' in the projectfile dialog
This commit is contained in:
parent
e675ede07d
commit
0561d59d28
|
@ -25,7 +25,8 @@ CheckStatistics::CheckStatistics(QObject *parent)
|
|||
clear();
|
||||
}
|
||||
|
||||
static void addItem(QMap<QString,unsigned> &m, const QString &key) {
|
||||
static void addItem(QMap<QString,unsigned> &m, const QString &key)
|
||||
{
|
||||
if (m.contains(key))
|
||||
m[key]++;
|
||||
else
|
||||
|
|
|
@ -384,6 +384,35 @@ void MainWindow::doAnalyzeProject(ImportProject p)
|
|||
v.push_back(i.toStdString());
|
||||
}
|
||||
p.ignorePaths(v);
|
||||
|
||||
if (!mProjectFile->getAnalyzeAllVsConfigs()) {
|
||||
std::set<std::string> filenames;
|
||||
Settings::PlatformType platform = (Settings::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
|
||||
for (std::list<ImportProject::FileSettings>::iterator it = p.fileSettings.begin(); it != p.fileSettings.end();) {
|
||||
if (it->cfg.empty()) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
const ImportProject::FileSettings &fs = *it;
|
||||
bool remove = false;
|
||||
if (fs.cfg.compare(0,5,"Debug") != 0)
|
||||
remove = true;
|
||||
if (platform == Settings::Win64 && fs.platformType != platform)
|
||||
remove = true;
|
||||
else if ((platform == Settings::Win32A || platform == Settings::Win32W) && fs.platformType == Settings::Win64)
|
||||
remove = true;
|
||||
else if (fs.platformType != Settings::Win64 && platform == Settings::Win64)
|
||||
remove = true;
|
||||
else if (filenames.find(fs.filename) != filenames.end())
|
||||
remove = true;
|
||||
if (remove) {
|
||||
it = p.fileSettings.erase(it);
|
||||
} else {
|
||||
filenames.insert(fs.filename);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enableProjectActions(false);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ static const char ProjectVersionAttrib[] = "version";
|
|||
static const char ProjectFileVersion[] = "1";
|
||||
static const char BuildDirElementName[] = "builddir";
|
||||
static const char ImportProjectElementName[] = "importproject";
|
||||
static const char AnalyzeAllVsConfigsElementName[] = "analyze-all-vs-configs";
|
||||
static const char IncludeDirElementName[] = "includedir";
|
||||
static const char DirElementName[] = "dir";
|
||||
static const char DirNameAttrib[] = "name";
|
||||
|
@ -56,15 +57,32 @@ static const char AddonsElementName[] = "addons";
|
|||
ProjectFile::ProjectFile(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
|
||||
QObject(parent),
|
||||
mFilename(filename)
|
||||
{
|
||||
clear();
|
||||
read();
|
||||
}
|
||||
|
||||
void ProjectFile::clear()
|
||||
{
|
||||
mRootPath.clear();
|
||||
mBuildDir.clear();
|
||||
mImportProject.clear();
|
||||
mAnalyzeAllVsConfigs = true;
|
||||
mIncludeDirs.clear();
|
||||
mDefines.clear();
|
||||
mPaths.clear();
|
||||
mExcludedPaths.clear();
|
||||
mLibraries.clear();
|
||||
mSuppressions.clear();
|
||||
mAddons.clear();
|
||||
}
|
||||
|
||||
bool ProjectFile::read(const QString &filename)
|
||||
{
|
||||
if (!filename.isEmpty())
|
||||
|
@ -74,6 +92,8 @@ bool ProjectFile::read(const QString &filename)
|
|||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return false;
|
||||
|
||||
clear();
|
||||
|
||||
QXmlStreamReader xmlReader(&file);
|
||||
bool insideProject = false;
|
||||
bool projectTagFound = false;
|
||||
|
@ -99,6 +119,9 @@ bool ProjectFile::read(const QString &filename)
|
|||
if (insideProject && xmlReader.name() == ImportProjectElementName)
|
||||
readImportProject(xmlReader);
|
||||
|
||||
if (insideProject && xmlReader.name() == AnalyzeAllVsConfigsElementName)
|
||||
readAnalyzeAllVsConfigs(xmlReader);
|
||||
|
||||
// Find include directory from inside project element
|
||||
if (insideProject && xmlReader.name() == IncludeDirElementName)
|
||||
readIncludeDirs(xmlReader);
|
||||
|
@ -211,6 +234,31 @@ void ProjectFile::readImportProject(QXmlStreamReader &reader)
|
|||
} while (1);
|
||||
}
|
||||
|
||||
void ProjectFile::readAnalyzeAllVsConfigs(QXmlStreamReader &reader)
|
||||
{
|
||||
mImportProject.clear();
|
||||
do {
|
||||
const QXmlStreamReader::TokenType type = reader.readNext();
|
||||
switch (type) {
|
||||
case QXmlStreamReader::Characters:
|
||||
mAnalyzeAllVsConfigs = (reader.text().toString() == "true");
|
||||
case QXmlStreamReader::EndElement:
|
||||
return;
|
||||
// Not handled
|
||||
case QXmlStreamReader::StartElement:
|
||||
case QXmlStreamReader::NoToken:
|
||||
case QXmlStreamReader::Invalid:
|
||||
case QXmlStreamReader::StartDocument:
|
||||
case QXmlStreamReader::EndDocument:
|
||||
case QXmlStreamReader::Comment:
|
||||
case QXmlStreamReader::DTD:
|
||||
case QXmlStreamReader::EntityReference:
|
||||
case QXmlStreamReader::ProcessingInstruction:
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
|
||||
{
|
||||
QXmlStreamReader::TokenType type;
|
||||
|
@ -477,6 +525,10 @@ bool ProjectFile::write(const QString &filename)
|
|||
xmlWriter.writeEndElement();
|
||||
}
|
||||
|
||||
xmlWriter.writeStartElement(AnalyzeAllVsConfigsElementName);
|
||||
xmlWriter.writeCharacters(mAnalyzeAllVsConfigs ? "true" : "false");
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
if (!mIncludeDirs.isEmpty()) {
|
||||
xmlWriter.writeStartElement(IncludeDirElementName);
|
||||
foreach (QString incdir, mIncludeDirs) {
|
||||
|
|
|
@ -62,6 +62,10 @@ public:
|
|||
return mImportProject;
|
||||
}
|
||||
|
||||
bool getAnalyzeAllVsConfigs() const {
|
||||
return mAnalyzeAllVsConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get list of include directories.
|
||||
* @return list of directories.
|
||||
|
@ -143,6 +147,10 @@ public:
|
|||
mImportProject = importProject;
|
||||
}
|
||||
|
||||
void setAnalyzeAllVsConfigs(bool b) {
|
||||
mAnalyzeAllVsConfigs = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set list of includes.
|
||||
* @param includes List of defines.
|
||||
|
@ -215,6 +223,8 @@ protected:
|
|||
*/
|
||||
void readImportProject(QXmlStreamReader &reader);
|
||||
|
||||
void readAnalyzeAllVsConfigs(QXmlStreamReader &reader);
|
||||
|
||||
/**
|
||||
* @brief Read list of include directories from XML.
|
||||
* @param reader XML stream reader.
|
||||
|
@ -258,6 +268,8 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @brief Convert paths
|
||||
*/
|
||||
|
@ -282,6 +294,13 @@ private:
|
|||
/** Visual studio project/solution , compile database */
|
||||
QString mImportProject;
|
||||
|
||||
/**
|
||||
* Should all visual studio configurations be analyzed?
|
||||
* If this is false then only the Debug configuration
|
||||
* for the set platform is analyzed.
|
||||
*/
|
||||
bool mAnalyzeAllVsConfigs;
|
||||
|
||||
/**
|
||||
* @brief List of include directories used to search include files.
|
||||
*/
|
||||
|
|
|
@ -140,6 +140,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
|||
setDefines(projectFile->getDefines());
|
||||
setCheckPaths(projectFile->getCheckPaths());
|
||||
setImportProject(projectFile->getImportProject());
|
||||
mUI.mChkAllVsConfigs->setChecked(projectFile->getAnalyzeAllVsConfigs());
|
||||
setExcludedPaths(projectFile->getExcludedPaths());
|
||||
setLibraries(projectFile->getLibraries());
|
||||
setSuppressions(projectFile->getSuppressions());
|
||||
|
@ -155,6 +156,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
|
|||
projectFile->setRootPath(getRootPath());
|
||||
projectFile->setBuildDir(getBuildDir());
|
||||
projectFile->setImportProject(getImportProject());
|
||||
projectFile->setAnalyzeAllVsConfigs(mUI.mChkAllVsConfigs->isChecked());
|
||||
projectFile->setIncludes(getIncludePaths());
|
||||
projectFile->setDefines(getDefines());
|
||||
projectFile->setCheckPaths(getCheckPaths());
|
||||
|
@ -218,7 +220,8 @@ void ProjectFileDialog::browseBuildDir()
|
|||
|
||||
void ProjectFileDialog::updatePathsAndDefines()
|
||||
{
|
||||
bool importProject = !mUI.mEditImportProject->text().isEmpty();
|
||||
const QString &fileName = mUI.mEditImportProject->text();
|
||||
bool importProject = !fileName.isEmpty();
|
||||
mUI.mBtnClearImportProject->setEnabled(importProject);
|
||||
mUI.mListCheckPaths->setEnabled(!importProject);
|
||||
mUI.mListIncludeDirs->setEnabled(!importProject);
|
||||
|
@ -231,6 +234,7 @@ void ProjectFileDialog::updatePathsAndDefines()
|
|||
mUI.mBtnRemoveInclude->setEnabled(!importProject);
|
||||
mUI.mBtnIncludeUp->setEnabled(!importProject);
|
||||
mUI.mBtnIncludeDown->setEnabled(!importProject);
|
||||
mUI.mChkAllVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj"));
|
||||
}
|
||||
|
||||
void ProjectFileDialog::clearImportProject()
|
||||
|
|
|
@ -110,6 +110,16 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mChkAllVsConfigs">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>You have a choice:</p><p> * Analyze all Debug and Release configurations</p><p> * Only analyze the first matching Debug configuration</p><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Analyze all Visual Studio configurations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Reference in New Issue