1
/***************************************************************************
3
copyright : (C) 2004 by Scott Wheeler
4
email : wheeler@kde.org
5
***************************************************************************/
7
/***************************************************************************
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. *
14
***************************************************************************/
19
#include <kactivelabel.h>
23
#include <qguardedptr.h>
25
#include "filehandle.h"
31
class PlaylistCollection;
35
* This is the widget that holds all of the other items and handles updating them
36
* when the playing item changes.
39
class NowPlaying : public QHBox
44
NowPlaying(QWidget *parent, PlaylistCollection *collection,
45
const char *name = 0);
46
void addItem(NowPlayingItem *item);
47
PlaylistCollection *collection() const;
53
struct Observer : public PlaylistObserver
55
Observer(NowPlaying *parent, PlaylistInterface *playlist) :
56
PlaylistObserver(playlist),
58
virtual void updateCurrent() {}
59
virtual void updateData() { m_parent->slotUpdate(); }
62
friend struct Observer;
65
PlaylistCollection *m_collection;
66
QValueList<NowPlayingItem *> m_items;
70
* Abstract base for the other NowPlaying items.
76
virtual void update(const FileHandle &file) = 0;
77
NowPlaying *parent() const { return m_parent; }
79
NowPlayingItem(NowPlaying *parent) : m_parent(parent) { parent->addItem(this); }
85
* Displays the cover of the currently playing file if available, or hides
89
class CoverItem : public QLabel, public NowPlayingItem
92
CoverItem(NowPlaying *parent);
93
virtual void update(const FileHandle &file);
94
virtual void mouseReleaseEvent(QMouseEvent *event);
97
virtual void dragEnterEvent(QDragEnterEvent *e);
98
virtual void dropEvent(QDropEvent *e);
105
* A link label that doesn't automatically open Konqueror.
108
class LinkLabel : public KActiveLabel
111
LinkLabel(QWidget *parent, const char *name = 0) : KActiveLabel(parent, name) {}
112
virtual void openLink(const QString &) {}
116
* Show the text information on the current track and provides links to the
117
* album and artist of the currently playing item.
120
class TrackItem : public QWidget, public NowPlayingItem
125
TrackItem(NowPlaying *parent);
126
virtual void update(const FileHandle &file);
129
void slotOpenLink(const QString &link);
138
* Shows up to 10 items of history and links to those items.
141
class HistoryItem : public LinkLabel, public NowPlayingItem
146
HistoryItem(NowPlaying *parent);
147
virtual void update(const FileHandle &file);
148
virtual void openLink(const QString &link);
151
void slotAddPlaying();
157
Item(const QString &a, const FileHandle &f, Playlist *p)
158
: anchor(a), file(f), playlist(p) {}
162
QGuardedPtr<Playlist> playlist;
165
QValueList<Item> m_history;