[Pkg-owncloud-commits] [owncloud-client] 201/498: IgnoreEditor: Make UI more explicit. #3172
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 77941b5ba70d5b72a166f30bc4749361a3dcbb33
Author: Christian Kamm <kamm at incasoftware.de>
Date: Fri Jun 19 12:42:46 2015 +0200
IgnoreEditor: Make UI more explicit. #3172
People were mistaking the checkbox for something that enables
and disables specific ignore patterns. Now it's much more
explicit.
---
src/gui/ignorelisteditor.cpp | 104 +++++++++++++++++++++----------------------
src/gui/ignorelisteditor.h | 3 +-
src/gui/ignorelisteditor.ui | 33 +++++++++++---
3 files changed, 78 insertions(+), 62 deletions(-)
diff --git a/src/gui/ignorelisteditor.cpp b/src/gui/ignorelisteditor.cpp
index 24d075c..537c0f7 100644
--- a/src/gui/ignorelisteditor.cpp
+++ b/src/gui/ignorelisteditor.cpp
@@ -25,6 +25,9 @@
namespace OCC {
+static int patternCol = 0;
+static int deletableCol = 1;
+
IgnoreListEditor::IgnoreListEditor(QWidget *parent) :
QDialog(parent),
ui(new Ui::IgnoreListEditor)
@@ -33,25 +36,26 @@ IgnoreListEditor::IgnoreListEditor(QWidget *parent) :
ui->setupUi(this);
ui->descriptionLabel->setText(tr("Files or directories matching a pattern will not be synchronized.\n\n"
- "Checked items will also be deleted if they prevent a directory from "
- "being removed. This is useful for meta data."));
+ "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)));
+
readIgnoreFile(cfgFile.excludeFile(ConfigFile::SystemScope), true);
readIgnoreFile(cfgFile.excludeFile(ConfigFile::UserScope), false);
connect(this, SIGNAL(accepted()), SLOT(slotUpdateLocalIgnoreList()));
ui->removePushButton->setEnabled(false);
- connect(ui->listWidget, SIGNAL(itemSelectionChanged()), SLOT(slotItemSelectionChanged()));
+ connect(ui->tableWidget, SIGNAL(itemSelectionChanged()), SLOT(slotItemSelectionChanged()));
connect(ui->removePushButton, SIGNAL(clicked()), SLOT(slotRemoveCurrentItem()));
connect(ui->addPushButton, SIGNAL(clicked()), SLOT(slotAddPattern()));
- connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(slotEditPattern(QListWidgetItem*)));
-}
-static void setupItemFlags(QListWidgetItem* item)
-{
- item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable);
- item->setCheckState(Qt::Unchecked);
+ ui->tableWidget->horizontalHeader()->setResizeMode(patternCol, QHeaderView::Stretch);
+ ui->tableWidget->verticalHeader()->setVisible(false);
}
IgnoreListEditor::~IgnoreListEditor()
@@ -61,7 +65,7 @@ IgnoreListEditor::~IgnoreListEditor()
void IgnoreListEditor::slotItemSelectionChanged()
{
- QListWidgetItem *item = ui->listWidget->currentItem();
+ QTableWidgetItem *item = ui->tableWidget->currentItem();
if (!item) {
ui->removePushButton->setEnabled(false);
return;
@@ -73,7 +77,7 @@ void IgnoreListEditor::slotItemSelectionChanged()
void IgnoreListEditor::slotRemoveCurrentItem()
{
- delete ui->listWidget->currentItem();
+ ui->tableWidget->removeRow(ui->tableWidget->currentRow());
}
void IgnoreListEditor::slotUpdateLocalIgnoreList()
@@ -82,14 +86,15 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList()
QString ignoreFile = cfgFile.excludeFile(ConfigFile::UserScope);
QFile ignores(ignoreFile);
if (ignores.open(QIODevice::WriteOnly)) {
- for(int i = 0; i < ui->listWidget->count(); ++i) {
- QListWidgetItem *item = ui->listWidget->item(i);
- if (item->flags() & Qt::ItemIsEnabled) {
+ for(int row = 0; row < ui->tableWidget->rowCount(); ++row) {
+ QTableWidgetItem *patternItem = ui->tableWidget->item(row, patternCol);
+ QTableWidgetItem *deletableItem = ui->tableWidget->item(row, deletableCol);
+ if (patternItem->flags() & Qt::ItemIsEnabled) {
QByteArray prepend;
- if (item->checkState() == Qt::Checked) {
+ if (deletableItem->checkState() == Qt::Checked) {
prepend = "]";
}
- ignores.write(prepend+item->text().toUtf8()+'\n');
+ ignores.write(prepend+patternItem->text().toUtf8()+'\n');
}
}
} else {
@@ -108,59 +113,50 @@ void IgnoreListEditor::slotAddPattern()
if (!okClicked || pattern.isEmpty())
return;
- 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);
-}
-
-void IgnoreListEditor::slotEditPattern(QListWidgetItem *item)
-{
- if (!(item->flags() & Qt::ItemIsEnabled))
- return;
-
- QString pattern = QInputDialog::getText(this, tr("Edit Ignore Pattern"),
- tr("Edit ignore pattern:"),
- QLineEdit::Normal, item->text());
- if (!pattern.isEmpty()) {
- item->setText(pattern);
- }
+ addPattern(pattern, false, false);
+ ui->tableWidget->scrollToBottom();
}
void IgnoreListEditor::readIgnoreFile(const QString &file, bool readOnly)
{
-
- ConfigFile cfgFile;
- const QString disabledTip(tr("This entry is provided by the system at '%1' "
- "and cannot be modified in this view.")
- .arg(QDir::toNativeSeparators(cfgFile.excludeFile(ConfigFile::SystemScope))));
-
QFile ignores(file);
if (ignores.open(QIODevice::ReadOnly)) {
while (!ignores.atEnd()) {
QString line = QString::fromUtf8(ignores.readLine());
line.chop(1);
if (!line.isEmpty() && !line.startsWith("#")) {
- QListWidgetItem *item = new QListWidgetItem;
- setupItemFlags(item);
- if (line.startsWith("]")) {
+ bool deletable = false;
+ if (line.startsWith(']')) {
+ deletable = true;
line = line.mid(1);
- item->setCheckState(Qt::Checked);
- }
- item->setText(line);
- if (readOnly) {
- item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
- item->setToolTip(disabledTip);
}
- ui->listWidget->addItem(item);
+ addPattern(line, deletable, readOnly);
}
}
}
}
+int IgnoreListEditor::addPattern(const QString &pattern, bool deletable, bool readOnly)
+{
+ int newRow = ui->tableWidget->rowCount();
+ ui->tableWidget->setRowCount(newRow + 1);
+
+ QTableWidgetItem *patternItem = new QTableWidgetItem;
+ patternItem->setText(pattern);
+ ui->tableWidget->setItem(newRow, patternCol, patternItem);
+
+ QTableWidgetItem *deletableItem = new QTableWidgetItem;
+ deletableItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ deletableItem->setCheckState(deletable ? Qt::Checked : Qt::Unchecked);
+ ui->tableWidget->setItem(newRow, deletableCol, deletableItem);
+
+ if (readOnly) {
+ patternItem->setFlags(patternItem->flags() ^ Qt::ItemIsEnabled);
+ patternItem->setToolTip(readOnlyTooltip);
+ deletableItem->setFlags(deletableItem->flags() ^ Qt::ItemIsEnabled);
+ }
+
+ return newRow;
+}
+
} // namespace OCC
diff --git a/src/gui/ignorelisteditor.h b/src/gui/ignorelisteditor.h
index e775563..22b5e8e 100644
--- a/src/gui/ignorelisteditor.h
+++ b/src/gui/ignorelisteditor.h
@@ -37,10 +37,11 @@ private slots:
void slotRemoveCurrentItem();
void slotUpdateLocalIgnoreList();
void slotAddPattern();
- void slotEditPattern(QListWidgetItem*);
private:
void readIgnoreFile(const QString& file, bool readOnly);
+ int addPattern(const QString& pattern, bool deletable, bool readOnly);
+ QString readOnlyTooltip;
Ui::IgnoreListEditor *ui;
};
diff --git a/src/gui/ignorelisteditor.ui b/src/gui/ignorelisteditor.ui
index ad030f2..e6b7c11 100644
--- a/src/gui/ignorelisteditor.ui
+++ b/src/gui/ignorelisteditor.ui
@@ -37,13 +37,6 @@
</property>
</spacer>
</item>
- <item row="1" column="0" rowspan="3">
- <widget class="QListWidget" name="listWidget">
- <property name="enabled">
- <bool>true</bool>
- </property>
- </widget>
- </item>
<item row="1" column="1">
<widget class="QPushButton" name="addPushButton">
<property name="enabled">
@@ -77,6 +70,32 @@
</property>
</widget>
</item>
+ <item row="1" column="0" rowspan="3">
+ <widget class="QTableWidget" name="tableWidget">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="columnCount">
+ <number>2</number>
+ </property>
+ <column>
+ <property name="text">
+ <string>Pattern</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Allow Deletion</string>
+ </property>
+ </column>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list