File indexing completed on 2024-12-22 04:40:08
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 0003 SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef MPLAYER2OUTPUTFORMAT_H 0009 #define MPLAYER2OUTPUTFORMAT_H 0010 0011 #include "formats/outputformat.h" 0012 #include "core/richtext/richdocument.h" 0013 #include "core/subtitleiterator.h" 0014 0015 namespace SubtitleComposer { 0016 class MPlayer2OutputFormat : public OutputFormat 0017 { 0018 friend class FormatManager; 0019 0020 protected: 0021 QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 0022 { 0023 QString ret; 0024 0025 for(SubtitleIterator it(subtitle); it.current(); ++it) { 0026 const SubtitleLine *line = it.current(); 0027 0028 QString text = (primary ? line->primaryDoc() : line->secondaryDoc())->toPlainText(); 0029 0030 ret += m_lineBuilder.arg(static_cast<long>((line->showTime().toMillis() / 100.0) + 0.5)) 0031 .arg(static_cast<long>((line->hideTime().toMillis() / 100.0) + 0.5)) 0032 .arg(text.replace('\n', '|')); 0033 } 0034 return ret; 0035 } 0036 0037 MPlayer2OutputFormat() : 0038 OutputFormat(QStringLiteral("MPlayer2"), QStringList(QStringLiteral("mpl"))), 0039 m_lineBuilder(QStringLiteral("[%1][%2]%3\n")) 0040 {} 0041 0042 const QString m_lineBuilder; 0043 }; 0044 } 0045 0046 #endif