Skip to content

Commit

Permalink
Remove dead class SelectiveSyncDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Jun 16, 2023
1 parent 4bbb3f5 commit 1742528
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 152 deletions.
2 changes: 1 addition & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ set(client_SRCS
issueswidget.cpp
activitydata.cpp
activitywidget.cpp
selectivesyncdialog.cpp
selectivesyncwidget.cpp
settingsdialog.cpp
sharedialog.cpp
sharelinkwidget.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "filesystem.h"
#include "folder.h"
#include "lockwatcher.h"
#include "selectivesyncdialog.h"
#include "selectivesyncwidget.h"
#include "socketapi/socketapi.h"
#include "syncresult.h"
#include "theme.h"
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include "gui/accountstate.h"
#include "gui/folderman.h"
#include "gui/selectivesyncdialog.h"
#include "gui/selectivesyncwidget.h"
#include "gui/spaces/spacesmodel.h"

#include <QDesktopServices>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard/folderwizardselectivesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "gui/application.h"
#include "gui/askexperimentalvirtualfilesfeaturemessagebox.h"
#include "gui/selectivesyncdialog.h"
#include "gui/selectivesyncwidget.h"

#include "libsync/theme.h"

Expand Down
1 change: 0 additions & 1 deletion src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

#ifdef WITH_LIBCLOUDPROVIDERS
#include "libcloudproviders/libcloudproviders.h"
#include "selectivesyncdialog.h"
#endif

using namespace std::chrono_literals;
Expand Down
138 changes: 22 additions & 116 deletions src/gui/selectivesyncdialog.cpp → src/gui/selectivesyncwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "selectivesyncdialog.h"
#include "folder.h"
#include "account.h"
#include "networkjobs.h"
#include "theme.h"
#include "folderman.h"
#include "configfile.h"
#include "selectivesyncwidget.h"

#include "gui/folderman.h"
#include "libsync/configfile.h"
#include "libsync/networkjobs.h"
#include "libsync/theme.h"

#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QTreeWidget>
#include <qpushbutton.h>
#include <QFileIconProvider>
#include <QHeaderView>
#include <QSettings>
#include <QScopedValueRollback>
#include <QTreeWidgetItem>
#include <QLabel>
#include <QScopedValueRollback>
#include <QSettings>
#include <QTreeWidget>
#include <QVBoxLayout>

namespace OCC {
Expand Down Expand Up @@ -82,10 +79,8 @@ SelectiveSyncWidget::SelectiveSyncWidget(AccountPtr account, QWidget *parent)

layout->addWidget(_folderTree);

connect(_folderTree, &QTreeWidget::itemExpanded,
this, &SelectiveSyncWidget::slotItemExpanded);
connect(_folderTree, &QTreeWidget::itemChanged,
this, &SelectiveSyncWidget::slotItemChanged);
connect(_folderTree, &QTreeWidget::itemExpanded, this, &SelectiveSyncWidget::slotItemExpanded);
connect(_folderTree, &QTreeWidget::itemChanged, this, &SelectiveSyncWidget::slotItemChanged);
_folderTree->setSortingEnabled(true);
_folderTree->sortByColumn(0, Qt::AscendingOrder);
_folderTree->setColumnCount(2);
Expand All @@ -108,11 +103,9 @@ void SelectiveSyncWidget::refreshFolders()
{
// TODO: legacy
PropfindJob *job = new PropfindJob(_account, _account->davUrl(), _folderPath, PropfindJob::Depth::One, this);
job->setProperties({ QByteArrayLiteral("resourcetype"), QByteArrayLiteral("http://owncloud.org/ns:size") });
connect(job, &PropfindJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateDirectories);
connect(job, &PropfindJob::finishedWithError,
this, &SelectiveSyncWidget::slotLscolFinishedWithError);
job->setProperties({QByteArrayLiteral("resourcetype"), QByteArrayLiteral("http://owncloud.org/ns:size")});
connect(job, &PropfindJob::directoryListingSubfolders, this, &SelectiveSyncWidget::slotUpdateDirectories);
connect(job, &PropfindJob::finishedWithError, this, &SelectiveSyncWidget::slotLscolFinishedWithError);
job->start();
_folderTree->clear();
_loading->show();
Expand Down Expand Up @@ -152,8 +145,7 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem *parent, QStringList p
SelectiveSyncTreeViewItem *item = static_cast<SelectiveSyncTreeViewItem *>(findFirstChild(parent, pathTrail.first()));
if (!item) {
item = new SelectiveSyncTreeViewItem(parent);
if (parent->checkState(0) == Qt::Checked
|| parent->checkState(0) == Qt::PartiallyChecked) {
if (parent->checkState(0) == Qt::Checked || parent->checkState(0) == Qt::PartiallyChecked) {
item->setCheckState(0, Qt::Checked);
for (const auto &str : qAsConst(_oldBlackList)) {
if (str == path || str == QLatin1Char('/')) {
Expand Down Expand Up @@ -191,9 +183,10 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
const QString pathToRemove = Utility::concatUrlPath(_account->davUrl(), _folderPath).path();

// Check for excludes.
list.erase(std::remove_if(list.begin(), list.end(), [&pathToRemove, this](const QString &it) {
return _excludedFiles.isExcludedRemote(it, pathToRemove, FolderMan::instance()->ignoreHiddenFiles(), ItemTypeDirectory);
}),
list.erase(std::remove_if(list.begin(), list.end(),
[&pathToRemove, this](const QString &it) {
return _excludedFiles.isExcludedRemote(it, pathToRemove, FolderMan::instance()->ignoreHiddenFiles(), ItemTypeDirectory);
}),
list.end());

// Since / cannot be in the blacklist, expand it to the actual
Expand Down Expand Up @@ -272,9 +265,8 @@ void SelectiveSyncWidget::slotItemExpanded(QTreeWidgetItem *item)
return;
// TODO: legacy
PropfindJob *job = new PropfindJob(_account, _account->davUrl(), _folderPath + dir, PropfindJob::Depth::One, this);
job->setProperties({ QByteArrayLiteral("resourcetype"), QByteArrayLiteral("http://owncloud.org/ns:size") });
connect(job, &PropfindJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateDirectories);
job->setProperties({QByteArrayLiteral("resourcetype"), QByteArrayLiteral("http://owncloud.org/ns:size")});
connect(job, &PropfindJob::directoryListingSubfolders, this, &SelectiveSyncWidget::slotUpdateDirectories);
job->start();
}

Expand Down Expand Up @@ -407,90 +399,4 @@ qint64 SelectiveSyncWidget::estimatedSize(QTreeWidgetItem *root)
return result;
}


SelectiveSyncDialog::SelectiveSyncDialog(AccountPtr account, Folder *folder, QWidget *parent, Qt::WindowFlags f)
: QDialog(parent, f)
, _folder(folder)
, _okButton(nullptr) // defined in init()
{
bool ok;
init(account);
const auto selectiveSyncList = _folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
if (ok) {
_selectiveSync->setFolderInfo(_folder->remotePath(), QStringLiteral("/"), selectiveSyncList);
} else {
_okButton->setEnabled(false);
}
// Make sure we don't get crashes if the folder is destroyed while we are still open
connect(_folder, &QObject::destroyed, this, &QObject::deleteLater);
}

SelectiveSyncDialog::SelectiveSyncDialog(AccountPtr account, const QString &folder, QWidget *parent, Qt::WindowFlags f)
: QDialog(parent, f)
, _folder(nullptr)
{
init(account);
_selectiveSync->setFolderInfo(folder, folder);
}

void SelectiveSyncDialog::init(const AccountPtr &account)
{
setWindowTitle(tr("Choose What to Sync"));
QVBoxLayout *layout = new QVBoxLayout(this);
_selectiveSync = new SelectiveSyncWidget(account, this);
layout->addWidget(_selectiveSync);
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
_okButton = buttonBox->addButton(QDialogButtonBox::Ok);
connect(_okButton, &QPushButton::clicked, this, &SelectiveSyncDialog::accept);
QPushButton *button;
button = buttonBox->addButton(QDialogButtonBox::Cancel);
connect(button, &QAbstractButton::clicked, this, &QDialog::reject);
layout->addWidget(buttonBox);
}

void SelectiveSyncDialog::accept()
{
if (_folder) {
bool ok;
const auto oldBlackListSet = _folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
if (!ok) {
return;
}
const auto blackList = _selectiveSync->createBlackList();
_folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);

FolderMan *folderMan = FolderMan::instance();
if (_folder->isSyncRunning()) {
_folder->slotTerminateSync();
}

//The part that changed should not be read from the DB on next sync because there might be new folders
// (the ones that are no longer in the blacklist)
const auto changes = (oldBlackListSet - blackList) + (blackList - oldBlackListSet);
for (const auto &it : changes) {
_folder->journalDb()->schedulePathForRemoteDiscovery(it);
_folder->schedulePathForLocalDiscovery(it);
}
// Also make sure we see the local file that had been ignored before
_folder->slotNextSyncFullLocalDiscovery();

folderMan->scheduleFolder(_folder);
}
QDialog::accept();
}

QSet<QString> SelectiveSyncDialog::createBlackList() const
{
return _selectiveSync->createBlackList();
}

QSet<QString> SelectiveSyncDialog::oldBlackList() const
{
return _selectiveSync->oldBlackList();
}

qint64 SelectiveSyncDialog::estimatedSize()
{
return _selectiveSync->estimatedSize();
}
}
32 changes: 1 addition & 31 deletions src/gui/selectivesyncdialog.h → src/gui/selectivesyncwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*/

#pragma once
#include "accountfwd.h"
#include <QDialog>
#include <QTreeWidget>
#include "accountfwd.h"

#include "csync_exclude.h"

Expand Down Expand Up @@ -79,34 +79,4 @@ private slots:
ExcludedFiles _excludedFiles;
};

/**
* @brief The SelectiveSyncDialog class
* @ingroup gui
*/
class SelectiveSyncDialog : public QDialog
{
Q_OBJECT
public:
// Dialog for a specific folder (used from the account settings button)
explicit SelectiveSyncDialog(AccountPtr account, Folder *folder, QWidget *parent = nullptr, Qt::WindowFlags f = {});

// Dialog for the whole account (Used from the wizard)
explicit SelectiveSyncDialog(AccountPtr account, const QString &folder, QWidget *parent = nullptr, Qt::WindowFlags f = {});

void accept() override;

QSet<QString> createBlackList() const;
QSet<QString> oldBlackList() const;

// Estimate the size of the total of sync'ed files from the server
qint64 estimatedSize();

private:
void init(const AccountPtr &account);

SelectiveSyncWidget *_selectiveSync;

Folder *_folder;
QPushButton *_okButton;
};
}

0 comments on commit 1742528

Please sign in to comment.