summaryrefslogtreecommitdiffstats
path: root/amarok/src/queuemanager.h
blob: 10df80ba31979431040c6e6c5cd544895507c2ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************
 * copyright            : (C) 2005 Seb Ruiz <me@sebruiz.net>               *
 **************************************************************************/

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

#include "playlistitem.h"

#include <kdialogbase.h>    //baseclass
#include <klistview.h>      //baseclass

#include <tqmap.h>

class KPushButton;

class QueueItem : public KListViewItem
{
    public:
        QueueItem( TQListView *parent, TQListViewItem *after, TQString t )
            : KListViewItem( parent, after, t )
        { };

        void paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int align );

};

class QueueList : public KListView
{
        Q_OBJECT
  TQ_OBJECT

    friend class QueueManager;

    public:
        QueueList( TQWidget *parent, const char *name = 0 );
        ~QueueList() {};

        bool    hasSelection();
        bool    isEmpty() { return ( childCount() == 0 ); }
        TQPtrList<TQListViewItem>  selectedItems();

    public slots:
        void    moveSelectedUp();
        void    moveSelectedDown();
        void    removeSelected();
        virtual void    clear();

    private:
        void    contentsDragEnterEvent( TQDragEnterEvent *e );
        void    contentsDragMoveEvent( TQDragMoveEvent* e );
        void    contentsDropEvent( TQDropEvent *e );
        void    keyPressEvent( TQKeyEvent *e );
        void    viewportPaintEvent( TQPaintEvent* );

     signals:
        void    changed();
};

class QueueManager : public KDialogBase
{
        Q_OBJECT
  TQ_OBJECT

    public:
        QueueManager( TQWidget *parent = 0, const char *name = 0 );
        ~QueueManager();

        TQPtrList<PlaylistItem> newQueue();

        static QueueManager *instance() { return s_instance; }

    public slots:
        void    applyNow();
        void    addItems( TQListViewItem *after = 0 ); /// For the add button (uses selected playlist tracks)
        void    changeQueuedItems( const PLItemList &in, const PLItemList &out );  /// For keeping queue/dequeue in sync
        void    updateButtons();

    private slots:
        void    removeSelected();
        void    changed();

    private:
        void    insertItems();
        void    addQueuedItem( PlaylistItem *item );
        void    removeQueuedItem( PlaylistItem *item );

        TQMap<TQListViewItem*, PlaylistItem*> m_map;
        QueueList   *m_listview;
        KPushButton *m_up;
        KPushButton *m_down;
        KPushButton *m_remove;
        KPushButton *m_add;
        KPushButton *m_clear;

        static QueueManager *s_instance;
};

#endif /* AMAROK_TQUEUEMANAGER_H */