Enable/disable remove all button depending on the number of rows.

Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
Camila San 2018-02-02 15:49:58 +01:00
parent c29d3b7e0b
commit 73b7540468
No known key found for this signature in database
GPG key ID: A0A1A2FD03979524

View file

@ -29,6 +29,7 @@ namespace OCC {
static int patternCol = 0; static int patternCol = 0;
static int deletableCol = 1; static int deletableCol = 1;
static int readOnlyRows = 3;
IgnoreListEditor::IgnoreListEditor(QWidget *parent) IgnoreListEditor::IgnoreListEditor(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -96,6 +97,8 @@ void IgnoreListEditor::slotItemSelectionChanged()
void IgnoreListEditor::slotRemoveCurrentItem() void IgnoreListEditor::slotRemoveCurrentItem()
{ {
ui->tableWidget->removeRow(ui->tableWidget->currentRow()); ui->tableWidget->removeRow(ui->tableWidget->currentRow());
if(ui->tableWidget->rowCount() == readOnlyRows)
ui->removeAllPushButton->setEnabled(false);
} }
void IgnoreListEditor::slotRemoveAllItems() void IgnoreListEditor::slotRemoveAllItems()
@ -212,6 +215,11 @@ int IgnoreListEditor::addPattern(const QString &pattern, bool deletable, bool re
deletableItem->setFlags(deletableItem->flags() ^ Qt::ItemIsEnabled); deletableItem->setFlags(deletableItem->flags() ^ Qt::ItemIsEnabled);
} }
// most of the time we will have more than the read only rows
ui->removeAllPushButton->setEnabled(true);
if(ui->tableWidget->rowCount() == readOnlyRows)
ui->removeAllPushButton->setEnabled(false);
return newRow; return newRow;
} }