Sayonara Player
PlaylistItemDelegate.h
1 /* PlaylistItemDelegate.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef PLAYLISTITEMDELEGATE_H_
22 #define PLAYLISTITEMDELEGATE_H_
23 
24 #include <QItemDelegate>
25 
26 #include "Helper/Settings/SayonaraClass.h"
27 
28 class QListView;
30  public QItemDelegate,
31  protected SayonaraClass
32 {
33  Q_OBJECT
34 
35 public:
36  PlaylistItemDelegate(QListView *parent);
37  virtual ~PlaylistItemDelegate();
38 
39  void paint( QPainter *painter, const QStyleOptionViewItem &option,
40  const QModelIndex &index) const override;
41 
42 
43  QSize sizeHint(const QStyleOptionViewItem &option,
44  const QModelIndex &index) const override;
45 
46  QWidget* createEditor(QWidget *parent,
47  const QStyleOptionViewItem &option,
48  const QModelIndex &index) const override;
49 
50  void set_max_width(int w);
51  int get_row_height() const;
52 
53  void set_drag_index(int row);
54  bool is_drag_index(int row) const;
55  int get_drag_index() const;
56 
57 
58 private:
59 
60  int _row_height;
61  int _max_width;
62  int _drag_row;
63  bool _show_numbers;
64  QString _entry_template;
65 
66 
67 private slots:
68  int draw_number(QPainter* painter, int number, QFont& font, QRect& rect) const;
69 
70  void _sl_show_numbers_changed();
71  void _sl_look_changed();
72 };
73 
74 #endif /* PLAYLISTITEMDELEGATEINTERFACE_H_ */
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
Definition: PlaylistItemDelegate.h:29