forked from qt-creator/qt-creator
VCS Clean Dialog: Added "Select All" checkbox
Change-Id: I5bff60b1aa1985926efb6b850be958f48d67a029 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
This commit is contained in:
@@ -170,6 +170,8 @@ CleanDialog::CleanDialog(QWidget *parent) :
|
|||||||
d->ui.filesTreeView->setRootIsDecorated(false);
|
d->ui.filesTreeView->setRootIsDecorated(false);
|
||||||
connect(d->ui.filesTreeView, SIGNAL(doubleClicked(QModelIndex)),
|
connect(d->ui.filesTreeView, SIGNAL(doubleClicked(QModelIndex)),
|
||||||
this, SLOT(slotDoubleClicked(QModelIndex)));
|
this, SLOT(slotDoubleClicked(QModelIndex)));
|
||||||
|
connect(d->ui.selectAllCheckBox, SIGNAL(clicked(bool)), this, SLOT(selectAllItems(bool)));
|
||||||
|
connect(d->ui.filesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(updateSelectAllCheckBox()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CleanDialog::~CleanDialog()
|
CleanDialog::~CleanDialog()
|
||||||
@@ -193,6 +195,9 @@ void CleanDialog::setFileList(const QString &workingDirectory, const QStringList
|
|||||||
|
|
||||||
for (int c = 0; c < d->m_filesModel->columnCount(); c++)
|
for (int c = 0; c < d->m_filesModel->columnCount(); c++)
|
||||||
d->ui.filesTreeView->resizeColumnToContents(c);
|
d->ui.filesTreeView->resizeColumnToContents(c);
|
||||||
|
|
||||||
|
if (ignoredFiles.isEmpty())
|
||||||
|
d->ui.selectAllCheckBox->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanDialog::addFile(const QString &workingDirectory, QString fileName, bool checked)
|
void CleanDialog::addFile(const QString &workingDirectory, QString fileName, bool checked)
|
||||||
@@ -278,6 +283,31 @@ void CleanDialog::slotDoubleClicked(const QModelIndex &index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CleanDialog::selectAllItems(bool checked)
|
||||||
|
{
|
||||||
|
if (const int rowCount = d->m_filesModel->rowCount()) {
|
||||||
|
for (int r = 0; r < rowCount; ++r) {
|
||||||
|
QStandardItem *item = d->m_filesModel->item(r, 0);
|
||||||
|
item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanDialog::updateSelectAllCheckBox()
|
||||||
|
{
|
||||||
|
bool checked = true;
|
||||||
|
if (const int rowCount = d->m_filesModel->rowCount()) {
|
||||||
|
for (int r = 0; r < rowCount; ++r) {
|
||||||
|
const QStandardItem *item = d->m_filesModel->item(r, 0);
|
||||||
|
if (item->checkState() == Qt::Unchecked) {
|
||||||
|
checked = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d->ui.selectAllCheckBox->setChecked(checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CleanDialog::changeEvent(QEvent *e)
|
void CleanDialog::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
QDialog::changeEvent(e);
|
QDialog::changeEvent(e);
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotDoubleClicked(const QModelIndex &);
|
void slotDoubleClicked(const QModelIndex &);
|
||||||
|
void selectAllItems(bool checked);
|
||||||
|
void updateSelectAllCheckBox();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList checkedFiles() const;
|
QStringList checkedFiles() const;
|
||||||
|
|||||||
@@ -17,6 +17,13 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="selectAllCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select All</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="filesTreeView"/>
|
<widget class="QTreeView" name="filesTreeView"/>
|
||||||
</item>
|
</item>
|
||||||
@@ -44,8 +51,8 @@
|
|||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>248</x>
|
<x>257</x>
|
||||||
<y>254</y>
|
<y>649</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>157</x>
|
<x>157</x>
|
||||||
@@ -60,8 +67,8 @@
|
|||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>316</x>
|
<x>325</x>
|
||||||
<y>260</y>
|
<y>649</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>286</x>
|
||||||
|
|||||||
Reference in New Issue
Block a user