playlistbox.h 3.76 KB
Newer Older
1 2 3 4 5
/***************************************************************************
                          playlistbox.h  -  description
                             -------------------
    begin                : Thu Sep 12 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 21
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 PLAYLISTBOX_H
#define PLAYLISTBOX_H

#include <klistbox.h>
22
#include <kpopupmenu.h>
23 24 25 26

#include <qwidgetstack.h>

#include "listboxpixmap.h"
27 28 29

class Playlist;
class PlaylistItem;
30 31

class PlaylistBoxItem;
32
class PlaylistSplitter;
33 34 35 36 37 38

/** This is the play list selection box that is by default on the right side of
    JuK's main widget (PlaylistSplitter). */

class PlaylistBox : public KListBox
{
39 40
    friend class PlaylistBoxItem;

41
    Q_OBJECT
42

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

47
    void sort();
48 49
    QStringList names() const;

50
public slots:
51
    // All of the slots without parameters default to the selected item.
52 53 54 55 56 57 58 59 60 61 62
    void save();
    void save(PlaylistBoxItem *item);
    void saveAs();
    void saveAs(PlaylistBoxItem *item);
    void rename();
    void rename(PlaylistBoxItem *item);
    void duplicate();
    void duplicate(PlaylistBoxItem *item);
    void deleteItem();
    void deleteItem(PlaylistBoxItem *item);

63
private:
64
    virtual void resizeEvent(QResizeEvent *e);
65 66
    virtual void dropEvent(QDropEvent *e);
    virtual void dragMoveEvent(QDragMoveEvent *e);
67
    virtual void mousePressEvent(QMouseEvent *e);
68 69 70 71
    /** 
     * This is used by PlaylistItemBox (a friend class) to add names to the name
     * list returned by names(). 
     */
72
    void addName(const QString &name);
73

74
    PlaylistSplitter *splitter;
75
    QStringList nameList;
76 77 78
    KPopupMenu *collectionContextMenu;
    KPopupMenu *playlistContextMenu;
    PlaylistBoxItem *contextMenuOn;
79
    bool updatePlaylistStack;
80 81

private slots:
82 83 84 85
    /** 
     * Catches QListBox::currentChanged(QListBoxItem *), does a cast and then re-emits
     * the signal as  currentChanged(PlaylistBoxItem *). 
     */
86 87
    void playlistChanged(QListBoxItem *item);
    void playlistDoubleClicked(QListBoxItem *item);
88
    void drawContextMenu(QListBoxItem *item, const QPoint &point);
89

90 91 92 93
    // context menu entries
    void contextSave();
    void contextSaveAs();
    void contextRename();
94
    void contextDuplicate();
95
    void contextDeleteItem();
96 97 98

signals:
    void currentChanged(PlaylistBoxItem *);
99
    void doubleClicked(PlaylistBoxItem *);
100 101 102 103 104 105 106


#if QT_VERSION < 0x031000
public:
    // This method is defined in Qt 3.1 and later.
    QListBoxItem *selectedItem() { return(item(currentItem())); }
#endif
107 108
};

109 110


111
class PlaylistBoxItem : public QObject, public ListBoxPixmap
112
{
113 114
    friend class PlaylistBox;

115 116
    Q_OBJECT

117
public:
118 119
    PlaylistBoxItem(PlaylistBox *listbox, const QPixmap &pix, const QString &text, Playlist *l = 0);
    PlaylistBoxItem(PlaylistBox *listbox, const QString &text, Playlist *l = 0);
120 121 122
    virtual ~PlaylistBoxItem();

    Playlist *playlist() const;
123
    PlaylistBox *listBox() const;
124 125

public slots:
126
    void setName(const QString &name);
127 128 129 130 131 132
    
private:
    Playlist *list;
};

#endif