diff options
author | Daniel Molkentin <danimo@owncloud.com> | 2013-08-05 18:13:12 +0400 |
---|---|---|
committer | Daniel Molkentin <danimo@owncloud.com> | 2013-08-05 18:13:26 +0400 |
commit | 3f15e028814ada63e8645d0ad088f36e2fb2128c (patch) | |
tree | 70d7fe63641a178353cf5e37cd290640c5dc34af | |
parent | 6fb5c04bdeeac9cc4fc744ad31799c3fe9895f6d (diff) |
Add support for deletable ignores in IgnoreListEditor.
-rw-r--r-- | src/mirall/ignorelisteditor.cpp | 29 | ||||
-rw-r--r-- | src/mirall/ignorelisteditor.ui | 47 | ||||
-rw-r--r-- | sync-exclude.lst | 14 |
3 files changed, 55 insertions, 35 deletions
diff --git a/src/mirall/ignorelisteditor.cpp b/src/mirall/ignorelisteditor.cpp index e1e831d04..e82f557b9 100644 --- a/src/mirall/ignorelisteditor.cpp +++ b/src/mirall/ignorelisteditor.cpp @@ -32,7 +32,9 @@ IgnoreListEditor::IgnoreListEditor(QWidget *parent) : { ui->setupUi(this); - ui->descriptionLabel->setText(tr("Files matching the following patterns will not be synchronized:")); + ui->descriptionLabel->setText(tr("Files or Directories matching a pattern will not be synchronized.\n\n" + "Checked items mark files that will be removed if a folder " + "is otherwise empty.")); MirallConfigFile cfgFile; readIgnoreFile(cfgFile.excludeFile(MirallConfigFile::SystemScope), true); @@ -49,7 +51,8 @@ IgnoreListEditor::IgnoreListEditor(QWidget *parent) : static void setupItemFlags(QListWidgetItem* item) { - item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); + item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Unchecked); } IgnoreListEditor::~IgnoreListEditor() @@ -83,7 +86,11 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList() for(int i = 0; i < ui->listWidget->count(); ++i) { QListWidgetItem *item = ui->listWidget->item(i); if (item->flags() & Qt::ItemIsEnabled) { - ignores.write(item->text().toUtf8()+'\n'); + QByteArray prepend; + if (item->checkState() == Qt::Checked) { + prepend = "]"; + } + ignores.write(prepend+item->text().toUtf8()+'\n'); } } } else { @@ -95,8 +102,13 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList() void IgnoreListEditor::slotAddPattern() { QString pattern = QInputDialog::getText(this, tr("Add Ignore Pattern"), tr("Add a new ignore pattern:")); - QListWidgetItem *item = new QListWidgetItem(pattern); + QListWidgetItem *item = new QListWidgetItem; setupItemFlags(item); + if (pattern.startsWith("]")) { + pattern = pattern.mid(1); + item->setCheckState(Qt::Checked); + } + item->setText(pattern); ui->listWidget->addItem(item); ui->listWidget->scrollToItem(item); } @@ -128,9 +140,14 @@ void IgnoreListEditor::readIgnoreFile(const QString &file, bool readOnly) QString line = QString::fromUtf8(ignores.readLine()); line.chop(1); if (!line.isEmpty() && !line.startsWith("#")) { - QListWidgetItem *item = new QListWidgetItem(line); + QListWidgetItem *item = new QListWidgetItem; + setupItemFlags(item); + if (line.startsWith("]")) { + line = line.mid(1); + item->setCheckState(Qt::Checked); + } + item->setText(line); if (readOnly) { - setupItemFlags(item); item->setFlags(item->flags() ^ Qt::ItemIsEnabled); item->setToolTip(disabledTip); } diff --git a/src/mirall/ignorelisteditor.ui b/src/mirall/ignorelisteditor.ui index 7d5f98356..f65d3cb0f 100644 --- a/src/mirall/ignorelisteditor.ui +++ b/src/mirall/ignorelisteditor.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> + <width>471</width> <height>359</height> </rect> </property> @@ -14,15 +14,28 @@ <string>Ignored Files Editor</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="descriptionLabel"> + <item row="5" column="0" colspan="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="3" column="1"> + <spacer name="verticalSpacer"> <property name="enabled"> <bool>true</bool> </property> - <property name="text"> - <string/> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>213</height> + </size> + </property> + </spacer> </item> <item row="1" column="0" rowspan="3"> <widget class="QListWidget" name="listWidget"> @@ -51,26 +64,16 @@ </property> </widget> </item> - <item row="3" column="1"> - <spacer name="verticalSpacer"> + <item row="4" column="0" colspan="2"> + <widget class="QLabel" name="descriptionLabel"> <property name="enabled"> <bool>true</bool> </property> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>213</height> - </size> + <property name="text"> + <string/> </property> - </spacer> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + <property name="wordWrap"> + <bool>true</bool> </property> </widget> </item> diff --git a/sync-exclude.lst b/sync-exclude.lst index 703a524dd..e7898ae58 100644 --- a/sync-exclude.lst +++ b/sync-exclude.lst @@ -11,10 +11,10 @@ csync_journal.db.ctmp .*.sw? .*.*sw? -.DS_Store -.ds_store +].DS_Store +].ds_store +]Thumbs.db desktop.ini -Thumbs.db *.kate-swp *.aux @@ -24,15 +24,15 @@ Thumbs.db *_conflict-* -.TemporaryItems -.Trashes -.DocumentRevisions-V100 +].TemporaryItems +].Trashes +].DocumentRevisions-V100 .fseventd .apdisk .htaccess -Icon\r* +]Icon\r* ~$* .~lock.* |