TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicdownloadmanager.cpp
Go to the documentation of this file.
1 #include "musicdownloadmanager.h"
2 #include "musicconnectionpool.h"
6 
8 {
9  m_queueList << object;
10  const QObject *to = G_CONNECTION_PTR->value(MusicDownloadStatusModule::className());
11  if(to)
12  {
13  connect(object, SIGNAL(downLoadDataChanged(QString)), to, SLOT(showDownLoadInfoFinished(QString)));
14  }
15 }
16 
18 {
19  const int index = m_queueList.indexOf(object);
20  if(index != -1)
21  {
22  m_queueList.takeAt(index);
23  }
24 }
25 
27 {
28  QString className;
29  switch(pair.m_type)
30  {
31  case TTK::Record::NormalDownload: className = MusicDownloadRecordTableWidget::className(); break;
32  case TTK::Record::CloudDownload: className = MusicCloudDownloadTableWidget::className(); break;
33  case TTK::Record::CloudUpload: className = MusicCloudUploadTableWidget::className(); break;
34  default: break;
35  }
36 
37  const QObject *to = G_CONNECTION_PTR->value(className);
38  if(to && pair.m_object)
39  {
40  connect(pair.m_object, SIGNAL(createDownloadItem(QString, qint64)), to, SLOT(createDownloadItem(QString, qint64)));
41  connect(pair.m_object, SIGNAL(downloadProgressChanged(float, QString, qint64)), to, SLOT(downloadProgressChanged(float, QString, qint64)));
42  }
43 
44  connect(pair.m_object, SIGNAL(downloadProgressChanged(float, QString, qint64)), SLOT(downloadProgressChanged(float, QString, qint64)));
45  m_pairList << pair;
46 }
47 
49 {
50  const int index = m_pairList.indexOf(pair);
51  if(index != -1)
52  {
53  MusicDownLoadPairData *p = &m_pairList[index];
54  disconnect(p->m_object, SIGNAL(createDownloadItem(QString, qint64)), pair.m_object, SLOT(createDownloadItem(QString, qint64)));
55  disconnect(p->m_object, SIGNAL(downloadProgressChanged(float, QString, qint64)), pair.m_object, SLOT(downloadProgressChanged(float, QString, qint64)));
56 
57  connect(p->m_object, SIGNAL(createDownloadItem(QString, qint64)), pair.m_object, SLOT(createDownloadItem(QString, qint64)));
58  connect(p->m_object, SIGNAL(downloadProgressChanged(float, QString, qint64)), pair.m_object, SLOT(downloadProgressChanged(float, QString, qint64)));
59  }
60 }
61 
63 {
64  const int index = m_pairList.indexOf(pair);
65  if(index != -1)
66  {
67  m_pairList.takeAt(index);
68  }
69 }
70 
71 void MusicDownLoadManager::downloadProgressChanged(float percent, const QString &total, qint64 time)
72 {
73  Q_UNUSED(total);
74  if(percent >= 100)
75  {
77  }
78 }
void removeDownload(const MusicDownLoadPairData &pair)
void reconnectDownload(const MusicDownLoadPairData &pair)
void removeNetworkMultiValue(QObject *object)
#define G_CONNECTION_PTR
QList< MusicDownLoadPairData > m_pairList
void connectNetworkMultiValue(QObject *object)
The class of the download manager pair.
void downloadProgressChanged(float percent, const QString &total, qint64 time)
void connectDownload(const MusicDownLoadPairData &pair)