GUI: Try to simplify the 'Import Project' setting

This commit is contained in:
Daniel Marjamäki 2017-07-27 16:07:47 +02:00
parent f6ee0f6868
commit ca2f59a6d4
3 changed files with 56 additions and 152 deletions

View File

@ -92,8 +92,7 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept())); connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(mUI.mBtnBrowseBuildDir, SIGNAL(clicked()), this, SLOT(BrowseBuildDir())); connect(mUI.mBtnBrowseBuildDir, SIGNAL(clicked()), this, SLOT(BrowseBuildDir()));
connect(mUI.mBtnBrowseCompileDatabase, SIGNAL(clicked()), this, SLOT(BrowseCompileDatabase())); connect(mUI.mBtnBrowseImportProject, SIGNAL(clicked()), this, SLOT(BrowseImportProject()));
connect(mUI.mBtnBrowseVisualStudio, SIGNAL(clicked()), this, SLOT(BrowseVisualStudio()));
connect(mUI.mBtnAddCheckPath, SIGNAL(clicked()), this, SLOT(AddCheckPath())); connect(mUI.mBtnAddCheckPath, SIGNAL(clicked()), this, SLOT(AddCheckPath()));
connect(mUI.mBtnEditCheckPath, SIGNAL(clicked()), this, SLOT(EditCheckPath())); connect(mUI.mBtnEditCheckPath, SIGNAL(clicked()), this, SLOT(EditCheckPath()));
connect(mUI.mBtnRemoveCheckPath, SIGNAL(clicked()), this, SLOT(RemoveCheckPath())); connect(mUI.mBtnRemoveCheckPath, SIGNAL(clicked()), this, SLOT(RemoveCheckPath()));
@ -186,24 +185,14 @@ void ProjectFileDialog::BrowseBuildDir()
mUI.mEditBuildDir->setText(dir); mUI.mEditBuildDir->setText(dir);
} }
void ProjectFileDialog::BrowseCompileDatabase() void ProjectFileDialog::BrowseImportProject()
{ {
const QFileInfo inf(mFilePath); const QFileInfo inf(mFilePath);
const QDir &dir = inf.absoluteDir(); const QDir &dir = inf.absoluteDir();
QString fileName = QFileDialog::getOpenFileName(this, tr("Compile Database"), QString fileName = QFileDialog::getOpenFileName(this, tr("Import Project"),
dir.canonicalPath(), dir.canonicalPath(),
tr("Compile database (compile_database.json)")); tr("Visual Studio (*.sln *.vcxproj);;Compile database (compile_database.json)"));
mUI.mEditCompileDatabase->setText(dir.relativeFilePath(fileName)); mUI.mEditImportProject->setText(dir.relativeFilePath(fileName));
}
void ProjectFileDialog::BrowseVisualStudio()
{
const QFileInfo inf(mFilePath);
const QDir &dir = inf.absoluteDir();
QString fileName = QFileDialog::getOpenFileName(this, tr("Visual Studio"),
dir.canonicalPath(),
tr("Visual Studio Solution/Project (*.sln *.vcxproj)"));
mUI.mEditVisualStudio->setText(dir.relativeFilePath(fileName));
} }
void ProjectFileDialog::AddIncludeDir(const QString &dir) void ProjectFileDialog::AddIncludeDir(const QString &dir)
@ -254,7 +243,7 @@ QString ProjectFileDialog::GetBuildDir() const
QString ProjectFileDialog::GetImportProject() const QString ProjectFileDialog::GetImportProject() const
{ {
return mUI.mEditCompileDatabase->text() + mUI.mEditVisualStudio->text(); return mUI.mEditImportProject->text();
} }
QStringList ProjectFileDialog::GetIncludePaths() const QStringList ProjectFileDialog::GetIncludePaths() const
@ -337,12 +326,7 @@ void ProjectFileDialog::SetBuildDir(const QString &buildDir)
void ProjectFileDialog::SetImportProject(const QString &importProject) void ProjectFileDialog::SetImportProject(const QString &importProject)
{ {
mUI.mEditCompileDatabase->setText(""); mUI.mEditImportProject->setText(importProject);
mUI.mEditVisualStudio->setText("");
if (importProject.endsWith("compile_database.json", Qt::CaseInsensitive))
mUI.mEditCompileDatabase->setText(importProject);
else if (importProject.endsWith(".sln",Qt::CaseInsensitive) || importProject.endsWith(".vcxproj",Qt::CaseInsensitive))
mUI.mEditVisualStudio->setText(importProject);
} }
void ProjectFileDialog::SetIncludepaths(const QStringList &includes) void ProjectFileDialog::SetIncludepaths(const QStringList &includes)

