File indexing completed on 2024-04-14 15:01:15

0001 /**
0002  * Copyright (C) 2006 by Koos Vriezen <koos.vriezen@gmail.com>
0003  *
0004  *  This library is free software; you can redistribute it and/or
0005  *  modify it under the terms of the GNU Library General Public
0006  *  License version 2 as published by the Free Software Foundation.
0007  *
0008  *  This library is distributed in the hope that it will be useful,
0009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011  *  Library General Public License for more details.
0012  *
0013  *  You should have received a copy of the GNU Library General Public License
0014  *  along with this library; see the file COPYING.LIB.  If not, write to
0015  *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
0016  *  Boston, MA 02110-1301, USA.
0017  **/
0018 
0019 #ifndef PLAYLISTVIEW_H
0020 #define PLAYLISTVIEW_H
0021 
0022 #include "config-kmplayer.h"
0023 
0024 #include <QTreeView>
0025 #include <QModelIndex>
0026 
0027 #include "kmplayerplaylist.h"
0028 
0029 class QFont;
0030 class QPainter;
0031 class QMenu;
0032 class QDropEvent;
0033 class QStyleOptionViewItem;
0034 class QAction;
0035 class KActionCollection;
0036 class KFindDialog;
0037 
0038 namespace KMPlayer {
0039 
0040 class View;
0041 class PlayItem;
0042 class PlayModel;
0043 class TopPlayItem;
0044 
0045 /*
0046  * The playlist GUI
0047  */
0048 class KMPLAYER_EXPORT PlayListView : public QTreeView {
0049     Q_OBJECT
0050 public:
0051     PlayListView(QWidget* parent, View* view, KActionCollection* ac) KDE_NO_CDTOR_EXPORT;
0052     ~PlayListView() KDE_NO_CDTOR_EXPORT;
0053     void selectItem (const QString & txt);
0054     void showAllNodes(TopPlayItem*, bool show=true) KDE_NO_EXPORT;
0055     void setActiveForegroundColor (const QColor & c) { m_active_color = c; }
0056     const QColor & activeColor () const { return m_active_color; }
0057     TopPlayItem *rootItem (int id) const;
0058     void setFont(const QFont&) KDE_NO_EXPORT;
0059     PlayItem *selectedItem () const;
0060     NodePtr lastDragNode () const { return m_last_drag; }
0061     int lastDragTreeId () const { return last_drag_tree_id; }
0062     bool isDragValid(QDropEvent* de) KDE_NO_EXPORT;
0063     void paintCell (const QAbstractItemDelegate *,
0064                     QPainter *, const QStyleOptionViewItem&, const QModelIndex);
0065     QModelIndex index (PlayItem *item) const;
0066     PlayModel *playModel () const;
0067 signals:
0068     void addBookMark (const QString & title, const QString & url);
0069     void prepareMenu (KMPlayer::PlayItem * item, QMenu * menu);
0070     void dropped (QDropEvent *event, KMPlayer::PlayItem *item);
0071 protected:
0072     void dragEnterEvent(QDragEnterEvent* event) KDE_NO_EXPORT;
0073     void dropEvent(QDropEvent* event) KDE_NO_EXPORT;
0074     void dragMoveEvent(QDragMoveEvent* event) KDE_NO_EXPORT;
0075     void drawBranches(QPainter*, const QRect&, const QModelIndex&) const KDE_NO_EXPORT {}
0076     void contextMenuEvent(QContextMenuEvent* event) KDE_NO_EXPORT;
0077 private slots:
0078     void slotItemExpanded(const QModelIndex&) KDE_NO_EXPORT;
0079     void copyToClipboard() KDE_NO_EXPORT;
0080     void addBookMark() KDE_NO_EXPORT;
0081     void toggleShowAllNodes() KDE_NO_EXPORT;
0082     void slotCurrentItemChanged(QModelIndex, QModelIndex) KDE_NO_EXPORT;
0083     void modelUpdating(const QModelIndex&) KDE_NO_EXPORT;
0084     void modelUpdated(const QModelIndex&, const QModelIndex&, bool, bool) KDE_NO_EXPORT;
0085     void renameSelected() KDE_NO_EXPORT;
0086     void slotFind() KDE_NO_EXPORT;
0087     void slotFindOk() KDE_NO_EXPORT;
0088     void slotFindNext() KDE_NO_EXPORT;
0089 private:
0090     View * m_view;
0091     QMenu * m_itemmenu;
0092     QAction * m_find;
0093     QAction * m_find_next;
0094     QAction * m_edit_playlist_item;
0095     KFindDialog * m_find_dialog;
0096     QColor m_active_color;
0097     NodePtrW m_current_find_elm;
0098     NodePtrW m_last_drag;
0099     AttributePtrW m_current_find_attr;
0100     int last_drag_tree_id;
0101     int current_find_tree_id;
0102     bool m_ignore_expanded;
0103 };
0104 
0105 } // namespace
0106 
0107 #endif // PLAYLISTVIEW_H