Skip to content

Commit

Permalink
Revert "Improve "add space" wizard"
Browse files Browse the repository at this point in the history
This reverts commit 482ea66.
  • Loading branch information
TheOneRing committed Sep 6, 2022
1 parent 482ea66 commit f792307
Show file tree
Hide file tree
Showing 22 changed files with 336 additions and 555 deletions.
9 changes: 4 additions & 5 deletions src/gui/folderwizard/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "gui/accountstate.h"
#include "gui/folderman.h"
#include "gui/selectivesyncdialog.h"
#include "gui/spaces/spacesmodel.h"

#include <QDesktopServices>
#include <QDir>
Expand Down Expand Up @@ -103,7 +104,7 @@ QString FolderWizardPrivate::initialLocalPath() const
{
QString defaultPath = defaultSyncRoot();
if (_account->supportsSpaces()) {
defaultPath += QLatin1Char('/') + _spacesPage->selectedSpace()->title();
defaultPath += QLatin1Char('/') + _spacesPage->selectedSpace(Spaces::SpacesModel::Columns::Name).toString();
};
return FolderMan::instance()->findGoodPathForNewSyncFolder(defaultPath);
}
Expand All @@ -116,7 +117,7 @@ QString FolderWizardPrivate::remotePath() const
QUrl FolderWizardPrivate::davUrl() const
{
if (_account->supportsSpaces()) {
auto url = _spacesPage->selectedSpace()->webDavUrl();
auto url = _spacesPage->selectedSpace(Spaces::SpacesModel::Columns::WebDavUrl).toUrl();
if (!url.path().endsWith(QLatin1Char('/'))) {
url.setPath(url.path() + QLatin1Char('/'));
}
Expand All @@ -128,9 +129,7 @@ QUrl FolderWizardPrivate::davUrl() const
QString FolderWizardPrivate::displayName() const
{
if (_account->supportsSpaces()) {
const auto selectedSpace = _spacesPage->selectedSpace();
Q_ASSERT(selectedSpace.has_value());
return selectedSpace->title();
return _spacesPage->selectedSpace(Spaces::SpacesModel::Columns::Name).toString();
};
return QString();
}
Expand Down
36 changes: 9 additions & 27 deletions src/gui/folderwizard/spacespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,34 @@
* for more details.
*/
#include "spacespage.h"
#include "graphapi/drives.h"
#include "ui_spacespage.h"

#include <QModelIndex>
#include <QTimer>

using namespace OCC;

SpacesPage::SpacesPage(AccountPtr accountPtr, QWidget *parent)
SpacesPage::SpacesPage(AccountPtr acc, QWidget *parent)
: QWizardPage(parent)
, _ui(new Ui::SpacesPage)
, ui(new Ui::SpacesPage)
{
_ui->setupUi(this);
ui->setupUi(this);

connect(_ui->widget, &Spaces::SpacesBrowser::selectionChanged, this, &QWizardPage::completeChanged);
ui->widget->setAccount(acc);

QTimer::singleShot(0, this, [this, accountPtr] {
auto drive = new OCC::GraphApi::DrivesJob(accountPtr);

connect(drive, &OCC::GraphApi::DrivesJob::finishedSignal, [drive, accountPtr, this] {
QList<Spaces::Space> spaces;

for (const auto &d : drive->drives()) {
spaces.append(Spaces::Space::fromDrive(d));
}

_ui->widget->setItems(accountPtr, spaces);
});

drive->start();
});
connect(ui->widget, &Spaces::SpacesBrowser::selectionChanged, this, &QWizardPage::completeChanged);
}

SpacesPage::~SpacesPage()
{
delete _ui;
delete ui;
}

bool OCC::SpacesPage::isComplete() const
{
return _ui->widget->selectedSpace().has_value();
return ui->widget->currentSpace().isValid();
}

std::optional<Spaces::Space> OCC::SpacesPage::selectedSpace() const
QVariant OCC::SpacesPage::selectedSpace(Spaces::SpacesModel::Columns column) const
{
const auto &selectedSpace = _ui->widget->selectedSpace();
Q_ASSERT(selectedSpace.has_value());
return selectedSpace;
return ui->widget->currentSpace().siblingAtColumn(static_cast<int>(column)).data();
}
14 changes: 7 additions & 7 deletions src/gui/folderwizard/spacespage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
*/
#pragma once

#include "gui/spaces/spacesmodel.h"

#include "accountfwd.h"
#include "gui/spaces/space.h"

#include <QWizardPage>

#include <optional>


namespace Ui {
class SpacesPage;
Expand All @@ -31,15 +30,16 @@ class SpacesPage : public QWizardPage
Q_OBJECT

public:
explicit SpacesPage(AccountPtr accountPtr, QWidget *parent = nullptr);
explicit SpacesPage(AccountPtr acc, QWidget *parent = nullptr);
~SpacesPage();

bool isComplete() const override;

std::optional<Spaces::Space> selectedSpace() const;

QVariant selectedSpace(Spaces::SpacesModel::Columns column) const;

private:
Ui::SpacesPage *_ui;
Ui::SpacesPage *ui;
};

}
}
17 changes: 8 additions & 9 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "folderwizard/folderwizard.h"
#include "graphapi/drives.h"
#include "gui/accountsettings.h"
#include "gui/spaces/space.h"
#include "guiutility.h"
#include "logbrowser.h"
#include "logger.h"
Expand Down Expand Up @@ -70,26 +69,26 @@ void setUpInitialSyncFolder(AccountStatePtr accountStatePtr, bool useVfs)
};

if (accountStatePtr->supportsSpaces()) {
auto *drivesJob = new GraphApi::DrivesJob(accountStatePtr->account());
auto *drive = new GraphApi::Drives(accountStatePtr->account());

QObject::connect(drivesJob, &GraphApi::DrivesJob::finishedSignal, [accountStatePtr, drivesJob, addFolder, finalize] {
if (drivesJob->parseError().error == QJsonParseError::NoError) {
const auto &drives = drivesJob->drives();
QObject::connect(drive, &GraphApi::Drives::finishedSignal, [accountStatePtr, drive, addFolder, finalize] {
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());
for (const auto &d : drives) {
const auto space = Spaces::Space::fromDrive(d);
const QString folderName = FolderMan::instance()->findGoodPathForNewSyncFolder(localDir.filePath(space.title()));
addFolder(folderName, {}, QUrl::fromEncoded(d.getRoot().getWebDavUrl().toUtf8()), space.title());
const QString name = GraphApi::Drives::getDriveDisplayName(d);
const QString folderName = FolderMan::instance()->findGoodPathForNewSyncFolder(localDir.filePath(name));
addFolder(folderName, {}, QUrl::fromEncoded(d.getRoot().getWebDavUrl().toUtf8()), name);
}
finalize();
}
}
});

drivesJob->start();
drive->start();

return;
} else {
Expand Down
6 changes: 1 addition & 5 deletions src/gui/spaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
add_library(spaces STATIC
spacesbrowser.cpp
spacesbrowser.ui
spaceitemwidget.cpp
space.cpp
)
spacesmodel.cpp spacesbrowser.cpp spacesbrowser.ui)
target_link_libraries(spaces PUBLIC Qt5::Widgets libsync)
set_target_properties(spaces PROPERTIES AUTOUIC ON AUTORCC ON)
apply_common_target_settings(spaces)
106 changes: 0 additions & 106 deletions src/gui/spaces/space.cpp

This file was deleted.

46 changes: 0 additions & 46 deletions src/gui/spaces/space.h

This file was deleted.

Loading

0 comments on commit f792307

Please sign in to comment.