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;