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

0001 /**
0002  * \file filterconfig.h
0003  * Configuration for filter dialog.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 16 Jan 2008
0008  *
0009  * Copyright (C) 2008-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 "kid3api.h"
0032 
0033 /**
0034  * Filter configuration.
0035  */
0036 class KID3_CORE_EXPORT FilterConfig : public StoredConfig<FilterConfig> {
0037   Q_OBJECT
0038   /** Names of filter expressions */
0039   Q_PROPERTY(QStringList filterNames READ filterNames WRITE setFilterNames
0040              NOTIFY filterNamesChanged)
0041   /** Filter expressions */
0042   Q_PROPERTY(QStringList filterExpressions READ filterExpressions
0043              WRITE setFilterExpressions NOTIFY filterExpressionsChanged)
0044   /** Selected filter */
0045   Q_PROPERTY(int filterIndex READ filterIndex WRITE setFilterIndex
0046              NOTIFY filterIndexChanged)
0047   /** Window geometry */
0048   Q_PROPERTY(QByteArray windowGeometry READ windowGeometry
0049              WRITE setWindowGeometry NOTIFY windowGeometryChanged)
0050 
0051 public:
0052   /**
0053    * Constructor.
0054    */
0055   FilterConfig();
0056 
0057   /**
0058    * Destructor.
0059    */
0060   ~FilterConfig() override = default;
0061 
0062   /**
0063    * Persist configuration.
0064    *
0065    * @param config KDE configuration
0066    */
0067   void writeToConfig(ISettings* config) const override;
0068 
0069   /**
0070    * Read persisted configuration.
0071    *
0072    * @param config KDE configuration
0073    */
0074   void readFromConfig(ISettings* config) override;
0075 
0076   /**
0077    * Set the filename format in the "Filename Tag Mismatch" filter.
0078    *
0079    * @param format filename format
0080    */
0081   void setFilenameFormat(const QString& format);
0082 
0083   /** Get names of filter expressions. */
0084   QStringList filterNames() const { return m_filterNames; }
0085 
0086   /** Set names of filter expressions. */
0087   void setFilterNames(const QStringList& filterNames);
0088 
0089   /** Get filter expressions. */
0090   QStringList filterExpressions() const { return m_filterExpressions; }
0091 
0092   /** Set filter expressions. */
0093   void setFilterExpressions(const QStringList& filterExpressions);
0094 
0095   /** Get index of selected filter. */
0096   int filterIndex() const { return m_filterIdx; }
0097 
0098   /** Set index of selected filter. */
0099   void setFilterIndex(int filterIndex);
0100 
0101   /** Get window geometry. */
0102   QByteArray windowGeometry() const { return m_windowGeometry; }
0103 
0104   /** Set window geometry. */
0105   void setWindowGeometry(const QByteArray& windowGeometry);
0106 
0107 signals:
0108   /** Emitted when @a filterNames changed. */
0109   void filterNamesChanged(const QStringList& filterNames);
0110 
0111   /** Emitted when @a filterExpressions changed. */
0112   void filterExpressionsChanged(const QStringList& filterExpressions);
0113 
0114   /** Emitted when @a filterIdx changed. */
0115   void filterIndexChanged(int filterIndex);
0116 
0117   /** Emitted when @a windowGeometry changed. */
0118   void windowGeometryChanged(const QByteArray& windowGeometry);
0119 
0120 private:
0121   friend FilterConfig& StoredConfig<FilterConfig>::instance();
0122 
0123   QStringList m_filterNames;
0124   QStringList m_filterExpressions;
0125   int m_filterIdx;
0126   QByteArray m_windowGeometry;
0127 
0128   /** Index in configuration storage */
0129   static int s_index;
0130 };