File indexing completed on 2024-04-21 08:44:12

0001 /*
0002     SPDX-FileCopyrightText: 2006 Koos Vriezen <koos.vriezen@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef PLAYLISTVIEW_H
0008 #define PLAYLISTVIEW_H
0009 
0010 #include "config-kmplayer.h"
0011 
0012 #include <QTreeView>
0013 #include <QModelIndex>
0014 
0015 #include "kmplayerplaylist.h"
0016 
0017 class QFont;
0018 class QPainter;
0019 class QMenu;
0020 class QDropEvent;
0021 class QStyleOptionViewItem;
0022 class QAction;
0023 class KActionCollection;
0024 class KFindDialog;
0025 
0026 namespace KMPlayer {
0027 
0028 class View;
0029 class PlayItem;
0030 class PlayModel;
0031 class TopPlayItem;
0032 
0033 /*
0034  * The playlist GUI
0035  */
0036 class KMPLAYERCOMMON_EXPORT PlayListView : public QTreeView
0037 {
0038     Q_OBJECT
0039     friend class PartBase;
0040 public:
0041     PlayListView(QWidget* parent, View* view, KActionCollection* ac);
0042     ~PlayListView() override;
0043     void selectItem (const QString & txt);
0044     void showAllNodes(TopPlayItem*, bool show=true) KMPLAYERCOMMON_NO_EXPORT;
0045     void setActiveForegroundColor (const QColor & c) { m_active_color = c; }
0046     const QColor & activeColor () const { return m_active_color; }
0047     TopPlayItem *rootItem (int id) const;
0048     void setFont(const QFont&) KMPLAYERCOMMON_NO_EXPORT;
0049     PlayItem *selectedItem () const;
0050     NodePtr lastDragNode () const { return m_last_drag; }
0051     int lastDragTreeId () const { return last_drag_tree_id; }
0052     bool isDragValid(QDropEvent* de) KMPLAYERCOMMON_NO_EXPORT;
0053     void paintCell (const QAbstractItemDelegate *,
0054                     QPainter *, const QStyleOptionViewItem&, const QModelIndex);
0055     QModelIndex index (PlayItem *item) const;
0056     PlayModel *playModel () const;
0057 Q_SIGNALS:
0058     void addBookMark (const QString & title, const QString & url);
0059     void prepareMenu (KMPlayer::PlayItem * item, QMenu * menu);
0060     void dropped (QDropEvent *event, KMPlayer::PlayItem *item);
0061 protected:
0062     void dragEnterEvent(QDragEnterEvent* event) override KMPLAYERCOMMON_NO_EXPORT;
0063     void dropEvent(QDropEvent* event) override KMPLAYERCOMMON_NO_EXPORT;
0064     void dragMoveEvent(QDragMoveEvent* event) override KMPLAYERCOMMON_NO_EXPORT;
0065     void drawBranches(QPainter*, const QRect&, const QModelIndex&) const override KMPLAYERCOMMON_NO_EXPORT {}
0066     void contextMenuEvent(QContextMenuEvent* event) override KMPLAYERCOMMON_NO_EXPORT;
0067 private Q_SLOTS:
0068     void slotItemExpanded(const QModelIndex&) KMPLAYERCOMMON_NO_EXPORT;
0069     void copyToClipboard() KMPLAYERCOMMON_NO_EXPORT;
0070     void addBookMark() KMPLAYERCOMMON_NO_EXPORT;
0071     void toggleShowAllNodes() KMPLAYERCOMMON_NO_EXPORT;
0072     void slotCurrentItemChanged(QModelIndex, QModelIndex) KMPLAYERCOMMON_NO_EXPORT;
0073     void modelUpdating(const QModelIndex&) KMPLAYERCOMMON_NO_EXPORT;
0074     void modelUpdated(const QModelIndex&, const QModelIndex&, bool, bool) KMPLAYERCOMMON_NO_EXPORT;
0075     void renameSelected() KMPLAYERCOMMON_NO_EXPORT;
0076     void slotFind() KMPLAYERCOMMON_NO_EXPORT;
0077     void slotFindOk() KMPLAYERCOMMON_NO_EXPORT;
0078     void slotFindNext() KMPLAYERCOMMON_NO_EXPORT;
0079 private:
0080     View * m_view;
0081     QMenu * m_itemmenu;
0082     QAction * m_find;
0083     QAction * m_find_next;
0084     QAction * m_edit_playlist_item;
0085     KFindDialog * m_find_dialog;
0086     QColor m_active_color;
0087     NodePtrW m_current_find_elm;
0088     NodePtrW m_last_drag;
0089     AttributePtrW m_current_find_attr;
0090     int last_drag_tree_id;
0091     int current_find_tree_id;
0092     bool m_ignore_expanded;
0093 };
0094 
0095 } // namespace
0096 
0097 #endif // PLAYLISTVIEW_H