[Pkg-owncloud-commits] [owncloud-client] 29/171: User Sharing: Match user names and case insensitive #4269

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Feb 17 09:36:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to annotated tag upstream/2.1.1+dfsg
in repository owncloud-client.

commit 0555c884251c0ecc16924cd7a3a1cc2fad63cb7a
Author: Christian Kamm <mail at ckamm.de>
Date:   Thu Dec 10 14:56:15 2015 +0100

    User Sharing: Match user names and case insensitive #4269
---
 src/gui/sharee.cpp               | 18 +++++++++++++-----
 src/gui/shareusergroupwidget.cpp | 20 ++++++++++++++++++--
 src/gui/shareusergroupwidget.h   |  1 +
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/src/gui/sharee.cpp b/src/gui/sharee.cpp
index 86f6a20..5ff2aff 100644
--- a/src/gui/sharee.cpp
+++ b/src/gui/sharee.cpp
@@ -196,11 +196,19 @@ QVariant ShareeModel::data(const QModelIndex &index, int role) const
         return QVariant();
     }
 
-    if (role == Qt::DisplayRole || role == Qt::EditRole) {
-        return _sharees.at(index.row())->format();
-    } 
-    if (role == Qt::UserRole) {
-        return QVariant::fromValue(_sharees.at(index.row()));
+    const auto & sharee = _sharees.at(index.row());
+    if (role == Qt::DisplayRole) {
+        return sharee->format();
+
+    } else if (role == Qt::EditRole) {
+        // This role is used by the completer - it should match
+        // the full name and the user name and thus we include both
+        // in the output here. But we need to take care this string
+        // doesn't leak to the user.
+        return QString(sharee->displayName() + " (" + sharee->shareWith() + ")");
+
+    } else if (role == Qt::UserRole) {
+        return QVariant::fromValue(sharee);
     }
     
     return QVariant();
diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp
index 348b5f8..313c0b3 100644
--- a/src/gui/shareusergroupwidget.cpp
+++ b/src/gui/shareusergroupwidget.cpp
@@ -65,6 +65,7 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
     connect(_completerModel, SIGNAL(shareesReady()), this, SLOT(slotShareesReady()));
 
     _completer->setModel(_completerModel);
+    _completer->setCaseSensitivity(Qt::CaseInsensitive);
 #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
     _completer->setFilterMode(Qt::MatchContains);
 #endif
@@ -74,7 +75,13 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
     connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>)));
     connect(_manager, SIGNAL(shareCreated(QSharedPointer<Share>)), SLOT(getShares()));
     connect(_ui->shareeLineEdit, SIGNAL(returnPressed()), SLOT(slotLineEditReturn()));
-    connect(_completer, SIGNAL(activated(QModelIndex)), SLOT(slotCompleterActivated(QModelIndex)));
+
+    // By making the next two QueuedConnections we can override
+    // the strings the completer sets on the line edit.
+    connect(_completer, SIGNAL(activated(QModelIndex)), SLOT(slotCompleterActivated(QModelIndex)),
+            Qt::QueuedConnection);
+    connect(_completer, SIGNAL(highlighted(QModelIndex)), SLOT(slotCompleterHighlighted(QModelIndex)),
+            Qt::QueuedConnection);
 
     // Queued connection so this signal is recieved after textChanged
     connect(_ui->shareeLineEdit, SIGNAL(textEdited(QString)),
@@ -111,7 +118,9 @@ void ShareUserGroupWidget::slotLineEditReturn()
     const auto text = _ui->shareeLineEdit->text();
     for (int i = 0; i < _completerModel->rowCount(); ++i) {
         const auto sharee = _completerModel->getSharee(i);
-        if (sharee->format() == text) {
+        if (sharee->format() == text
+                || sharee->displayName() == text
+                || sharee->shareWith() == text) {
             slotCompleterActivated(_completerModel->index(i));
             break;
         }
@@ -214,6 +223,13 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index)
     _ui->shareeLineEdit->setText(QString());
 }
 
+void ShareUserGroupWidget::slotCompleterHighlighted(const QModelIndex & index)
+{
+    // By default the completer would set the text to EditRole,
+    // override that here.
+    _ui->shareeLineEdit->setText(index.data(Qt::DisplayRole).toString());
+}
+
 ShareWidget::ShareWidget(QSharedPointer<Share> share,
                          bool isFile,
                          QWidget *parent) :
diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h
index ba8bbd6..0b821b7 100644
--- a/src/gui/shareusergroupwidget.h
+++ b/src/gui/shareusergroupwidget.h
@@ -106,6 +106,7 @@ private slots:
 
     void slotLineEditReturn();
     void slotCompleterActivated(const QModelIndex & index);
+    void slotCompleterHighlighted(const QModelIndex & index);
     void slotShareesReady();
     void slotAdjustScrollWidgetSize();
 

-- 
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