[Pkg-owncloud-commits] [owncloud-client] 45/115: Selective sync: add a page in the folder wizard

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Aug 29 22:03:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit b6eda9076e37b81127da463e094f373dd61e5e63
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Aug 15 16:26:38 2014 +0200

    Selective sync: add a page in the folder wizard
---
 src/mirall/accountsettings.cpp     |  5 +++-
 src/mirall/folderman.cpp           |  4 ++-
 src/mirall/folderman.h             |  3 ++-
 src/mirall/folderwizard.cpp        | 50 +++++++++++++++++++++++++++++++++++++-
 src/mirall/folderwizard.h          | 25 ++++++++++++++++++-
 src/mirall/selectivesyncdialog.cpp | 12 ++++-----
 src/mirall/selectivesyncdialog.h   | 10 ++++++--
 7 files changed, 96 insertions(+), 13 deletions(-)

diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp
index f76d5a4..934fbba 100644
--- a/src/mirall/accountsettings.cpp
+++ b/src/mirall/accountsettings.cpp
@@ -193,10 +193,13 @@ void AccountSettings::slotFolderWizardAccepted()
     QString alias        = folderWizard->field(QLatin1String("alias")).toString();
     QString sourceFolder = folderWizard->field(QLatin1String("sourceFolder")).toString();
     QString targetPath   = folderWizard->property("targetPath").toString();
+    QStringList selectiveSyncBlackList
+                         = folderWizard->property("selectiveSyncBlackList").toStringList();
 
     if (!FolderMan::ensureJournalGone( sourceFolder ))
         return;
-    folderMan->addFolderDefinition(alias, sourceFolder, targetPath );
+
+    folderMan->addFolderDefinition(alias, sourceFolder, targetPath, selectiveSyncBlackList );
     Folder *f = folderMan->setupFolderFromConfigFile( alias );
     slotAddFolder( f );
     folderMan->setSyncEnabled(true);
diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp
index 24ad667..185d47c 100644
--- a/src/mirall/folderman.cpp
+++ b/src/mirall/folderman.cpp
@@ -516,7 +516,8 @@ void FolderMan::slotFolderSyncFinished( const SyncResult& )
     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);
     // Create a settings file named after the alias
@@ -527,6 +528,7 @@ void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceF
     // for compat reasons
     settings.setValue(QLatin1String("backend"),     "owncloud" );
     settings.setValue(QLatin1String("connection"),  Theme::instance()->appName());
+    settings.setValue(QLatin1String("blackList"), selectiveSyncBlackList);
     settings.sync();
 }
 
diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h
index abfaf12..469b24b 100644
--- a/src/mirall/folderman.h
+++ b/src/mirall/folderman.h
@@ -50,7 +50,8 @@ public:
       * QString sourceFolder on local machine
       * 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 */
     Folder* folderForPath(const QString& path);
diff --git a/src/mirall/folderwizard.cpp b/src/mirall/folderwizard.cpp
index e5792ab..e619cd7 100644
--- a/src/mirall/folderwizard.cpp
+++ b/src/mirall/folderwizard.cpp
@@ -18,6 +18,7 @@
 #include "mirall/theme.h"
 #include "mirall/networkjobs.h"
 #include "mirall/account.h"
+#include "selectivesyncdialog.h"
 
 #include <QDebug>
 #include <QDesktopServices>
@@ -30,6 +31,7 @@
 #include <QValidator>
 #include <QWizardPage>
 #include <QTreeWidget>
+#include <QVBoxLayout>
 
 #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
  */
@@ -431,7 +477,8 @@ void FolderWizardRemotePath::showWarn( const QString& msg ) const
 FolderWizard::FolderWizard( QWidget *parent )
     : QWizard(parent),
     _folderWizardSourcePage(new FolderWizardLocalPath),
-    _folderWizardTargetPage(0)
+    _folderWizardTargetPage(0),
+    _folderWizardSelectiveSyncPage(new FolderWizardSelectiveSync)
 {
     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
     setPage(Page_Source, _folderWizardSourcePage );
@@ -439,6 +486,7 @@ FolderWizard::FolderWizard( QWidget *parent )
         _folderWizardTargetPage = new FolderWizardRemotePath();
         setPage(Page_Target, _folderWizardTargetPage );
     }
+    setPage(Page_SelectiveSync, _folderWizardSelectiveSyncPage);
 
     setWindowTitle( tr("Add Folder") );
     setOptions(QWizard::CancelButtonOnLeft);
diff --git a/src/mirall/folderwizard.h b/src/mirall/folderwizard.h
index 8db9b13..157d29c 100644
--- a/src/mirall/folderwizard.h
+++ b/src/mirall/folderwizard.h
@@ -26,6 +26,8 @@
 
 namespace Mirall {
 
+class SelectiveSyncTreeView;
+
 class ownCloudInfo;
 
 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 {
         Page_Source,
-        Page_Target
+        Page_Target,
+        Page_SelectiveSync
     };
 
     FolderWizard(QWidget *parent = 0);
@@ -110,6 +132,7 @@ private:
 
     FolderWizardLocalPath *_folderWizardSourcePage;
     FolderWizardRemotePath *_folderWizardTargetPage;
+    FolderWizardSelectiveSync *_folderWizardSelectiveSyncPage;
 };
 
 
diff --git a/src/mirall/selectivesyncdialog.cpp b/src/mirall/selectivesyncdialog.cpp
index aa15f39..6401871 100644
--- a/src/mirall/selectivesyncdialog.cpp
+++ b/src/mirall/selectivesyncdialog.cpp
@@ -28,9 +28,8 @@
 
 namespace Mirall {
 
-SelectiveSyncTreeView::SelectiveSyncTreeView(const QString& folderPath, const QString &rootName,
-                                             const QStringList &oldBlackList, QWidget* parent)
-    : QTreeWidget(parent), _folderPath(folderPath), _rootName(rootName), _oldBlackList(oldBlackList)
+SelectiveSyncTreeView::SelectiveSyncTreeView(QWidget* parent)
+    : QTreeWidget(parent)
 {
     connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(slotItemExpanded(QTreeWidgetItem*)));
     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(_folderPath);
-    pathToRemove.append('/');
+    if (!_folderPath.isEmpty())
+        pathToRemove.append('/');
 
     foreach (QString path, list) {
         path.remove(pathToRemove);
@@ -245,7 +245,7 @@ SelectiveSyncDialog::SelectiveSyncDialog(Folder* folder, QWidget* parent, Qt::Wi
     :   QDialog(parent, f), _folder(folder)
 {
     QVBoxLayout *layout = new QVBoxLayout(this);
-    _treeView = new SelectiveSyncTreeView(_folder->remotePath(), _folder->alias(), _folder->selectiveSyncBlackList(), parent);
+    _treeView = new SelectiveSyncTreeView(parent);
     layout->addWidget(_treeView);
     QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
     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
     connect(_folder, SIGNAL(destroyed(QObject*)), this, SLOT(deleteLater()));
 
-    _treeView->refreshFolders();
+    _treeView->setFolderInfo(_folder->remotePath(), _folder->alias(), _folder->selectiveSyncBlackList());
 }
 
 void SelectiveSyncDialog::accept()
diff --git a/src/mirall/selectivesyncdialog.h b/src/mirall/selectivesyncdialog.h
index 45bc809..44cab64 100644
--- a/src/mirall/selectivesyncdialog.h
+++ b/src/mirall/selectivesyncdialog.h
@@ -25,10 +25,16 @@ class Folder;
 class SelectiveSyncTreeView : public QTreeWidget {
     Q_OBJECT
 public:
-    explicit SelectiveSyncTreeView(const QString &folderPath, const QString &rootName,
-                                   const QStringList &oldBlackList, QWidget* parent = 0);
+    explicit SelectiveSyncTreeView(QWidget* parent = 0);
     QStringList createBlackList(QTreeWidgetItem* root = 0) const;
     void refreshFolders();
+    void setFolderInfo(const QString &folderPath, const QString &rootName,
+                       const QStringList &oldBlackList) {
+        _folderPath = folderPath;
+        _rootName = rootName;
+        _oldBlackList = oldBlackList;
+        refreshFolders();
+    }
 private slots:
     void slotUpdateDirectories(const QStringList &);
     void slotItemExpanded(QTreeWidgetItem *);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list