View File

@ -148,14 +148,9 @@ protected slots:
void BrowseBuildDir(); void BrowseBuildDir();
/** /**
* @brief Browse for Visual Studio solution/project. * @brief Browse for solution / project / compile database.
*/ */
void BrowseVisualStudio(); void BrowseImportProject();
/**
* @brief Browse for Compile Database.
*/
void BrowseCompileDatabase();
/** /**
* @brief Add new path to check. * @brief Add new path to check.

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>635</width> <width>642</width>
<height>368</height> <height>434</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -23,13 +23,13 @@
<attribute name="title"> <attribute name="title">
<string>Project</string> <string>Project</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_12"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<layout class="QHBoxLayout" name="mLayoutProjectRoot"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QLabel" name="mLabelProjectRoot"> <widget class="QLabel" name="mLabelProjectRoot">
<property name="text"> <property name="text">
<string>Root:</string> <string>&amp;Root:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>mEditProjectRoot</cstring> <cstring>mEditProjectRoot</cstring>
@ -42,41 +42,60 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="mLayoutBuildDir"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="mLabelBuildDir"> <widget class="QLabel" name="mLabelBuildDir">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;In the build dir, cppcheck stores data about each translation unit.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;With a build dir you get whole program analysis and faster analysis.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;In the build dir, cppcheck stores data about each translation unit.&lt;/p&gt;&lt;p&gt;With a build dir you get whole program analysis.&lt;/p&gt;&lt;p&gt;Unchanged files will be analyzed much faster; Cppcheck skip the analysis of these files and reuse their old data.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Cppcheck build dir (optional)</string> <string>Cppcheck build dir (whole program analysis, faster analysis for unchanged files)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="mEditBuildDir"/> <layout class="QHBoxLayout" name="horizontalLayout_2">
</item> <item>
<item> <widget class="QLineEdit" name="mEditBuildDir"/>
<widget class="QPushButton" name="mBtnBrowseBuildDir"> </item>
<property name="text"> <item>
<string>...</string> <widget class="QPushButton" name="mBtnBrowseBuildDir">
</property> <property name="text">
</widget> <string>...</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_10"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="orientation"> <item>
<enum>Qt::Vertical</enum> <widget class="QLabel" name="mLabelImport">
</property> <property name="toolTip">
<property name="sizeHint" stdset="0"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Cppcheck can import Visual studio solutions (*.sln), Visual studio projects (*.vcxproj) or compile databases.&lt;/p&gt;&lt;p&gt;Files to check, include paths, configurations, defines, platform settings are imported.\n\nLibrary settings are not imported.\n\n&lt;/p&gt;&lt;p&gt;A compile database can be generated from a cmake project using cmake, or from a Makefile project using bear (build ear).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<size> </property>
<width>20</width> <property name="text">
<height>97</height> <string>Import Project (Visual studio / compile database)</string>
</size> </property>
</property> </widget>
</spacer> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="mEditImportProject"/>
</item>
<item>
<widget class="QPushButton" name="mBtnBrowseImportProject">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="mLayoutLibraries"> <layout class="QHBoxLayout" name="mLayoutLibraries">
@ -114,100 +133,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="mTabVisualStudio">
<attribute name="title">
<string>Visual Studio</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="mLabelVisualStudio">
<property name="text">
<string>Visual Studio
Cppcheck can import visual studio solutions and projects.
Files to check, include paths, configurations, defines, platform settings are imported.
Library settings are not imported.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="mLayoutVisualStudio">
<item>
<widget class="QLineEdit" name="mEditVisualStudio"/>
</item>
<item>
<widget class="QPushButton" name="mBtnBrowseVisualStudio">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>149</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="mTabCMake">
<attribute name="title">
<string>CMake</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="mLabelCMake">
<property name="text">
<string>Compile database
Cppcheck can import files to analyse, include paths, defines from the compile database.
Platform settings are not provided in compile database and must be configured.
Library settings are not provided in compile database, be careful about this configuration also.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="mLayoutCMake">
<item>
<widget class="QLineEdit" name="mEditCompileDatabase"/>
</item>
<item>
<widget class="QPushButton" name="mBtnBrowseCompileDatabase">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>149</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="mTabOther"> <widget class="QWidget" name="mTabOther">
<attribute name="title"> <attribute name="title">
<string>Other</string> <string>Other</string>