Sandboxie/SandboxiePlus/SandMan/Windows/RecoveryWindow.h

107 lines
2.2 KiB
C
Raw Normal View History

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-01-30 14:53:37 +00:00
bool IsDeleteShapshots() { return m_DeleteShapshots; }
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();
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;
2022-01-30 14:53:37 +00:00
bool m_DeleteShapshots;
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;
};