~neon/juk/master

978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
1
/***************************************************************************
2
    copyright            : (C) 2004 by Scott Wheeler
3
    email                : wheeler@kde.org
4
 ***************************************************************************/
5
6
/***************************************************************************
7
 *                                                                         *
8
 *   This program is free software; you can redistribute it and/or modify  *
9
 *   it under the terms of the GNU General Public License as published by  *
10
 *   the Free Software Foundation; either version 2 of the License, or     *
11
 *   (at your option) any later version.                                   *
12
 *                                                                         *
13
 ***************************************************************************/
14
15
#ifndef PLAYLIST_COLLECTION_H
16
#define PLAYLIST_COLLECTION_H
17
18
#include "stringhash.h"
1789 by Michael Pyne
Change QString::null to QString() in JuK where it makes sense. I believe there is a
19
#include "playlistinterface.h"
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
20
21
#include <kshortcut.h>
22
#include <klocale.h>
1184 by Michael Pyne
This commit changes the following:
23
#include <kdirlister.h>
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
24
1789 by Michael Pyne
Change QString::null to QString() in JuK where it makes sense. I believe there is a
25
#include <QPointer>
26
27
class QPixmap;
2008 by Michael Pyne
Port away from Q3WidgetStack. Not precisely sure why I bothered since I figure the Great Move to Interview
28
class QStackedWidget;
1791 by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
29
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
30
class KAction;
1791 by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
31
1080 by Scott Wheeler
Ok, I think this is the last of the significant regressions. Make the
32
class HistoryPlaylist;
1170 by Michael Pyne
OK, here it is. This commit introduces a new feature to JuK, the upcoming
33
class UpcomingPlaylist;
1367 by Scott Wheeler
Ok, so this is sort of working. Adding some stuff so that clicking on the
34
class SearchPlaylist;
35
class DynamicPlaylist;
1791 by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
36
class PlaylistItem;
37
class Playlist;
2151 by Michael Pyne
Make the history playlist work again.
38
class PlayerManager;
1791 by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
39
40
template<class T>
41
class QList;
42
43
typedef QList<PlaylistItem *> PlaylistItemList;
1712 by Tim Beaulen
Q3ValueList to QList
44
typedef QList<Playlist *> PlaylistList;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
45
1631 by Laurent Montel
Port it
46
class PlaylistCollection : public PlaylistInterface
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
47
{
48
    friend class Playlist;
49
    friend class CollectionList;
1005 by Scott Wheeler
Make the Tree View almost work again. It still seems to save and restore
50
    friend class DynamicPlaylist;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
51
52
public:
2151 by Michael Pyne
Make the history playlist work again.
53
    PlaylistCollection(PlayerManager *player, QStackedWidget *playlistStack);
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
54
    virtual ~PlaylistCollection();
55
1553 by Scott Wheeler
Since 3.5 devel seems to have mostly slowed down, I'm synching with the branch
56
    static PlaylistCollection *instance() { return m_instance; }
57
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
58
    virtual QString name() const;
59
    virtual FileHandle currentFile() const;
60
    virtual int count() const;
61
    virtual int time() const;
62
    virtual void playNext();
63
    virtual void playPrevious();
64
    virtual void stop();
995 by Scott Wheeler
Make the status bar work again by adding a PlaylistObserver class / pattern
65
    virtual bool playing() const;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
66
1031 by Scott Wheeler
A little code compacting -- take advantage of the fact that QStringList
67
    void playFirst();
1393 by Michael Pyne
Fix bug 89113 (Add functionality to switch to next/prev album in album random play), except for the previous album part.
68
    void playNextAlbum();
1031 by Scott Wheeler
A little code compacting -- take advantage of the fact that QStringList
69
1024 by Michael Pyne
Flesh out the rest of the DCOP interface.
70
    virtual QStringList playlists() const;
71
    virtual void createPlaylist(const QString &name);
1367 by Scott Wheeler
Ok, so this is sort of working. Adding some stuff so that clicking on the
72
    virtual void createDynamicPlaylist(const PlaylistList &playlists);
1824 by Arto Hytönen
kdemultimedia QString::null clean-up.
73
    virtual void showMore(const QString &artist, const QString &album = QString());
1024 by Michael Pyne
Flesh out the rest of the DCOP interface.
74
    virtual void removeTrack(const QString &playlist, const QStringList &files);
75
76
    virtual QString playlist() const;
1456 by Scott Wheeler
Add a "playingPlaylist()" DCOP method rather than overloading playlist() and
77
    virtual QString playingPlaylist() const;
1024 by Michael Pyne
Flesh out the rest of the DCOP interface.
78
    virtual void setPlaylist(const QString &playlist);
79
80
    virtual QStringList playlistTracks(const QString &playlist) const;
81
    virtual QString trackProperty(const QString &file, const QString &property) const;
1479 by Michael Pyne
DCOP improvements.
82
    virtual QPixmap trackCover(const QString &file, const QString &size = "Small") const;
1024 by Michael Pyne
Flesh out the rest of the DCOP interface.
83
1000 by Scott Wheeler
*) Clean up the PlaylistBox API removing signals, slots and methods that aren't
84
    virtual void open(const QStringList &files = QStringList());
