~ubuntu-branches/ubuntu/wily/smplayer/wily

« back to all changes in this revision

Viewing changes to src/corelib/tracks.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-0h2hfwpwlu9opbv2
* New upstream release. (Closes: #523791)
  - Reworked subtitle font preferences. (Closes: #503295)
  - No longer installs qt_fr.qm. (Closes: #486314)
* debian/control:
  - Bumped Standards-Version to 3.8.1.
  - Changed maintainer name (still the same person and GPG key).
  - Changed section to video.
  - Build-depend on zlib1g-dev for findsubtitles.
  - Require Qt >= 4.3 per readme.
  - Added ${misc:Depends}.
  - Make smplayer-translations depend on smplayer and smplayer recommend
    smplayer-translations, not the other way round. (Closes: #489375)
* debian/copyright:
  - Significantly expanded per-file with new upstream authors.
* debian/rules:
  - Make make use correct uic in install.
  - Clean svn_revision.
  - Removed get-orig-source - not needed with uscan --repack.
* debian/patches/01_gl_translation.patch:
  - Added patch to fix lrelease error on smplayer_gl.ts.
* Added debian/README.source for simple-patchsys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  smplayer, GUI front-end for mplayer.
2
 
    Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
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
 
#include "tracks.h"
20
 
#include <QRegExp>
21
 
 
22
 
TrackList::TrackList() { 
23
 
        clear();
24
 
}
25
 
 
26
 
TrackList::~TrackList() {
27
 
}
28
 
 
29
 
void TrackList::clear() {
30
 
        tm.clear();
31
 
}
32
 
 
33
 
void TrackList::addLang(int ID, QString lang) {
34
 
        tm[ID].setLang(lang);
35
 
        tm[ID].setID(ID);
36
 
}
37
 
 
38
 
void TrackList::addName(int ID, QString name) {
39
 
        tm[ID].setName(name);
40
 
        tm[ID].setID(ID);
41
 
}
42
 
 
43
 
void TrackList::addFilename(int ID, QString filename) {
44
 
        tm[ID].setFilename(filename);
45
 
        tm[ID].setID(ID);
46
 
}
47
 
 
48
 
void TrackList::addDuration(int ID, double duration) {
49
 
        tm[ID].setDuration(duration);
50
 
        tm[ID].setID(ID);
51
 
}
52
 
 
53
 
void TrackList::addChapters(int ID, int n) {
54
 
        tm[ID].setChapters(n);
55
 
        tm[ID].setID(ID);
56
 
}
57
 
 
58
 
void TrackList::addAngles(int ID, int n) {
59
 
        tm[ID].setAngles(n);
60
 
        tm[ID].setID(ID);
61
 
}
62
 
 
63
 
void TrackList::addID(int ID) {
64
 
        tm[ID].setID(ID);
65
 
}
66
 
 
67
 
 
68
 
int TrackList::numItems() {
69
 
        return tm.count();
70
 
}
71
 
 
72
 
bool TrackList::existsItemAt(int n) {
73
 
        return ((n > 0) && (n < numItems()));
74
 
}
75
 
 
76
 
TrackData TrackList::itemAt(int n) {
77
 
        return tm.values()[n];
78
 
}
79
 
 
80
 
TrackData TrackList::item(int ID) {
81
 
        return tm[ID];
82
 
}
83
 
 
84
 
int TrackList::find(int ID) {
85
 
        for (int n=0; n < numItems(); n++) {
86
 
                if (itemAt(n).ID() == ID) return n;
87
 
        }
88
 
        return -1;
89
 
}
90
 
 
91
 
int TrackList::findLang(QString expr) {
92
 
        qDebug( "TrackList::findLang: '%s'", expr.toUtf8().data());
93
 
        QRegExp rx( expr );
94
 
 
95
 
        int res_id = -1;
96
 
 
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();
102
 
                        break;  
103
 
                }
104
 
        }
105
 
 
106
 
        return res_id;
107
 
}
108
 
 
109
 
void TrackList::list() {
110
 
        for (int n=0; n < numItems(); n++) {
111
 
                qDebug("    item # %d", n);
112
 
                itemAt(n).list();
113
 
        }
114
 
}
115
 
 
116
 
 
117
 
int TrackList::lastID() {
118
 
        int key = -1;
119
 
        for (int n=0; n < numItems(); n++) {
120
 
                if (itemAt(n).ID() > key) 
121
 
                        key = itemAt(n).ID();
122
 
        }
123
 
        return key;
124
 
}
125
 
 
126
 
bool TrackList::existsFilename(QString name) {
127
 
        for (int n=0; n < numItems(); n++) {
128
 
                if (itemAt(n).filename() == name) 
129
 
                        return TRUE;
130
 
        }
131
 
        return FALSE;
132
 
}
133
 
 
134
 
#ifndef NO_USE_INI_FILES
135
 
void TrackList::save(QSettings & set) {
136
 
        qDebug("TrackList::save");
137
 
 
138
 
        set.setValue( "num_tracks", numItems() );
139
 
        for (int n=0; n < numItems(); n++) {
140
 
                set.beginGroup( "track_" + QString::number(n) );
141
 
                itemAt(n).save(set);
142
 
                set.endGroup();
143
 
        }
144
 
}
145
 
 
146
 
void TrackList::load(QSettings & set) {
147
 
        qDebug("TrackList::load");
148
 
 
149
 
        int num_tracks = set.value( "num_tracks", 0 ).toInt();
150
 
 
151
 
        int ID;
152
 
        for (int n=0; n < num_tracks; n++) {
153
 
                set.beginGroup( "track_" + QString::number(n) );
154
 
                ID = set.value("ID", -1).toInt();
155
 
                if (ID!=-1) {
156
 
                        tm[ID].setID(ID);
157
 
                        tm[ID].load(set);
158
 
                }
159
 
                set.endGroup();
160
 
        }
161
 
 
162
 
        //list();
163
 
}
164
 
#endif // NO_USE_INI_FILES
165