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