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 SUBVIEWER1OUTPUTFORMAT_H 0009 #define SUBVIEWER1OUTPUTFORMAT_H 0010 0011 #include "formats/outputformat.h" 0012 #include "core/richtext/richdocument.h" 0013 #include "core/subtitleiterator.h" 0014 0015 namespace SubtitleComposer { 0016 class SubViewer1OutputFormat : public OutputFormat 0017 { 0018 friend class FormatManager; 0019 0020 protected: 0021 QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 0022 { 0023 QString ret(QStringLiteral("[TITLE]\n\n[AUTHOR]\n\n[SOURCE]\n\n[PRG]\n\n[FILEPATH]\n\n[DELAY]\n0\n[CD TRACK]\n0\n[BEGIN]\n" "******** START SCRIPT ********\n")); 0024 0025 for(SubtitleIterator it(subtitle); it.current(); ++it) { 0026 const SubtitleLine *line = it.current(); 0027 0028 Time showTime = line->showTime(); 0029 ret += QString::asprintf("[%02d:%02d:%02d]\n", showTime.hours(), showTime.minutes(), showTime.seconds()); 0030 0031 QString text = (primary ? line->primaryDoc() : line->secondaryDoc())->toPlainText(); 0032 ret += text.replace('\n', '|'); 0033 0034 Time hideTime = line->hideTime(); 0035 ret += QString::asprintf("\n[%02d:%02d:%02d]\n\n", hideTime.hours(), hideTime.minutes(), hideTime.seconds()); 0036 } 0037 ret += "[END]\n" "******** END SCRIPT ********\n"; 0038 0039 return ret; 0040 } 0041 0042 SubViewer1OutputFormat() : 0043 OutputFormat(QStringLiteral("SubViewer 1.0"), QStringList(QStringLiteral("sub"))) 0044 {} 0045 }; 0046 } 0047 0048 #endif