GUI: Allow reordering includes in project dialog.

Since include dir order is important (Cppcheck uses the first file
it finds) user must be able to edit the order of include paths.
This commit adds "Up" and "Down" buttons to the Project-dialog's
inlude paths-tab. User can use those two buttons to re-order the
include directories.

Ticket: #3037 (GUI: Allow reordering include paths in project dialog)
This commit is contained in:
Kimmo Varis 2011-08-22 22:16:59 +03:00
parent 042693a305
commit 63e8e9ea57
3 changed files with 47 additions and 0 deletions

View File

@ -190,6 +190,20 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="mBtnIncludeUp">
<property name="text">
<string>Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnIncludeDown">
<property name="text">
<string>Down</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -282,6 +296,8 @@
<tabstop>mBtnAddInclude</tabstop>
<tabstop>mBtnEditInclude</tabstop>
<tabstop>mBtnRemoveInclude</tabstop>
<tabstop>mBtnIncludeUp</tabstop>
<tabstop>mBtnIncludeDown</tabstop>
<tabstop>mListIgnoredPaths</tabstop>
<tabstop>mBtnAddIgnorePath</tabstop>
<tabstop>mBtnEditIgnorePath</tabstop>

View File

@ -50,6 +50,8 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
connect(mUI.mBtnAddIgnorePath, SIGNAL(clicked()), this, SLOT(AddIgnorePath()));
connect(mUI.mBtnEditIgnorePath, SIGNAL(clicked()), this, SLOT(EditIgnorePath()));
connect(mUI.mBtnRemoveIgnorePath, SIGNAL(clicked()), this, SLOT(RemoveIgnorePath()));
connect(mUI.mBtnIncludeUp, SIGNAL(clicked()), this, SLOT(MoveIncludePathUp()));
connect(mUI.mBtnIncludeDown, SIGNAL(clicked()), this, SLOT(MoveIncludePathDown()));
}
ProjectFileDialog::~ProjectFileDialog()
@ -291,3 +293,22 @@ void ProjectFileDialog::RemoveIgnorePath()
QListWidgetItem *item = mUI.mListIgnoredPaths->takeItem(row);
delete item;
}
void ProjectFileDialog::MoveIncludePathUp()
{
int row = mUI.mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI.mListIncludeDirs->takeItem(row);
row = row > 0 ? row - 1 : 0;
mUI.mListIncludeDirs->insertItem(row, item);
mUI.mListIncludeDirs->setCurrentItem(item);
}
void ProjectFileDialog::MoveIncludePathDown()
{
int row = mUI.mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI.mListIncludeDirs->takeItem(row);
const int count = mUI.mListIncludeDirs->count();
row = row < count ? row + 1 : count;
mUI.mListIncludeDirs->insertItem(row, item);
mUI.mListIncludeDirs->setCurrentItem(item);
}

View File

@ -150,6 +150,16 @@ protected slots:
*/
void RemoveIgnorePath();
/**
* @brief Move include path up in the list.
*/
void MoveIncludePathUp();
/**
* @brief Move include path down in the list.
*/
void MoveIncludePathDown();
protected:
/**