From e420ae694272cf364f790af5c2a89ad42cf8b864 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Sun, 15 Sep 2013 22:46:32 +0200 Subject: [PATCH] Folder Wizard: Fix various issues - Use data role for pathes - call root dir "ownCloud" - don't connect() multiple times - ensure chars like # or ? in path are interpreted as part of the url path segment Should fix #992 --- src/mirall/folderwizard.cpp | 13 ++++++------- src/mirall/owncloudinfo.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/mirall/folderwizard.cpp b/src/mirall/folderwizard.cpp index abfe58fa69..2b4200ac07 100644 --- a/src/mirall/folderwizard.cpp +++ b/src/mirall/folderwizard.cpp @@ -243,6 +243,7 @@ static void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QStr item = new QTreeWidgetItem(parent); item->setIcon(0, folderIcon); item->setText(0, pathTrail.first()); + item->setData(0, Qt::UserRole, pathTrail.first()); item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); } @@ -253,17 +254,13 @@ static void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QStr void FolderWizardTargetPage::slotUpdateDirectories(QStringList list) { - QFileIconProvider prov; - QIcon folderIcon = prov.icon(QFileIconProvider::Folder); - QString webdavFolder = QUrl(ownCloudInfo::instance()->webdavUrl()).path(); - connect(_ui.folderTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), SLOT(slotItemExpanded(QTreeWidgetItem*))); QTreeWidgetItem *root = _ui.folderTreeWidget->topLevelItem(0); if (!root) { root = new QTreeWidgetItem(_ui.folderTreeWidget); - root->setText(0, tr("Root (\"/\")", "root folder")); - root->setIcon(0, folderIcon); + root->setText(0, Theme::instance()->appNameGUI()); + root->setIcon(0, Theme::instance()->applicationIcon()); root->setToolTip(0, tr("Choose this to sync the entire account")); root->setData(0, Qt::UserRole, "/"); } @@ -284,7 +281,7 @@ void FolderWizardTargetPage::slotRefreshFolders() void FolderWizardTargetPage::slotItemExpanded(QTreeWidgetItem *item) { - ownCloudInfo::instance()->getDirectoryListing(item->text(0)); + ownCloudInfo::instance()->getDirectoryListing(item->data(0, Qt::UserRole).toString()); } FolderWizardTargetPage::~FolderWizardTargetPage() @@ -342,6 +339,8 @@ void FolderWizardTargetPage::initializePage() SLOT(slotCreateRemoteFolderFinished( QNetworkReply::NetworkError ))); connect( ocInfo, SIGNAL(directoryListingUpdated(QStringList)), SLOT(slotUpdateDirectories(QStringList))); + connect(_ui.folderTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), + SLOT(slotItemExpanded(QTreeWidgetItem*))); slotRefreshFolders(); } diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp index d96baf88f0..68c323a26a 100644 --- a/src/mirall/owncloudinfo.cpp +++ b/src/mirall/owncloudinfo.cpp @@ -138,7 +138,8 @@ QNetworkReply* ownCloudInfo::mkdirRequest( const QString& dir ) qDebug() << "OCInfo Making dir " << dir; _authAttempts = 0; QNetworkRequest req; - QUrl url = QUrl(webdavUrl(_connection)); + QUrl url( webdavUrl(_connection) ); + // ensure #, ? and co are interpreted as part of the path and nothing else url.setEncodedPath(url.encodedPath()+QUrl::toPercentEncoding(dir, "/")); req.setUrl( url ); @@ -162,7 +163,7 @@ QNetworkReply* ownCloudInfo::mkdirRequest( const QString& dir ) QNetworkReply* ownCloudInfo::getQuotaRequest( const QString& dir ) { QNetworkRequest req; - req.setUrl( QUrl( webdavUrl(_connection) + dir ) ); + req.setUrl( QUrl( webdavUrl(_connection) + QUrl::toPercentEncoding(dir, "/") ) ); req.setRawHeader("Depth", "0"); QByteArray xml("\n" "\n" @@ -190,7 +191,10 @@ QNetworkReply* ownCloudInfo::getQuotaRequest( const QString& dir ) QNetworkReply* ownCloudInfo::getDirectoryListing( const QString& dir ) { QNetworkRequest req; - req.setUrl( QUrl( webdavUrl(_connection) + dir ) ); + QUrl url( webdavUrl(_connection) ); + // ensure #, ? and co are interpreted as part of the path and nothing else + url.setPath(url.path() + dir ); + req.setUrl( url ); req.setRawHeader("Depth", "1"); QByteArray xml("\n" "\n"