2021-10-16 16:19:51 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QtWidgets/QMainWindow>
|
|
|
|
#include <QFileIconProvider>
|
|
|
|
#include "ui_RecoveryWindow.h"
|
|
|
|
#include "SbiePlusAPI.h"
|
|
|
|
class CSimpleTreeModel;
|
|
|
|
|
|
|
|
class CRecoveryCounter : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
CRecoveryCounter(const QString& BoxPath, QWidget* parent = Q_NULLPTR) : QThread(parent) {
|
|
|
|
m_BoxPath = BoxPath;
|
|
|
|
m_run = true;
|
|
|
|
start(QThread::LowPriority);
|
|
|
|
}
|
|
|
|
~CRecoveryCounter() {
|
|
|
|
m_run = false;
|
|
|
|
wait(2000);
|
|
|
|
terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void Count(quint32 fileCount, quint32 folderCount, quint64 totalSize);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
|
|
|
|
QString m_BoxPath;
|
|
|
|
bool m_run;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CRecoveryWindow : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-06-14 19:58:13 +01:00
|
|
|
CRecoveryWindow(const CSandBoxPtr& pBox, bool bImmediate = false, QWidget *parent = Q_NULLPTR);
|
2021-10-16 16:19:51 +01:00
|
|
|
~CRecoveryWindow();
|
|
|
|
|
2022-12-21 09:14:31 +00:00
|
|
|
bool IsDeleteDialog() const;
|
2023-02-03 07:00:11 +00:00
|
|
|
bool IsDeleteSnapshots() { return m_DeleteSnapshots; }
|
2022-01-30 14:53:37 +00:00
|
|
|
|
2021-10-16 16:19:51 +01:00
|
|
|
virtual void accept() {}
|
|
|
|
virtual void reject() { this->close(); }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void Closed();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
int exec();
|
|
|
|
|
|
|
|
int FindFiles();
|
2022-09-22 09:27:04 +01:00
|
|
|
void SelectFiles();
|
2021-10-16 16:19:51 +01:00
|
|
|
void AddFile(const QString& FilePath, const QString& BoxPath);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void OnAddFolder();
|
|
|
|
void OnRecover();
|
2022-07-14 09:46:13 +01:00
|
|
|
void OnDelete();
|
2021-10-16 16:19:51 +01:00
|
|
|
void OnTargetChanged();
|
|
|
|
void OnDeleteAll();
|
2022-01-30 14:53:37 +00:00
|
|
|
void OnDeleteEverything();
|
2021-10-16 16:19:51 +01:00
|
|
|
void OnCloseUntil();
|
2022-06-04 20:07:04 +01:00
|
|
|
void OnAutoDisable();
|
2021-10-16 16:19:51 +01:00
|
|
|
void OnCount(quint32 fileCount, quint32 folderCount, quint64 totalSize);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *e);
|
|
|
|
|
|
|
|
int FindFiles(const QString& Folder);
|
|
|
|
int FindBoxFiles(const QString& Folder);
|
|
|
|
QPair<int, quint64> FindFiles(const QString& BoxedFolder, const QString& RealFolder, const QString& Name, const QString& ParentID = QString());
|
|
|
|
|
2022-07-14 09:46:13 +01:00
|
|
|
struct SRecItem {
|
|
|
|
QString FullPath;
|
|
|
|
QString RelPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
QMap<QString, SRecItem> GetFiles();
|
|
|
|
|
2021-10-16 16:19:51 +01:00
|
|
|
void RecoverFiles(bool bBrowse, QString RecoveryFolder = QString());
|
|
|
|
|
|
|
|
CSandBoxPtr m_pBox;
|
|
|
|
|
|
|
|
QMap<QVariant, QVariantMap> m_FileMap;
|
|
|
|
QSet<QString> m_NewFiles;
|
|
|
|
|
|
|
|
QStringList m_RecoveryFolders;
|
|
|
|
|
|
|
|
CRecoveryCounter* m_pCounter;
|
|
|
|
|
|
|
|
int m_LastTargetIndex;
|
|
|
|
bool m_bTargetsChanged;
|
|
|
|
bool m_bReloadPending;
|
2023-02-03 07:00:11 +00:00
|
|
|
bool m_DeleteSnapshots;
|
2022-06-14 19:58:13 +01:00
|
|
|
bool m_bImmediate;
|
2021-10-16 16:19:51 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::RecoveryWindow ui;
|
|
|
|
QAction* m_pRemember;
|
|
|
|
|
|
|
|
CSimpleTreeModel* m_pFileModel;
|
|
|
|
QSortFilterProxyModel* m_pSortProxy;
|
|
|
|
|
|
|
|
QFileIconProvider m_IconProvider;
|
|
|
|
};
|