1031 by Scott Wheeler
A little code compacting -- take advantage of the fact that QStringList
85
    virtual void open(const QString &playlist, const QStringList &files);
1000 by Scott Wheeler
*) Clean up the PlaylistBox API removing signals, slots and methods that aren't
86
    virtual void addFolder();
87
    virtual void rename();
88
    virtual void duplicate();
89
    virtual void save();
90
    virtual void saveAs();
1431 by Scott Wheeler
Some general playlist fixes that make it possible to add a playlist with a given
91
    virtual void remove() = 0;
1000 by Scott Wheeler
*) Clean up the PlaylistBox API removing signals, slots and methods that aren't
92
    virtual void reload();
93
    virtual void editSearch();
1553 by Scott Wheeler
Since 3.5 devel seems to have mostly slowed down, I'm synching with the branch
94
    virtual void setDynamicListsFrozen(bool) = 0;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
95
1366 by Scott Wheeler
I have the "Show More" stuff mostly working here. It still needs a thing
96
    bool showMoreActive() const;
1414 by Scott Wheeler
Add a link to clear the selection from the "more playing" thinger.
97
    void clearShowMore(bool raise = true);
1128 by Michael Pyne
Fix a stupid method visibility mistake I made, and which my compiler happened
98
    void enableDirWatch(bool enable);
99
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
100
    void removeItems();
101
    void refreshItems();
102
    void renameItems();
1299 by Scott Wheeler
Ok, huge patch from Nathan Toone to add a cover manager and such. There
103
    void addCovers(bool fromFile);
104
    void removeCovers();
105
    void viewCovers();
1485 by Michael Pyne
Add a CoverManager class to JuK (with a shockingly minimal GUI). It will
106
    void showCoverManager();
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
107
1431 by Scott Wheeler
Some general playlist fixes that make it possible to add a playlist with a given
108
    virtual PlaylistItemList selectedItems();
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
109
110
    void scanFolders();
111
112
    void createPlaylist();
113
    void createSearchPlaylist();
114
    void createFolderPlaylist();
115
116
    void guessTagFromFile();
117
    void guessTagFromInternet();
118
119
    void setSearchEnabled(bool enable);
120
1080 by Scott Wheeler
Ok, I think this is the last of the significant regressions. Make the
121
    HistoryPlaylist *historyPlaylist() const;
122
    void setHistoryPlaylistEnabled(bool enable);
123
1170 by Michael Pyne
OK, here it is. This commit introduces a new feature to JuK, the upcoming
124
    UpcomingPlaylist *upcomingPlaylist() const;
125
    void setUpcomingPlaylistEnabled(bool enable);
126
1125 by Michael Pyne
Fix bug 85534 (a regression due to the reorganization a few weeks ago).
127
    void dirChanged(const QString &path);
128
1429 by Scott Wheeler
Clear the "now playing" text if we switch playlists.
129
    /**
130
     * Returns a pointer to the action handler.
131
     */
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
132
    QObject *object() const;
133
1192 by Michael Pyne
This method should be public, not protected.
134
    void newItems(const KFileItemList &list) const;
135
1271 by Scott Wheeler
Clean up all of the mess with the visible / current playlist split. This
136
    /**
137
     * This is the current playlist in all things relating to the player.  It
138
     * represents the playlist that either should be played from or is currently
139
     * playing.
140
     */
141
    virtual Playlist *currentPlaylist() const;
142
143
    /**
144
     * This is the currently visible playlist and should be used for all user
145
     * interaction elements.
146
     */
147
    virtual Playlist *visiblePlaylist() const;
