11 #include <QButtonGroup>
18 QHeaderView *headerView = horizontalHeader();
19 headerView->resizeSection(0, 30);
20 headerView->resizeSection(1, 273);
21 headerView->resizeSection(2, 105);
22 headerView->resizeSection(3, 105);
23 headerView->resizeSection(4, 55);
24 headerView->resizeSection(5, 23);
25 headerView->resizeSection(6, 26);
26 headerView->resizeSection(7, 26);
27 headerView->resizeSection(8, 26);
51 MusicSearchRecordList records;
57 records.insert(0, record);
95 QHeaderView *headerView = horizontalHeader();
100 for(
int i = 0; i < rowCount(); ++i)
102 QTableWidgetItem *it = item(i, 1);
116 if(column == 7 || column == 8)
118 setCursor(QCursor(Qt::PointingHandCursor));
139 if(column <= 0 || row < 0 || row >= rowCount() - 1)
155 const int count = rowCount();
156 setRowCount(count + 1);
158 QHeaderView *headerView = horizontalHeader();
159 QTableWidgetItem *item =
new QTableWidgetItem;
161 setItem(count, 0, item);
163 item =
new QTableWidgetItem;
165 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(1) - 15));
167 setItem(count, 1, item);
169 item =
new QTableWidgetItem;
171 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(2) - 30));
173 setItem(count, 2, item);
175 item =
new QTableWidgetItem;
177 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(3) - 30));
179 setItem(count, 3, item);
181 item =
new QTableWidgetItem(songItem.
m_duration);
183 setItem(count, 4, item);
185 item =
new QTableWidgetItem;
187 setItem(count, 5, item);
189 item =
new QTableWidgetItem;
190 item->setIcon(QIcon(
":/tiny/lb_server_type"));
191 item->setToolTip(songItem.
m_type);
192 setItem(count, 6, item);
194 item =
new QTableWidgetItem;
195 item->setIcon(QIcon(
":/contextMenu/btn_add"));
196 setItem(count, 7, item);
198 item =
new QTableWidgetItem;
199 item->setIcon(QIcon(
":/contextMenu/btn_download"));
200 setItem(count, 8, item);
205 const int row = currentRow();
214 switch(action->data().toInt())
228 MusicItemSearchTableWidget::contextMenuEvent(event);
231 m_actionGroup->addAction(menu.addAction(QIcon(
":/contextMenu/btn_play"), tr(
"Play")))->setData(4);
237 const QString &albumName = (currentRow() != -1 && rowCount() > 0) ? item(currentRow(), 3)->toolTip() : QString();
239 QAction *action =
m_actionGroup->addAction(tr(
"Search '%1'").arg(albumName));
241 menu.insertAction(lastAction, action);
243 menu.exec(QCursor::pos());
261 if(row >= songInfos.count())
299 QVBoxLayout *boxLayout =
new QVBoxLayout(
this);
300 boxLayout->setContentsMargins(0, 0, 0, 0);
301 boxLayout->setSpacing(0);
303 QWidget *toolWidget =
new QWidget(
this);
304 toolWidget->setFixedHeight(80);
305 QPalette plt(palette());
306 plt.setColor(QPalette::Background, Qt::white);
307 toolWidget->setAutoFillBackground(
true);
308 toolWidget->setPalette(plt);
311 boxLayout->addWidget(toolWidget);
312 #if !TTK_QT_VERSION_CHECK(5,0,0)
313 QWidget *containerWidget =
new QWidget(
this);
314 containerWidget->setAutoFillBackground(
true);
315 containerWidget->setPalette(plt);
317 QVBoxLayout *layout =
new QVBoxLayout(containerWidget);
318 layout->setContentsMargins(0, 0, 0, 0);
319 layout->setSpacing(0);
321 containerWidget->setLayout(layout);
322 boxLayout->addWidget(containerWidget);
326 setLayout(boxLayout);
380 for(
int i = 0; i < list.count(); ++i)
408 QVBoxLayout *wLayout =
new QVBoxLayout(widget);
409 wLayout->setContentsMargins(0, 0, 0, 0);
410 wLayout->setSpacing(0);
411 widget->setLayout(wLayout);
413 QWidget *funcWidget =
new QWidget(widget);
414 QHBoxLayout *funcLayout =
new QHBoxLayout(funcWidget);
415 funcLayout->setContentsMargins(0, 0, 10, 0);
416 funcLayout->setSpacing(10);
425 m_playButton->setIcon(QIcon(
":/contextMenu/btn_play_white"));
429 m_playButton->setCursor(QCursor(Qt::PointingHandCursor));
432 QPushButton *addButton =
new QPushButton(tr(
"Add"),
this);
433 addButton->setFixedSize(70, 25);
435 addButton->setCursor(QCursor(Qt::PointingHandCursor));
436 funcLayout->addWidget(addButton);
438 QPushButton *downloadButton =
new QPushButton(tr(
"Download"),
this);
439 downloadButton->setFixedSize(70, 25);
441 downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
442 funcLayout->addWidget(downloadButton);
444 QButtonGroup *buttonGroup =
new QButtonGroup(
this);
446 buttonGroup->addButton(addButton, 1);
447 buttonGroup->addButton(downloadButton, 2);
449 funcWidget->setLayout(funcLayout);
450 wLayout->addWidget(funcWidget);
454 QWidget *labelWidget =
new QWidget(widget);
455 QHBoxLayout *labelLayout =
new QHBoxLayout(labelWidget);
456 labelLayout->setContentsMargins(7, 0, 10, 0);
457 labelLayout->setSpacing(0);
460 QCheckBox *labelCheckBox =
new QCheckBox(
this);
462 connect(labelCheckBox, SIGNAL(clicked(
bool)),
m_tableWidget, SLOT(checkedItemsState(
bool)));
463 labelLayout->addWidget(labelCheckBox, headerView->sectionSize(0));
468 addButton->setFocusPolicy(Qt::NoFocus);
469 downloadButton->setFocusPolicy(Qt::NoFocus);
470 labelCheckBox->setFocusPolicy(Qt::NoFocus);
473 QLabel *label1 =
new QLabel(tr(
"Song"),
this);
475 labelLayout->addWidget(label1, headerView->sectionSize(1));
478 QLabel *label2 =
new QLabel(tr(
"Artist"),
this);
480 labelLayout->addWidget(label2, headerView->sectionSize(2));
483 QLabel *label3 =
new QLabel(tr(
"Album"),
this);
485 labelLayout->addWidget(label3, headerView->sectionSize(3));
488 QLabel *label4 =
new QLabel(tr(
"Operator"),
this);
490 labelLayout->addWidget(label4, headerView->sectionSize(4) + headerView->sectionSize(5) + headerView->sectionSize(6) * 3);
493 labelWidget->setLayout(labelLayout);
494 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.
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)
void setQueryType(QueryType type)
static const QString PushButtonStyle03
static const QString BackgroundStyle09
#define QtButtonGroupConnect(p, q, f, s)
Button group connect.
static const QString ColorStyle03
static qint64 currentTimestamp()
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)