TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkitemdelegate.h
Go to the documentation of this file.
1 #ifndef TTKITEMDELEGATE_H
2 #define TTKITEMDELEGATE_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QItemDelegate>
23 #include "ttkmoduleexport.h"
24 
25 #define TTK_DATA_ROLE Qt::UserRole + 101
26 #define TTK_TIME_ROLE Qt::UserRole + 102
27 #define TTK_CHECKED_ROLE Qt::UserRole + 103
28 #define TTK_DISPLAY_ROLE Qt::UserRole + 104
29 #define TTK_ENABLED_ROLE Qt::UserRole + 105
30 #define TTK_PROGRESS_ROLE Qt::UserRole + 110
31 
32 class QLabel;
33 class QCheckBox;
34 class QPushButton;
35 class QProgressBar;
36 
40 class TTK_MODULE_EXPORT TTKAbstractItemDelegate : public QItemDelegate
41 {
42  Q_OBJECT
44 public:
45  enum Module
46  {
47  Null = 0x0,
48  DisplayMode = 0x1,
49  ElideMode = 0x2,
50  TreeMode = 0x4
51  };
52 
56  explicit TTKAbstractItemDelegate(QObject* parent = nullptr);
57 
61  inline void setModuleMode(TTKUInt8 mode) { m_mode = mode; }
62 
66  void setStyleSheet(const QString &style) const;
67 
71  virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &) const override final;
75  virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
76 
77 protected:
78  TTKUInt8 m_mode;
79  QWidget *m_container;
80 
81 };
82 
83 
88 {
89  Q_OBJECT
91 public:
95  explicit TTKCheckBoxItemDelegate(QObject* parent = nullptr);
100 
104  virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override final;
105 
106 Q_SIGNALS:
110  void buttonChecked();
111 
112 private:
114  QCheckBox *m_checkBox;
115 
116 };
117 
118 
123 {
124  Q_OBJECT
126 public:
130  explicit TTKProgressBarItemDelegate(QObject* parent = nullptr);
135 
139  virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override final;
140 
141 private:
142  QProgressBar *m_progress;
143 
144 };
145 
146 
151 {
152  Q_OBJECT
154 public:
158  explicit TTKLabelItemDelegate(QObject* parent = nullptr);
163 
167  void setAlignment(Qt::Alignment alignment) const;
168 
172  virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override final;
173 
174 private:
175  QLabel *m_label;
176 
177 };
178 
179 
184 {
185  Q_OBJECT
187 public:
191  explicit TTKPushButtonItemDelegate(QObject* parent = nullptr);
196 
200  virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override final;
201 
202 private:
203  QPushButton *m_pushButton;
204 
205 };
206 
207 #endif // TTKITEMDELEGATE_H
#define TTK_MODULE_EXPORT
The class of the label item delegate.
The class of the progress bar item delegate.
unsigned char TTKUInt8
Definition: ttkglobal.h:107
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
The class of the push button item delegate.
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
void setModuleMode(TTKUInt8 mode)
The class of the abstract item delegate.
const char int mode
Definition: ioapi.h:135
#define const
Definition: zconf.h:233
The class of the checkbox item delegate.