1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
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.
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.
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
22
TrackList::TrackList() {
26
TrackList::~TrackList() {
29
void TrackList::clear() {
33
void TrackList::addLang(int ID, QString lang) {
38
void TrackList::addName(int ID, QString name) {
43
void TrackList::addFilename(int ID, QString filename) {
44
tm[ID].setFilename(filename);
48
void TrackList::addDuration(int ID, double duration) {
49
tm[ID].setDuration(duration);
53
void TrackList::addChapters(int ID, int n) {
54
tm[ID].setChapters(n);
58
void TrackList::addAngles(int ID, int n) {
63
void TrackList::addID(int ID) {
68
int TrackList::numItems() {
72
bool TrackList::existsItemAt(int n) {
73
return ((n > 0) && (n < numItems()));
76
TrackData TrackList::itemAt(int n) {
77
return tm.values()[n];
80
TrackData TrackList::item(int ID) {
84
int TrackList::find(int ID) {
85
for (int n=0; n < numItems(); n++) {
86
if (itemAt(n).ID() == ID) return n;
91
int TrackList::findLang(QString expr) {
92
qDebug( "TrackList::findLang: '%s'", expr.toUtf8().data());
97
for (int n=0; n < numItems(); n++) {
98
qDebug("TrackList::findLang: lang #%d '%s'", n, itemAt(n).lang().toUtf8().data());
99
if (rx.indexIn( itemAt(n).lang() ) > -1) {
100
qDebug("TrackList::findLang: found preferred lang!");
101
res_id = itemAt(n).ID();
109
void TrackList::list() {
110
for (int n=0; n < numItems(); n++) {
111
qDebug(" item # %d", n);
117
int TrackList::lastID() {
119
for (int n=0; n < numItems(); n++) {
120
if (itemAt(n).ID() > key)
121
key = itemAt(n).ID();
126
bool TrackList::existsFilename(QString name) {
127
for (int n=0; n < numItems(); n++) {
128
if (itemAt(n).filename() == name)
134
#ifndef NO_USE_INI_FILES
135
void TrackList::save(QSettings & set) {
136
qDebug("TrackList::save");
138
set.setValue( "num_tracks", numItems() );
139
for (int n=0; n < numItems(); n++) {
140
set.beginGroup( "track_" + QString::number(n) );
146
void TrackList::load(QSettings & set) {
147
qDebug("TrackList::load");
149
int num_tracks = set.value( "num_tracks", 0 ).toInt();
152
for (int n=0; n < num_tracks; n++) {
153
set.beginGroup( "track_" + QString::number(n) );
154
ID = set.value("ID", -1).toInt();
164
#endif // NO_USE_INI_FILES