File indexing completed on 2024-05-19 04:55:54
0001 /** 0002 * \file findreplaceconfig.h 0003 * Configuration for find/replace dialog. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 5 Mar 2014 0008 * 0009 * Copyright (C) 2014-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 "tagsearcher.h" 0032 #include "kid3api.h" 0033 0034 class BatchImportProfile; 0035 0036 /** 0037 * Filter configuration. 0038 */ 0039 class KID3_CORE_EXPORT FindReplaceConfig : public StoredConfig<FindReplaceConfig> { 0040 Q_OBJECT 0041 /** search parameters */ 0042 Q_PROPERTY(QVariantList parameterList READ parameterList 0043 WRITE setParameterList NOTIFY parameterListChanged) 0044 /** window geometry */ 0045 Q_PROPERTY(QByteArray windowGeometry READ windowGeometry 0046 WRITE setWindowGeometry NOTIFY windowGeometryChanged) 0047 0048 public: 0049 /** 0050 * Constructor. 0051 */ 0052 FindReplaceConfig(); 0053 0054 /** 0055 * Destructor. 0056 */ 0057 ~FindReplaceConfig() override = default; 0058 0059 /** 0060 * Persist configuration. 0061 * 0062 * @param config configuration 0063 */ 0064 void writeToConfig(ISettings* config) const override; 0065 0066 /** 0067 * Read persisted configuration. 0068 * 0069 * @param config configuration 0070 */ 0071 void readFromConfig(ISettings* config) override; 0072 0073 /** 0074 * Get search parameters. 0075 * @return search parameters. 0076 */ 0077 const TagSearcher::Parameters& getParameters() const { return m_params; } 0078 0079 /** 0080 * Set search parameters. 0081 * @param params search parameters 0082 */ 0083 void setParameters(const TagSearcher::Parameters& params) { 0084 m_params = params; 0085 } 0086 0087 /** 0088 * Get search parameters as variant list. 0089 * @return variant list containing search text, replace text, flags, 0090 * frameMask. 0091 */ 0092 QVariantList parameterList() const { return m_params.toVariantList(); } 0093 0094 /** 0095 * Set search parameters from variant list. 0096 * @param lst variant list containing search text, replace text, flags, 0097 * frameMask. 0098 */ 0099 void setParameterList(const QVariantList& lst); 0100 0101 /** 0102 * Get window geometry. 0103 * @return window geometry. 0104 */ 0105 QByteArray windowGeometry() const { return m_windowGeometry; } 0106 0107 /** 0108 * Set window geometry. 0109 * @param windowGeometry geometry 0110 */ 0111 void setWindowGeometry(const QByteArray& windowGeometry); 0112 0113 signals: 0114 /** Emitted when the parameters are changed using setParameterList(). */ 0115 void parameterListChanged(); 0116 0117 /** Emitted when @a windowGeometry changed. */ 0118 void windowGeometryChanged(const QByteArray& windowGeometry); 0119 0120 private: 0121 friend FindReplaceConfig& StoredConfig<FindReplaceConfig>::instance(); 0122 0123 TagSearcher::Parameters m_params; 0124 QByteArray m_windowGeometry; 0125 0126 /** Index in configuration storage */ 0127 static int s_index; 0128 };