Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <vonreth@kde.org>2022-05-06 17:00:51 +0300
committerHannah von Reth <vonreth@kde.org>2022-05-06 17:50:09 +0300
commit0c4f977615fcd19ca46962b45ce15fcc912f51b6 (patch)
treebe324c636bc7f1e3e1fc7c0072328861810d2c60
parente9c9c9313da3428def1cdc973b33c505c7e4934b (diff)
Sync spaces to Spaces subfolder
-rw-r--r--src/gui/folderman.cpp2
-rw-r--r--src/gui/folderwizard/folderwizard.cpp4
-rw-r--r--src/gui/owncloudgui.cpp10
-rw-r--r--src/gui/spaces/spacesbrowser.cpp2
-rw-r--r--src/gui/spaces/spacesmodel.cpp6
-rw-r--r--src/gui/spaces/spacesmodel.h1
-rw-r--r--src/libsync/graphapi/drives.cpp9
-rw-r--r--src/libsync/graphapi/drives.h2
8 files changed, 29 insertions, 7 deletions
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index 3b38def09..3a92affe1 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -1316,7 +1316,7 @@ QString FolderMan::checkPathValidityForNewFolder(const QString &path) const
QString FolderMan::findGoodPathForNewSyncFolder(const QString &basePath) const
{
- QString folder = basePath;
+ QString folder = canonicalPath(basePath);
// If the parent folder is a sync folder or contained in one, we can't
// possibly find a valid sync folder inside it.
diff --git a/src/gui/folderwizard/folderwizard.cpp b/src/gui/folderwizard/folderwizard.cpp
index f05875b4e..e4a99d3a1 100644
--- a/src/gui/folderwizard/folderwizard.cpp
+++ b/src/gui/folderwizard/folderwizard.cpp
@@ -637,7 +637,9 @@ QString FolderWizard::destination() const
}
QString defaultPath = _account->defaultSyncRoot();
if (_account->capabilities().spacesSupport().enabled) {
- defaultPath += QLatin1Char('/') + _spacesPage->selectedSpace(Spaces::SpacesModel::Columns::Name).toString();
+ defaultPath += QDir::separator() + _spacesPage->selectedSpace(Spaces::SpacesModel::Columns::LocalMountPoint).toString();
+ FolderMan::prepareFolder(defaultPath);
+ defaultPath += QDir::separator() + _spacesPage->selectedSpace(Spaces::SpacesModel::Columns::Name).toString();
};
return FolderMan::instance()->findGoodPathForNewSyncFolder(defaultPath);
}
diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index 87c42247c..60cb35b51 100644
--- a/src/gui/owncloudgui.cpp
+++ b/src/gui/owncloudgui.cpp
@@ -74,12 +74,14 @@ void setUpInitialSyncFolder(AccountStatePtr accountStatePtr, bool useVfs)
if (drive->parseError().error == QJsonParseError::NoError) {
const auto &drives = drive->drives();
if (!drives.isEmpty()) {
- const QDir localDir(accountStatePtr->account()->defaultSyncRoot());
- FileSystem::setFolderMinimumPermissions(localDir.path());
- Utility::setupFavLink(localDir.path());
+ const QString localDir(accountStatePtr->account()->defaultSyncRoot());
+ FolderMan::prepareFolder(localDir);
+ Utility::setupFavLink(localDir);
for (const auto &d : drives) {
const QString name = GraphApi::Drives::getDriveDisplayName(d);
- const QString folderName = FolderMan::instance()->findGoodPathForNewSyncFolder(localDir.filePath(name));
+ const QString mountPoint = localDir + QDir::separator() + GraphApi::Drives::getDriveMountPoint(d);
+ FolderMan::prepareFolder(mountPoint);
+ const QString folderName = FolderMan::instance()->findGoodPathForNewSyncFolder(mountPoint + QDir::separator() + name);
addFolder(folderName, {}, QUrl::fromEncoded(d.getRoot().getWebDavUrl().toUtf8()), name);
}
finalize();
diff --git a/src/gui/spaces/spacesbrowser.cpp b/src/gui/spaces/spacesbrowser.cpp
index a237bed68..b8a475dd4 100644
--- a/src/gui/spaces/spacesbrowser.cpp
+++ b/src/gui/spaces/spacesbrowser.cpp
@@ -42,6 +42,8 @@ SpacesBrowser::SpacesBrowser(QWidget *parent)
header->hideSection(static_cast<int>(SpacesModel::Columns::WebDavUrl));
// not used yet
header->hideSection(static_cast<int>(SpacesModel::Columns::WebUrl));
+ // not relevant for users
+ header->hideSection(static_cast<int>(SpacesModel::Columns::LocalMountPoint));
header->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header, &QHeaderView::customContextMenuRequested, header, [header, this] {
auto menu = new QMenu(this);
diff --git a/src/gui/spaces/spacesmodel.cpp b/src/gui/spaces/spacesmodel.cpp
index ca7388411..57a777d40 100644
--- a/src/gui/spaces/spacesmodel.cpp
+++ b/src/gui/spaces/spacesmodel.cpp
@@ -45,6 +45,8 @@ QVariant SpacesModel::headerData(int section, Qt::Orientation orientation, int r
return tr("Web Dav URL");
case Columns::Image:
return tr("Image");
+ case Columns::LocalMountPoint:
+ return tr("Local Mount Point");
case Columns::ColumnCount:
Q_UNREACHABLE();
break;
@@ -95,6 +97,8 @@ QVariant SpacesModel::data(const QModelIndex &index, int role) const
});
return img == special.cend() ? QString() : img->getWebDavUrl();
}
+ case Columns::LocalMountPoint:
+ return GraphApi::Drives::getDriveMountPoint(item);
case Columns::ColumnCount:
Q_UNREACHABLE();
break;
@@ -118,7 +122,7 @@ QVariant SpacesModel::data(const QModelIndex &index, int role) const
auto job = new OCC::SimpleNetworkJob(_acc, davUrl, path, "GET", {}, {}, nullptr);
connect(job, &OCC::SimpleNetworkJob::finishedSignal, this, [job, id = item.getId(), index, this] {
QPixmap img;
- qDebug() << img.loadFromData(job->reply()->readAll());
+ img.loadFromData(job->reply()->readAll());
img = img.scaled(ImageSizeC, Qt::KeepAspectRatio);
_images[id] = img;
Q_EMIT const_cast<SpacesModel *>(this)->dataChanged(index, index, { Qt::DecorationRole });
diff --git a/src/gui/spaces/spacesmodel.h b/src/gui/spaces/spacesmodel.h
index 8f40cd9e7..290d0a2d6 100644
--- a/src/gui/spaces/spacesmodel.h
+++ b/src/gui/spaces/spacesmodel.h
@@ -31,6 +31,7 @@ public:
Description,
WebUrl,
WebDavUrl,
+ LocalMountPoint,
ColumnCount
};
diff --git a/src/libsync/graphapi/drives.cpp b/src/libsync/graphapi/drives.cpp
index cf842a3db..533df8714 100644
--- a/src/libsync/graphapi/drives.cpp
+++ b/src/libsync/graphapi/drives.cpp
@@ -29,6 +29,7 @@ namespace {
const auto mountpointC = QLatin1String("mountpoint");
const auto personalC = QLatin1String("personal");
+const auto projectC = QLatin1String("project");
const auto shareC = QLatin1String("virtual");
}
@@ -66,4 +67,12 @@ QString Drives::getDriveDisplayName(const OpenAPI::OAIDrive &drive)
return tr("Shares");
}
return drive.getName();
+}
+
+QString OCC::GraphApi::Drives::getDriveMountPoint(const OpenAPI::OAIDrive &drive)
+{
+ if (drive.getDriveType() == projectC) {
+ return tr("Spaces");
+ }
+ return QString();
} \ No newline at end of file
diff --git a/src/libsync/graphapi/drives.h b/src/libsync/graphapi/drives.h
index b0415492c..782eb01b5 100644
--- a/src/libsync/graphapi/drives.h
+++ b/src/libsync/graphapi/drives.h
@@ -34,6 +34,8 @@ namespace GraphApi {
*/
static QString getDriveDisplayName(const OpenAPI::OAIDrive &drive);
+ static QString getDriveMountPoint(const OpenAPI::OAIDrive &drive);
+
const QList<OpenAPI::OAIDrive> &drives() const;
private: