summaryrefslogtreecommitdiffstats
path: root/src/playlistview.h
blob: f2909ff0bd99bcf829427616a4ee955387d84c3e (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/**
 * Copyright (C) 2006 by Koos Vriezen <koos.vriezen@gmail.com>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License version 2 as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 **/

#ifndef PLAYLISTVIEW_H
#define PLAYLISTVIEW_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tdelistview.h>

#include "kmplayerplaylist.h"

class TQFont;
class TQPixmap;
class TQPainter;
class TQPopupMenu;
class TQDropEvent;

namespace KMPlayer {

class View;
class PlayListView;

bool isDragValid (TQDropEvent * de) KMPLAYER_NO_MBR_EXPORT;

/*
 * An item in the playlist
 */
class KMPLAYER_NO_EXPORT PlayListItem : public TQListViewItem {
public:
    PlayListItem (TQListViewItem *p, const NodePtr & e, PlayListView * lv);
    PlayListItem (TQListViewItem *p, const AttributePtr & e, PlayListView * lv);
    PlayListItem (PlayListView *v, const NodePtr & d, TQListViewItem * b);
    KDE_NO_CDTOR_EXPORT ~PlayListItem () {}
    void paintCell (TQPainter * p, const TQColorGroup & cg, int column, int width, int align);
    void paintBranches(TQPainter *p, const TQColorGroup &cg, int w, int y, int h);
    PlayListView * playListView () const;
    NodePtrW node;
    AttributePtrW m_attr;
    PlayListView * listview;
protected:
    PlayListItem (PlayListView *v, const NodePtr & e);
};

class KMPLAYER_NO_EXPORT RootPlayListItem : public PlayListItem {
public:
    RootPlayListItem (int id, PlayListView *v, const NodePtr & d, TQListViewItem * b, int flags);
    KDE_NO_CDTOR_EXPORT ~RootPlayListItem () {}
    void paintCell (TQPainter * p, const TQColorGroup & cg, int column, int width, int align);
    TQString source;
    TQString icon;
    int id;
    int flags;
    bool show_all_nodes;
    bool have_dark_nodes;
};

/*
 * The playlist GUI
 */
class KMPLAYER_EXPORT PlayListView : public TDEListView {
    TQ_OBJECT
  
public:
    enum Flags {
        AllowDrops = 0x01, AllowDrag = 0x02,
        InPlaceEdit = 0x04, TreeEdit = 0x08,
        Moveable = 0x10, Deleteable = 0x20
    };
    PlayListView (TQWidget * parent, View * view, TDEActionCollection * ac);
    ~PlayListView ();
    void selectItem (const TQString & txt);
    void showAllNodes (RootPlayListItem *, bool show=true);
    void setActiveForegroundColor (const TQColor & c) { m_active_color = c; }
    const TQColor & activeColor () const { return m_active_color; }
    int addTree (NodePtr r, const TQString & src, const TQString & ico, int flgs);
    RootPlayListItem * rootItem (TQListViewItem * item) const;
    RootPlayListItem * rootItem (int id) const;
    void setFont (const TQFont &);
    PlayListItem * currentPlayListItem () const;
    PlayListItem * selectedPlayListItem () const;
    NodePtr lastDragNode () const { return m_last_drag; }
    int lastDragTreeId () const { return last_drag_tree_id; }
signals:
    void addBookMark (const TQString & title, const TQString & url);
    void prepareMenu (KMPlayer::PlayListItem * item, TQPopupMenu * menu);
protected:
    bool acceptDrag (TQDropEvent* event) const;
    TQDragObject * dragObject ();
public slots:
    void editCurrent ();
    void rename (TQListViewItem * item, int c);
    void updateTree (int id, NodePtr root, NodePtr active, bool sel, bool open);
private slots:
    void contextMenuItem (TQListViewItem *, const TQPoint &, int);
    void itemExpanded (TQListViewItem *);
    void copyToClipboard ();
    void addBookMark ();
    void toggleShowAllNodes ();
    void itemDropped (TQDropEvent * e, TQListViewItem * after);
    void itemIsRenamed (TQListViewItem * item);
    void itemIsSelected (TQListViewItem * item);
    void updateTrees ();
    void slotFind ();
    void slotFindOk ();
    void slotFindNext ();
private:
    void updateTree (RootPlayListItem * ritem, NodePtr active, bool select);
    PlayListItem * populate (NodePtr e, NodePtr focus, RootPlayListItem *root, PlayListItem * item, PlayListItem ** curitem);
    struct KMPLAYER_NO_EXPORT TreeUpdate {
        KDE_NO_CDTOR_EXPORT TreeUpdate (RootPlayListItem *ri, NodePtr n, bool s, bool o, SharedPtr <TreeUpdate> &nx) : root_item (ri), node (n), select (s), open (o), next (nx) {}
        KDE_NO_CDTOR_EXPORT ~TreeUpdate () {}
        RootPlayListItem * root_item;
        NodePtrW node;
        bool select;
        bool open;
        SharedPtr <TreeUpdate> next;
    };
    SharedPtr <TreeUpdate> tree_update;
    View * m_view;
    TQPopupMenu * m_itemmenu;
    TDEAction * m_find;
    TDEAction * m_find_next;
    KFindDialog * m_find_dialog;
    TQPixmap folder_pix;
    TQPixmap auxiliary_pix;
    TQPixmap video_pix;
    TQPixmap unknown_pix;
    TQPixmap menu_pix;
    TQPixmap config_pix;
    TQPixmap url_pix;
    TQPixmap info_pix;
    TQPixmap img_pix;
    TQColor m_active_color;
    NodePtrW m_current_find_elm;
    NodePtrW m_last_drag;
    AttributePtrW m_current_find_attr;
    int last_id;
    int last_drag_tree_id;
    int current_find_tree_id;
    bool m_ignore_expanded;
};

TDE_NO_EXPORT inline PlayListView * PlayListItem::playListView () const {
    return static_cast <PlayListView *> (listView ());
}

TDE_NO_EXPORT inline PlayListItem * PlayListView::currentPlayListItem () const {
    return static_cast <PlayListItem *> (currentItem ());
}

TDE_NO_EXPORT inline PlayListItem * PlayListView::selectedPlayListItem() const {
    return static_cast <PlayListItem *> (selectedItem ());
}

} // namespace

#endif // PLAYLISTVIEW_H