diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-09-09 01:25:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-09 01:25:01 -0400 |
| commit | 99fdbb2539227cec4fab534efc7420cfc5ca1a92 (patch) | |
| tree | 4fe70561a85d86b65cc4c6725541767684af09a7 /src/serverinfo.h | |
| parent | 73626b297904d50507bb7d5d1342120040e655e8 (diff) | |
| parent | d863e62c6e2f3c0daa50e16a0206f59558a7bb7e (diff) | |
Merge pull request #830 from isanae/settings-interface
Settings interface
Diffstat (limited to 'src/serverinfo.h')
| -rw-r--r-- | src/serverinfo.h | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/src/serverinfo.h b/src/serverinfo.h index 8e5e935a..af8f77c8 100644 --- a/src/serverinfo.h +++ b/src/serverinfo.h @@ -5,14 +5,66 @@ #include <QDate>
#include <QMetaType>
-struct ServerInfo
+class ServerInfo
{
- QString name;
- bool premium;
- QDate lastSeen;
- bool preferred;
+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
|
