1 /** 2 * \file commandformatreplacer.h 3 * Replaces context command format codes in a string. 4 * 5 * \b Project: Kid3 6 * \author Urs Fleisch 7 * \date 09 Aug 2011 8 * 9 * Copyright (C) 2011-2018 Urs Fleisch 10 * 11 * This file is part of Kid3. 12 * 13 * Kid3 is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * Kid3 is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program. If not, see <http://www.gnu.org/licenses/>. 25 */ 26 27 #pragma once 28 29 #include "frame.h" 30 31 /** 32 * Replaces context command format codes in a string. 33 */ 34 class KID3_CORE_EXPORT CommandFormatReplacer : public FrameFormatReplacer { 35 public: 36 /** 37 * Constructor. 38 * 39 * @param frames frame collection 40 * @param str string with format codes 41 * @param files file list 42 * @param isDir true if directory 43 */ 44 explicit CommandFormatReplacer( 45 const FrameCollection& frames, const QString& str, 46 const QStringList& files, bool isDir); 47 48 /** 49 * Destructor. 50 */ 51 virtual ~CommandFormatReplacer() override = default; 52 53 /** 54 * Get help text for supported format codes. 55 * 56 * @param onlyRows if true only the tr elements are returned, 57 * not the surrounding table 58 * 59 * @return help text. 60 */ 61 static QString getToolTip(bool onlyRows = false); 62 63 protected: 64 /** 65 * Replace a format code (one character %c or multiple characters %{chars}). 66 * Supported format fields: 67 * Those supported by FrameFormatReplacer::getReplacement() 68 * %f %{file} filename 69 * %d %{directory} directory name 70 * %b %{browser} the web browser set in the configuration 71 * %q %{qmlpath} base directory for QML files 72 * 73 * @param code format code 74 * 75 * @return replacement string, 76 * QString::null if code not found. 77 */ 78 virtual QString getReplacement(const QString& code) const override; 79 80 private: 81 const QStringList& m_files; 82 const bool m_isDir; 83 }; 84