GUI: Use list to manage paths in project file.
Handling paths in line edit control is quite hard. List control is much more pleasant to use for it. Convert Project file path handling to similar list control usage than include paths earlier.
This commit is contained in:
parent
d1d0706154
commit
cf4a73eb80
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>467</width>
|
<width>467</width>
|
||||||
<height>313</height>
|
<height>329</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -23,78 +23,114 @@
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Project</string>
|
<string>Project</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Project:</string>
|
<widget class="QLabel" name="label_4">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="buddy">
|
<string>Project:</string>
|
||||||
<cstring>mEditProjectRoot</cstring>
|
</property>
|
||||||
</property>
|
<property name="buddy">
|
||||||
</widget>
|
<cstring>mEditProjectRoot</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="mEditProjectRoot"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="mEditProjectRoot"/>
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Defines:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>mEditDefines</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="mEditDefines"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Paths:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<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>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="mListPaths"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnAddPath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnEditPath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnRemovePath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<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>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Paths:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>mEditPaths</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="mEditPaths"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="mBtnBrowsePaths">
|
|
||||||
<property name="text">
|
|
||||||
<string>Browse...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Defines:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>mEditDefines</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="mEditDefines"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
@ -178,9 +214,11 @@
|
|||||||
<tabstop>mButtons</tabstop>
|
<tabstop>mButtons</tabstop>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
<tabstop>mEditProjectRoot</tabstop>
|
<tabstop>mEditProjectRoot</tabstop>
|
||||||
<tabstop>mEditPaths</tabstop>
|
|
||||||
<tabstop>mBtnBrowsePaths</tabstop>
|
|
||||||
<tabstop>mEditDefines</tabstop>
|
<tabstop>mEditDefines</tabstop>
|
||||||
|
<tabstop>mListPaths</tabstop>
|
||||||
|
<tabstop>mBtnAddPath</tabstop>
|
||||||
|
<tabstop>mBtnEditPath</tabstop>
|
||||||
|
<tabstop>mBtnRemovePath</tabstop>
|
||||||
<tabstop>mListIncludeDirs</tabstop>
|
<tabstop>mListIncludeDirs</tabstop>
|
||||||
<tabstop>mBtnAddInclude</tabstop>
|
<tabstop>mBtnAddInclude</tabstop>
|
||||||
<tabstop>mBtnEditInclude</tabstop>
|
<tabstop>mBtnEditInclude</tabstop>
|
||||||
@ -195,8 +233,8 @@
|
|||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>257</x>
|
<x>266</x>
|
||||||
<y>148</y>
|
<y>319</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>157</x>
|
<x>157</x>
|
||||||
@ -211,8 +249,8 @@
|
|||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>325</x>
|
<x>334</x>
|
||||||
<y>148</y>
|
<y>319</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>286</x>
|
||||||
|
@ -38,9 +38,11 @@ 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.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));
|
connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));
|
||||||
connect(mUI.mBtnBrowsePaths, SIGNAL(clicked()), this, SLOT(BrowsePaths()));
|
connect(mUI.mBtnAddPath, SIGNAL(clicked()), this, SLOT(AddPath()));
|
||||||
connect(mUI.mBtnEditInclude, SIGNAL(clicked()), this, SLOT(EditIncludeDir()));
|
connect(mUI.mBtnEditInclude, SIGNAL(clicked()), this, SLOT(EditIncludeDir()));
|
||||||
connect(mUI.mBtnRemoveInclude, SIGNAL(clicked()), this, SLOT(RemoveIncludeDir()));
|
connect(mUI.mBtnRemoveInclude, SIGNAL(clicked()), this, SLOT(RemoveIncludeDir()));
|
||||||
|
connect(mUI.mBtnEditPath, SIGNAL(clicked()), this, SLOT(EditPath()));
|
||||||
|
connect(mUI.mBtnRemovePath, SIGNAL(clicked()), this, SLOT(RemovePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileDialog::AddIncludeDir(const QString &dir)
|
void ProjectFileDialog::AddIncludeDir(const QString &dir)
|
||||||
@ -53,6 +55,16 @@ void ProjectFileDialog::AddIncludeDir(const QString &dir)
|
|||||||
mUI.mListIncludeDirs->addItem(item);
|
mUI.mListIncludeDirs->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectFileDialog::AddPath(const QString &path)
|
||||||
|
{
|
||||||
|
if (path.isNull() || path.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(path);
|
||||||
|
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||||
|
mUI.mListPaths->addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
QString ProjectFileDialog::GetRootPath() const
|
QString ProjectFileDialog::GetRootPath() const
|
||||||
{
|
{
|
||||||
QString root = mUI.mEditProjectRoot->text();
|
QString root = mUI.mEditProjectRoot->text();
|
||||||
@ -89,16 +101,12 @@ QStringList ProjectFileDialog::GetDefines() const
|
|||||||
|
|
||||||
QStringList ProjectFileDialog::GetPaths() const
|
QStringList ProjectFileDialog::GetPaths() const
|
||||||
{
|
{
|
||||||
QString path = mUI.mEditPaths->text();
|
const int count = mUI.mListPaths->count();
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
if (!path.isEmpty())
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
path = path.trimmed();
|
QListWidgetItem *item = mUI.mListPaths->item(i);
|
||||||
path = QDir::fromNativeSeparators(path);
|
paths << item->text();
|
||||||
if (path.indexOf(';') != -1)
|
|
||||||
paths = path.split(";");
|
|
||||||
else
|
|
||||||
paths.append(path);
|
|
||||||
}
|
}
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
@ -110,8 +118,7 @@ void ProjectFileDialog::SetRootPath(const QString &root)
|
|||||||
|
|
||||||
void ProjectFileDialog::SetIncludepaths(const QStringList &includes)
|
void ProjectFileDialog::SetIncludepaths(const QStringList &includes)
|
||||||
{
|
{
|
||||||
QString dir;
|
foreach(QString dir, includes)
|
||||||
foreach(dir, includes)
|
|
||||||
{
|
{
|
||||||
AddIncludeDir(dir);
|
AddIncludeDir(dir);
|
||||||
}
|
}
|
||||||
@ -134,18 +141,10 @@ void ProjectFileDialog::SetDefines(const QStringList &defines)
|
|||||||
|
|
||||||
void ProjectFileDialog::SetPaths(const QStringList &paths)
|
void ProjectFileDialog::SetPaths(const QStringList &paths)
|
||||||
{
|
{
|
||||||
QString pathstr;
|
foreach(QString path, paths)
|
||||||
QString path;
|
|
||||||
foreach(path, paths)
|
|
||||||
{
|
{
|
||||||
pathstr += path;
|
AddPath(path);
|
||||||
pathstr += ";";
|
|
||||||
}
|
}
|
||||||
// Remove ; from the end of the string
|
|
||||||
if (pathstr.endsWith(';'))
|
|
||||||
pathstr = pathstr.left(pathstr.length() - 1);
|
|
||||||
pathstr = QDir::toNativeSeparators(pathstr);
|
|
||||||
mUI.mEditPaths->setText(pathstr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileDialog::AddIncludeDir()
|
void ProjectFileDialog::AddIncludeDir()
|
||||||
@ -160,7 +159,7 @@ void ProjectFileDialog::AddIncludeDir()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileDialog::BrowsePaths()
|
void ProjectFileDialog::AddPath()
|
||||||
{
|
{
|
||||||
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
||||||
tr("Select directory to check"),
|
tr("Select directory to check"),
|
||||||
@ -168,20 +167,10 @@ void ProjectFileDialog::BrowsePaths()
|
|||||||
|
|
||||||
if (!selectedDir.isEmpty())
|
if (!selectedDir.isEmpty())
|
||||||
{
|
{
|
||||||
AppendDirname(mUI.mEditPaths, selectedDir);
|
AddPath(selectedDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectFileDialog::AppendDirname(QLineEdit *edit, const QString &dir)
|
|
||||||
{
|
|
||||||
QString wholeText = edit->text();
|
|
||||||
wholeText += ";";
|
|
||||||
wholeText += dir;
|
|
||||||
if (!wholeText.endsWith(QDir::separator()))
|
|
||||||
wholeText += QDir::separator();
|
|
||||||
edit->setText(wholeText);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectFileDialog::RemoveIncludeDir()
|
void ProjectFileDialog::RemoveIncludeDir()
|
||||||
{
|
{
|
||||||
const int row = mUI.mListIncludeDirs->currentRow();
|
const int row = mUI.mListIncludeDirs->currentRow();
|
||||||
@ -194,3 +183,16 @@ void ProjectFileDialog::EditIncludeDir()
|
|||||||
QListWidgetItem *item = mUI.mListIncludeDirs->currentItem();
|
QListWidgetItem *item = mUI.mListIncludeDirs->currentItem();
|
||||||
mUI.mListIncludeDirs->editItem(item);
|
mUI.mListIncludeDirs->editItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectFileDialog::EditPath()
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = mUI.mListPaths->currentItem();
|
||||||
|
mUI.mListPaths->editItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectFileDialog::RemovePath()
|
||||||
|
{
|
||||||
|
const int row = mUI.mListPaths->currentRow();
|
||||||
|
QListWidgetItem *item = mUI.mListPaths->takeItem(row);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
@ -96,11 +96,11 @@ protected slots:
|
|||||||
* Allow user to add new include directory to the list.
|
* Allow user to add new include directory to the list.
|
||||||
*/
|
*/
|
||||||
void AddIncludeDir();
|
void AddIncludeDir();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Browse for checked directory.
|
* @brief Add new path to check.
|
||||||
* Allow user to choose new checked directory.
|
|
||||||
*/
|
*/
|
||||||
void BrowsePaths();
|
void AddPath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove include directory from the list.
|
* @brief Remove include directory from the list.
|
||||||
@ -112,6 +112,16 @@ protected slots:
|
|||||||
*/
|
*/
|
||||||
void EditIncludeDir();
|
void EditIncludeDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Edit path in the list.
|
||||||
|
*/
|
||||||
|
void EditPath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Remove path from the list.
|
||||||
|
*/
|
||||||
|
void RemovePath();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,11 +131,10 @@ protected:
|
|||||||
void AddIncludeDir(const QString &dir);
|
void AddIncludeDir(const QString &dir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append new path to the edit control.
|
* @brief Add new path to check.
|
||||||
* @param edit Edit control to modify.
|
* @param path Path to add.
|
||||||
* @param dir Path to add.
|
|
||||||
*/
|
*/
|
||||||
void AppendDirname(QLineEdit *edit, const QString &dir);
|
void AddPath(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ProjectFile mUI;
|
Ui::ProjectFile mUI;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user