add check for role to data()
[amarok.git] / src / queuemanager.h
blob55e126516ab6573adba552d9079b0514d8e88698
1 /***************************************************************************
2 * copyright : (C) 2005 Seb Ruiz <me@sebruiz.net> *
3 **************************************************************************/
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
14 #ifndef AMAROK_QUEUEMANAGER_H
15 #define AMAROK_QUEUEMANAGER_H
17 #include "playlistitem.h"
19 #include <KDialog> //baseclass
21 #include <QListWidget> //baseclass
22 #include <QListWidgetItem> //baseclass
23 #include <QMap>
25 class KPushButton;
26 class QDragEnterEvent;
27 class QDragMoveEvent;
28 class QDropEvent;
29 class QKeyEvent;
30 class QPaintEvent;
32 class QueueItem : public QListWidgetItem
35 public:
36 QueueItem( const QString& s ) : QListWidgetItem( s ) { }
37 #if 0
38 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
39 #endif
42 class QueueList : public QListWidget
44 Q_OBJECT
46 friend class QueueManager;
48 public:
49 explicit QueueList( QWidget *parent, const char *name = 0 );
50 ~QueueList() {}
52 bool hasSelection();
53 bool isEmpty() { return ( count() == 0 ); }
55 public slots:
56 void moveSelectedUp() { moveSelected( -1 ); }
57 void moveSelectedDown() { moveSelected( 1 ); }
58 void removeSelected();
59 virtual void clear();
61 private:
62 void moveSelected( int direction );
63 void dragEnterEvent( QDragEnterEvent *e );
64 void dragMoveEvent( QDragMoveEvent* e );
65 void dropEvent( QDropEvent *e );
66 void keyPressEvent( QKeyEvent *e );
67 void paintEvent( QPaintEvent* );
69 signals:
70 void changed();
73 class QueueManager : public KDialog
75 Q_OBJECT
77 public:
78 explicit QueueManager( QWidget *parent = 0, const char *name = 0 );
79 ~QueueManager();
81 QList<PlaylistItem* > newQueue();
83 static QueueManager *instance() { return s_instance; }
85 public slots:
86 void applyNow();
87 void addItems( QListWidgetItem *after = 0 ); /// For the add button (uses selected playlist tracks)
88 void changeQueuedItems( const QList<PlaylistItem*> &in, const QList<PlaylistItem*> &out ); /// For keeping queue/dequeue in sync
89 void updateButtons();
91 private slots:
92 void removeSelected();
93 void changed();
95 private:
96 void insertItems();
97 void addQueuedItem( PlaylistItem *item );
98 void removeQueuedItem( PlaylistItem *item );
100 QMap<QListWidgetItem*, PlaylistItem*> m_map;
101 QueueList *m_listview;
102 KPushButton *m_up;
103 KPushButton *m_down;
104 KPushButton *m_remove;
105 KPushButton *m_add;
106 KPushButton *m_clear;
108 static QueueManager *s_instance;
111 #endif /* AMAROK_QUEUEMANAGER_H */