File indexing completed on 2024-05-19 04:56:11

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