[Pkg-owncloud-commits] [owncloud-client] 103/171: Sharing: feedback when there is no result while searching for an user #4348
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Feb 17 09:36:56 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 980010174826e952fcc90cd831d574ecf6292c87
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Jan 12 14:35:35 2016 +0100
Sharing: feedback when there is no result while searching for an user #4348
---
src/gui/sharee.cpp | 1 +
src/gui/sharee.h | 3 +++
src/gui/shareusergroupwidget.cpp | 24 ++++++++++++++++++------
src/gui/shareusergroupwidget.h | 2 +-
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/src/gui/sharee.cpp b/src/gui/sharee.cpp
index 5ff2aff..510d4f9 100644
--- a/src/gui/sharee.cpp
+++ b/src/gui/sharee.cpp
@@ -63,6 +63,7 @@ void ShareeModel::fetch(const QString &search, const ShareeSet &blacklist)
_shareeBlacklist = blacklist;
OcsShareeJob *job = new OcsShareeJob(_account);
connect(job, SIGNAL(shareeJobFinished(QVariantMap)), SLOT(shareesFetched(QVariantMap)));
+ connect(job, SIGNAL(ocsError(int,QString)), SIGNAL(displayErrorMessage(int,QString)));
job->getSharees(_search, _type, 1, 50);
}
diff --git a/src/gui/sharee.h b/src/gui/sharee.h
index 9a99da8..f91b8ac 100644
--- a/src/gui/sharee.h
+++ b/src/gui/sharee.h
@@ -64,8 +64,11 @@ public:
QSharedPointer<Sharee> getSharee(int at);
+ QString currentSearch() const { return _search; }
+
signals:
void shareesReady();
+ void displayErrorMessage(int code, const QString &);
private slots:
void shareesFetched(const QVariantMap &reply);
diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp
index 898242e..07b5f47 100644
--- a/src/gui/shareusergroupwidget.cpp
+++ b/src/gui/shareusergroupwidget.cpp
@@ -48,7 +48,8 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
_account(account),
_sharePath(sharePath),
_localPath(localPath),
- _resharingAllowed(resharingAllowed)
+ _resharingAllowed(resharingAllowed),
+ _disableCompleterActivated(false)
{
setAttribute(Qt::WA_DeleteOnClose);
setObjectName("SharingDialogUG"); // required as group for saveGeometry call
@@ -63,6 +64,7 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
_isFile ? QLatin1String("file") : QLatin1String("folder"),
_completer);
connect(_completerModel, SIGNAL(shareesReady()), this, SLOT(slotShareesReady()));
+ connect(_completerModel, SIGNAL(displayErrorMessage(int,QString)), this, SLOT(displayError(int,QString)));
_completer->setModel(_completerModel);
_completer->setCaseSensitivity(Qt::CaseInsensitive);
@@ -107,6 +109,7 @@ void ShareUserGroupWidget::on_shareeLineEdit_textChanged(const QString &)
void ShareUserGroupWidget::slotLineEditTextEdited(const QString& text)
{
+ _disableCompleterActivated = false;
// First textChanged is called first and we stopped the timer when the text is changed, programatically or not
// Then we restart the timer here if the user touched a key
if (!text.isEmpty()) {
@@ -116,6 +119,7 @@ void ShareUserGroupWidget::slotLineEditTextEdited(const QString& text)
void ShareUserGroupWidget::slotLineEditReturn()
{
+ _disableCompleterActivated = false;
// did the user type in one of the options?
const auto text = _ui->shareeLineEdit->text();
for (int i = 0; i < _completerModel->rowCount(); ++i) {
@@ -124,9 +128,11 @@ void ShareUserGroupWidget::slotLineEditReturn()
|| sharee->displayName() == text
|| sharee->shareWith() == text) {
slotCompleterActivated(_completerModel->index(i));
- break;
+ // make sure we do not send the same item twice (because return is called when we press
+ // return to activate an item inthe completer)
+ _disableCompleterActivated = true;
+ return;
}
-
}
// nothing found? try to refresh completion
@@ -146,7 +152,7 @@ void ShareUserGroupWidget::searchForSharees()
foreach (auto sw, _ui->scrollArea->findChildren<ShareWidget*>()) {
blacklist << sw->share()->getShareWith();
}
-
+ _ui->errorLabel->hide();
_completerModel->fetch(_ui->shareeLineEdit->text(), blacklist);
}
@@ -160,7 +166,6 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
{
QScrollArea *scrollArea = _ui->scrollArea;
-
auto newViewPort = new QWidget(scrollArea);
auto layout = new QVBoxLayout(newViewPort);
@@ -190,6 +195,8 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
scrollArea->setMinimumSize(minimumSize);
scrollArea->setVisible(!shares.isEmpty());
scrollArea->setWidget(newViewPort);
+
+ _disableCompleterActivated = false;
}
void ShareUserGroupWidget::slotAdjustScrollWidgetSize()
@@ -204,14 +211,19 @@ void ShareUserGroupWidget::slotAdjustScrollWidgetSize()
}
}
-
void ShareUserGroupWidget::slotShareesReady()
{
+ if (_completerModel->rowCount() == 0) {
+ displayError(0, tr("No results for '%1'").arg(_completerModel->currentSearch()));
+ return;
+ }
_completer->complete();
}
void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index)
{
+ if (_disableCompleterActivated)
+ return;
// The index is an index from the QCompletion model which is itelf a proxy
// model proxying the _completerModel
auto sharee = qvariant_cast<QSharedPointer<Sharee>>(index.data(Qt::UserRole));
diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h
index 0c827d6..cbe2263 100644
--- a/src/gui/shareusergroupwidget.h
+++ b/src/gui/shareusergroupwidget.h
@@ -123,7 +123,7 @@ private:
bool _resharingAllowed;
bool _isFile;
-
+ bool _disableCompleterActivated; // in order to avoid that we share the contents twice
ShareManager *_manager;
};
--
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