summaryrefslogtreecommitdiffstats
path: root/amarok/src/cuefile.h
blob: 3b9ca6056ced1857bc6d556262eb744d806f25e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// (c) 2005 Martin Ehmke <ehmke@gmx.de>
// License: GNU General Public License V2

#ifndef CUEFILE_H
#define CUEFILE_H

#include <tqstring.h>
#include <tqmap.h>

#include <tqobject.h>
#include "engineobserver.h"

class CueFileItem {
    public:
        CueFileItem (const TQString& title, const TQString& artist, const TQString& album, const int trackNumber, const long index)
            : m_title( title )
            , m_artist( artist )
            , m_album( album )
            , m_trackNumber( trackNumber )
            , m_index( index )
            , m_length( -1 )
        {}

        CueFileItem()
            : m_title( )
            , m_artist( )
            , m_album( )
            , m_trackNumber( -1 )
            , m_index( -1 )
            , m_length( -1 )
        {}

        void setLength(const long length) { m_length = length; }

        const TQString getTitle () const { return m_title; }
        const TQString getArtist () const { return m_artist; }
        const TQString getAlbum () const { return m_album; }
        const int getTrackNumber () const { return m_trackNumber; }
        const long getIndex () const { return m_index; }
        const long getLength () const { return m_length; }

    private:
        TQString m_title;
        TQString m_artist;
        TQString m_album;
        int     m_trackNumber;
        long    m_index;
        long    m_length;
};

// <<Singleton>>
class CueFile : public TQObject, public TQMap<long, CueFileItem>, public EngineObserver
{
        Q_OBJECT
  

    public:
        static CueFile *instance();

        void setCueFileName( TQString name ) { m_cueFileName = name; };
        bool load(int mediaLength);

        // EngineObserver
        virtual void engineTrackPositionChanged( long /*position*/ , bool /*userSeek*/ );

    signals:
        /** Transmits new metadata bundle */
        void metaData( const MetaBundle& );
        /** Transmits new length information associated with current cue */
        void newCuePoint( long currentPos, long startPos, long endPos );

    protected:
        CueFile() : EngineObserver(), m_lastSeekPos(-1) { };
        CueFile(EngineSubject *s) : EngineObserver(s), m_lastSeekPos(-1) { };
        ~CueFile();

    private:
        TQString m_cueFileName;
        int m_lastSeekPos; // in seconds
};


#endif