diff options
author | Maia Kozheva <sikon@ubuntu.com> | 2009-11-20 18:22:19 +0600 |
---|---|---|
committer | Maia Kozheva <sikon@ubuntu.com> | 2009-11-20 18:22:19 +0600 |
commit | 263b32f108c15cd1c55a8f4eb4704fac6553f1ac (patch) | |
tree | 1c49e7848aa2d3d64a9d9b96b8852cb1884da2f7 /src/subtracks.h |
Imported Upstream version 0.6.8
Diffstat (limited to 'src/subtracks.h')
-rw-r--r-- | src/subtracks.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/subtracks.h b/src/subtracks.h new file mode 100644 index 0000000..c07e967 --- /dev/null +++ b/src/subtracks.h @@ -0,0 +1,117 @@ +/* smplayer, GUI front-end for mplayer. + Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#ifndef _SUBTRACKS_H_ +#define _SUBTRACKS_H_ + +#include <QString> +#include <QFileInfo> +#include <QList> + +class SubData +{ + +public: + enum Type { None = -1, Vob = 0, Sub = 1, File = 2 }; + + SubData() { _ID=-1; _lang=""; _name=""; _filename=""; _type = None; }; + ~SubData() {}; + + void setType( Type t ) { _type = t; }; + void setID(int id) { _ID = id; }; + void setLang(QString lang) { _lang = lang; }; + void setName(QString name) { _name = name; }; + void setFilename(QString f) { _filename = f; }; + + Type type() { return _type; }; + int ID() { return _ID; }; + QString lang() { return _lang; }; + QString name() { return _name; }; + QString filename() { return _filename; }; + + QString displayName() { + QString dname=""; + + if (!_name.isEmpty()) { + dname = _name; + } + else + if (!_lang.isEmpty()) { + dname = _lang; + } + else + if (!_filename.isEmpty()) { + QFileInfo f(_filename); + dname = f.fileName(); + } + else + dname = QString::number(_ID); + + return dname; + }; + +protected: + Type _type; + int _ID; + QString _lang; + QString _name; + QString _filename; +}; + +typedef QList <SubData> SubList; + + +class SubTracks +{ +public: + enum ParseResult { SubtitleUnchanged = 0, SubtitleAdded = 1, SubtitleChanged = 2 }; + + SubTracks(); + ~SubTracks(); + + void clear(); + int find( SubData::Type t, int ID ); + + void add( SubData::Type t, int ID ); + bool changeLang( SubData::Type t, int ID, QString lang ); + bool changeName( SubData::Type t, int ID, QString name ); + bool changeFilename( SubData::Type t, int ID, QString filename ); + + int numItems(); + bool existsItemAt(int n); + + SubData itemAt(int n); + SubData findItem( SubData::Type t, int ID ); + + int findLang(QString expr); + int selectOne(QString preferred_lang, int default_sub=0); + + //! Parses a line from mplayer output with subtitle info + ParseResult parse(QString text); + + void list(); + void listNames(); + /* void test(); */ + +protected: + SubList subs; + int index; +}; + +#endif |