2014-08-11 17:09:17 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Olivier Goffart <ogoffart@woboq.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <QDialog>
|
2014-08-15 16:58:16 +04:00
|
|
|
#include <QTreeWidget>
|
2014-12-18 14:09:48 +03:00
|
|
|
#include "accountfwd.h"
|
2014-08-11 17:09:17 +04:00
|
|
|
|
2017-11-29 14:04:01 +03:00
|
|
|
#include "csync_exclude.h"
|
|
|
|
|
2014-08-11 17:09:17 +04:00
|
|
|
class QTreeWidgetItem;
|
|
|
|
class QTreeWidget;
|
2015-02-06 14:25:58 +03:00
|
|
|
class QNetworkReply;
|
2014-10-22 15:48:05 +04:00
|
|
|
class QLabel;
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2014-08-11 17:09:17 +04:00
|
|
|
|
|
|
|
class Folder;
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2017-01-03 17:33:06 +03:00
|
|
|
* @brief The SelectiveSyncWidget contains a folder tree with labels
|
2015-06-29 19:56:09 +03:00
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2017-01-03 17:33:06 +03:00
|
|
|
class SelectiveSyncWidget : public QWidget
|
|
|
|
{
|
2014-08-11 17:09:17 +04:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-11 12:56:22 +03:00
|
|
|
explicit SelectiveSyncWidget(AccountPtr account, QWidget *parent = nullptr);
|
2014-10-24 17:46:35 +04:00
|
|
|
|
|
|
|
/// Returns a list of blacklisted paths, each including the trailing /
|
2018-11-11 12:56:22 +03:00
|
|
|
QStringList createBlackList(QTreeWidgetItem *root = nullptr) const;
|
2017-01-03 17:33:06 +03:00
|
|
|
|
|
|
|
/** Returns the oldBlackList passed into setFolderInfo(), except that
|
|
|
|
* a "/" entry is expanded to all top-level folder names.
|
|
|
|
*/
|
2015-08-24 13:52:41 +03:00
|
|
|
QStringList oldBlackList() const;
|
2015-01-14 17:59:36 +03:00
|
|
|
|
2015-10-05 07:21:19 +03:00
|
|
|
// Estimates the total size of checked items (recursively)
|
2018-11-11 12:56:22 +03:00
|
|
|
qint64 estimatedSize(QTreeWidgetItem *root = nullptr);
|
2014-10-24 17:46:35 +04:00
|
|
|
|
|
|
|
// oldBlackList is a list of excluded paths, each including a trailing /
|
2014-08-15 18:26:38 +04:00
|
|
|
void setFolderInfo(const QString &folderPath, const QString &rootName,
|
2015-02-06 14:02:42 +03:00
|
|
|
const QStringList &oldBlackList = QStringList());
|
2015-01-21 14:18:08 +03:00
|
|
|
|
2018-11-11 13:09:29 +03:00
|
|
|
QSize sizeHint() const override;
|
2017-01-03 17:33:06 +03:00
|
|
|
|
2014-08-15 16:58:16 +04:00
|
|
|
private slots:
|
2015-10-02 14:22:52 +03:00
|
|
|
void slotUpdateDirectories(QStringList);
|
2014-08-11 17:09:17 +04:00
|
|
|
void slotItemExpanded(QTreeWidgetItem *);
|
|
|
|
void slotItemChanged(QTreeWidgetItem *, int);
|
2015-02-06 14:25:58 +03:00
|
|
|
void slotLscolFinishedWithError(QNetworkReply *);
|
2017-05-17 11:55:42 +03:00
|
|
|
|
2014-08-11 17:09:17 +04:00
|
|
|
private:
|
2017-01-03 17:33:06 +03:00
|
|
|
void refreshFolders();
|
2015-01-14 17:07:17 +03:00
|
|
|
void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path, qint64 size);
|
2017-01-03 17:33:06 +03:00
|
|
|
|
|
|
|
AccountPtr _account;
|
|
|
|
|
2014-08-15 16:58:16 +04:00
|
|
|
QString _folderPath;
|
|
|
|
QString _rootName;
|
|
|
|
QStringList _oldBlackList;
|
2017-01-03 17:33:06 +03:00
|
|
|
|
2014-10-08 20:56:30 +04:00
|
|
|
bool _inserting; // set to true when we are inserting new items on the list
|
2014-10-22 15:48:05 +04:00
|
|
|
QLabel *_loading;
|
2017-01-03 17:33:06 +03:00
|
|
|
|
|
|
|
QTreeWidget *_folderTree;
|
2017-11-29 14:04:01 +03:00
|
|
|
|
|
|
|
// During account setup we want to filter out excluded folders from the
|
|
|
|
// view without having a Folder.SyncEngine.ExcludedFiles instance.
|
|
|
|
ExcludedFiles _excludedFiles;
|
2014-08-15 16:58:16 +04:00
|
|
|
};
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The SelectiveSyncDialog class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2014-08-15 16:58:16 +04:00
|
|
|
class SelectiveSyncDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-08-27 21:03:11 +04:00
|
|
|
// Dialog for a specific folder (used from the account settings button)
|
2020-10-09 23:56:45 +03:00
|
|
|
explicit SelectiveSyncDialog(AccountPtr account, Folder *folder, QWidget *parent = nullptr, Qt::WindowFlags f = {});
|
2014-08-15 16:58:16 +04:00
|
|
|
|
2014-08-28 14:25:44 +04:00
|
|
|
// Dialog for the whole account (Used from the wizard)
|
2020-10-09 23:56:45 +03:00
|
|
|
explicit SelectiveSyncDialog(AccountPtr account, const QString &folder, const QStringList &blacklist, QWidget *parent = nullptr, Qt::WindowFlags f = {});
|
2014-08-28 14:25:44 +04:00
|
|
|
|
2018-11-11 13:09:29 +03:00
|
|
|
void accept() override;
|
2014-08-15 16:58:16 +04:00
|
|
|
|
2014-08-27 21:03:11 +04:00
|
|
|
QStringList createBlackList() const;
|
2015-08-24 13:52:41 +03:00
|
|
|
QStringList oldBlackList() const;
|
2014-08-27 21:03:11 +04:00
|
|
|
|
2015-01-14 17:59:36 +03:00
|
|
|
// Estimate the size of the total of sync'ed files from the server
|
2015-01-15 15:07:16 +03:00
|
|
|
qint64 estimatedSize();
|
2015-01-14 17:59:36 +03:00
|
|
|
|
2014-08-15 16:58:16 +04:00
|
|
|
private:
|
2017-01-03 17:33:06 +03:00
|
|
|
void init(const AccountPtr &account);
|
2014-08-28 14:25:44 +04:00
|
|
|
|
2017-01-03 17:33:06 +03:00
|
|
|
SelectiveSyncWidget *_selectiveSync;
|
2014-08-11 17:09:17 +04:00
|
|
|
|
|
|
|
Folder *_folder;
|
2016-04-06 16:01:28 +03:00
|
|
|
QPushButton *_okButton;
|
2014-08-11 17:09:17 +04:00
|
|
|
};
|
2014-08-18 17:45:58 +04:00
|
|
|
}
|