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 IMPORTSETTINGS_H
0007 #define IMPORTSETTINGS_H
0008 
0009 #include <DB/ImageInfoList.h>
0010 
0011 #include <QMap>
0012 #include <QUrl>
0013 namespace ImportExport
0014 {
0015 
0016 class CategoryMatchSetting
0017 {
0018 public:
0019     CategoryMatchSetting(const QString &DBCategoryName, const QString &XMLFileCategoryName)
0020         : m_XMLCategoryName(XMLFileCategoryName)
0021         , m_DBCategoryName(DBCategoryName)
0022     {
0023     }
0024     void add(const QString &DBFileNameItem, const QString &XMLFileNameItem);
0025 
0026     QString XMLCategoryName() const;
0027     QString DBCategoryName() const;
0028     const QMap<QString, QString> &XMLtoDB() const;
0029 
0030 private:
0031     QString m_XMLCategoryName;
0032     QString m_DBCategoryName;
0033     QMap<QString, QString> m_XMLtoDB;
0034 };
0035 
0036 /**
0037  * The class contains all the data that is transported between the
0038  * ImportDialog, and the ImportHandler. The purpose of this class is to
0039  * decouple the above two.
0040  */
0041 class ImportSettings
0042 {
0043 public:
0044     enum ImportAction { Replace = 1,
0045                         Keep = 2,
0046                         Merge = 3 };
0047 
0048     void setSelectedImages(const DB::ImageInfoList &);
0049     DB::ImageInfoList selectedImages() const;
0050 
0051     void setDestination(const QString &);
0052     QString destination() const;
0053 
0054     void setExternalSource(bool b);
0055     bool externalSource() const;
0056 
0057     void setKimFile(const QUrl &kimFile);
0058     QUrl kimFile() const;
0059 
0060     void setBaseURL(const QUrl &url);
0061     QUrl baseURL() const;
0062 
0063     void setImportActions(const QMap<QString, ImportAction> &actions);
0064     ImportAction importAction(const QString &item);
0065 
0066     void addCategoryMatchSetting(const CategoryMatchSetting &);
0067     QList<CategoryMatchSetting> categoryMatchSetting() const;
0068 
0069 private:
0070     DB::ImageInfoList m_selectedImages;
0071     QString m_destination;
0072     bool m_externalSource = false;
0073     QUrl m_kimFile;
0074     QUrl m_baseURL;
0075     QMap<QString, ImportAction> m_actions;
0076     QList<CategoryMatchSetting> m_categoryMatchSettings;
0077 };
0078 
0079 }
0080 
0081 #endif /* IMPORTSETTINGS_H */
0082 
0083 // vi:expandtab:tabstop=4 shiftwidth=4: