Sayonara Player
PlaylistItemDelegate.h
1 /* PlaylistItemDelegateInterface.cpp */
2 
3 /* Copyright (C) 2011-2016 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 
22 #ifndef PLAYLISTITEMDELEGATEINTERFACE_H_
23 #define PLAYLISTITEMDELEGATEINTERFACE_H_
24 
25 
26 #include <QLabel>
27 #include <QListView>
28 #include <QStyledItemDelegate>
29 
30 #include "Helper/Settings/SayonaraClass.h"
31 
32 
34  public QStyledItemDelegate,
35  protected SayonaraClass
36 {
37 
38  Q_OBJECT
39 
40 public:
41  PlaylistItemDelegate(QListView *parent);
42  virtual ~PlaylistItemDelegate();
43 
44  void paint( QPainter *painter, const QStyleOptionViewItem &option,
45  const QModelIndex &index) const override;
46 
47 
48  QSize sizeHint(const QStyleOptionViewItem &option,
49  const QModelIndex &index) const override;
50 
51  QWidget* createEditor(QWidget *parent,
52  const QStyleOptionViewItem &option,
53  const QModelIndex &index) const override;
54 
55  void set_max_width(int w);
56  int get_row_height() const;
57 
58  void set_drag_index(int row);
59  bool is_drag_index(int row) const;
60  int get_drag_index() const;
61 
62 
63 
64 private:
65 
66  QListView* _parent=nullptr;
67 
68  int _row_height;
69  int _max_width;
70  int _drag_row;
71  bool _show_numbers;
72  QString _entry_template;
73 
74 
75 
76 private slots:
77  int draw_number(QPainter* painter, int number, QFont& font, QRect& rect) const;
78 
79  void _sl_show_numbers_changed();
80  void _sl_look_changed();
81 
82 };
83 
84 
85 #endif /* PLAYLISTITEMDELEGATEINTERFACE_H_ */
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: PlaylistItemDelegate.h:33