GUI: Moved 'import project' to 'Paths and Defines' tab

This commit is contained in:
Daniel Marjamäki 2017-07-28 18:13:17 +02:00
parent 22abfb811a
commit 2828742e1e
3 changed files with 95 additions and 35 deletions

View File

@ -92,6 +92,7 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(mUI.mBtnBrowseBuildDir, SIGNAL(clicked()), this, SLOT(browseBuildDir()));
connect(mUI.mBtnClearImportProject, SIGNAL(clicked(bool)), this, SLOT(clearImportProject()));
connect(mUI.mBtnBrowseImportProject, SIGNAL(clicked()), this, SLOT(browseImportProject()));
connect(mUI.mBtnAddCheckPath, SIGNAL(clicked()), this, SLOT(addCheckPath()));
connect(mUI.mBtnEditCheckPath, SIGNAL(clicked()), this, SLOT(editCheckPath()));
@ -138,6 +139,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
setExcludedPaths(projectFile->getExcludedPaths());
setLibraries(projectFile->getLibraries());
setSuppressions(projectFile->getSuppressions());
updatePathsAndDefines();
}
void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
@ -185,6 +187,26 @@ void ProjectFileDialog::browseBuildDir()
mUI.mEditBuildDir->setText(dir);
}
void ProjectFileDialog::updatePathsAndDefines() {
bool importProject = !mUI.mEditImportProject->text().isEmpty();
mUI.mBtnClearImportProject->setEnabled(importProject);
mUI.mListCheckPaths->setEnabled(!importProject);
mUI.mBtnAddCheckPath->setEnabled(!importProject);
mUI.mBtnEditCheckPath->setEnabled(!importProject);
mUI.mBtnRemoveCheckPath->setEnabled(!importProject);
mUI.mEditDefines->setEnabled(!importProject);
mUI.mBtnAddInclude->setEnabled(!importProject);
mUI.mBtnEditInclude->setEnabled(!importProject);
mUI.mBtnRemoveInclude->setEnabled(!importProject);
mUI.mBtnIncludeUp->setEnabled(!importProject);
mUI.mBtnIncludeDown->setEnabled(!importProject);
}
void ProjectFileDialog::clearImportProject() {
mUI.mEditImportProject->clear();
updatePathsAndDefines();
}
void ProjectFileDialog::browseImportProject()
{
const QFileInfo inf(mFilePath);
@ -192,8 +214,15 @@ void ProjectFileDialog::browseImportProject()
QString fileName = QFileDialog::getOpenFileName(this, tr("Import Project"),
dir.canonicalPath(),
tr("Visual Studio (*.sln *.vcxproj);;Compile database (compile_database.json)"));
if (!fileName.isEmpty())
if (!fileName.isEmpty()) {
mUI.mEditImportProject->setText(dir.relativeFilePath(fileName));
updatePathsAndDefines();
}
}
QString ProjectFileDialog::getImportProject() const
{
return mUI.mEditImportProject->text();
}
void ProjectFileDialog::addIncludeDir(const QString &dir)
@ -242,10 +271,6 @@ QString ProjectFileDialog::getBuildDir() const
return mUI.mEditBuildDir->text();
}
QString ProjectFileDialog::getImportProject() const
{
return mUI.mEditImportProject->text();
}
QStringList ProjectFileDialog::getIncludePaths() const
{

View File

@ -46,6 +46,10 @@ public:
void loadFromProjectFile(const ProjectFile *projectFile);
void saveToProjectFile(ProjectFile *projectFile) const;
private:
/** Enable and disable widgets in the 'Paths and Defines' tab */
void updatePathsAndDefines();
/**
* @brief Return project root path from the dialog control.
* @return Project root path.
@ -147,6 +151,11 @@ protected slots:
*/
void browseBuildDir();
/**
* @brief Clear 'import project'.
*/
void clearImportProject();
/**
* @brief Browse for solution / project / compile database.
*/

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>642</width>
<height>434</height>
<height>498</height>
</rect>
</property>
<property name="windowTitle">
@ -69,34 +69,6 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="mLabelImport">
<property name="toolTip">
<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>
</property>
<property name="text">
<string>Import Project (Visual studio / compile database)</string>
</property>
</widget>
</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>
<layout class="QHBoxLayout" name="mLayoutLibraries">
<item>
@ -137,7 +109,61 @@
<attribute name="title">
<string>Paths and Defines</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="mLabelImport">
<property name="toolTip">
<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, defines, include paths are imported.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Import Project (Visual studio / compile database)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="mEditImportProject">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnClearImportProject">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<activeon>:/images/edit-clear.png</activeon>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnBrowseImportProject">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="mLayoutCheckPaths">
<item>