TTKMusicPlayer  4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsongitemselectedareawidget.cpp
Go to the documentation of this file.
2 #include "ui_musicsongitemselecteddialog.h"
4 #include "musicwidgetheaders.h"
5 #include "ttkclickedlabel.h"
6 
9 {
10  setAttribute(Qt::WA_TranslucentBackground, false);
11  setSelectionMode(QAbstractItemView::ExtendedSelection);
12  setColumnCount(2);
13 
14  QHeaderView *headerView = horizontalHeader();
15  headerView->resizeSection(0, 30);
16 #ifdef Q_OS_UNIX
17  headerView->resizeSection(1, 219);
18 #else
19  headerView->resizeSection(1, 222);
20 #endif
21  verticalScrollBar()->setStyleSheet(TTK::UI::ScrollBarStyle01);
22 }
23 
24 void MusicSongItemSelectedTableWidget::addCellItems(MusicSongItemList *items)
25 {
26  if(items->count() >= 4)
27  {
28  items->takeAt(1); //MUSIC_LOVEST_LIST
29  items->takeAt(1); //MUSIC_NETWORK_LIST
30  items->takeAt(1); //MUSIC_RECENT_LIST
31  }
32 
33  setRowCount(items->count());
34  QHeaderView *headerView = horizontalHeader();
35 
36  for(int i = 0; i < items->count(); ++i)
37  {
38  const MusicSongItem &v = items->at(i);
39 
40  QTableWidgetItem *item = new QTableWidgetItem;
41  item->setData(TTK_CHECKED_ROLE, Qt::Unchecked);
42  item->setData(TTK_DATA_ROLE, v.m_itemIndex);
43  setItem(i, 0, item);
44 
45  item = new QTableWidgetItem;
46  item->setToolTip(v.m_itemName);
47  item->setText(TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(1) - 30));
48  QtItemSetTextAlignment(item, Qt::AlignLeft | Qt::AlignVCenter);
49  setItem(i, 1, item);
50  }
51 }
52 
54 {
55  TTKIntList list;
56  for(int i = 0; i < rowCount(); ++i)
57  {
58  const QTableWidgetItem *it = item(i, 0);
59  if(it && it->data(TTK_CHECKED_ROLE) == Qt::Checked)
60  {
61  list << it->data(TTK_DATA_ROLE).toInt();
62  }
63  }
64  return list;
65 }
66 
67 
68 
70  : MusicAbstractMoveDialog(parent),
72 {
73  m_ui->setupUi(this);
74  setFixedSize(size());
75  setBackgroundLabel(m_ui->background);
76 
77  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
78  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
79  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
80  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
81  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
82 
83  m_ui->confirmButton->setStyleSheet(TTK::UI::PushButtonStyle04);
84  m_ui->selectAllCheckButton->setStyleSheet(TTK::UI::CheckBoxStyle01);
85 #ifdef Q_OS_UNIX
86  m_ui->confirmButton->setFocusPolicy(Qt::NoFocus);
87  m_ui->selectAllCheckButton->setFocusPolicy(Qt::NoFocus);
88 #endif
89 
90  connect(m_ui->confirmButton, SIGNAL(clicked()), SLOT(confirmButtonClicked()));
91  connect(m_ui->selectAllCheckButton, SIGNAL(clicked(bool)), m_ui->itemTableWidget, SLOT(checkedItemsStatus(bool)));
92 }
93 
95 {
96  delete m_ui;
97 }
98 
99 void MusicSongItemSelectedDialog::addCellItems(MusicSongItemList *items)
100 {
101  m_ui->itemTableWidget->addCellItems(items);
102 }
103 
105 {
106  Q_EMIT itemListChanged(m_ui->itemTableWidget->checkedDataList());
107  accept();
108 }
109 
110 
111 
113  : QWidget(parent),
114  m_selected(false)
115 {
116  m_label = new QLabel(tr("Range:"));
117  m_itemLabel = new QLabel(tr("All List"));
118  m_modifiedItemButton = new TTKClickedLabel(tr("Mod"));
119 
120  m_label->setFixedWidth(60);
121  m_itemLabel->setFixedWidth(75);
122  m_modifiedItemButton->setFixedWidth(30);
123 
125  m_itemLabel->setStyleSheet(TTK::UI::ColorStyle04);
127 
128  QHBoxLayout *layout = new QHBoxLayout(this);
129  layout->setContentsMargins(0, 0, 0, 0);
130  layout->addWidget(m_label);
131  layout->addWidget(m_itemLabel);
132  layout->addWidget(m_modifiedItemButton);
133  setLayout(layout);
134 
135  connect(m_modifiedItemButton, SIGNAL(clicked()), SLOT(modifiedItemButtonClicked()));
136 }
137 
139 {
140  delete m_label;
141  delete m_itemLabel;
142  delete m_modifiedItemButton;
143 }
144 
146 {
147  MusicSongItemList items;
149 
150  MusicSongList selectedSongs;
151  for(const MusicSongItem &item : qAsConst(items))
152  {
153  if(m_selected)
154  {
155  if(m_items.contains(item.m_itemIndex))
156  {
157  selectedSongs << item.m_songs;
158  }
159  }
160  else
161  {
162  if(TTK::playlistRowValid(item.m_itemIndex))
163  {
164  selectedSongs << item.m_songs;
165  }
166  }
167  }
168  return selectedSongs;
169 }
170 
172 {
173  MusicSongItemList items;
175 
176  m_selected = true;
177 
179  connect(&widget, SIGNAL(itemListChanged(TTKIntList)), SLOT(itemListChanged(TTKIntList)));
180  widget.addCellItems(&items);
181  widget.exec();
182 
183  Q_EMIT confirmChanged();
184 }
185 
187 {
188  m_items = items;
189  m_itemLabel->setText(tr("Custom List"));
190 }
void setBackgroundLabel(QLabel *label)
The class of the song item selected dialog widget.
TTK_MODULE_EXPORT bool playlistRowValid(int index)
Definition: musicsong.cpp:95
static const QString CheckBoxStyle01
CheckBox.
voidpf void uLong size
Definition: ioapi.h:136
MusicSongItemSelectedTableWidget(QWidget *parent=nullptr)
static const QString ColorStyle04
Definition: musicuiobject.h:46
#define QtItemSetTextAlignment(p, a)
Item text alignment.
Definition: ttkqtcompat.h:45
The class of the label widget that can click.
The class of the fill item table widget.
static const QString FontStyle01
Font.
void addCellItems(MusicSongItemList *items)
QList< int > TTKIntList
Definition: ttkqtglobal.h:204
#define qAsConst
Definition: ttkqtglobal.h:51
static const QString ColorStyle02
Definition: musicuiobject.h:40
static const QString ScrollBarStyle01
ScrollBar.
void itemListChanged(const TTKIntList &items)
static const QString PushButtonStyle04
static MusicSongsContainerWidget * instance()
TTK_MODULE_EXPORT QString elidedText(const QFont &font, const QString &text, Qt::TextElideMode mode, int width)
void querySongItemList(MusicSongItemList &songs)
The class of the moving dialog base.
static const QString ColorStyle07
Definition: musicuiobject.h:55
The class of the music song item.
Definition: musicsong.h:161
MusicSongItemSelectedDialog(QWidget *parent=nullptr)
QString m_itemName
Definition: musicsong.h:165
static const QString ToolButtonStyle04
Ui::MusicSongItemSelectedDialog * m_ui
#define TTK_CHECKED_ROLE
#define TTK_DATA_ROLE