1 /*  smplayer, GUI front-end for mplayer.
2     Copyright (C) 2006-2021 Ricardo Villalba <ricardo@smplayer.info>
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19 #ifndef TITLETRACKS_H
20 #define TITLETRACKS_H
21 
22 #include <QMap>
23 #include "helper.h"
24 
25 /* Class to store info about DVD titles */
26 
27 class TitleData {
28 
29 public:
TitleData()30 	TitleData() { _name = ""; _duration = 0; _ID = -1; _chapters = 0; _angles = 0; };
~TitleData()31 	~TitleData() {};
32 
setName(const QString & n)33 	void setName( const QString & n ) { _name = n; };
setDuration(double d)34 	void setDuration( double d ) { _duration = d; };
setChapters(int n)35 	void setChapters( int n ) { _chapters = n; };
setAngles(int n)36 	void setAngles( int n ) { _angles = n; };
setID(int id)37 	void setID( int id ) { _ID = id; };
38 
name()39 	QString name() const { return _name; };
duration()40 	double duration() const { return _duration; };
chapters()41 	int chapters() const { return _chapters; };
angles()42 	int angles() const { return _angles; };
ID()43 	int ID() const { return _ID; };
44 
displayName()45 	QString displayName() const {
46 		QString dname = "";
47 
48 	    if (!_name.isEmpty()) {
49 	        dname = _name;
50 		}
51 		else
52 	    dname = QString::number(_ID);
53 
54 		if (_duration > 0) {
55 			dname += " ("+ Helper::formatTime( (int) _duration ) +")";
56 		}
57 
58 		return dname;
59 	};
60 
61 protected:
62 	QString _name;
63 	double _duration;
64 	int _chapters;
65 	int _angles;
66 
67 	int _ID;
68 };
69 
70 
71 class TitleTracks {
72 
73 public:
74 	TitleTracks();
75 	~TitleTracks();
76 
77 	void clear();
78 	void list();
79 
80 	void addName(int ID, QString name);
81 	void addDuration(int ID, double duration);
82 	void addChapters(int ID, int n);
83 	void addAngles(int ID, int n);
84 	void addID(int ID);
85 
86 	int numItems();
87 	bool existsItemAt(int n);
88 
89 	TitleData itemAt(int n);
90 	TitleData item(int ID);
91 	int find(int ID);
92 
93 protected:
94 	typedef QMap <int, TitleData> TitleMap;
95 	TitleMap tm;
96 };
97 
98 #endif
99