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
|
/**
* Copyright (C) 2006 by Koos Vriezen <[email protected]>
*
* 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 <klistview.h>
#include "kmplayerplaylist.h"
class QFont;
class QPixmap;
class QPainter;
class QPopupMenu;
class QDropEvent;
namespace KMPlayer {
class View;
class PlayListView;
bool isDragValid (QDropEvent * de) KMPLAYER_NO_MBR_EXPORT;
/*
* An item in the playlist
*/
class KMPLAYER_NO_EXPORT PlayListItem : public QListViewItem {
public:
PlayListItem (QListViewItem *p, const NodePtr & e, PlayListView * lv);
PlayListItem (QListViewItem *p, const AttributePtr & e, PlayListView * lv);
PlayListItem (PlayListView *v, const NodePtr & d, QListViewItem * b);
KDE_NO_CDTOR_EXPORT ~PlayListItem () {}
void paintCell (QPainter * p, const QColorGroup & cg, int column, int width, int align);
void paintBranches(QPainter *p, const QColorGroup &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, QListViewItem * b, int flags);
KDE_NO_CDTOR_EXPORT ~RootPlayListItem () {}
void paintCell (QPainter * p, const QColorGroup & cg, int column, int width, int align);
QString source;
QString icon;
int id;
int flags;
bool show_all_nodes;
bool have_dark_nodes;
};
/*
* The playlist GUI
*/
class KMPLAYER_EXPORT PlayListView : public KListView {
Q_OBJECT
public:
enum Flags {
AllowDrops = 0x01, AllowDrag = 0x02,
InPlaceEdit = 0x04, TreeEdit = 0x08,
Moveable = 0x10, Deleteable = 0x20
};
PlayListView (QWidget * parent, View * view, KActionCollection * ac);
~PlayListView ();
void selectItem (const QString & txt);
void showAllNodes (RootPlayListItem *, bool show=true);
void setActiveForegroundColor (const QColor & c) { m_active_color = c; }
const QColor & activeColor () const { return m_active_color; }
int addTree (NodePtr r, const QString & src, const QString & ico, int flgs);
RootPlayListItem * rootItem (QListViewItem * item) const;
RootPlayListItem * rootItem (int id) const;
void setFont (const QFont &);
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 QString & title, const QString & url);
void prepareMenu (KMPlayer::PlayListItem * item, QPopupMenu * menu);
protected:
bool acceptDrag (QDropEvent* event) const;
QDragObject * dragObject ();
public slots:
void editCurrent ();
void rename (QListViewItem * item, int c);
void updateTree (int id, NodePtr root, NodePtr active, bool sel, bool open);
private slots:
void contextMenuItem (QListViewItem *, const QPoint &, int);
void itemExpanded (QListViewItem *);
void copyToClipboard ();
void addBookMark ();
void toggleShowAllNodes ();
void itemDropped (QDropEvent * e, QListViewItem * after);
void itemIsRenamed (QListViewItem * item);
void itemIsSelected (QListViewItem * 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;
QPopupMenu * m_itemmenu;
KAction * m_find;
KAction * m_find_next;
KFindDialog * m_find_dialog;
QPixmap folder_pix;
QPixmap auxiliary_pix;
QPixmap video_pix;
QPixmap unknown_pix;
QPixmap menu_pix;
QPixmap config_pix;
QPixmap url_pix;
QPixmap info_pix;
QPixmap img_pix;
QColor 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;
};
KDE_NO_EXPORT inline PlayListView * PlayListItem::playListView () const {
return static_cast <PlayListView *> (listView ());
}
KDE_NO_EXPORT inline PlayListItem * PlayListView::currentPlayListItem () const {
return static_cast <PlayListItem *> (currentItem ());
}
KDE_NO_EXPORT inline PlayListItem * PlayListView::selectedPlayListItem() const {
return static_cast <PlayListItem *> (selectedItem ());
}
} // namespace
#endif // PLAYLISTVIEW_H
|