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

« back to all changes in this revision

Viewing changes to src/corelib/trackdata.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mto: (1.1.9 upstream) (3.1.2 squeeze)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-nsklbxenl2hf2n6h
ImportĀ upstreamĀ versionĀ 0.6.7

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 "trackdata.h"
20
 
#include "helper.h"
21
 
#include <QFileInfo>
22
 
 
23
 
TrackData::TrackData() {
24
 
        _lang = "";
25
 
        _name = "";
26
 
        _filename = "";
27
 
        _duration = 0;
28
 
        _ID = -1;
29
 
        _chapters = 0;
30
 
        _angles = 0;
31
 
}
32
 
 
33
 
TrackData::~TrackData() {
34
 
}
35
 
 
36
 
QString TrackData::displayName() const {
37
 
        //qDebug("TrackData::displayName");
38
 
 
39
 
        QString dname="";
40
 
 
41
 
    if (!_name.isEmpty()) {
42
 
        dname = _name;
43
 
                if (!_lang.isEmpty()) {
44
 
                        dname += " ["+ _lang + "]";
45
 
                }
46
 
        }
47
 
    else
48
 
    if (!_lang.isEmpty()) {
49
 
        dname = _lang;
50
 
        }
51
 
    else
52
 
        if (!_filename.isEmpty()) {
53
 
                QFileInfo f(_filename);
54
 
            dname = f.fileName();
55
 
        }
56
 
        else
57
 
    dname = QString::number(_ID);
58
 
 
59
 
        if (_duration > 0) {
60
 
                dname += " ("+ Helper::formatTime( (int) _duration ) +")";
61
 
        }
62
 
 
63
 
        return dname;
64
 
}
65
 
 
66
 
#ifndef NO_USE_INI_FILES
67
 
void TrackData::save(QSettings & set) {
68
 
        //qDebug("TrackData::save");
69
 
 
70
 
        set.setValue( "lang", _lang );
71
 
        set.setValue( "name", _name );
72
 
        set.setValue( "filename", _filename );
73
 
        set.setValue( "duration", _duration );
74
 
        set.setValue( "chapters", _chapters );
75
 
        set.setValue( "angles", _angles );
76
 
        set.setValue( "ID", _ID );
77
 
}
78
 
 
79
 
void TrackData::load(QSettings & set) {
80
 
        //qDebug("TrackData::load");
81
 
 
82
 
        _lang = set.value( "lang", _lang ).toString();
83
 
        _name = set.value( "name", _name ).toString();
84
 
        _filename = set.value( "filename", _filename ).toString();
85
 
        _duration = set.value( "duration", _duration).toDouble();
86
 
        _chapters = set.value( "chapters", _chapters ).toInt();
87
 
        _angles =  set.value( "angles", _angles ).toInt();
88
 
        _ID = set.value( "ID", _ID ).toInt();
89
 
}
90
 
 
91
 
#endif // NO_USE_INI_FILES
92
 
 
93
 
void TrackData::list() {
94
 
        //qDebug("TrackData::list");
95
 
 
96
 
        qDebug("     ID: '%d' lang: '%s' name: '%s'", _ID, _lang.toUtf8().data(), _name.toUtf8().data() );
97
 
        qDebug("     filename: '%s' duration: %f chapters: %d angles: %d", 
98
 
            _filename.toUtf8().data(), _duration, _chapters, _angles );
99
 
}