Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
[kdemultimedia.git] / juk / dynamicplaylist.h
blob1858369b97d5bd6dbdacc189b06b9c5cd773c83d
1 /***************************************************************************
2 begin : Mon May 5 2003
3 copyright : (C) 2003 - 2004 by Scott Wheeler
4 email : wheeler@kde.org
5 ***************************************************************************/
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 ***************************************************************************/
16 #ifndef DYNAMICPLAYLIST_H
17 #define DYNAMICPLAYLIST_H
19 #include "playlist.h"
21 #include <QList>
23 /**
24 * A Playlist that is a union of other playlists that is created dynamically.
27 class DynamicPlaylist : public Playlist
29 Q_OBJECT
30 public:
31 /**
32 * Creates a dynamic playlist based on lists.
34 DynamicPlaylist(const PlaylistList &lists,
35 PlaylistCollection *collection,
36 const QString &name = QString(),
37 const QString &iconName = "midi",
38 bool setupPlaylist = true,
39 bool synchronizePlaying = false);
41 virtual ~DynamicPlaylist();
43 virtual bool canReload() const { return false; }
45 void setPlaylists(const PlaylistList &playlists);
47 public slots:
48 /**
49 * Reimplemented so that it will reload all of the playlists that are
50 * associated with the dynamic list.
52 virtual void slotReload();
53 void slotSetDirty() { m_dirty = true; }
55 /**
56 * This is called when lowering the widget from the widget stack so that
57 * it can synchronize the playing item with the one that playlist it was
58 * create from.
60 void lower(QWidget *top = 0);
62 protected:
63 /**
64 * Returns true if this list's items need to be updated the next time it's
65 * shown.
67 bool dirty() const { return m_dirty; }
69 /**
70 * Return a list of the items in this playlist. For example in a search
71 * list this should return only the matched items. By default it returns
72 * all of the items in the playlists associated with this dynamic list.
74 virtual PlaylistItemList items();
76 /**
77 * Reimplemented from QWidget. Here it updates the list of items (when
78 * appropriate) as the widget is shown.
80 virtual void showEvent(QShowEvent *e);
82 virtual void paintEvent(QPaintEvent *e);
84 /**
85 * Updates the items (unconditionally). This should be reimplemented in
86 * subclasses to refresh the items in the dynamic list (i.e. running a
87 * search).
89 virtual void updateItems();
91 bool synchronizePlaying() const;
93 private:
94 /**
95 * Checks to see if the current list of items is "dirty" and if so updates
96 * this dynamic playlist's items to be in sync with the lists that it is a
97 * wrapper around.
99 void checkUpdateItems();
101 private slots:
102 void slotUpdateItems();
104 private:
105 QList<PlaylistObserver *> m_observers;
106 PlaylistItemList m_siblings;
107 PlaylistList m_playlists;
108 bool m_dirty;
109 bool m_synchronizePlaying;
112 #endif
114 // vim: set et sw=4 tw=0 sta: