File indexing completed on 2024-05-05 05:50:38
0001 /* 0002 SPDX-FileCopyrightText: 2008 Harald Hvaal <haraldhv@stud.ntnu.no> 0003 SPDX-FileCopyrightText: 2009 Raphael Kubo da Costa <rakuco@FreeBSD.org> 0004 0005 SPDX-License-Identifier: BSD-2-Clause 0006 */ 0007 0008 #ifndef ADDTOARCHIVE_H 0009 #define ADDTOARCHIVE_H 0010 0011 #include "archive_kerfuffle.h" 0012 #include "kerfuffle_export.h" 0013 0014 #include <KJob> 0015 0016 #include <QUrl> 0017 0018 /** 0019 * Compresses all input files into an archive. 0020 * 0021 * This is a job class that creates a compressed archive 0022 * with all the given input files. 0023 * 0024 * It provides the functionality for the --add command-line 0025 * option, and does not need the GUI to be running. 0026 * 0027 * @author Harald Hvaal <haraldhv@stud.ntnu.no> 0028 */ 0029 namespace Kerfuffle 0030 { 0031 class KERFUFFLE_EXPORT AddToArchive : public KJob 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 explicit AddToArchive(QObject *parent = nullptr); 0037 ~AddToArchive() override; 0038 0039 bool showAddDialog(QWidget *parentWidget); 0040 void setPreservePaths(bool value); 0041 void setChangeToFirstPath(bool value); 0042 void setImmediateProgressReporting(bool immediateProgressReporting); 0043 static QString getFileNameForEntries(const QVector<Archive::Entry *> &entries, const QString &suffix); 0044 static QString getFileNameForUrls(const QList<QUrl> &entries, const QString &suffix); 0045 0046 QString fileName() const 0047 { 0048 return m_filename; 0049 } 0050 0051 public Q_SLOTS: 0052 bool addInput(const QUrl &url); 0053 void setAutoFilenameSuffix(const QString &suffix); 0054 void setFilename(const QUrl &path); 0055 void setMimeType(const QString &mimeType); 0056 void setPassword(const QString &password); 0057 void setHeaderEncryptionEnabled(bool enabled); 0058 void start() override; 0059 0060 protected: 0061 bool doKill() override; 0062 0063 private Q_SLOTS: 0064 void slotFinished(KJob *); 0065 void slotStartJob(); 0066 0067 private: 0068 void detectFileName(); 0069 0070 CompressionOptions m_options; 0071 CreateJob *m_createJob; 0072 QString m_filename; 0073 QString m_strippedPath; 0074 QString m_autoFilenameSuffix; 0075 QString m_firstPath; 0076 QString m_mimeType; 0077 QString m_password; 0078 QVector<Archive::Entry *> m_entries; 0079 bool m_changeToFirstPath; 0080 bool m_enableHeaderEncryption; 0081 bool m_immediateProgressReporting; 0082 }; 0083 } 0084 0085 #endif // ADDTOARCHIVE_H