148
1413 by Scott Wheeler
Make the history playlist actually do something when the items are clicked on.
149
    /**
150
     * Makes \a playlist the currently visible playlist.
151
     */
152
    virtual void raise(Playlist *playlist);
153
1448 by Scott Wheeler
Rework the painting optimization junk. Rather than attempting to compress the
154
    /**
155
     * This is used to put up a temporary widget over the top of the playlist
156
     * stack.  This is part of a trick to significantly speed up painting by
157
     * hiding the playlist to which items are being added.
158
     */
159
    void raiseDistraction();
160
    void lowerDistraction();
161
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
162
    class ActionHandler;
163
164
protected:
2008 by Michael Pyne
Port away from Q3WidgetStack. Not precisely sure why I bothered since I figure the Great Move to Interview
165
    virtual QStackedWidget *playlistStack() const;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
166
    virtual void setupPlaylist(Playlist *playlist, const QString &iconName);
1553 by Scott Wheeler
Since 3.5 devel seems to have mostly slowed down, I'm synching with the branch
167
    virtual void removePlaylist(Playlist *playlist) = 0;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
168
169
    bool importPlaylists() const;
1029 by Scott Wheeler
The deleteLater() thing for duplicate playlist file was a bad, bad idea.
170
    bool containsPlaylistFile(const QString &file) const;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
171
1000 by Scott Wheeler
*) Clean up the PlaylistBox API removing signals, slots and methods that aren't
172
    QString playlistNameDialog(const QString &caption = i18n("Create New Playlist"),
1789 by Michael Pyne
Change QString::null to QString() in JuK where it makes sense. I believe there is a
173
                               const QString &suggest = QString(),
1017 by Scott Wheeler
Don't append a " (1)" to the playlist name in the rename dialog.
174
                               bool forceUnique = true) const;
1000 by Scott Wheeler
*) Clean up the PlaylistBox API removing signals, slots and methods that aren't
175
    QString uniquePlaylistName(const QString &suggest = i18n("Playlist")) const;
176
1431 by Scott Wheeler
Some general playlist fixes that make it possible to add a playlist with a given
177
    void addNameToDict(const QString &name);
178
    void addFileToDict(const QString &file);
179
    void removeNameFromDict(const QString &name);
180
    void removeFileFromDict(const QString &file);
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
181
1024 by Michael Pyne
Flesh out the rest of the DCOP interface.
182
    Playlist *playlistByName(const QString &name) const;
183
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
184
private:
185
    void readConfig();
186
    void saveConfig();
187
2008 by Michael Pyne
Port away from Q3WidgetStack. Not precisely sure why I bothered since I figure the Great Move to Interview
188
    QStackedWidget   *m_playlistStack;
1170 by Michael Pyne
OK, here it is. This commit introduces a new feature to JuK, the upcoming
189
    HistoryPlaylist  *m_historyPlaylist;
190
    UpcomingPlaylist *m_upcomingPlaylist;
191
    ActionHandler    *m_actionHandler;
2151 by Michael Pyne
Make the history playlist work again.
192
    PlayerManager    *m_playerManager;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
193
1184 by Michael Pyne
This commit changes the following:
194
    KDirLister  m_dirLister;
1000 by Scott Wheeler
*) Clean up the PlaylistBox API removing signals, slots and methods that aren't
195
    StringHash  m_playlistNames;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
196
    StringHash  m_playlistFiles;
197
    QStringList m_folderList;
198
    bool        m_importPlaylists;
199
    bool        m_searchEnabled;
995 by Scott Wheeler
Make the status bar work again by adding a PlaylistObserver class / pattern
200
    bool        m_playing;
1366 by Scott Wheeler
I have the "Show More" stuff mostly working here. It still needs a thing
201
1530 by Laurent Montel
qt3to4 + my script
202
    QPointer<SearchPlaylist> m_showMorePlaylist;
203
    QPointer<Playlist> m_belowShowMorePlaylist;
204
    QPointer<DynamicPlaylist> m_dynamicPlaylist;
205
    QPointer<Playlist> m_belowDistraction;
1448 by Scott Wheeler
Rework the painting optimization junk. Rather than attempting to compress the
206
207
    QWidget *m_distraction;
1553 by Scott Wheeler
Since 3.5 devel seems to have mostly slowed down, I'm synching with the branch
208
209
    static PlaylistCollection *m_instance;
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
210
};
211
212
/**
213
 * This class is just used as a proxy to handle the signals coming from action
214
 * activations without requiring PlaylistCollection to be a QObject.
215
 */
