File indexing completed on 2024-05-19 16:49:48

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #ifndef RESTOREDIALOG_H
0006 #define RESTOREDIALOG_H
0007 
0008 #include "versionlistmodel.h"
0009 
0010 #include <KIO/Job>
0011 #include <KIO/UDSEntry>
0012 
0013 #include <QDialog>
0014 #include <QFileInfo>
0015 
0016 namespace Ui {
0017 class RestoreDialog;
0018 }
0019 
0020 class DirSelector;
0021 class KFileWidget;
0022 class KMessageWidget;
0023 class KWidgetJobTracker;
0024 class QTreeWidget;
0025 
0026 class RestoreDialog : public QDialog
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     explicit RestoreDialog(BupSourceInfo pPathInfo, QWidget *parent = nullptr);
0032     ~RestoreDialog() override;
0033 
0034 protected:
0035     void changeEvent(QEvent *pEvent) override;
0036 
0037 protected slots:
0038     void setOriginalDestination();
0039     void setCustomDestination();
0040     void checkDestinationSelection();
0041     void checkDestinationSelection2();
0042     void startPrechecks();
0043     void collectSourceListing(KIO::Job *pJob, const KIO::UDSEntryList &pEntryList);
0044     void sourceListingCompleted(KJob *pJob);
0045     void completePrechecks();
0046     void fileOverwriteConfirmed();
0047     void startRestoring();
0048     void restoringCompleted(KJob *pJob);
0049     void fileMoveCompleted(KJob *pJob);
0050     void folderMoveCompleted(KJob *pJob);
0051     void createNewFolder();
0052     void openDestinationFolder();
0053 
0054 private:
0055     void checkForExistingFiles(const KIO::UDSEntryList &pEntryList);
0056     void moveFolder();
0057     Ui::RestoreDialog *mUI;
0058     KFileWidget *mFileWidget;
0059     DirSelector *mDirSelector;
0060     QFileInfo mDestination;
0061     QFileInfo mFolderToCreate;
0062     QString mRestorationPath; // not necessarily same as destination
0063     BupSourceInfo mSourceInfo;
0064     qint64 mDestinationSize{}; //size of files about to be overwritten
0065     qint64 mSourceSize{}; //size of files about to be read
0066     KMessageWidget *mMessageWidget;
0067     QString mSavedWorkingDirectory;
0068     QString mSourceFileName;
0069     QHash<QString, qint64> mFileSizes;
0070     int mDirectoriesCount{};
0071     KWidgetJobTracker *mJobTracker;
0072 };
0073 
0074 #endif // RESTOREDIALOG_H