File indexing completed on 2024-05-05 04:22:01

0001 // SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org>
0002 // SPDX-FileCopyrightText: 2022 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006 #ifndef IMPORTEXPORT_H
0007 #define IMPORTEXPORT_H
0008 
0009 #include <ImageManager/ImageClientInterface.h>
0010 #include <Utilities/UniqFilenameMapper.h>
0011 
0012 #include <QDialog>
0013 #include <QEventLoop>
0014 #include <QPointer>
0015 
0016 class QRadioButton;
0017 class QSpinBox;
0018 class QCheckBox;
0019 class KZip;
0020 class QProgressDialog;
0021 
0022 namespace DB
0023 {
0024 class FileNameList;
0025 }
0026 
0027 namespace ImportExport
0028 {
0029 
0030 enum ImageFileLocation { Inline,
0031                          ManualCopy,
0032                          AutoCopy,
0033                          Link,
0034                          Symlink };
0035 
0036 class Export : public ImageManager::ImageClientInterface
0037 {
0038 
0039 public:
0040     static void imageExport(const DB::FileNameList &list);
0041 
0042     Export(const DB::FileNameList &list, const QString &zipFile,
0043            bool compress, int maxSize,
0044            ImageFileLocation, const QString &baseUrl,
0045            bool generateThumbnails,
0046            bool *ok);
0047     ~Export() override;
0048 
0049     static void showUsageDialog();
0050 
0051     // ImageManager::ImageClient callback.
0052     void pixmapLoaded(ImageManager::ImageRequest *request, const QImage &image) override;
0053 
0054 protected:
0055     void generateThumbnails(const DB::FileNameList &list);
0056     void copyImages(const DB::FileNameList &list);
0057 
0058 private:
0059     bool m_internalOk = false; // used in case m_ok is null
0060     bool *m_ok = nullptr;
0061     int m_filesRemaining = 0;
0062     int m_steps = 0;
0063     QProgressDialog *m_progressDialog = nullptr;
0064     KZip *m_zip = nullptr;
0065     int m_maxSize = 0;
0066     QString m_subdir;
0067     bool m_loopEntered = false;
0068     ImageFileLocation m_location;
0069     Utilities::UniqFilenameMapper m_filenameMapper;
0070     bool m_copyingFiles = false;
0071     QString m_destdir;
0072     const QPointer<QEventLoop> m_eventLoop;
0073 };
0074 
0075 class ExportConfig : public QDialog
0076 {
0077     Q_OBJECT
0078 
0079 public:
0080     ExportConfig();
0081     QCheckBox *mp_compress;
0082     QCheckBox *mp_generateThumbnails;
0083     QCheckBox *mp_enforeMaxSize;
0084     QSpinBox *mp_maxSize;
0085 
0086     ImageFileLocation imageFileLocation() const;
0087 
0088 private:
0089     QRadioButton *m_include;
0090     QRadioButton *m_manually;
0091     QRadioButton *m_link;
0092     QRadioButton *m_symlink;
0093     QRadioButton *m_auto;
0094 
0095 private Q_SLOTS:
0096     void showHelp();
0097 };
0098 }
0099 
0100 #endif /* IMPORTEXPORT_H */
0101 
0102 // vi:expandtab:tabstop=4 shiftwidth=4: