File indexing completed on 2024-05-05 04:51:41

0001 /*
0002     SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl>
0003     SPDX-FileCopyrightText: 1998-2010 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef K3B_AUDIO_PROJECT_DELEGATE_H
0009 #define K3B_AUDIO_PROJECT_DELEGATE_H
0010 
0011 #include <QStyledItemDelegate>
0012 
0013 class QAbstractItemView;
0014 
0015 namespace K3b {
0016 
0017     class AudioProjectDelegate : public QStyledItemDelegate
0018     {
0019         Q_OBJECT
0020 
0021     public:
0022         explicit AudioProjectDelegate( QAbstractItemView& view, QObject* parent = 0 );
0023         ~AudioProjectDelegate() override;
0024 
0025         QWidget* createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
0026 
0027     public Q_SLOTS:
0028         void setPlayingTrack( const QModelIndex& index );
0029 
0030     protected:
0031         void initStyleOption( QStyleOptionViewItem* option, const QModelIndex& index ) const override;
0032         bool eventFilter( QObject* obj, QEvent* event ) override;
0033 
0034     private:
0035         QAbstractItemView& m_view;
0036         QPersistentModelIndex m_playingTrack;
0037         mutable QPersistentModelIndex m_current;
0038     };
0039 
0040 } // namespace K3b
0041 
0042 #endif // K3B_AUDIO_PROJECT_DELEGATE_H