mirror of https://github.com/nextcloud/desktop
Add support for deletable ignores in IgnoreListEditor.
This commit is contained in:
parent
6fb5c04bde
commit
3f15e02881
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>213</height>
|
||||
</size>
|
||||
</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>
|
||||
|
|
|
@ -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.*
|
||||
|
|
Loading…
Reference in New Issue