Simplify InfoHash, TrackerEntry class internals

This commit is contained in:
Chocobo1
2018-12-24 00:39:14 +08:00
parent 2a84345835
commit a5c53ff756
4 changed files with 36 additions and 53 deletions

View File

@@ -29,14 +29,12 @@
#include "trackerentry.h"
#include <QString>
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include <QUrl>
using namespace BitTorrent;
TrackerEntry::TrackerEntry(const QString &url)
: m_nativeEntry(libtorrent::announce_entry(url.toStdString()))
: m_nativeEntry(url.toStdString())
{
}
@@ -45,11 +43,6 @@ TrackerEntry::TrackerEntry(const libtorrent::announce_entry &nativeEntry)
{
}
TrackerEntry::TrackerEntry(const TrackerEntry &other)
: m_nativeEntry(other.m_nativeEntry)
{
}
QString TrackerEntry::url() const
{
return QString::fromStdString(m_nativeEntry.url);
@@ -74,23 +67,17 @@ TrackerEntry::Status TrackerEntry::status() const
return NotWorking;
}
void TrackerEntry::setTier(int value)
void TrackerEntry::setTier(const int value)
{
m_nativeEntry.tier = value;
}
TrackerEntry &TrackerEntry::operator=(const TrackerEntry &other)
{
this->m_nativeEntry = other.m_nativeEntry;
return *this;
}
bool TrackerEntry::operator==(const TrackerEntry &other) const
{
return (QUrl(url()) == QUrl(other.url()));
}
libtorrent::announce_entry TrackerEntry::nativeEntry() const
{
return m_nativeEntry;
}
bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right)
{
return (QUrl(left.url()) == QUrl(right.url()));
}