~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to juk/nowplaying.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    begin                : Tue Nov 9 2004
 
3
    copyright            : (C) 2004 by Scott Wheeler
 
4
    email                : wheeler@kde.org
 
5
 ***************************************************************************/
 
6
 
 
7
/***************************************************************************
 
8
 *                                                                         *
 
9
 *   This program is free software; you can redistribute it and/or modify  *
 
10
 *   it under the terms of the GNU General Public License as published by  *
 
11
 *   the Free Software Foundation; either version 2 of the License, or     *
 
12
 *   (at your option) any later version.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
 
15
 
 
16
#ifndef NOWPLAYING_H
 
17
#define NOWPLAYING_H
 
18
 
 
19
#include <kactivelabel.h>
 
20
 
 
21
#include <qhbox.h>
 
22
#include <qlabel.h>
 
23
#include <qguardedptr.h>
 
24
 
 
25
#include "filehandle.h"
 
26
#include "playlist.h"
 
27
 
 
28
class QTimer;
 
29
 
 
30
class NowPlayingItem;
 
31
class PlaylistCollection;
 
32
class Playlist;
 
33
 
 
34
/**
 
35
 * This is the widget that holds all of the other items and handles updating them
 
36
 * when the playing item changes.
 
37
 */
 
38
 
 
39
class NowPlaying : public QHBox
 
40
{
 
41
    Q_OBJECT
 
42
 
 
43
public:
 
44
    NowPlaying(QWidget *parent, PlaylistCollection *collection,
 
45
               const char *name = 0);
 
46
    void addItem(NowPlayingItem *item);
 
47
    PlaylistCollection *collection() const;
 
48
 
 
49
private slots:
 
50
    void slotUpdate();
 
51
 
 
52
private:
 
53
    struct Observer : public PlaylistObserver
 
54
    {
 
55
        Observer(NowPlaying *parent, PlaylistInterface *playlist) :
 
56
            PlaylistObserver(playlist),
 
57
            m_parent(parent) {}
 
58
        virtual void updateCurrent() {}
 
59
        virtual void updateData() { m_parent->slotUpdate(); }
 
60
        NowPlaying *m_parent;
 
61
    };
 
62
    friend struct Observer;
 
63
 
 
64
    Observer m_observer;
 
65
    PlaylistCollection *m_collection;
 
66
    QValueList<NowPlayingItem *> m_items;
 
67
};
 
68
 
 
69
/**
 
70
 * Abstract base for the other NowPlaying items.
 
71
 */
 
72
 
 
73
class NowPlayingItem
 
74
{
 
75
public:
 
76
    virtual void update(const FileHandle &file) = 0;
 
77
    NowPlaying *parent() const { return m_parent; }
 
78
protected:
 
79
    NowPlayingItem(NowPlaying *parent) : m_parent(parent) { parent->addItem(this); }
 
80
private:
 
81
    NowPlaying *m_parent;
 
82
};
 
83
 
 
84
/**
 
85
 * Displays the cover of the currently playing file if available, or hides
 
86
 * itself if not.
 
87
 */
 
88
 
 
89
class CoverItem : public QLabel, public NowPlayingItem
 
90
{
 
91
public:
 
92
    CoverItem(NowPlaying *parent);
 
93
    virtual void update(const FileHandle &file);
 
94
    virtual void mouseReleaseEvent(QMouseEvent *event);
 
95
 
 
96
protected:
 
97
    virtual void dragEnterEvent(QDragEnterEvent *e);
 
98
    virtual void dropEvent(QDropEvent *e);
 
99
 
 
100
private:
 
101
    FileHandle m_file;
 
102
};
 
103
 
 
104
/**
 
105
 * A link label that doesn't automatically open Konqueror.
 
106
 */
 
107
 
 
108
class LinkLabel : public KActiveLabel
 
109
{
 
110
public:
 
111
    LinkLabel(QWidget *parent, const char *name = 0) : KActiveLabel(parent, name) {}
 
112
    virtual void openLink(const QString &) {}
 
113
};
 
114
 
 
115
/**
 
116
 * Show the text information on the current track and provides links to the
 
117
 * album and artist of the currently playing item.
 
118
 */
 
119
 
 
120
class TrackItem : public QWidget, public NowPlayingItem
 
121
{
 
122
    Q_OBJECT
 
123
 
 
124
public:
 
125
    TrackItem(NowPlaying *parent);
 
126
    virtual void update(const FileHandle &file);
 
127
 
 
128
private slots:
 
129
    void slotOpenLink(const QString &link);
 
130
    void slotUpdate();
 
131
 
 
132
private:
 
133
    FileHandle m_file;
 
134
    LinkLabel *m_label;
 
135
};
 
136
 
 
137
/**
 
138
 * Shows up to 10 items of history and links to those items.
 
139
 */
 
140
 
 
141
class HistoryItem : public LinkLabel, public NowPlayingItem
 
142
{
 
143
    Q_OBJECT
 
144
 
 
145
public:
 
146
    HistoryItem(NowPlaying *parent);
 
147
    virtual void update(const FileHandle &file);
 
148
    virtual void openLink(const QString &link);
 
149
 
 
150
private slots:
 
151
    void slotAddPlaying();
 
152
 
 
153
private:
 
154
    struct Item
 
155
    {
 
156
        Item() {}
 
157
        Item(const QString &a, const FileHandle &f, Playlist *p)
 
158
            : anchor(a), file(f), playlist(p) {}
 
159
 
 
160
        QString anchor;
 
161
        FileHandle file;
 
162
        QGuardedPtr<Playlist> playlist;
 
163
    };
 
164
 
 
165
    QValueList<Item> m_history;
 
166
    LinkLabel *m_label;
 
167
    QTimer *m_timer;
 
168
    FileHandle m_file;
 
169
};
 
170
 
 
171
#endif