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.
This commit is contained in:
Kimmo Varis 2011-02-28 15:58:44 +02:00
parent 46f7a81b7b
commit bd405c454a
4 changed files with 157 additions and 1 deletions

View File

@ -85,6 +85,9 @@ void Project::Edit()
dlg.SetDefines(defines);
QStringList paths = mPFile->GetCheckPaths();
dlg.SetPaths(paths);
QStringList ignorepaths = mPFile->GetIgnoredPaths();
dlg.SetIgnorePaths(ignorepaths);
int rv = dlg.exec();
if (rv == QDialog::Accepted)
{
@ -96,6 +99,9 @@ void Project::Edit()
mPFile->SetDefines(defines);
QStringList paths = dlg.GetPaths();
mPFile->SetCheckPaths(paths);
QStringList ignorepaths = dlg.GetIgnorePaths();
mPFile->SetIgnoredPaths(ignorepaths);
bool writeSuccess = mPFile->Write();
if (!writeSuccess)
{

View File

@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -196,6 +196,65 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Ignore</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Paths:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QListWidget" name="mListIgnoredPaths"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QPushButton" name="mBtnAddIgnorePath">
<property name="text">
<string>Add...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnEditIgnorePath">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnRemoveIgnorePath">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>

View File

@ -43,6 +43,9 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
connect(mUI.mBtnRemoveInclude, SIGNAL(clicked()), this, SLOT(RemoveIncludeDir()));
connect(mUI.mBtnEditPath, SIGNAL(clicked()), this, SLOT(EditPath()));
connect(mUI.mBtnRemovePath, SIGNAL(clicked()), this, SLOT(RemovePath()));
connect(mUI.mBtnAddIgnorePath, SIGNAL(clicked()), this, SLOT(AddIgnorePath()));
connect(mUI.mBtnEditIgnorePath, SIGNAL(clicked()), this, SLOT(EditIgnorePath()));
connect(mUI.mBtnRemoveIgnorePath, SIGNAL(clicked()), this, SLOT(RemoveIgnorePath()));
}
void ProjectFileDialog::AddIncludeDir(const QString &dir)
@ -65,6 +68,16 @@ void ProjectFileDialog::AddPath(const QString &path)
mUI.mListPaths->addItem(item);
}
void ProjectFileDialog::AddIgnorePath(const QString &path)
{
if (path.isNull() || path.isEmpty())
return;
QListWidgetItem *item = new QListWidgetItem(path);
item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI.mListIgnoredPaths->addItem(item);
}
QString ProjectFileDialog::GetRootPath() const
{
QString root = mUI.mEditProjectRoot->text();
@ -111,6 +124,18 @@ QStringList ProjectFileDialog::GetPaths() const
return paths;
}
QStringList ProjectFileDialog::GetIgnorePaths() const
{
const int count = mUI.mListIncludeDirs->count();
QStringList paths;
for (int i = 0; i < count; i++)
{
QListWidgetItem *item = mUI.mListIncludeDirs->item(i);
paths << item->text();
}
return paths;
}
void ProjectFileDialog::SetRootPath(const QString &root)
{
mUI.mEditProjectRoot->setText(root);
@ -147,6 +172,14 @@ void ProjectFileDialog::SetPaths(const QStringList &paths)
}
}
void ProjectFileDialog::SetIgnorePaths(const QStringList &paths)
{
foreach(QString path, paths)
{
AddIgnorePath(path);
}
}
void ProjectFileDialog::AddIncludeDir()
{
QString selectedDir = QFileDialog::getExistingDirectory(this,
@ -196,3 +229,28 @@ void ProjectFileDialog::RemovePath()
QListWidgetItem *item = mUI.mListPaths->takeItem(row);
delete item;
}
void ProjectFileDialog::AddIgnorePath()
{
QString selectedDir = QFileDialog::getExistingDirectory(this,
tr("Select directory to ignore"),
QString());
if (!selectedDir.isEmpty())
{
AddIgnorePath(selectedDir);
}
}
void ProjectFileDialog::EditIgnorePath()
{
QListWidgetItem *item = mUI.mListIgnoredPaths->currentItem();
mUI.mListIgnoredPaths->editItem(item);
}
void ProjectFileDialog::RemoveIgnorePath()
{
const int row = mUI.mListIgnoredPaths->currentRow();
QListWidgetItem *item = mUI.mListIgnoredPaths->takeItem(row);
delete item;
}

View File

@ -66,6 +66,12 @@ public:
*/
QStringList GetPaths() const;
/**
* @brief Return ignored paths from the dialog control.
* @return List of ignored paths.
*/
QStringList GetIgnorePaths() const;
/**
* @brief Set project root path to dialog control.
* @param root Project root path to set to dialog control.
@ -90,6 +96,12 @@ public:
*/
void SetPaths(const QStringList &paths);
/**
* @brief Set ignored paths to dialog control.
* @param paths List of path names to set to dialog control.
*/
void SetIgnorePaths(const QStringList &paths);
protected slots:
/**
* @brief Browse for include directory.
@ -122,6 +134,21 @@ protected slots:
*/
void RemovePath();
/**
* @brief Add new path to ignore.
*/
void AddIgnorePath();
/**
* @brief Edit ignored path in the list.
*/
void EditIgnorePath();
/**
* @brief Remove ignored path from the list.
*/
void RemoveIgnorePath();
protected:
/**
@ -136,6 +163,12 @@ protected:
*/
void AddPath(const QString &path);
/**
* @brief Add new path to ignore list.
* @param path Path to add.
*/
void AddIgnorePath(const QString &path);
private:
Ui::ProjectFile mUI;
};