From 70c8803a79e9df0ea9adcc6d1016730cdf9bb09e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Feb 2015 12:25:58 +0100 Subject: [PATCH] SelectiveSync: show a message in case of error or if there is no subfolder Usefull when the folder does not exist (for example in case the theme has a defaultServerFolder that does not yet exist, #2788) But also to avoid confusion (issue #2663) --- src/gui/selectivesyncdialog.cpp | 23 +++++++++++++++++++++-- src/gui/selectivesyncdialog.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index 243558a32..6652bbe16 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -58,6 +58,8 @@ void SelectiveSyncTreeView::refreshFolders() LsColJob *job = new LsColJob(_account, _folderPath, this); connect(job, SIGNAL(directoryListingSubfolders(QStringList)), this, SLOT(slotUpdateDirectories(QStringList))); + connect(job, SIGNAL(finishedWithError(QNetworkReply*)), + this, SLOT(slotLscolFinishedWithError(QNetworkReply*))); job->start(); clear(); _loading->show(); @@ -135,9 +137,16 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list) QScopedValueRollback isInserting(_inserting); _inserting = true; - _loading->hide(); - QTreeWidgetItem *root = topLevelItem(0); + + if (!root && list.size() <= 1) { + _loading->setText(tr("No subfolders currently on the server.")); + _loading->resize(_loading->sizeHint()); // because it's not in a layout + return; + } else { + _loading->hide(); + } + if (!root) { root = new QTreeWidgetItem(this); root->setText(0, _rootName); @@ -175,6 +184,16 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list) root->setExpanded(true); } +void SelectiveSyncTreeView::slotLscolFinishedWithError(QNetworkReply *r) +{ + if (r->error() == QNetworkReply::ContentNotFoundError) { + _loading->setText(tr("No subfolders currently on the server.")); + } else { + _loading->setText(tr("An error occured while loading the list of sub folders.")); + } + _loading->resize(_loading->sizeHint()); // because it's not in a layout +} + void SelectiveSyncTreeView::slotItemExpanded(QTreeWidgetItem *item) { QString dir = item->data(0, Qt::UserRole).toString(); diff --git a/src/gui/selectivesyncdialog.h b/src/gui/selectivesyncdialog.h index 79c0d6e96..b601a8f10 100644 --- a/src/gui/selectivesyncdialog.h +++ b/src/gui/selectivesyncdialog.h @@ -19,6 +19,7 @@ class QTreeWidgetItem; class QTreeWidget; +class QNetworkReply; class QLabel; namespace OCC { @@ -45,6 +46,7 @@ private slots: void slotUpdateDirectories(const QStringList &); void slotItemExpanded(QTreeWidgetItem *); void slotItemChanged(QTreeWidgetItem*,int); + void slotLscolFinishedWithError(QNetworkReply*); private: void recursiveInsert(QTreeWidgetItem* parent, QStringList pathTrail, QString path, qint64 size); QString _folderPath;