1 /** 2 * \file textexporter.h 3 * Export tags as text. 4 * 5 * \b Project: Kid3 6 * \author Urs Fleisch 7 * \date 22 Jul 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 <QObject> 30 #include "trackdata.h" 31 #include "kid3api.h" 32 33 /** 34 * Export text from tags. 35 */ 36 class KID3_CORE_EXPORT TextExporter : public QObject { 37 public: 38 /** 39 * Constructor. 40 * @param parent parent object 41 */ 42 explicit TextExporter(QObject* parent = nullptr); 43 44 /** 45 * Destructor. 46 */ 47 virtual ~TextExporter() override; 48 49 /** 50 * Set data to be exported. 51 * 52 * @param trackDataVector data to export 53 */ setTrackData(const ImportTrackDataVector & trackDataVector)54 void setTrackData(const ImportTrackDataVector& trackDataVector) { 55 m_trackDataVector = trackDataVector; 56 } 57 58 /** 59 * Reread the tags in the track data. 60 * @param tagVersion tag version 61 */ readTagsInTrackData(Frame::TagVersion tagVersion)62 void readTagsInTrackData(Frame::TagVersion tagVersion) { 63 m_trackDataVector.readTags(tagVersion); 64 } 65 66 /** 67 * Get exported text. 68 * @return exported text. 69 */ getText()70 QString getText() const { return m_text; } 71 72 /** 73 * Update text from tags. 74 * 75 * @param headerFormat header format 76 * @param trackFormat track format 77 * @param trailerFormat trailer format 78 */ 79 void updateText(const QString& headerFormat, const QString& trackFormat, 80 const QString& trailerFormat); 81 82 /** 83 * Update text from tags using formats from the configuration. 84 * 85 * int fmtIdx index of format 86 */ 87 void updateTextUsingConfig(int fmtIdx); 88 89 /** 90 * Export to a file. 91 * 92 * @param fn file name 93 * 94 * @return true if ok. 95 */ 96 bool exportToFile(const QString& fn); 97 98 private: 99 ImportTrackDataVector m_trackDataVector; 100 QString m_text; 101 }; 102