diff options
author | Camila San <hello@camila.codes> | 2018-02-02 00:35:38 +0300 |
---|---|---|
committer | Camila San <hello@camila.codes> | 2018-02-02 00:35:38 +0300 |
commit | 6dd349a8a6bf432add47152f057d1a34c401f807 (patch) | |
tree | 4ff0ed726b1bb3b1caf31cdae9fb01ce8c3272e3 /src/gui/ignorelisteditor.cpp | |
parent | f7697b0584f19a84ae82da89b17aefff7d82e76f (diff) |
Adds button to restore default patterns in the ignore list.
Signed-off-by: Camila San <hello@camila.codes>
Diffstat (limited to 'src/gui/ignorelisteditor.cpp')
-rw-r--r-- | src/gui/ignorelisteditor.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/gui/ignorelisteditor.cpp b/src/gui/ignorelisteditor.cpp index b6e262eac..0d49933f1 100644 --- a/src/gui/ignorelisteditor.cpp +++ b/src/gui/ignorelisteditor.cpp @@ -37,27 +37,23 @@ IgnoreListEditor::IgnoreListEditor(QWidget *parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui->setupUi(this); + ConfigFile cfgFile; ui->descriptionLabel->setText(tr("Files or folders matching a pattern will not be synchronized.\n\n" "Items where deletion is allowed will be deleted if they prevent a " "directory from being removed. " "This is useful for meta data.")); - - ConfigFile cfgFile; readOnlyTooltip = tr("This entry is provided by the system at '%1' " "and cannot be modified in this view.") .arg(QDir::toNativeSeparators(cfgFile.excludeFile(ConfigFile::SystemScope))); - addPattern(".csync_journal.db*", /*deletable=*/false, /*readonly=*/true); - addPattern("._sync_*.db*", /*deletable=*/false, /*readonly=*/true); - addPattern(".sync_*.db*", /*deletable=*/false, /*readonly=*/true); - readIgnoreFile(cfgFile.excludeFile(ConfigFile::SystemScope), false); - readIgnoreFile(cfgFile.excludeFile(ConfigFile::UserScope), false); + populateIgnoreFileTable(); connect(this, &QDialog::accepted, this, &IgnoreListEditor::slotUpdateLocalIgnoreList); ui->removePushButton->setEnabled(false); connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &IgnoreListEditor::slotItemSelectionChanged); connect(ui->removePushButton, &QAbstractButton::clicked, this, &IgnoreListEditor::slotRemoveCurrentItem); connect(ui->addPushButton, &QAbstractButton::clicked, this, &IgnoreListEditor::slotAddPattern); + connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &IgnoreListEditor::slotRestoreDefaults); ui->tableWidget->resizeColumnsToContents(); ui->tableWidget->horizontalHeader()->setSectionResizeMode(patternCol, QHeaderView::Stretch); @@ -150,6 +146,11 @@ void IgnoreListEditor::slotAddPattern() ui->tableWidget->scrollToBottom(); } +void IgnoreListEditor::slotRestoreDefaults(QAbstractButton *button){ + if(ui->buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) + populateIgnoreFileTable(); +} + void IgnoreListEditor::readIgnoreFile(const QString &file, bool readOnly) { QFile ignores(file); @@ -169,6 +170,18 @@ void IgnoreListEditor::readIgnoreFile(const QString &file, bool readOnly) } } +void IgnoreListEditor::populateIgnoreFileTable(){ + ui->tableWidget->setRowCount(0); + + addPattern(".csync_journal.db*", /*deletable=*/false, /*readonly=*/true); + addPattern("._sync_*.db*", /*deletable=*/false, /*readonly=*/true); + addPattern(".sync_*.db*", /*deletable=*/false, /*readonly=*/true); + + ConfigFile cfgFile; + readIgnoreFile(cfgFile.excludeFile(ConfigFile::SystemScope), false); + readIgnoreFile(cfgFile.excludeFile(ConfigFile::UserScope), false); +} + int IgnoreListEditor::addPattern(const QString &pattern, bool deletable, bool readOnly) { int newRow = ui->tableWidget->rowCount(); |