10 #include <QButtonGroup>
17 QHeaderView *headerView = horizontalHeader();
18 headerView->resizeSection(0, 30);
19 headerView->resizeSection(1, 273);
20 headerView->resizeSection(2, 105);
21 headerView->resizeSection(3, 105);
22 headerView->resizeSection(4, 55);
23 headerView->resizeSection(5, 23);
24 headerView->resizeSection(6, 26);
25 headerView->resizeSection(7, 26);
26 headerView->resizeSection(8, 26);
43 MusicSearchRecordList records;
49 records.insert(0, record);
86 QHeaderView *headerView = horizontalHeader();
91 for(
int i = 0; i < rowCount(); ++i)
93 QTableWidgetItem *it = item(i, 1);
107 if(column == 7 || column == 8)
109 setCursor(QCursor(Qt::PointingHandCursor));
130 if(column <= 0 || row < 0 || row >= rowCount() - 1)
146 const int count = rowCount();
147 setRowCount(count + 1);
149 QHeaderView *headerView = horizontalHeader();
150 QTableWidgetItem *item =
new QTableWidgetItem;
152 setItem(count, 0, item);
154 item =
new QTableWidgetItem;
156 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(1) - 15));
158 setItem(count, 1, item);
160 item =
new QTableWidgetItem;
162 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(2) - 30));
164 setItem(count, 2, item);
166 item =
new QTableWidgetItem;
168 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(3) - 30));
170 setItem(count, 3, item);
172 item =
new QTableWidgetItem(songItem.
m_duration);
174 setItem(count, 4, item);
176 item =
new QTableWidgetItem;
178 setItem(count, 5, item);
180 item =
new QTableWidgetItem;
181 item->setIcon(QIcon(
":/tiny/lb_server_type"));
182 item->setToolTip(songItem.
m_type);
183 setItem(count, 6, item);
185 item =
new QTableWidgetItem;
186 item->setIcon(QIcon(
":/contextMenu/btn_add"));
187 setItem(count, 7, item);
189 item =
new QTableWidgetItem;
190 item->setIcon(QIcon(
":/contextMenu/btn_download"));
191 setItem(count, 8, item);
196 const int row = currentRow();
205 switch(action->data().toInt())
219 MusicItemSearchTableWidget::contextMenuEvent(event);
222 m_actionGroup->addAction(menu.addAction(QIcon(
":/contextMenu/btn_play"), tr(
"Play")))->setData(4);
228 const QString &albumName = (currentRow() != -1 && rowCount() > 0) ? item(currentRow(), 3)->toolTip() : QString();
230 QAction *action =
m_actionGroup->addAction(tr(
"Search '%1'").arg(albumName));
232 menu.insertAction(lastAction, action);
234 menu.exec(QCursor::pos());
252 if(row >= songInfos.count())
290 QVBoxLayout *boxLayout =
new QVBoxLayout(
this);
291 boxLayout->setContentsMargins(0, 0, 0, 0);
292 boxLayout->setSpacing(0);
294 QWidget *toolWidget =
new QWidget(
this);
295 toolWidget->setFixedHeight(80);
296 QPalette plt(palette());
297 plt.setColor(QPalette::Background, Qt::white);
298 toolWidget->setAutoFillBackground(
true);
299 toolWidget->setPalette(plt);
302 boxLayout->addWidget(toolWidget);
303 #if !TTK_QT_VERSION_CHECK(5,0,0)
304 QWidget *containerWidget =
new QWidget(
this);
305 containerWidget->setAutoFillBackground(
true);
306 containerWidget->setPalette(plt);
308 QVBoxLayout *layout =
new QVBoxLayout(containerWidget);
309 layout->setContentsMargins(0, 0, 0, 0);
310 layout->setSpacing(0);
312 containerWidget->setLayout(layout);
313 boxLayout->addWidget(containerWidget);
317 setLayout(boxLayout);
371 for(
int i = 0; i < list.count(); ++i)
399 QVBoxLayout *wLayout =
new QVBoxLayout(widget);
400 wLayout->setContentsMargins(0, 0, 0, 0);
401 wLayout->setSpacing(0);
402 widget->setLayout(wLayout);
404 QWidget *funcWidget =
new QWidget(widget);
405 QHBoxLayout *funcLayout =
new QHBoxLayout(funcWidget);
406 funcLayout->setContentsMargins(0, 0, 10, 0);
407 funcLayout->setSpacing(10);
416 m_playButton->setIcon(QIcon(
":/contextMenu/btn_play_white"));
420 m_playButton->setCursor(QCursor(Qt::PointingHandCursor));
423 QPushButton *addButton =
new QPushButton(tr(
"Add"),
this);
424 addButton->setFixedSize(70, 25);
426 addButton->setCursor(QCursor(Qt::PointingHandCursor));
427 funcLayout->addWidget(addButton);
429 QPushButton *downloadButton =
new QPushButton(tr(
"Download"),
this);
430 downloadButton->setFixedSize(70, 25);
432 downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
433 funcLayout->addWidget(downloadButton);
435 QButtonGroup *buttonGroup =
new QButtonGroup(
this);
437 buttonGroup->addButton(addButton, 1);
438 buttonGroup->addButton(downloadButton, 2);
440 funcWidget->setLayout(funcLayout);
441 wLayout->addWidget(funcWidget);
445 QWidget *labelWidget =
new QWidget(widget);
446 QHBoxLayout *labelLayout =
new QHBoxLayout(labelWidget);
447 labelLayout->setContentsMargins(7, 0, 10, 0);
448 labelLayout->setSpacing(0);
451 QCheckBox *labelCheckBox =
new QCheckBox(
this);
453 connect(labelCheckBox, SIGNAL(clicked(
bool)),
m_tableWidget, SLOT(checkedItemsState(
bool)));
454 labelLayout->addWidget(labelCheckBox, headerView->sectionSize(0));
459 addButton->setFocusPolicy(Qt::NoFocus);
460 downloadButton->setFocusPolicy(Qt::NoFocus);
461 labelCheckBox->setFocusPolicy(Qt::NoFocus);
464 QLabel *label1 =
new QLabel(tr(
"Song"),
this);
466 labelLayout->addWidget(label1, headerView->sectionSize(1));
469 QLabel *label2 =
new QLabel(tr(
"Artist"),
this);
471 labelLayout->addWidget(label2, headerView->sectionSize(2));
474 QLabel *label3 =
new QLabel(tr(
"Album"),
this);
476 labelLayout->addWidget(label3, headerView->sectionSize(3));
479 QLabel *label4 =
new QLabel(tr(
"Operator"),
this);
481 labelLayout->addWidget(label4, headerView->sectionSize(4) + headerView->sectionSize(5) + headerView->sectionSize(6) * 3);
484 labelWidget->setLayout(labelLayout);
485 wLayout->addWidget(labelWidget);
TTK_MODULE_EXPORT QString generateSongName(const QString &title, const QString &artist)
virtual bool writeBuffer(const MusicSearchRecordList &items) overridefinal
The class of the search result data item.
static qint64 currentTimestamp() noexcept
bool fromFile(const QString &name)
The class of the music song property.
static const QString CheckBoxStyle01
CheckBox.
static constexpr unsigned int Color02
The class of the search history Config.
static const QString FontStyle01
Font.
virtual void startToSearchByID(const QString &value)
static void popup(const QString &text)
virtual bool readBuffer(MusicSearchRecordList &items) overridefinal
virtual void startToQueryResult(TTK::MusicSongInformation *info, int bitrate)
static const QString PushButtonStyle03
static const QString BackgroundStyle09
#define QtButtonGroupConnect(p, q, f, s)
Button group connect.
static const QString ColorStyle03
The class of the search result info item.
The class of the searched record item.
virtual void startToSearch(const QString &value)=0
QString queryServer() const
The class of the abstract query download data from net.
const TTK::MusicSongInformationList & items() const
#define TTKObjectCast(x, y)