TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicdownloadmanager.h
Go to the documentation of this file.
1 #ifndef MUSICDOWNLOADMANAGER_H
2 #define MUSICDOWNLOADMANAGER_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2025 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "ttksingleton.h"
23 #include "musicnetworkdefines.h"
24 
29 {
30  qint64 m_timestamp;
31  QObject *m_object;
33 
35  : m_timestamp(-1),
36  m_object(nullptr),
37  m_type(TTK::Record::NormalDownload)
38  {
39 
40  }
41 
42  MusicDownLoadPairData(qint64 t) noexcept
44  {
45  m_timestamp = t;
46  }
47 
48  MusicDownLoadPairData(qint64 t, QObject *object, TTK::Record type) noexcept
49  : m_timestamp(t),
50  m_object(object),
51  m_type(type)
52  {
53 
54  }
55 
56  inline bool operator< (const MusicDownLoadPairData &other) const noexcept
57  {
58  return m_timestamp < other.m_timestamp;
59  }
60 
61  inline bool operator== (const MusicDownLoadPairData &other) const noexcept
62  {
63  return m_timestamp == other.m_timestamp;
64  }
65 };
66 
71 {
72  Q_OBJECT
75 public:
79  void connectMultiNetwork(QObject *object);
83  void removeMultiNetwork(QObject *object);
84 
88  void connectNetworkData(const MusicDownLoadPairData &pair);
92  void reconnectNetworkData(const MusicDownLoadPairData &pair);
96  void removeNetworkData(const MusicDownLoadPairData &pair);
97 
98 private Q_SLOTS:
102  void downloadProgressChanged(float percent, const QString &total, qint64 time);
103 
104 private:
105  QObjectList m_objects;
106  QList<MusicDownLoadPairData> m_datas;
107 
108 };
109 
110 #define G_DOWNLOAD_MANAGER_PTR makeMusicDownLoadManager()
112 
113 #endif // MUSICDOWNLOADMANAGER_H
#define TTK_MODULE_EXPORT
QList< MusicDownLoadPairData > m_datas
bool operator==(const TTKOptional< T > &v, const T &other)
Definition: ttkoptional.h:144
TTK_MODULE_EXPORT MusicDownLoadManager * makeMusicDownLoadManager()
#define TTK_DECLARE_SINGLETON_CLASS(Class)
// Singleton Macro // //
Definition: ttksingleton.h:86
MusicDownLoadPairData(qint64 t) noexcept
The namespace of the application object.
Definition: ttkcompat.h:24
The class of the produce the download manager.
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:164
The class of the download manager pair.
MusicDownLoadPairData(qint64 t, QObject *object, TTK::Record type) noexcept
constexpr bool operator<(int128_t, int128_t)
Definition: int128.h:634