File indexing completed on 2024-05-12 04:55:37

0001 /**
0002  * \file id3libmetadataplugin.h
0003  * id3lib metadata plugin.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 23 Jul 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 <QObject>
0030 #include "itaggedfilefactory.h"
0031 
0032 /**
0033  * id3lib metadata plugin.
0034  */
0035 class KID3_PLUGIN_EXPORT Id3libMetadataPlugin
0036     : public QObject, public ITaggedFileFactory {
0037   Q_OBJECT
0038   Q_PLUGIN_METADATA(IID "org.kde.kid3.ITaggedFileFactory")
0039   Q_INTERFACES(ITaggedFileFactory)
0040 public:
0041   /*!
0042    * Constructor.
0043    * @param parent parent object
0044    */
0045   explicit Id3libMetadataPlugin(QObject* parent = nullptr);
0046 
0047   /**
0048    * Destructor.
0049    */
0050   ~Id3libMetadataPlugin() override = default;
0051 
0052   /**
0053    * Get name of factory, the same as the QObject::objectName() of the plugin.
0054    * @return factory name.
0055    */
0056   QString name() const override;
0057 
0058   /**
0059    * Get keys of available tagged file formats.
0060    * @return list of keys.
0061    */
0062   QStringList taggedFileKeys() const override;
0063 
0064   /**
0065    * Get features supported.
0066    * @param key tagged file key
0067    * @return bit mask with TaggedFile::Feature flags set.
0068    */
0069   int taggedFileFeatures(const QString& key) const override;
0070 
0071   /**
0072    * Initialize tagged file factory.
0073    *
0074    * @param key tagged file key
0075    */
0076   void initialize(const QString& key) override;
0077 
0078   /**
0079    * Create a tagged file.
0080    *
0081    * @param key tagged file key
0082    * @param fileName filename
0083    * @param idx model index
0084    * @param features optional tagged file features (TaggedFile::Feature flags)
0085    * to activate at creation
0086    *
0087    * @return tagged file, 0 if type not supported.
0088    */
0089   TaggedFile* createTaggedFile(
0090       const QString& key,
0091       const QString& fileName,
0092       const QPersistentModelIndex& idx,
0093       int features = 0) override;
0094 
0095   /**
0096    * Get a list with all extensions (e.g. ".mp3") supported by TaggedFile subclass.
0097    *
0098    * @param key tagged file key
0099    *
0100    * @return list of file extensions.
0101    */
0102   QStringList supportedFileExtensions(const QString& key) const override;
0103 
0104   /**
0105    * Notify about configuration change.
0106    * This method shall be called when the configuration changes.
0107    *
0108    * @param key tagged file key
0109    */
0110   void notifyConfigurationChange(const QString& key) override;
0111 };