mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Selective sync: add a page in the folder wizard
This commit is contained in:
parent
4c4d02c0d0
commit
b6eda9076e
7 changed files with 96 additions and 13 deletions
|
@ -193,10 +193,13 @@ void AccountSettings::slotFolderWizardAccepted()
|
||||||
QString alias = folderWizard->field(QLatin1String("alias")).toString();
|
QString alias = folderWizard->field(QLatin1String("alias")).toString();
|
||||||
QString sourceFolder = folderWizard->field(QLatin1String("sourceFolder")).toString();
|
QString sourceFolder = folderWizard->field(QLatin1String("sourceFolder")).toString();
|
||||||
QString targetPath = folderWizard->property("targetPath").toString();
|
QString targetPath = folderWizard->property("targetPath").toString();
|
||||||
|
QStringList selectiveSyncBlackList
|
||||||
|
= folderWizard->property("selectiveSyncBlackList").toStringList();
|
||||||
|
|
||||||
if (!FolderMan::ensureJournalGone( sourceFolder ))
|
if (!FolderMan::ensureJournalGone( sourceFolder ))
|
||||||
return;
|
return;
|
||||||
folderMan->addFolderDefinition(alias, sourceFolder, targetPath );
|
|
||||||
|
folderMan->addFolderDefinition(alias, sourceFolder, targetPath, selectiveSyncBlackList );
|
||||||
Folder *f = folderMan->setupFolderFromConfigFile( alias );
|
Folder *f = folderMan->setupFolderFromConfigFile( alias );
|
||||||
slotAddFolder( f );
|
slotAddFolder( f );
|
||||||
folderMan->setSyncEnabled(true);
|
folderMan->setSyncEnabled(true);
|
||||||
|
|
|
@ -516,7 +516,8 @@ void FolderMan::slotFolderSyncFinished( const SyncResult& )
|
||||||
QTimer::singleShot(200, this, SLOT(slotScheduleFolderSync()));
|
QTimer::singleShot(200, this, SLOT(slotScheduleFolderSync()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceFolder, const QString& targetPath )
|
void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceFolder,
|
||||||
|
const QString& targetPath, const QStringList &selectiveSyncBlackList )
|
||||||
{
|
{
|
||||||
QString escapedAlias = escapeAlias(alias);
|
QString escapedAlias = escapeAlias(alias);
|
||||||
// Create a settings file named after the alias
|
// Create a settings file named after the alias
|
||||||
|
@ -527,6 +528,7 @@ void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceF
|
||||||
// for compat reasons
|
// for compat reasons
|
||||||
settings.setValue(QLatin1String("backend"), "owncloud" );
|
settings.setValue(QLatin1String("backend"), "owncloud" );
|
||||||
settings.setValue(QLatin1String("connection"), Theme::instance()->appName());
|
settings.setValue(QLatin1String("connection"), Theme::instance()->appName());
|
||||||
|
settings.setValue(QLatin1String("blackList"), selectiveSyncBlackList);
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ public:
|
||||||
* QString sourceFolder on local machine
|
* QString sourceFolder on local machine
|
||||||
* QString targetPath on remote
|
* QString targetPath on remote
|
||||||
*/
|
*/
|
||||||
void addFolderDefinition(const QString&, const QString&, const QString& );
|
void addFolderDefinition(const QString&, const QString&, const QString& ,
|
||||||
|
const QStringList &selectiveSyncBlacklist = QStringList{} );
|
||||||
|
|
||||||
/** Returns the folder which the file or directory stored in path is in */
|
/** Returns the folder which the file or directory stored in path is in */
|
||||||
Folder* folderForPath(const QString& path);
|
Folder* folderForPath(const QString& path);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "mirall/theme.h"
|
#include "mirall/theme.h"
|
||||||
#include "mirall/networkjobs.h"
|
#include "mirall/networkjobs.h"
|
||||||
#include "mirall/account.h"
|
#include "mirall/account.h"
|
||||||
|
#include "selectivesyncdialog.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
#include <QWizardPage>
|
#include <QWizardPage>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -424,6 +426,50 @@ void FolderWizardRemotePath::showWarn( const QString& msg ) const
|
||||||
|
|
||||||
// ====================================================================================
|
// ====================================================================================
|
||||||
|
|
||||||
|
FolderWizardSelectiveSync::FolderWizardSelectiveSync()
|
||||||
|
{
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
_treeView = new SelectiveSyncTreeView(this);
|
||||||
|
layout->addWidget(new QLabel(tr("Selective Sync: You can optionally deselect subfolders you do not wish to synchronize.")));
|
||||||
|
layout->addWidget(_treeView);
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderWizardSelectiveSync::~FolderWizardSelectiveSync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FolderWizardSelectiveSync::initializePage()
|
||||||
|
{
|
||||||
|
QString alias = wizard()->field(QLatin1String("alias")).toString();
|
||||||
|
QString targetPath = wizard()->property("targetPath").toString();
|
||||||
|
if (targetPath.startsWith('/')) {
|
||||||
|
targetPath = targetPath.mid(1);
|
||||||
|
}
|
||||||
|
_treeView->setFolderInfo(targetPath, alias, {});
|
||||||
|
QWizardPage::initializePage();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FolderWizardSelectiveSync::validatePage()
|
||||||
|
{
|
||||||
|
wizard()->setProperty("selectiveSyncBlackList", QVariant(_treeView->createBlackList()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FolderWizardSelectiveSync::cleanupPage()
|
||||||
|
{
|
||||||
|
QString alias = wizard()->field(QLatin1String("alias")).toString();
|
||||||
|
QString targetPath = wizard()->property("targetPath").toString();
|
||||||
|
_treeView->setFolderInfo(targetPath, alias, {});
|
||||||
|
QWizardPage::cleanupPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Folder wizard itself
|
* Folder wizard itself
|
||||||
*/
|
*/
|
||||||
|
@ -431,7 +477,8 @@ void FolderWizardRemotePath::showWarn( const QString& msg ) const
|
||||||
FolderWizard::FolderWizard( QWidget *parent )
|
FolderWizard::FolderWizard( QWidget *parent )
|
||||||
: QWizard(parent),
|
: QWizard(parent),
|
||||||
_folderWizardSourcePage(new FolderWizardLocalPath),
|
_folderWizardSourcePage(new FolderWizardLocalPath),
|
||||||
_folderWizardTargetPage(0)
|
_folderWizardTargetPage(0),
|
||||||
|
_folderWizardSelectiveSyncPage(new FolderWizardSelectiveSync)
|
||||||
{
|
{
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
setPage(Page_Source, _folderWizardSourcePage );
|
setPage(Page_Source, _folderWizardSourcePage );
|
||||||
|
@ -439,6 +486,7 @@ FolderWizard::FolderWizard( QWidget *parent )
|
||||||
_folderWizardTargetPage = new FolderWizardRemotePath();
|
_folderWizardTargetPage = new FolderWizardRemotePath();
|
||||||
setPage(Page_Target, _folderWizardTargetPage );
|
setPage(Page_Target, _folderWizardTargetPage );
|
||||||
}
|
}
|
||||||
|
setPage(Page_SelectiveSync, _folderWizardSelectiveSyncPage);
|
||||||
|
|
||||||
setWindowTitle( tr("Add Folder") );
|
setWindowTitle( tr("Add Folder") );
|
||||||
setOptions(QWizard::CancelButtonOnLeft);
|
setOptions(QWizard::CancelButtonOnLeft);
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
namespace Mirall {
|
namespace Mirall {
|
||||||
|
|
||||||
|
class SelectiveSyncTreeView;
|
||||||
|
|
||||||
class ownCloudInfo;
|
class ownCloudInfo;
|
||||||
|
|
||||||
class FormatWarningsWizardPage : public QWizardPage {
|
class FormatWarningsWizardPage : public QWizardPage {
|
||||||
|
@ -90,6 +92,25 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class FolderWizardSelectiveSync : public QWizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
FolderWizardSelectiveSync();
|
||||||
|
~FolderWizardSelectiveSync();
|
||||||
|
|
||||||
|
virtual bool validatePage() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
virtual void initializePage() Q_DECL_OVERRIDE;
|
||||||
|
virtual void cleanupPage() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SelectiveSyncTreeView *_treeView;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -100,7 +121,8 @@ public:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Page_Source,
|
Page_Source,
|
||||||
Page_Target
|
Page_Target,
|
||||||
|
Page_SelectiveSync
|
||||||
};
|
};
|
||||||
|
|
||||||
FolderWizard(QWidget *parent = 0);
|
FolderWizard(QWidget *parent = 0);
|
||||||
|
@ -110,6 +132,7 @@ private:
|
||||||
|
|
||||||
FolderWizardLocalPath *_folderWizardSourcePage;
|
FolderWizardLocalPath *_folderWizardSourcePage;
|
||||||
FolderWizardRemotePath *_folderWizardTargetPage;
|
FolderWizardRemotePath *_folderWizardTargetPage;
|
||||||
|
FolderWizardSelectiveSync *_folderWizardSelectiveSyncPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,8 @@
|
||||||
|
|
||||||
namespace Mirall {
|
namespace Mirall {
|
||||||
|
|
||||||
SelectiveSyncTreeView::SelectiveSyncTreeView(const QString& folderPath, const QString &rootName,
|
SelectiveSyncTreeView::SelectiveSyncTreeView(QWidget* parent)
|
||||||
const QStringList &oldBlackList, QWidget* parent)
|
: QTreeWidget(parent)
|
||||||
: QTreeWidget(parent), _folderPath(folderPath), _rootName(rootName), _oldBlackList(oldBlackList)
|
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
||||||
connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int)));
|
connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int)));
|
||||||
|
@ -121,7 +120,8 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
|
||||||
pathToRemove.append('/');
|
pathToRemove.append('/');
|
||||||
}
|
}
|
||||||
pathToRemove.append(_folderPath);
|
pathToRemove.append(_folderPath);
|
||||||
pathToRemove.append('/');
|
if (!_folderPath.isEmpty())
|
||||||
|
pathToRemove.append('/');
|
||||||
|
|
||||||
foreach (QString path, list) {
|
foreach (QString path, list) {
|
||||||
path.remove(pathToRemove);
|
path.remove(pathToRemove);
|
||||||
|
@ -245,7 +245,7 @@ SelectiveSyncDialog::SelectiveSyncDialog(Folder* folder, QWidget* parent, Qt::Wi
|
||||||
: QDialog(parent, f), _folder(folder)
|
: QDialog(parent, f), _folder(folder)
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
_treeView = new SelectiveSyncTreeView(_folder->remotePath(), _folder->alias(), _folder->selectiveSyncBlackList(), parent);
|
_treeView = new SelectiveSyncTreeView(parent);
|
||||||
layout->addWidget(_treeView);
|
layout->addWidget(_treeView);
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
|
||||||
QPushButton *button;
|
QPushButton *button;
|
||||||
|
@ -258,7 +258,7 @@ SelectiveSyncDialog::SelectiveSyncDialog(Folder* folder, QWidget* parent, Qt::Wi
|
||||||
// Make sure we don't get crashes if the folder is destroyed while we are still open
|
// Make sure we don't get crashes if the folder is destroyed while we are still open
|
||||||
connect(_folder, SIGNAL(destroyed(QObject*)), this, SLOT(deleteLater()));
|
connect(_folder, SIGNAL(destroyed(QObject*)), this, SLOT(deleteLater()));
|
||||||
|
|
||||||
_treeView->refreshFolders();
|
_treeView->setFolderInfo(_folder->remotePath(), _folder->alias(), _folder->selectiveSyncBlackList());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectiveSyncDialog::accept()
|
void SelectiveSyncDialog::accept()
|
||||||
|
|
|
@ -25,10 +25,16 @@ class Folder;
|
||||||
class SelectiveSyncTreeView : public QTreeWidget {
|
class SelectiveSyncTreeView : public QTreeWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SelectiveSyncTreeView(const QString &folderPath, const QString &rootName,
|
explicit SelectiveSyncTreeView(QWidget* parent = 0);
|
||||||
const QStringList &oldBlackList, QWidget* parent = 0);
|
|
||||||
QStringList createBlackList(QTreeWidgetItem* root = 0) const;
|
QStringList createBlackList(QTreeWidgetItem* root = 0) const;
|
||||||
void refreshFolders();
|
void refreshFolders();
|
||||||
|
void setFolderInfo(const QString &folderPath, const QString &rootName,
|
||||||
|
const QStringList &oldBlackList) {
|
||||||
|
_folderPath = folderPath;
|
||||||
|
_rootName = rootName;
|
||||||
|
_oldBlackList = oldBlackList;
|
||||||
|
refreshFolders();
|
||||||
|
}
|
||||||
private slots:
|
private slots:
|
||||||
void slotUpdateDirectories(const QStringList &);
|
void slotUpdateDirectories(const QStringList &);
|
||||||
void slotItemExpanded(QTreeWidgetItem *);
|
void slotItemExpanded(QTreeWidgetItem *);
|
||||||
|
|
Loading…
Reference in a new issue