Skip to content

Commit ca2f59a

Browse files
committed
GUI: Try to simplify the 'Import Project' setting
1 parent f6ee0f6 commit ca2f59a

3 files changed

Lines changed: 53 additions & 149 deletions

File tree

gui/projectfiledialog.cpp

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
9292

9393
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
9494
connect(mUI.mBtnBrowseBuildDir, SIGNAL(clicked()), this, SLOT(BrowseBuildDir()));
95-
connect(mUI.mBtnBrowseCompileDatabase, SIGNAL(clicked()), this, SLOT(BrowseCompileDatabase()));
96-
connect(mUI.mBtnBrowseVisualStudio, SIGNAL(clicked()), this, SLOT(BrowseVisualStudio()));
95+
connect(mUI.mBtnBrowseImportProject, SIGNAL(clicked()), this, SLOT(BrowseImportProject()));
9796
connect(mUI.mBtnAddCheckPath, SIGNAL(clicked()), this, SLOT(AddCheckPath()));
9897
connect(mUI.mBtnEditCheckPath, SIGNAL(clicked()), this, SLOT(EditCheckPath()));
9998
connect(mUI.mBtnRemoveCheckPath, SIGNAL(clicked()), this, SLOT(RemoveCheckPath()));
@@ -186,24 +185,14 @@ void ProjectFileDialog::BrowseBuildDir()
186185
mUI.mEditBuildDir->setText(dir);
187186
}
188187

189-
void ProjectFileDialog::BrowseCompileDatabase()
188+
void ProjectFileDialog::BrowseImportProject()
190189
{
191190
const QFileInfo inf(mFilePath);
192191
const QDir &dir = inf.absoluteDir();
193-
QString fileName = QFileDialog::getOpenFileName(this, tr("Compile Database"),
194-
dir.canonicalPath(),
195-
tr("Compile database (compile_database.json)"));
196-
mUI.mEditCompileDatabase->setText(dir.relativeFilePath(fileName));
197-
}
198-
199-
void ProjectFileDialog::BrowseVisualStudio()
200-
{
201-
const QFileInfo inf(mFilePath);
202-
const QDir &dir = inf.absoluteDir();
203-
QString fileName = QFileDialog::getOpenFileName(this, tr("Visual Studio"),
204-
dir.canonicalPath(),
205-
tr("Visual Studio Solution/Project (*.sln *.vcxproj)"));
206-
mUI.mEditVisualStudio->setText(dir.relativeFilePath(fileName));
192+
QString fileName = QFileDialog::getOpenFileName(this, tr("Import Project"),
193+
dir.canonicalPath(),
194+
tr("Visual Studio (*.sln *.vcxproj);;Compile database (compile_database.json)"));
195+
mUI.mEditImportProject->setText(dir.relativeFilePath(fileName));
207196
}
208197

209198
void ProjectFileDialog::AddIncludeDir(const QString &dir)
@@ -254,7 +243,7 @@ QString ProjectFileDialog::GetBuildDir() const
254243

255244
QString ProjectFileDialog::GetImportProject() const
256245
{
257-
return mUI.mEditCompileDatabase->text() + mUI.mEditVisualStudio->text();
246+
return mUI.mEditImportProject->text();
258247
}
259248

260249
QStringList ProjectFileDialog::GetIncludePaths() const
@@ -337,12 +326,7 @@ void ProjectFileDialog::SetBuildDir(const QString &buildDir)
337326

338327
void ProjectFileDialog::SetImportProject(const QString &importProject)
339328
{
340-
mUI.mEditCompileDatabase->setText("");
341-
mUI.mEditVisualStudio->setText("");
342-
if (importProject.endsWith("compile_database.json", Qt::CaseInsensitive))
343-
mUI.mEditCompileDatabase->setText(importProject);
344-
else if (importProject.endsWith(".sln",Qt::CaseInsensitive) || importProject.endsWith(".vcxproj",Qt::CaseInsensitive))
345-
mUI.mEditVisualStudio->setText(importProject);
329+
mUI.mEditImportProject->setText(importProject);
346330
}
347331

348332
void ProjectFileDialog::SetIncludepaths(const QStringList &includes)

gui/projectfiledialog.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,9 @@ protected slots:
148148
void BrowseBuildDir();
149149

150150
/**
151-
* @brief Browse for Visual Studio solution/project.
151+
* @brief Browse for solution / project / compile database.
152152
*/
153-
void BrowseVisualStudio();
154-
155-
/**
156-
* @brief Browse for Compile Database.
157-
*/
158-
void BrowseCompileDatabase();
153+
void BrowseImportProject();
159154

