blob: 00b4764347a389a3ca0cada253f0e64cfbb33bd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#ifndef SERVERINFO_H
#define SERVERINFO_H
#include <QDate>
#include <QMetaType>
#include <QString>
class ServerInfo
{
public:
using SpeedList = std::vector<int>;
ServerInfo();
ServerInfo(QString name, bool premium, QDate lastSeen, int preferred,
SpeedList lastDownloads);
const QString& name() const;
bool isPremium() const;
void setPremium(bool b);
const QDate& lastSeen() const;
void updateLastSeen();
int preferred() const;
void setPreferred(int i);
const SpeedList& lastDownloads() const;
int averageSpeed() const;
void addDownload(int bytesPerSecond);
private:
QString m_name;
bool m_premium;
QDate m_lastSeen;
int m_preferred;
SpeedList m_lastDownloads;
};
Q_DECLARE_METATYPE(ServerInfo)
class ServerList
{
public:
using container = std::vector<ServerInfo>;
using iterator = container::iterator;
using const_iterator = container::const_iterator;
void add(ServerInfo s);
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
std::size_t size() const;
bool empty() const;
container getPreferred() const;
// removes servers that haven't been seen in a while
//
void cleanup();
private:
container m_servers;
};
#endif // SERVERINFO_H
|