00001 /* 00002 * SubTimer header file 00003 * Copyright (C) 2005 Peter Salvi 00004 * Last modification: <2005.03.23., 16:20:14> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef SUBTITLE_HH 00022 #define SUBTITLE_HH 00023 00026 #include <vector> 00027 00028 #include <qdatetime.h> 00029 #include <qstring.h> 00030 00031 class QFile; 00032 00049 class SubTitle 00050 { 00051 public: 00064 enum SubType { 00074 SSASUB, 00075 00085 SRTSUB, 00086 00096 TXTSUB 00097 }; 00098 00111 struct Event 00112 { 00122 QTime start; 00123 00133 QTime end; 00134 00144 QString name; 00145 00155 QString dialogue; 00156 }; 00157 00168 SubTitle(); 00169 00180 SubTitle(SubTitle const *s); 00181 virtual ~SubTitle(); 00182 00201 virtual bool loadFromFile(QFile *f) = 0; 00202 00219 virtual void saveToFile(QFile *f) const = 0; 00220 00233 size_t count() const; 00234 00249 Event *operator[](size_t const i) const; 00250 00265 void insertBefore(size_t const i, Event *e); 00266 00281 void insertAfter(size_t const i, Event *e); 00282 00295 void erase(size_t const i); 00296 00307 void eraseAll(); 00308 00309 protected: 00335 bool extractTime(QString const s, QTime &t, 00336 bool const srt_style = false) const; 00337 00347 SubType type; 00348 00358 size_t line_count; 00359 00369 std::vector<Event *> events; 00370 }; 00371 00372 #endif // SUBTITLE_HH