TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicquerytablewidget.cpp
Go to the documentation of this file.
2 #include "musicgiflabelwidget.h"
3 
5  : MusicFillItemTableWidget(parent),
6  m_networkRequest(nullptr)
7 {
9 
12 
13  connect(this, SIGNAL(cellDoubleClicked(int,int)), SLOT(itemDoubleClicked(int,int)));
14 }
15 
17 {
18  delete m_loadingLabel;
19  delete m_labelDelegate;
20  delete m_networkRequest;
21 }
22 
24 {
25  delete m_networkRequest;
26  m_networkRequest = query;
27  connect(m_networkRequest, SIGNAL(clearItems()), SLOT(removeItems()));
28  connect(m_networkRequest, SIGNAL(downLoadDataChanged(QString)), SLOT(createFinishedItem()));
30 }
31 
33 {
34  return m_networkRequest;
35 }
36 
37 void MusicQueryTableWidget::itemCellClicked(int row, int column)
38 {
40 
41  if(rowCount() > 0 && row == rowCount() - 1)
42  {
43  QTableWidgetItem *it = item(row, 0);
44  if(it && it->data(TTK_DISPLAY_ROLE).toString() == tr("Query more data"))
45  {
46  setItemDelegateForRow(row, nullptr);
47  clearSpans();
48  removeRow(row);
49 
50  setLoadingStatus(true);
52  }
53  }
54 }
55 
57 {
58  if(rowCount() > 0)
59  {
60  setItemDelegateForRow(rowCount() - 1, nullptr);
61  }
62 
64 }
65 
67 {
68  setLoadingStatus(false);
69 
70  setRowCount(rowCount() + 1);
71  const int count = rowCount() - 1;
72 
73  for(int i = 0; i < columnCount(); ++i)
74  {
75  setItem(count, i, new QTableWidgetItem);
76  }
77  setSpan(count, 0, 1, columnCount());
78 
79  QTableWidgetItem *it = item(count, 0);
80  if(it)
81  {
82  it->setData(TTK_DISPLAY_ROLE, m_networkRequest->pageValid() ? tr("Query more data") : tr("No more data"));
83  setItemDelegateForRow(count, m_labelDelegate);
84  }
85 }
86 
87 void MusicQueryTableWidget::resizeEvent(QResizeEvent *event)
88 {
89  MusicFillItemTableWidget::resizeEvent(event);
90  m_loadingLabel->move((width() - m_loadingLabel->width()) / 2, (height() - m_loadingLabel->height()) / 2);
91 }
92 
94 {
95  m_loadingLabel->run(status);
96 }
bool pageValid() const noexcept
virtual void setQueryInput(MusicAbstractQueryRequest *query)
The class of the label item delegate.
#define TTK_DISPLAY_ROLE
virtual void resizeEvent(QResizeEvent *event) override
MusicGifLabelWidget * m_loadingLabel
int pageIndex() const noexcept
virtual void itemCellClicked(int row, int column) override
void setStyleSheet(const QString &style) const
virtual void itemDoubleClicked(int row, int column)=0
The class of the fill item table widget.
MusicAbstractQueryRequest * queryInput() const
static const QString BackgroundStyle12
TTKLabelItemDelegate * m_labelDelegate
MusicQueryTableWidget(QWidget *parent=nullptr)
virtual void startToPage(int offset)
virtual void removeItems() override
The class of the search result info item.
The class of the float gif label widget.
virtual void itemCellClicked(int row, int column) override
The class of the abstract query download data from net.
virtual void createResultItem(const MusicResultInfoItem &songItem)=0
void setLoadingStatus(bool status) const
MusicAbstractQueryRequest * m_networkRequest