216
217
class PlaylistCollection::ActionHandler : public QObject
218
{
219
    Q_OBJECT
220
public:
221
    ActionHandler(PlaylistCollection *collection);
222
223
private:
224
    KAction *createAction(const QString &text,
225
                          const char *slot,
226
                          const char *name,
1789 by Michael Pyne
Change QString::null to QString() in JuK where it makes sense. I believe there is a
227
                          const QString &icon = QString(),
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
228
                          const KShortcut &shortcut = KShortcut());
229
private slots:
1393 by Michael Pyne
Fix bug 89113 (Add functionality to switch to next/prev album in album random play), except for the previous album part.
230
    void slotPlayFirst()     { m_collection->playFirst(); }
231
    void slotPlayNextAlbum() { m_collection->playNextAlbum(); }
992 by Michael Pyne
Made it possible to quickly play the found song from the search bar by
232
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
233
    void slotOpen()         { m_collection->open(); }
234
    void slotAddFolder()    { m_collection->addFolder(); }
235
    void slotRename()       { m_collection->rename(); }
236
    void slotDuplicate()    { m_collection->duplicate(); }
237
    void slotSave()         { m_collection->save(); }
238
    void slotSaveAs()       { m_collection->saveAs(); }
239
    void slotReload()       { m_collection->reload(); }
240
    void slotRemove()       { m_collection->remove(); }
241
    void slotEditSearch()   { m_collection->editSearch(); }
242
243
    void slotRemoveItems()  { m_collection->removeItems(); }
244
    void slotRefreshItems() { m_collection->refreshItems(); }
245
    void slotRenameItems()  { m_collection->renameItems(); }
246
    void slotScanFolders()  { m_collection->scanFolders(); }
247
1299 by Scott Wheeler
Ok, huge patch from Nathan Toone to add a cover manager and such. There
248
    void slotViewCovers()   { m_collection->viewCovers(); }
249
    void slotRemoveCovers() { m_collection->removeCovers(); }
250
    void slotAddLocalCover()    { m_collection->addCovers(true); }
251
    void slotAddInternetCover() { m_collection->addCovers(false); }
252
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
253
    void slotCreatePlaylist()       { m_collection->createPlaylist(); }
254
    void slotCreateSearchPlaylist() { m_collection->createSearchPlaylist(); }
255
    void slotCreateFolderPlaylist() { m_collection->createFolderPlaylist(); }
256
257
    void slotGuessTagFromFile()     { m_collection->guessTagFromFile(); }
258
    void slotGuessTagFromInternet() { m_collection->guessTagFromInternet(); }
259
1173 by Scott Wheeler
CVS_SILENT this looks nicer
260
    void slotSetSearchEnabled(bool enable)           { m_collection->setSearchEnabled(enable); }
1170 by Michael Pyne
OK, here it is. This commit introduces a new feature to JuK, the upcoming
261
    void slotSetUpcomingPlaylistEnabled(bool enable) { m_collection->setUpcomingPlaylistEnabled(enable); }
1485 by Michael Pyne
Add a CoverManager class to JuK (with a shockingly minimal GUI). It will
262
    void slotShowCoverManager()                      { m_collection->showCoverManager(); }
1173 by Scott Wheeler
CVS_SILENT this looks nicer
263
    void slotEnableDirWatch(bool enable)             { m_collection->enableDirWatch(enable); }
264
    void slotDirChanged(const QString &path)         { m_collection->dirChanged(path); }
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
265
1188 by Michael Pyne
Hmm, seems there was a reason I had this redirect for slotNewItems() in place after all. I should really stop coding at night. =D
266
    void slotNewItems(const KFileItemList &list)     { m_collection->newItems(list); }
267
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
268
signals:
269
    void signalSelectedItemsChanged();
995 by Scott Wheeler
Make the status bar work again by adding a PlaylistObserver class / pattern
270
    void signalCountChanged();
978 by Scott Wheeler
Ok, big cleanups essentially implimenting the stuff that has been in the
271
272
private:
273
    PlaylistCollection *m_collection;
274
};
275
276
#endif
1562 by Michael Pyne
Since we're standardizing the source style, figured I'd throw in the Big Huge Vim Modeline
277
278
// vim: set et sw=4 tw=0 sta: