Skip to content

Commit bd405c4

Browse files
committed
GUI: Add GUI for ignored paths in project files.
Add similar GUI than include paths has. Currently there is only possibly select directories directly from the GUI. But filename can be added to the path by editing it.
1 parent 46f7a81 commit bd405c4

File tree

4 files changed

+157
-1
lines changed

4 files changed

+157
-1
lines changed

gui/project.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ void Project::Edit()
8585
dlg.SetDefines(defines);
8686
QStringList paths = mPFile->GetCheckPaths();
8787
dlg.SetPaths(paths);
88+
QStringList ignorepaths = mPFile->GetIgnoredPaths();
89+
dlg.SetIgnorePaths(ignorepaths);
90+
8891
int rv = dlg.exec();
8992
if (rv == QDialog::Accepted)
9093
{
@@ -96,6 +99,9 @@ void Project::Edit()
9699
mPFile->SetDefines(defines);
97100
QStringList paths = dlg.GetPaths();
98101
mPFile->SetCheckPaths(paths);
102+
QStringList ignorepaths = dlg.GetIgnorePaths();
103+
mPFile->SetIgnoredPaths(ignorepaths);
104+
99105
bool writeSuccess = mPFile->Write();
100106
if (!writeSuccess)
101107
{

gui/projectfile.ui

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<item>
1818
<widget class="QTabWidget" name="tabWidget">
1919
<property name="currentIndex">
20-
<number>1</number>
20+
<number>2</number>
2121
</property>
2222
<widget class="QWidget" name="tab">
2323
<attribute name="title">
@@ -196,6 +196,65 @@
196196
</item>
197197
</layout>
198198
</widget>
199+
<widget class="QWidget" name="tab_3">
200+
<attribute name="title">
201+
<string>Ignore</string>
202+
</attribute>
203+
<layout class="QVBoxLayout" name="verticalLayout_9">
204+
<item>
205+
<widget class="QLabel" name="label_5">
206+
<property name="text">
207+
<string>Paths:</string>
208+
</property>
209+
</widget>
210+
</item>
211+
<item>
212+
<layout class="QHBoxLayout" name="horizontalLayout_5">
213+
<item>
214+
<widget class="QListWidget" name="mListIgnoredPaths"/>
215+
</item>
216+
<item>
217+
<layout class="QVBoxLayout" name="verticalLayout_8">
218+
<item>
219+
<widget class="QPushButton" name="mBtnAddIgnorePath">
220+
<property name="text">
221+
<string>Add...</string>
222+
</property>
223+
</widget>
224+
</item>
225+
<item>
226+
<widget class="QPushButton" name="mBtnEditIgnorePath">
227+
<property name="text">
228+
<string>Edit</string>
229+
</property>
230+
</widget>
231+
</item>
232+
<item>
233+
<widget class="QPushButton" name="mBtnRemoveIgnorePath">
234+
<property name="text">
235+
<string>Remove</string>
236+
</property>
237+
</widget>
238+
</item>
239+
<item>
240+
<spacer name="verticalSpacer_4">
241+
<property name="orientation">
242+
<enum>Qt::Vertical</enum>
243+
</property>
244+
<property name="sizeHint" stdset="0">
245+
<size>
246+
<width>20</width>
247+
<height>40</height>
248+
</size>
249+
</property>
250+
</spacer>
251+
</item>
252+
</layout>
253+
</item>
254+
</layout>
255+
</item>
256+
</layout>
257+
</widget>
199258
</widget>
200259
</item>
201260
<item>

gui/projectfiledialog.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
4343
connect(mUI.mBtnRemoveInclude, SIGNAL(clicked()), this, SLOT(RemoveIncludeDir()));
4444
connect(mUI.mBtnEditPath, SIGNAL(clicked()), this, SLOT(EditPath()));
4545
connect(mUI.mBtnRemovePath, SIGNAL(clicked()), this, SLOT(RemovePath()));
46+
connect(mUI.mBtnAddIgnorePath, SIGNAL(clicked()), this, SLOT(AddIgnorePath()));
47+
connect(mUI.mBtnEditIgnorePath, SIGNAL(clicked()), this, SLOT(EditIgnorePath()));
48+
connect(mUI.mBtnRemoveIgnorePath, SIGNAL(clicked()), this, SLOT(RemoveIgnorePath()));
4649
}
4750

4851
void ProjectFileDialog::AddIncludeDir(const QString &dir)
@@ -65,6 +68,16 @@ void ProjectFileDialog::AddPath(const QString &path)
6568
mUI.mListPaths->addItem(item);
6669
}
6770

71+
void ProjectFileDialog::AddIgnorePath(const QString &path)
72+
{
73+
if (path.isNull() || path.isEmpty())
74+
return;
75+
76+
QListWidgetItem *item = new QListWidgetItem(path);
77+
item->setFlags(item->flags() | Qt::ItemIsEditable);
78+
mUI.mListIgnoredPaths->addItem(item);
79+
}
80+
6881
QString ProjectFileDialog::GetRootPath() const
6982
{
7083
QString root = mUI.mEditProjectRoot->text();
@@ -111,6 +124,18 @@ QStringList ProjectFileDialog::GetPaths() const
111124
return paths;
112125
}
113126

127+
QStringList ProjectFileDialog::GetIgnorePaths() const
128+
{
129+
const int count = mUI.mListIncludeDirs->count();
130+
QStringList paths;
131+
for (int i = 0; i < count; i++)
132+
{
133+
QListWidgetItem *item = mUI.mListIncludeDirs->item(i);
134+
paths << item->text();
135+
}
136+
return paths;
137+
}
138+
114139
void ProjectFileDialog::SetRootPath(const QString &root)
115140
{
116141
mUI.mEditProjectRoot->setText(root);
@@ -147,6 +172,14 @@ void ProjectFileDialog::SetPaths(const QStringList &paths)
147172
}
148173
}
149174

175+
void ProjectFileDialog::SetIgnorePaths(const QStringList &paths)
176+
{
177+
foreach(QString path, paths)
178+
{
179+
AddIgnorePath(path);
180+
}
181+
}
182+
150183
void ProjectFileDialog::AddIncludeDir()
151184
{
152185
QString selectedDir = QFileDialog::getExistingDirectory(this,
@@ -196,3 +229,28 @@ void ProjectFileDialog::RemovePath()
196229
QListWidgetItem *item = mUI.mListPaths->takeItem(row);
197230
delete item;
198231
}
232+
233+
void ProjectFileDialog::AddIgnorePath()
234+
{
235+
QString selectedDir = QFileDialog::getExistingDirectory(this,
236+
tr("Select directory to ignore"),
237+
QString());
238+
239+
if (!selectedDir.isEmpty())
240+
{
241+
AddIgnorePath(selectedDir);
242+
}
243+
}
244+
245+
void ProjectFileDialog::EditIgnorePath()
246+
{
247+
QListWidgetItem *item = mUI.mListIgnoredPaths->currentItem();
248+
mUI.mListIgnoredPaths->editItem(item);
249+
}
250+
251+
void ProjectFileDialog::RemoveIgnorePath()
252+
{
253+
const int row = mUI.mListIgnoredPaths->currentRow();
254+
QListWidgetItem *item = mUI.mListIgnoredPaths->takeItem(row);
255+
delete item;
256+
}

gui/projectfiledialog.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class ProjectFileDialog : public QDialog
6666
*/
6767
QStringList GetPaths() const;
6868

69+
/**
70+
* @brief Return ignored paths from the dialog control.
71+
* @return List of ignored paths.
72+
*/
73+
QStringList GetIgnorePaths() const;
74+
6975
/**
7076
* @brief Set project root path to dialog control.
7177
* @param root Project root path to set to dialog control.
@@ -90,6 +96,12 @@ class ProjectFileDialog : public QDialog
9096
*/
9197
void SetPaths(const QStringList &paths);
9298

99+
/**
100+
* @brief Set ignored paths to dialog control.
101+
* @param paths List of path names to set to dialog control.
102+
*/
103+
void SetIgnorePaths(const QStringList &paths);
104+
93105
protected slots:
94106
/**
95107
* @brief Browse for include directory.
@@ -122,6 +134,21 @@ protected slots:
122134
*/
123135
void RemovePath();
124136

137+
/**
138+
* @brief Add new path to ignore.
139+
*/
140+
void AddIgnorePath();
141+
142+
/**
143+
* @brief Edit ignored path in the list.
144+
*/
145+
void EditIgnorePath();
146+
147+
/**
148+
* @brief Remove ignored path from the list.
149+
*/
150+
void RemoveIgnorePath();
151+
125152
protected:
126153

127154
/**
@@ -136,6 +163,12 @@ protected slots:
136163
*/
137164
void AddPath(const QString &path);
138165

166+
/**
167+
* @brief Add new path to ignore list.
168+
* @param path Path to add.
169+
*/
170+
void AddIgnorePath(const QString &path);
171+
139172
private:
140173
Ui::ProjectFile mUI;
141174
};

0 commit comments

Comments
 (0)