File indexing completed on 2024-05-19 04:55:53

0001 /**
0002  * \file batchimportconfig.h
0003  * Configuration for batch import.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 3 Jan 2013
0008  *
0009  * Copyright (C) 2013-2024  Urs Fleisch
0010  *
0011  * This file is part of Kid3.
0012  *
0013  * Kid3 is free software; you can redistribute it and/or modify
0014  * it under the terms of the GNU General Public License as published by
0015  * the Free Software Foundation; either version 2 of the License, or
0016  * (at your option) any later version.
0017  *
0018  * Kid3 is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021  * GNU General Public License for more details.
0022  *
0023  * You should have received a copy of the GNU General Public License
0024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0025  */
0026 
0027 #pragma once
0028 
0029 #include <QStringList>
0030 #include "generalconfig.h"
0031 #include "frame.h"
0032 #include "kid3api.h"
0033 
0034 class BatchImportProfile;
0035 
0036 /**
0037  * Filter configuration.
0038  */
0039 class KID3_CORE_EXPORT BatchImportConfig : public StoredConfig<BatchImportConfig> {
0040   Q_OBJECT
0041   /** tag version to import */
0042   Q_PROPERTY(int importDest READ importDest WRITE setImportDestInt
0043              NOTIFY importDestChanged)
0044   /** Names of profiles */
0045   Q_PROPERTY(QStringList profileNames READ profileNames WRITE setProfileNames
0046              NOTIFY profileNamesChanged)
0047   /** Profile import sources */
0048   Q_PROPERTY(QStringList profileSources READ profileSources
0049              WRITE setProfileSources NOTIFY profileSourcesChanged)
0050   /** Selected profile */
0051   Q_PROPERTY(int profileIndex READ profileIndex WRITE setProfileIndex
0052              NOTIFY profileIndexChanged)
0053   /** Window geometry */
0054   Q_PROPERTY(QByteArray windowGeometry READ windowGeometry
0055              WRITE setWindowGeometry NOTIFY windowGeometryChanged)
0056 
0057 public:
0058   /**
0059    * Constructor.
0060    */
0061   BatchImportConfig();
0062 
0063   /**
0064    * Destructor.
0065    */
0066   ~BatchImportConfig() override = default;
0067 
0068   /**
0069    * Persist configuration.
0070    *
0071    * @param config KDE configuration
0072    */
0073   void writeToConfig(ISettings* config) const override;
0074 
0075   /**
0076    * Read persisted configuration.
0077    *
0078    * @param config KDE configuration
0079    */
0080   void readFromConfig(ISettings* config) override;
0081 
0082   /**
0083    * Get a batch import profile.
0084    *
0085    * @param name name of profile
0086    * @param profile the profile will be returned here
0087    * @return true if profile with @a name found.
0088    */
0089   bool getProfileByName(const QString& name, BatchImportProfile& profile) const;
0090 
0091   /** Get tag version to import. */
0092   Frame::TagVersion importDest() const { return m_importDest; }
0093 
0094   /** Set tag version to import. */
0095   void setImportDest(Frame::TagVersion importDest);
0096 
0097   /** Get names of profiles. */
0098   QStringList profileNames() const { return m_profileNames; }
0099 
0100   /** Set names of profiles. */
0101   void setProfileNames(const QStringList& profileNames);
0102 
0103   /** Get profile import sources. */
0104   QStringList profileSources() const { return m_profileSources; }
0105 
0106   /** Set profile import sources. */
0107   void setProfileSources(const QStringList& profileSources);
0108 
0109   /** Get index of selected profile. */
0110   int profileIndex() const { return m_profileIdx; }
0111 
0112   /** Set index of selected profile. */
0113   void setProfileIndex(int profileIdx);
0114 
0115   /** Get window geometry. */
0116   QByteArray windowGeometry() const { return m_windowGeometry; }
0117 
0118   /** Set window geometry. */
0119   void setWindowGeometry(const QByteArray& windowGeometry);
0120 
0121 signals:
0122   /** Emitted when @a importDest changed. */
0123   void importDestChanged(Frame::TagVersion importDest);
0124 
0125   /** Emitted when @a profileNames changed. */
0126   void profileNamesChanged(const QStringList& profileNames);
0127 
0128   /** Emitted when @a profileSources changed. */
0129   void profileSourcesChanged(const QStringList& profileSources);
0130 
0131   /** Emitted when @a profileIdx changed. */
0132   void profileIndexChanged(int profileIdx);
0133 
0134   /** Emitted when @a windowGeometry changed. */
0135   void windowGeometryChanged(const QByteArray& windowGeometry);
0136 
0137 private:
0138   friend BatchImportConfig& StoredConfig<BatchImportConfig>::instance();
0139 
0140   void setImportDestInt(int importDest) {
0141     setImportDest(Frame::tagVersionCast(importDest));
0142   }
0143 
0144   Frame::TagVersion m_importDest;
0145   QStringList m_profileNames;
0146   QStringList m_profileSources;
0147   int m_profileIdx;
0148   QByteArray m_windowGeometry;
0149 
0150   /** Index in configuration storage */
0151   static int s_index;
0152 };