nextcloud-desktop/src/gui/selectivesyncdialog.h

120 lines
3.6 KiB
C
Raw Normal View History

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>
#include <QTreeWidget>
#include "accountfwd.h"
2014-08-11 17:09:17 +04:00
#include "csync_exclude.h"
2014-08-11 17:09:17 +04:00
class QTreeWidgetItem;
class QTreeWidget;
class QNetworkReply;
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
/**
* @brief The SelectiveSyncWidget contains a folder tree with labels
2015-06-29 19:56:09 +03:00
* @ingroup gui
*/
2017-05-17 11:55:42 +03:00
class SelectiveSyncWidget : public QWidget
{
2014-08-11 17:09:17 +04:00
Q_OBJECT
public:
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 /
QStringList createBlackList(QTreeWidgetItem *root = nullptr) const;
/** Returns the oldBlackList passed into setFolderInfo(), except that
* a "/" entry is expanded to all top-level folder names.
*/
[[nodiscard]] QStringList oldBlackList() const;
// Estimates the total size of checked items (recursively)
qint64 estimatedSize(QTreeWidgetItem *root = nullptr);
2014-10-24 17:46:35 +04:00
// oldBlackList is a list of excluded paths, each including a trailing /
void setFolderInfo(const QString &folderPath, const QString &rootName,
2017-05-17 11:55:42 +03:00
const QStringList &oldBlackList = QStringList());
[[nodiscard]] QSize sizeHint() const override;
private slots:
2015-10-02 14:22:52 +03:00
void slotUpdateDirectories(QStringList);
void slotUpdateRootFolderFilesSize(const QStringList &subfolders);
2014-08-11 17:09:17 +04:00
void slotItemExpanded(QTreeWidgetItem *);
2017-05-17 11:55:42 +03:00
void slotItemChanged(QTreeWidgetItem *, int);
void slotLscolFinishedWithError(QNetworkReply *);
void slotGatherEncryptedPaths(const QString &, const QMap<QString, QString> &);
2017-05-17 11:55:42 +03:00
2014-08-11 17:09:17 +04:00
private:
void refreshFolders();
2017-05-17 11:55:42 +03:00
void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path, qint64 size);
AccountPtr _account;
QString _folderPath;
QString _rootName;
QStringList _oldBlackList;
bool _inserting = false; // set to true when we are inserting new items on the list
QLabel *_loading;
QTreeWidget *_folderTree;
// During account setup we want to filter out excluded folders from the
// view without having a Folder.SyncEngine.ExcludedFiles instance.
ExcludedFiles _excludedFiles;
QStringList _encryptedPaths;
qint64 _rootFilesSize = 0;
};
2015-06-29 19:56:09 +03:00
/**
* @brief The SelectiveSyncDialog class
* @ingroup gui
*/
2017-05-17 11:55:42 +03:00
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, const QStringList &blacklist, QWidget *parent = nullptr, Qt::WindowFlags f = {});
void accept() override;
[[nodiscard]] QStringList createBlackList() const;
[[nodiscard]] QStringList 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 = nullptr;
2014-08-11 17:09:17 +04:00
Folder *_folder;
QPushButton *_okButton = nullptr;
2014-08-11 17:09:17 +04:00
};
2014-08-18 17:45:58 +04:00
}