| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #include "subtitleformatsregistry.h" |
| 16 | |
| 17 | #include "subconvert/formats/microdvd.h" |
| 18 | #include "subconvert/formats/mpl2.h" |
| 19 | #include "subconvert/formats/subrip.h" |
| 20 | #include "subconvert/formats/tmplayer.h" |
| 21 | |
| 22 | SubtitleFormatsRegistry::SubtitleFormatsRegistry() { |
| 23 | registerFormat(new MicroDVDSubtitleFormat); |
| 24 | registerFormat(new MPL2SubtitleFormat); |
| 25 | registerFormat(new SubRipSubtitleFormat); |
| 26 | registerFormat(new TMPlayerSubtitleFormat); |
| 27 | } |
| 28 | |
| 29 | QStringList SubtitleFormatsRegistry::listFormatNames() const { |
| 30 | QStringList formatNames; |
| 31 | foreach (QString format, formats.keys()) { |
| 32 | formatNames << select(format)->formatName(); |
| 33 | } |
| 34 | return formatNames; |
| 35 | } |
| 36 | |
| 37 | QSharedPointer<const SubtitleFormat> SubtitleFormatsRegistry::select( |
| 38 | const QString &format) const { |
| 39 | return formats.value(format.toLower(), QSharedPointer<SubtitleFormat>(0)); |
| 40 | } |
| 41 | |
| 42 | void SubtitleFormatsRegistry::registerFormat(SubtitleFormat *format) { |
| 43 | formats.insert(format->formatName().toLower(), |
| 44 | QSharedPointer<SubtitleFormat>(format)); |
| 45 | } |