playlistsplitter.h 4.54 KB
Newer Older
1 2 3 4 5
/***************************************************************************
                          playlistsplitter.h  -  description
                             -------------------
    begin                : Fri Sep 13 2002
    copyright            : (C) 2002 by Scott Wheeler
6
    email                : wheeler@kde.org
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PLAYLISTSPLITTER_H
#define PLAYLISTSPLITTER_H

21
#include <kfiledialog.h>
22 23 24 25 26
#include <klocale.h>

#include <qsplitter.h>
#include <qwidgetstack.h>

27
#include "playlistitem.h"
28
#include "playlistbox.h"
29 30 31 32 33

class Playlist;
class PlaylistBoxItem;
class CollectionList;
class TagEditor;
34

35 36
/**
 * This is the main layout class of JuK.  It should contain a PlaylistBox and
37 38
 * a QWidgetStack of the Playlists.  
 */
39 40 41 42

class PlaylistSplitter : public QSplitter
{
    Q_OBJECT
43

44
public:
45 46
    PlaylistSplitter(QWidget *parent, const char *name = 0);
    virtual ~PlaylistSplitter();
47

48 49 50 51 52
    /**
     * Returns a unique string to be used as new playlist names.  This follows
     * the format "[startingWith] i" where "i" is the first integer greater than 0
     * that does not currently exist in the PlaylistBox.
     */
53
    QString uniquePlaylistName(const QString &startingWith, bool useParentheses = false);
54 55 56 57 58 59 60 61
    /* This calls the above method with startingWith == i18n("Playlist") to 
     * produce "Playlist 1", "Playlist 2", ...
     */
    QString uniquePlaylistName();
    /**
     * Returns a QPtrList of the selected PlaylistItems in the top playlist in 
     * the QWidgetStack of playlists.
     */
62
    PlaylistItemList playlistSelection() const;
63 64 65 66
    /**
     * This returns a pointer to the first item in the playlist on the top
     * of the QWidgetStack of playlists.
     */
67 68
    PlaylistItem *playlistFirstItem() const;

69 70
    // static (non-initialization) methods

71 72 73 74
    /**
     * Returns a lif of the extensions that are used for playlists.
     */
    QStringList playlistExtensions() const;
75 76 77 78 79 80 81
    /** 
     * Merges a list of file extensions, and a description of those types into a
     * format that makes sense to KFileDialog.  If type = QString::null then no
     * description is appended.
     */
    static QString extensionsString(const QStringList &extensions, const QString &type = QString::null);

82
public slots:
83 84
    void open();
    void openDirectory();
85 86
    void open(const QStringList &files);
    void open(const QString &file);
87
    void save();
88 89 90
    /**
     * Deletes the selected items from the hard disk. 
     */
91
    void remove();
92
    void refresh();
93 94 95
    /**
     * Removes the selected items from the playlist. 
     */
96 97 98 99 100
    void clearSelectedItems();
    void selectAll(bool select = true);

    void setEditorVisible(bool visible);

101 102
    Playlist *createPlaylist();
    Playlist *createPlaylist(const QString &name);
103 104 105 106 107 108 109 110 111 112 113 114 115 116
    void openPlaylist();
    Playlist *openPlaylist(const QString &playlistFile);

    void add(const QString &file, Playlist *list);
    void add(const QStringList &files, Playlist *list);

    // PlaylistBox forwarding methods
    void savePlaylist() { playlistBox->save(); }
    void saveAsPlaylist() { playlistBox->saveAs(); }
    void renamePlaylist() { playlistBox->rename(); }
    void duplicatePlaylist() { playlistBox->duplicate(); }
    void deleteItemPlaylist() { playlistBox->deleteItem(); }

protected:
117

118 119 120
private:
    void setupLayout();
    void readConfig();
121
    void saveConfig();
122 123 124
    void addImpl(const QString &file, Playlist *list);

    static PlaylistSplitter *splitter;
125 126 127 128 129 130 131

    PlaylistBox *playlistBox;
    QWidgetStack *playlistStack;
    TagEditor *editor;

    CollectionList *collection;

132 133
    QStringList playlistFiles;

134 135 136
    QStringList mediaExtensions;
    QStringList listExtensions;

137 138 139 140 141
    bool showEditor;

private slots:
    // playlist box slots
    void changePlaylist(PlaylistBoxItem *item);
142
    void playlistBoxDoubleClicked(PlaylistBoxItem *item);
143 144 145

signals:
    void playlistDoubleClicked(QListViewItem *);
146
    void playlistChanged(Playlist *);
147 148 149
};

#endif