[Pkg-owncloud-commits] [owncloud-client] 21/219: Selective sync: new design in the wizard

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:05 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 a73316306d9605752ae1388ac0a15ef013e93849
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Wed Aug 27 19:03:11 2014 +0200

    Selective sync: new design in the wizard
---
 src/mirall/accountsettings.cpp           |  2 +-
 src/mirall/folderwizard.cpp              |  2 +-
 src/mirall/owncloudsetupwizard.cpp       |  6 +--
 src/mirall/selectivesyncdialog.cpp       | 46 +++++++++++-------
 src/mirall/selectivesyncdialog.h         | 10 +++-
 src/wizard/owncloudadvancedsetuppage.cpp | 34 +++++++++++++
 src/wizard/owncloudadvancedsetuppage.h   |  4 ++
 src/wizard/owncloudadvancedsetuppage.ui  | 83 ++++++++++++++++++++++++++++++--
 src/wizard/owncloudwizard.cpp            |  6 +++
 src/wizard/owncloudwizard.h              |  1 +
 10 files changed, 164 insertions(+), 30 deletions(-)

diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp
index c278617..8ae4f8f 100644
--- a/src/mirall/accountsettings.cpp
+++ b/src/mirall/accountsettings.cpp
@@ -398,7 +398,7 @@ void AccountSettings::slotSelectiveSync()
         FolderMan *folderMan = FolderMan::instance();
         Folder *f = folderMan->folder(alias);
         if (f) {
-            (new SelectiveSyncDialog(f, this))->open();
+            (new SelectiveSyncDialog(AccountManager::instance()->account(), f, this))->open();
         }
     }
 
diff --git a/src/mirall/folderwizard.cpp b/src/mirall/folderwizard.cpp
index 6affd96..f849203 100644
--- a/src/mirall/folderwizard.cpp
+++ b/src/mirall/folderwizard.cpp
@@ -429,7 +429,7 @@ void FolderWizardRemotePath::showWarn( const QString& msg ) const
 FolderWizardSelectiveSync::FolderWizardSelectiveSync()
 {
     QVBoxLayout *layout = new QVBoxLayout(this);
-    _treeView = new SelectiveSyncTreeView(this);
+    _treeView = new SelectiveSyncTreeView(AccountManager::instance()->account(), this);
     layout->addWidget(new QLabel(tr("Choose What to Sync: You can optionally deselect subfolders you do not wish to synchronize.")));
     layout->addWidget(_treeView);
 }
diff --git a/src/mirall/owncloudsetupwizard.cpp b/src/mirall/owncloudsetupwizard.cpp
index ba65f9a..84f4fa6 100644
--- a/src/mirall/owncloudsetupwizard.cpp
+++ b/src/mirall/owncloudsetupwizard.cpp
@@ -421,7 +421,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
         // 1. Initial setup, no prior account exists
         if (isInitialSetup) {
             folderMan->addFolderDefinition(Theme::instance()->appName(),
-                                           localFolder, _remoteFolder );
+                                           localFolder, _remoteFolder, _ocWizard->blacklist() );
             replaceDefaultAccountWith(newAccount);
         }
         // 2. Server URL or user changed, requires reinit of folders
@@ -430,7 +430,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
             if (startFromScratch) {
                 if (ensureStartFromScratch(localFolder)) {
                     folderMan->addFolderDefinition(Theme::instance()->appName(),
-                                                   localFolder, _remoteFolder );
+                                                   localFolder, _remoteFolder, _ocWizard->blacklist() );
                     _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
                     replaceDefaultAccountWith(newAccount);
                 }
@@ -439,7 +439,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
             else {
                 folderMan->removeAllFolderDefinitions();
                 folderMan->addFolderDefinition(Theme::instance()->appName(),
-                                               localFolder, _remoteFolder );
+                                               localFolder, _remoteFolder, _ocWizard->blacklist() );
                 _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
                 replaceDefaultAccountWith(newAccount);
             }
diff --git a/src/mirall/selectivesyncdialog.cpp b/src/mirall/selectivesyncdialog.cpp
index 4345c3d..86f1182 100644
--- a/src/mirall/selectivesyncdialog.cpp
+++ b/src/mirall/selectivesyncdialog.cpp
@@ -30,8 +30,8 @@
 
 namespace Mirall {
 
-SelectiveSyncTreeView::SelectiveSyncTreeView(QWidget* parent)
-    : QTreeWidget(parent)
+SelectiveSyncTreeView::SelectiveSyncTreeView(Account *account, QWidget* parent)
+    : QTreeWidget(parent), _account(account)
 {
     connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(slotItemExpanded(QTreeWidgetItem*)));
     connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int)));
@@ -40,7 +40,7 @@ SelectiveSyncTreeView::SelectiveSyncTreeView(QWidget* parent)
 
 void SelectiveSyncTreeView::refreshFolders()
 {
-    LsColJob *job = new LsColJob(AccountManager::instance()->account(), _folderPath, this);
+    LsColJob *job = new LsColJob(_account, _folderPath, this);
     connect(job, SIGNAL(directoryListing(QStringList)),
             this, SLOT(slotUpdateDirectories(QStringList)));
     job->start();
@@ -116,8 +116,7 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
         }
     }
 
-    Account *account = AccountManager::instance()->account();
-    QUrl url = account->davUrl();
+    QUrl url = _account->davUrl();
     QString pathToRemove = url.path();
     if (!pathToRemove.endsWith('/')) {
         pathToRemove.append('/');
@@ -145,7 +144,7 @@ void SelectiveSyncTreeView::slotItemExpanded(QTreeWidgetItem *item)
     if (!_folderPath.isEmpty()) {
         prefix = _folderPath + QLatin1Char('/');
     }
-    LsColJob *job = new LsColJob(AccountManager::instance()->account(), prefix + dir, this);
+    LsColJob *job = new LsColJob(_account, prefix + dir, this);
     connect(job, SIGNAL(directoryListing(QStringList)),
             SLOT(slotUpdateDirectories(QStringList)));
     job->start();
@@ -249,11 +248,11 @@ QStringList SelectiveSyncTreeView::createBlackList(QTreeWidgetItem* root) const
 
 
 
-SelectiveSyncDialog::SelectiveSyncDialog(Folder* folder, QWidget* parent, Qt::WindowFlags f)
+SelectiveSyncDialog::SelectiveSyncDialog(Account * account, Folder* folder, QWidget* parent, Qt::WindowFlags f)
     :   QDialog(parent, f), _folder(folder)
 {
     QVBoxLayout *layout = new QVBoxLayout(this);
-    _treeView = new SelectiveSyncTreeView(parent);
+    _treeView = new SelectiveSyncTreeView(account, parent);
     layout->addWidget(new QLabel(tr("Only checked folders will sync to this computer")));
     layout->addWidget(_treeView);
     QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
@@ -264,25 +263,36 @@ SelectiveSyncDialog::SelectiveSyncDialog(Folder* folder, QWidget* parent, Qt::Wi
     connect(button, SIGNAL(clicked()), this, SLOT(reject()));
     layout->addWidget(buttonBox);
 
-    // 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()));
+    if (_folder) {
+        // 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->setFolderInfo(_folder->remotePath(), _folder->alias(), _folder->selectiveSyncBlackList());
+    } else {
+        _treeView->refreshFolders();
+    }
 
-    _treeView->setFolderInfo(_folder->remotePath(), _folder->alias(), _folder->selectiveSyncBlackList());
 }
 
 void SelectiveSyncDialog::accept()
 {
-    QStringList blackList = _treeView->createBlackList();
-    _folder->setSelectiveSyncBlackList(blackList);
-
-    // FIXME: Use MirallConfigFile
-    QSettings settings(_folder->configFile(), QSettings::IniFormat);
-    settings.beginGroup(FolderMan::escapeAlias(_folder->alias()));
-    settings.setValue("blackList", blackList);
+    if (_folder) {
+        QStringList blackList = _treeView->createBlackList();
+        _folder->setSelectiveSyncBlackList(blackList);
 
+        // FIXME: Use MirallConfigFile
+        QSettings settings(_folder->configFile(), QSettings::IniFormat);
+        settings.beginGroup(FolderMan::escapeAlias(_folder->alias()));
+        settings.setValue("blackList", blackList);
+    }
     QDialog::accept();
 }
 
+QStringList SelectiveSyncDialog::createBlackList() const
+{
+    return _treeView->createBlackList();
+}
+
 
 
 }
diff --git a/src/mirall/selectivesyncdialog.h b/src/mirall/selectivesyncdialog.h
index 0506c18..6c68128 100644
--- a/src/mirall/selectivesyncdialog.h
+++ b/src/mirall/selectivesyncdialog.h
@@ -20,12 +20,14 @@ class QTreeWidgetItem;
 class QTreeWidget;
 namespace Mirall {
 
+class Account;
+
 class Folder;
 
 class SelectiveSyncTreeView : public QTreeWidget {
     Q_OBJECT
 public:
-    explicit SelectiveSyncTreeView(QWidget* parent = 0);
+    explicit SelectiveSyncTreeView(Account *account, QWidget* parent = 0);
     QStringList createBlackList(QTreeWidgetItem* root = 0) const;
     void refreshFolders();
     void setFolderInfo(const QString &folderPath, const QString &rootName,
@@ -45,15 +47,19 @@ private:
     QString _rootName;
     QStringList _oldBlackList;
     bool _inserting = false; // set to true when we are inserting new items on the list
+    Account *_account;
 };
 
 class SelectiveSyncDialog : public QDialog {
     Q_OBJECT
 public:
-    explicit SelectiveSyncDialog(Folder *folder, QWidget* parent = 0, Qt::WindowFlags f = 0);
+    // Dialog for a specific folder (used from the account settings button)
+    explicit SelectiveSyncDialog(Account *account, Folder *folder, QWidget* parent = 0, Qt::WindowFlags f = 0);
 
     virtual void accept() Q_DECL_OVERRIDE;
 
+    QStringList createBlackList() const;
+
 private:
 
     SelectiveSyncTreeView *_treeView;
diff --git a/src/wizard/owncloudadvancedsetuppage.cpp b/src/wizard/owncloudadvancedsetuppage.cpp
index a4e49ed..cb89b3f 100644
--- a/src/wizard/owncloudadvancedsetuppage.cpp
+++ b/src/wizard/owncloudadvancedsetuppage.cpp
@@ -26,6 +26,7 @@
 #include "mirall/account.h"
 #include "mirall/theme.h"
 #include "mirall/mirallconfigfile.h"
+#include <selectivesyncdialog.h>
 #include "creds/abstractcredentials.h"
 
 namespace Mirall
@@ -56,6 +57,9 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
 
     connect( _ui.pbSelectLocalFolder, SIGNAL(clicked()), SLOT(slotSelectFolder()));
     setButtonText(QWizard::NextButton, tr("Connect..."));
+
+    connect( _ui.tbSyncEverything, SIGNAL(clicked()), SLOT(slotSyncEverythingClicked()));
+    connect( _ui.tbSelectiveSync, SIGNAL(clicked()), SLOT(slotSelectiveSyncClicked()));
 }
 
 void OwncloudAdvancedSetupPage::setupCustomization()
@@ -179,6 +183,11 @@ QString OwncloudAdvancedSetupPage::localFolder() const
     return folder;
 }
 
+QStringList OwncloudAdvancedSetupPage::blacklist() const
+{
+    return _blacklist;
+}
+
 bool OwncloudAdvancedSetupPage::validatePage()
 {
     if(!_created) {
@@ -249,4 +258,29 @@ void OwncloudAdvancedSetupPage::setConfigExists(bool config)
     }
 }
 
+void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
+{
+    // Because clicking on it also changes it, restore it to the previous state in case the user cancel the dialog
+    _ui.tbSelectiveSync->setChecked(!_blacklist.isEmpty());
+
+    Account *acc = static_cast<OwncloudWizard *>(wizard())->account();
+    SelectiveSyncDialog *dlg = new SelectiveSyncDialog(acc, 0, this);
+    if (dlg->exec() == QDialog::Accepted) {
+        _blacklist = dlg->createBlackList();
+        if (!_blacklist.isEmpty()) {
+            _ui.tbSyncEverything->setChecked(false);
+            _ui.tbSelectiveSync->setChecked(true);
+        }
+        wizard()->setProperty("blacklist", _blacklist);
+    }
+}
+
+void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()
+{
+    _ui.tbSyncEverything->setChecked(true);
+    _ui.tbSelectiveSync->setChecked(false);
+    _blacklist.clear();
+}
+
+
 } // ns Mirall
diff --git a/src/wizard/owncloudadvancedsetuppage.h b/src/wizard/owncloudadvancedsetuppage.h
index 1d897fe..c085832 100644
--- a/src/wizard/owncloudadvancedsetuppage.h
+++ b/src/wizard/owncloudadvancedsetuppage.h
@@ -36,6 +36,7 @@ public:
   virtual int nextId() const Q_DECL_OVERRIDE;
   bool validatePage() Q_DECL_OVERRIDE;
   QString localFolder() const;
+  QStringList blacklist() const;
   void setRemoteFolder( const QString& remoteFolder);
   void setMultipleFoldersExist( bool exist );
   void directoriesCreated();
@@ -49,6 +50,8 @@ public slots:
 
 private slots:
   void slotSelectFolder();
+  void slotSyncEverythingClicked();
+  void slotSelectiveSyncClicked();
 
 private:
   void setupCustomization();
@@ -65,6 +68,7 @@ private:
   QProgressIndicator* _progressIndi;
   QString _oldLocalFolder;
   QString _remoteFolder;
+  QStringList _blacklist;
 };
 
 } // ns Mirall
diff --git a/src/wizard/owncloudadvancedsetuppage.ui b/src/wizard/owncloudadvancedsetuppage.ui
index c5a4eed..679914a 100644
--- a/src/wizard/owncloudadvancedsetuppage.ui
+++ b/src/wizard/owncloudadvancedsetuppage.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>484</width>
-    <height>336</height>
+    <width>917</width>
+    <height>493</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -57,7 +57,10 @@
    </item>
    <item>
     <layout class="QFormLayout" name="advancedBox">
-     <item row="0" column="0">
+     <property name="fieldGrowthPolicy">
+      <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+     </property>
+     <item row="1" column="0">
       <widget class="QLabel" name="label">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@@ -73,7 +76,7 @@
        </property>
       </widget>
      </item>
-     <item row="0" column="1">
+     <item row="1" column="1">
       <widget class="QPushButton" name="pbSelectLocalFolder">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -86,7 +89,7 @@
        </property>
       </widget>
      </item>
-     <item row="1" column="1">
+     <item row="2" column="1">
       <widget class="QWidget" name="resolutionWidget" native="true">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -209,6 +212,76 @@
        </layout>
       </widget>
      </item>
+     <item row="0" column="1">
+      <widget class="QWidget" name="widget" native="true">
+       <layout class="QGridLayout" name="gridLayout">
+        <item row="0" column="1">
+         <widget class="QLabel" name="label_3">
+          <property name="text">
+           <string>or</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="2">
+         <widget class="QToolButton" name="tbSelectiveSync">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize">
+           <size>
+            <width>160</width>
+            <height>80</height>
+           </size>
+          </property>
+          <property name="text">
+           <string>Choose what to sync</string>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="0">
+         <widget class="QToolButton" name="tbSyncEverything">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize">
+           <size>
+            <width>160</width>
+            <height>80</height>
+           </size>
+          </property>
+          <property name="text">
+           <string>Sync everything from server</string>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item row="0" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Remote</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
diff --git a/src/wizard/owncloudwizard.cpp b/src/wizard/owncloudwizard.cpp
index 5cb6215..e2edeb6 100644
--- a/src/wizard/owncloudwizard.cpp
+++ b/src/wizard/owncloudwizard.cpp
@@ -104,6 +104,12 @@ QString OwncloudWizard::localFolder() const
     return(_advancedSetupPage->localFolder());
 }
 
+QStringList OwncloudWizard::blacklist() const
+{
+    return _advancedSetupPage->blacklist();
+}
+
+
 QString OwncloudWizard::ocUrl() const
 {
     QString url = field("OCUrl").toString().simplified();
diff --git a/src/wizard/owncloudwizard.h b/src/wizard/owncloudwizard.h
index b3c319e..0d2e77a 100644
--- a/src/wizard/owncloudwizard.h
+++ b/src/wizard/owncloudwizard.h
@@ -50,6 +50,7 @@ public:
     void setupCustomMedia( QVariant, QLabel* );
     QString ocUrl() const;
     QString localFolder() const;
+    QStringList blacklist() const;
 
     void enableFinishOnResultWidget(bool enable);
 

-- 
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