1 /**
2  * Copyright (C) 2006 by Koos Vriezen <koos.vriezen@gmail.com>
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Library General Public
6  *  License version 2 as published by the Free Software Foundation.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Library General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Library General Public License
14  *  along with this library; see the file COPYING.LIB.  If not, write to
15  *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
16  *  Boston, MA 02110-1301, USA.
17  **/
18 
19 #ifndef PLAYLISTVIEW_H
20 #define PLAYLISTVIEW_H
21 
22 #include "config-kmplayer.h"
23 
24 #include <QTreeView>
25 #include <QModelIndex>
26 
27 #include "kmplayerplaylist.h"
28 
29 class QFont;
30 class QPainter;
31 class QMenu;
32 class QDropEvent;
33 class QStyleOptionViewItem;
34 class QAction;
35 class KActionCollection;
36 class KFindDialog;
37 
38 namespace KMPlayer {
39 
40 class View;
41 class PlayItem;
42 class PlayModel;
43 class TopPlayItem;
44 
45 /*
46  * The playlist GUI
47  */
48 class KMPLAYER_EXPORT PlayListView : public QTreeView {
49     Q_OBJECT
50 public:
51     PlayListView(QWidget* parent, View* view, KActionCollection* ac) KDE_NO_CDTOR_EXPORT;
52     ~PlayListView() KDE_NO_CDTOR_EXPORT;
53     void selectItem (const QString & txt);
54     void showAllNodes(TopPlayItem*, bool show=true) KDE_NO_EXPORT;
setActiveForegroundColor(const QColor & c)55     void setActiveForegroundColor (const QColor & c) { m_active_color = c; }
activeColor()56     const QColor & activeColor () const { return m_active_color; }
57     TopPlayItem *rootItem (int id) const;
58     void setFont(const QFont&) KDE_NO_EXPORT;
59     PlayItem *selectedItem () const;
lastDragNode()60     NodePtr lastDragNode () const { return m_last_drag; }
lastDragTreeId()61     int lastDragTreeId () const { return last_drag_tree_id; }
62     bool isDragValid(QDropEvent* de) KDE_NO_EXPORT;
63     void paintCell (const QAbstractItemDelegate *,
64                     QPainter *, const QStyleOptionViewItem&, const QModelIndex);
65     QModelIndex index (PlayItem *item) const;
66     PlayModel *playModel () const;
67 signals:
68     void addBookMark (const QString & title, const QString & url);
69     void prepareMenu (KMPlayer::PlayItem * item, QMenu * menu);
70     void dropped (QDropEvent *event, KMPlayer::PlayItem *item);
71 protected:
72     void dragEnterEvent(QDragEnterEvent* event) KDE_NO_EXPORT;
73     void dropEvent(QDropEvent* event) KDE_NO_EXPORT;
74     void dragMoveEvent(QDragMoveEvent* event) KDE_NO_EXPORT;
drawBranches(QPainter *,const QRect &,const QModelIndex &)75     void drawBranches(QPainter*, const QRect&, const QModelIndex&) const KDE_NO_EXPORT {}
76     void contextMenuEvent(QContextMenuEvent* event) KDE_NO_EXPORT;
77 private slots:
78     void slotItemExpanded(const QModelIndex&) KDE_NO_EXPORT;
79     void copyToClipboard() KDE_NO_EXPORT;
80     void addBookMark() KDE_NO_EXPORT;
81     void toggleShowAllNodes() KDE_NO_EXPORT;
82     void slotCurrentItemChanged(QModelIndex, QModelIndex) KDE_NO_EXPORT;
83     void modelUpdating(const QModelIndex&) KDE_NO_EXPORT;
84     void modelUpdated(const QModelIndex&, const QModelIndex&, bool, bool) KDE_NO_EXPORT;
85     void renameSelected() KDE_NO_EXPORT;
86     void slotFind() KDE_NO_EXPORT;
87     void slotFindOk() KDE_NO_EXPORT;
88     void slotFindNext() KDE_NO_EXPORT;
89 private:
90     View * m_view;
91     QMenu * m_itemmenu;
92     QAction * m_find;
93     QAction * m_find_next;
94     QAction * m_edit_playlist_item;
95     KFindDialog * m_find_dialog;
96     QColor m_active_color;
97     NodePtrW m_current_find_elm;
98     NodePtrW m_last_drag;
99     AttributePtrW m_current_find_attr;
100     int last_drag_tree_id;
101     int current_find_tree_id;
102     bool m_ignore_expanded;
103 };
104 
105 } // namespace
106 
107 #endif // PLAYLISTVIEW_H
108