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

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 IMPORT_H
0007 #define IMPORT_H
0008 
0009 #include "ImportMatcher.h"
0010 #include "ImportSettings.h"
0011 
0012 #include <KAssistantDialog>
0013 #include <QUrl>
0014 
0015 class QTemporaryFile;
0016 class QLineEdit;
0017 
0018 namespace DB
0019 {
0020 class ImageInfo;
0021 }
0022 
0023 namespace ImportExport
0024 {
0025 class ImportMatcher;
0026 class ImageRow;
0027 class KimFileReader;
0028 class MD5CheckPage;
0029 
0030 /**
0031  * This is the wizard that configures the import process
0032  */
0033 class ImportDialog : public KAssistantDialog
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     explicit ImportDialog(QWidget *parent);
0039     // prevent hiding of base class method:
0040     using KAssistantDialog::exec;
0041     bool exec(KimFileReader *kimFileReader, const QUrl &kimFilePath);
0042     ImportSettings settings();
0043 
0044 protected:
0045     friend class ImageRow;
0046 
0047     void setupPages();
0048     bool readFile(const QByteArray &data);
0049     void createIntroduction();
0050     void createImagesPage();
0051     void createDestination();
0052     void createCategoryPages();
0053     ImportMatcher *createCategoryPage(const QString &myCategory, const QString &otherCategory);
0054     void selectImage(bool on);
0055     DB::ImageInfoList selectedImages() const;
0056     void possiblyAddMD5CheckPage();
0057 
0058 protected Q_SLOTS:
0059     void slotEditDestination();
0060     void updateNextButtonState();
0061     void next() override;
0062     void slotSelectAll();
0063     void slotSelectNone();
0064     void slotHelp();
0065 
0066 Q_SIGNALS:
0067     void failedToCopy(QStringList files);
0068 
0069 private:
0070     DB::ImageInfoList m_images;
0071     QLineEdit *m_destinationEdit = nullptr;
0072     KPageWidgetItem *m_destinationPage = nullptr;
0073     KPageWidgetItem *m_categoryMatcherPage = nullptr;
0074     KPageWidgetItem *m_dummy = nullptr;
0075     ImportMatcher *m_categoryMatcher = nullptr;
0076     ImportMatchers m_matchers;
0077     QList<ImageRow *> m_imagesSelect;
0078     QTemporaryFile *m_tmp = nullptr;
0079     bool m_externalSource = false;
0080     QUrl m_kimFile;
0081     bool m_hasFilled = false;
0082     QUrl m_baseUrl;
0083     KimFileReader *m_kimFileReader = nullptr;
0084     MD5CheckPage *m_md5CheckPage = nullptr;
0085 };
0086 }
0087 
0088 #endif /* IMPORT_H */
0089 
0090 // vi:expandtab:tabstop=4 shiftwidth=4: