TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicfillitemtablewidget.cpp
Go to the documentation of this file.
2 
5 {
6  setStyleSheet(styleSheet() + TTK::UI::TableWidgetStyle02);
7 
9 #if defined Q_OS_UNIX && !TTK_QT_VERSION_CHECK(5,7,0) //Fix linux selection-background-color stylesheet bug
10  TTK::Widget::setTransparent(this, QColor(220, 220, 220));
11 #endif
14  setItemDelegateForColumn(0, m_checkBoxDelegate);
15 }
16 
18 {
19  removeItems();
20  delete m_checkBoxDelegate;
21 }
22 
24 {
25  TTKIntList list;
26  for(int i = 0; i < rowCount(); ++i)
27  {
28  const QTableWidgetItem *it = item(i, 0);
29  if(it && it->data(TTK_CHECKED_ROLE) == Qt::Checked)
30  {
31  list << i;
32  }
33  }
34  return list;
35 }
36 
38 {
39  TTKIntList list;
40  for(int i = 0; i < rowCount(); ++i)
41  {
42  const QTableWidgetItem *it = item(i, 0);
43  if(it && it->data(TTK_CHECKED_ROLE) == Qt::Unchecked)
44  {
45  list << i;
46  }
47  }
48  return list;
49 }
50 
52 {
53  QTableWidgetItem *it = nullptr;
54  if(column == 0)
55  {
56  it = item(row, 0);
57  const Qt::CheckState status = TTKStaticCast(Qt::CheckState, it->data(TTK_CHECKED_ROLE).toInt());
58  it->setData(TTK_CHECKED_ROLE, status == Qt::Checked ? Qt::Unchecked : Qt::Checked);
59  }
60  else
61  {
62  if(m_previousClickRow != -1 && (it = item(m_previousClickRow, 0)))
63  {
64  it->setData(TTK_CHECKED_ROLE, Qt::Unchecked);
65  }
66 
67  m_previousClickRow = row;
68  item(row, 0)->setData(TTK_CHECKED_ROLE, Qt::Checked);
69  }
70 }
71 
73 {
74  for(int i = 0; i < rowCount(); ++i)
75  {
76  item(i, 0)->setData(TTK_CHECKED_ROLE, checked ? Qt::Checked : Qt::Unchecked);
77  }
78 
79  clearSelection();
80 }
81 
83 {
84  for(int i = 0; i < rowCount(); ++i)
85  {
86  item(i, 0)->setData(TTK_CHECKED_ROLE, checked ? Qt::Checked : Qt::Unchecked);
87  }
88 
89  if(!checked)
90  {
91  clearSelection();
92  setCurrentIndex(QModelIndex());
93  }
94  else
95  {
96  selectAll();
97  }
98 }
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:159
virtual void itemCellClicked(int row, int column) override
The class of the table widget base.
static const QString CheckBoxStyle01
CheckBox.
void setStyleSheet(const QString &style) const
MusicFillItemTableWidget(QWidget *parent=nullptr)
TTKCheckBoxItemDelegate * m_checkBoxDelegate
QList< int > TTKIntList
Definition: ttkqtglobal.h:188
TTK_MODULE_EXPORT void setTransparent(QWidget *widget, int alpha)
static const QString TableWidgetStyle02
TTKIntList uncheckedIndexList() const
The class of the checkbox item delegate.
#define TTK_CHECKED_ROLE