160155
/**
161156
* @brief Add new path to check.

gui/projectfiledialog.ui

Lines changed: 43 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>635</width>
10-
<height>368</height>
9+
<width>642</width>
10+
<height>434</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -23,13 +23,13 @@
2323
<attribute name="title">
2424
<string>Project</string>
2525
</attribute>
26-
<layout class="QVBoxLayout" name="verticalLayout_12">
26+
<layout class="QVBoxLayout" name="verticalLayout_7">
2727
<item>
28-
<layout class="QHBoxLayout" name="mLayoutProjectRoot">
28+
<layout class="QVBoxLayout" name="verticalLayout_4">
2929
<item>
3030
<widget class="QLabel" name="mLabelProjectRoot">
3131
<property name="text">
32-
<string>Root:</string>
32+
<string>&amp;Root:</string>
3333
</property>
3434
<property name="buddy">
3535
<cstring>mEditProjectRoot</cstring>
@@ -42,42 +42,61 @@
4242
</layout>
4343
</item>
4444
<item>
45-
<layout class="QHBoxLayout" name="mLayoutBuildDir">
45+
<layout class="QVBoxLayout" name="verticalLayout_2">
4646
<item>
4747
<widget class="QLabel" name="mLabelBuildDir">
4848
<property name="toolTip">
49-
<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>
49+
<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>
5050
</property>
5151
<property name="text">
52-
<string>Cppcheck build dir (optional)</string>
52+
<string>Cppcheck build dir (whole program analysis, faster analysis for unchanged files)</string>
5353
</property>
5454
</widget>
5555
</item>
5656
<item>
57-
<widget class="QLineEdit" name="mEditBuildDir"/>
57+
<layout class="QHBoxLayout" name="horizontalLayout_2">
58+
<item>
59+
<widget class="QLineEdit" name="mEditBuildDir"/>
60+
</item>
61+
<item>
62+
<widget class="QPushButton" name="mBtnBrowseBuildDir">
63+
<property name="text">
64+
<string>...</string>
65+
</property>
66+
</widget>
67+
</item>
68+
</layout>
5869
</item>
70+
</layout>
71+
</item>
72+
<item>
73+
<layout class="QVBoxLayout" name="verticalLayout_3">
5974
<item>
60-
<widget class="QPushButton" name="mBtnBrowseBuildDir">
75+
<widget class="QLabel" name="mLabelImport">
76+
<property name="toolTip">
77+
<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>
78+
</property>
6179
<property name="text">
62-
<string>...</string>
80+
<string>Import Project (Visual studio / compile database)</string>
6381
</property>
6482
</widget>
6583
</item>
84+
<item>
85+
<layout class="QHBoxLayout" name="horizontalLayout">
86+
<item>
87+
<widget class="QLineEdit" name="mEditImportProject"/>
88+
</item>
89+
<item>
90+
<widget class="QPushButton" name="mBtnBrowseImportProject">
91+
<property name="text">
92+
<string>...</string>
93+
</property>
94+
</widget>
95+
</item>
96+
</layout>
97+
</item>
6698
</layout>
6799
</item>
68-
<item>
69-
<spacer name="verticalSpacer_10">
70-
<property name="orientation">
71-
<enum>Qt::Vertical</enum>
72-
</property>
73-
<property name="sizeHint" stdset="0">
74-
<size>
75-
<width>20</width>
76-
<height>97</height>
77-
</size>
78-
</property>
79-
</spacer>
80-
</item>
81100
<item>
82101
<layout class="QHBoxLayout" name="mLayoutLibraries">
83102
<item>
@@ -114,100 +133,6 @@
114133
</item>
115134
</layout>
116135
</widget>
117-
<widget class="QWidget" name="mTabVisualStudio">
118-
<attribute name="title">
119-
<string>Visual Studio</string>
120-
</attribute>
121-
<layout class="QVBoxLayout" name="verticalLayout_4">
122-
<item>
123-
<widget class="QLabel" name="mLabelVisualStudio">
124-
<property name="text">
125-
<string>Visual Studio
126-
127-
Cppcheck can import visual studio solutions and projects.
128-
129-
Files to check, include paths, configurations, defines, platform settings are imported.
130-
131-
Library settings are not imported.</string>
132-
</property>
133-
</widget>
134-
</item>
135-
<item>
136-
<layout class="QHBoxLayout" name="mLayoutVisualStudio">
137-
<item>
138-
<widget class="QLineEdit" name="mEditVisualStudio"/>
139-
</item>
140-
<item>
141-
<widget class="QPushButton" name="mBtnBrowseVisualStudio">
142-
<property name="text">
143-
<string>...</string>
144-
</property>
145-
</widget>
146-
</item>
147-
</layout>
148-
</item>
149-
<item>
150-
<spacer name="verticalSpacer_5">
151-
<property name="orientation">
152-
<enum>Qt::Vertical</enum>
153-
</property>
154-
<property name="sizeHint" stdset="0">
155-
<size>
156-
<width>20</width>
157-
<height>149</height>
158-
</size>
159-
</property>
160-
</spacer>
161-
</item>
162-
</layout>
163-
</widget>
164-
<widget class="QWidget" name="mTabCMake">
165-
<attribute name="title">
166-
<string>CMake</string>
167-
</attribute>
168-
<layout class="QVBoxLayout" name="verticalLayout_7">
169-
<item>
170-
<widget class="QLabel" name="mLabelCMake">
171-
<property name="text">
172-
<string>Compile database
173-
174-
Cppcheck can import files to analyse, include paths, defines from the compile database.
175-
176-
Platform settings are not provided in compile database and must be configured.
177-
178-
Library settings are not provided in compile database, be careful about this configuration also.</string>
179-
</property>
180-
</widget>
181-
</item>
182-
<item>
183-
<layout class="QHBoxLayout" name="mLayoutCMake">
184-
<item>
185-
<widget class="QLineEdit" name="mEditCompileDatabase"/>
186-
</item>
187-
<item>
188-
<widget class="QPushButton" name="mBtnBrowseCompileDatabase">
189-
<property name="text">
190-
<string>...</string>
191-
</property>
192-
</widget>
193-
</item>
194-
</layout>
195-
</item>
196-
<item>
197-
<spacer name="verticalSpacer_7">
198-
<property name="orientation">
199-
<enum>Qt::Vertical</enum>
200-
</property>
201-
<property name="sizeHint" stdset="0">
202-
<size>
203-
<width>20</width>
204-
<height>149</height>
205-
</size>
206-
</property>
207-
</spacer>
208-
</item>
209-
</layout>
210-
</widget>
211136
<widget class="QWidget" name="mTabOther">
212137
<attribute name="title">
213138
<string>Other</string>

0 commit comments

Comments
 (0)