2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QMetaType>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
#include <libtransmission/transmission.h>
|
2012-12-22 20:35:19 +00:00
|
|
|
#include <libtransmission/quark.h>
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "CustomVariantType.h"
|
|
|
|
#include "Speed.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2013-09-08 18:39:37 +00:00
|
|
|
#ifdef ERROR
|
2017-04-19 12:04:45 +00:00
|
|
|
#undef ERROR
|
2013-09-08 18:39:37 +00:00
|
|
|
#endif
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
class QPixmap;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
class Prefs;
|
2015-06-10 21:27:11 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct tr_variant;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Peer
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
bool clientIsChoked;
|
|
|
|
bool clientIsInterested;
|
|
|
|
bool isDownloadingFrom;
|
|
|
|
bool isEncrypted;
|
|
|
|
bool isIncoming;
|
|
|
|
bool isUploadingTo;
|
|
|
|
bool peerIsChoked;
|
|
|
|
bool peerIsInterested;
|
|
|
|
QString address;
|
|
|
|
QString clientName;
|
|
|
|
QString flagStr;
|
|
|
|
int port;
|
|
|
|
Speed rateToClient;
|
|
|
|
Speed rateToPeer;
|
|
|
|
double progress;
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Peer)
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
typedef QList<Peer> PeerList;
|
2009-04-09 18:55:47 +00:00
|
|
|
Q_DECLARE_METATYPE(PeerList)
|
|
|
|
|
2010-04-03 14:23:29 +00:00
|
|
|
struct TrackerStat
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
QPixmap getFavicon() const;
|
|
|
|
|
|
|
|
bool hasAnnounced;
|
|
|
|
bool hasScraped;
|
|
|
|
bool isBackup;
|
|
|
|
bool lastAnnounceSucceeded;
|
|
|
|
bool lastAnnounceTimedOut;
|
|
|
|
bool lastScrapeSucceeded;
|
|
|
|
bool lastScrapeTimedOut;
|
|
|
|
int announceState;
|
|
|
|
int downloadCount;
|
|
|
|
int id;
|
|
|
|
int lastAnnouncePeerCount;
|
|
|
|
int lastAnnounceStartTime;
|
|
|
|
int lastAnnounceTime;
|
|
|
|
int lastScrapeStartTime;
|
|
|
|
int lastScrapeTime;
|
|
|
|
int leecherCount;
|
|
|
|
int nextAnnounceTime;
|
|
|
|
int nextScrapeTime;
|
|
|
|
int scrapeState;
|
|
|
|
int seederCount;
|
|
|
|
int tier;
|
|
|
|
QString announce;
|
|
|
|
QString host;
|
|
|
|
QString lastAnnounceResult;
|
|
|
|
QString lastScrapeResult;
|
2010-04-03 14:23:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(TrackerStat)
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
typedef QList<TrackerStat> TrackerStatsList;
|
2010-04-03 14:23:29 +00:00
|
|
|
Q_DECLARE_METATYPE(TrackerStatsList)
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
struct TorrentFile
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TorrentFile() :
|
|
|
|
wanted(true),
|
|
|
|
index(-1),
|
|
|
|
priority(0),
|
|
|
|
size(0),
|
|
|
|
have(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wanted;
|
|
|
|
int index;
|
|
|
|
int priority;
|
|
|
|
QString filename;
|
|
|
|
uint64_t size;
|
|
|
|
uint64_t have;
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
Q_DECLARE_METATYPE(TorrentFile)
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
typedef QList<TorrentFile> FileList;
|
|
|
|
Q_DECLARE_METATYPE(FileList)
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
class Torrent : public QObject
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2014-12-11 05:11:02 +00:00
|
|
|
Q_OBJECT
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2013-09-14 22:45:04 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
ID,
|
|
|
|
UPLOAD_SPEED,
|
|
|
|
DOWNLOAD_SPEED,
|
|
|
|
DOWNLOAD_DIR,
|
|
|
|
ACTIVITY,
|
|
|
|
NAME,
|
|
|
|
ERROR,
|
|
|
|
ERROR_STRING,
|
|
|
|
SIZE_WHEN_DONE,
|
|
|
|
LEFT_UNTIL_DONE,
|
|
|
|
HAVE_UNCHECKED,
|
|
|
|
HAVE_VERIFIED,
|
|
|
|
DESIRED_AVAILABLE,
|
|
|
|
TOTAL_SIZE,
|
|
|
|
PIECE_SIZE,
|
|
|
|
PIECE_COUNT,
|
|
|
|
PEERS_GETTING_FROM_US,
|
|
|
|
PEERS_SENDING_TO_US,
|
|
|
|
WEBSEEDS_SENDING_TO_US,
|
|
|
|
PERCENT_DONE,
|
|
|
|
METADATA_PERCENT_DONE,
|
|
|
|
PERCENT_VERIFIED,
|
|
|
|
DATE_ACTIVITY,
|
|
|
|
DATE_ADDED,
|
|
|
|
DATE_STARTED,
|
|
|
|
DATE_CREATED,
|
|
|
|
PEERS_CONNECTED,
|
|
|
|
ETA,
|
|
|
|
RATIO,
|
|
|
|
DOWNLOADED_EVER,
|
|
|
|
UPLOADED_EVER,
|
|
|
|
FAILED_EVER,
|
|
|
|
TRACKERS,
|
|
|
|
HOSTS,
|
|
|
|
TRACKERSTATS,
|
|
|
|
MIME_ICON,
|
|
|
|
SEED_RATIO_LIMIT,
|
|
|
|
SEED_RATIO_MODE,
|
|
|
|
SEED_IDLE_LIMIT,
|
|
|
|
SEED_IDLE_MODE,
|
|
|
|
DOWN_LIMIT,
|
|
|
|
DOWN_LIMITED,
|
|
|
|
UP_LIMIT,
|
|
|
|
UP_LIMITED,
|
|
|
|
HONORS_SESSION_LIMITS,
|
|
|
|
PEER_LIMIT,
|
|
|
|
HASH_STRING,
|
|
|
|
IS_FINISHED,
|
|
|
|
IS_PRIVATE,
|
|
|
|
IS_STALLED,
|
|
|
|
COMMENT,
|
|
|
|
CREATOR,
|
|
|
|
MANUAL_ANNOUNCE_TIME,
|
|
|
|
PEERS,
|
|
|
|
BANDWIDTH_PRIORITY,
|
|
|
|
QUEUE_POSITION,
|
|
|
|
//
|
|
|
|
PROPERTY_COUNT
|
2013-09-14 22:45:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList<tr_quark> KeyList;
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2017-04-20 16:02:19 +00:00
|
|
|
Torrent(Prefs const&, int id);
|
2017-04-19 12:04:45 +00:00
|
|
|
virtual ~Torrent();
|
|
|
|
|
|
|
|
int getBandwidthPriority() const
|
|
|
|
{
|
|
|
|
return getInt(BANDWIDTH_PRIORITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
int id() const
|
|
|
|
{
|
|
|
|
return getInt(ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString name() const
|
|
|
|
{
|
|
|
|
return getString(NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString creator() const
|
|
|
|
{
|
|
|
|
return getString(CREATOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString comment() const
|
|
|
|
{
|
|
|
|
return getString(COMMENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getPath() const
|
|
|
|
{
|
|
|
|
return getString(DOWNLOAD_DIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getError() const;
|
|
|
|
|
|
|
|
QString hashString() const
|
|
|
|
{
|
|
|
|
return getString(HASH_STRING);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasError() const
|
|
|
|
{
|
|
|
|
return !getError().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDone() const
|
|
|
|
{
|
|
|
|
return getSize(LEFT_UNTIL_DONE) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSeed() const
|
|
|
|
{
|
|
|
|
return haveVerified() >= totalSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPrivate() const
|
|
|
|
{
|
|
|
|
return getBool(IS_PRIVATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getSeedRatio(double& setme) const;
|
|
|
|
|
|
|
|
uint64_t haveVerified() const
|
|
|
|
{
|
|
|
|
return getSize(HAVE_VERIFIED);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t haveUnverified() const
|
|
|
|
{
|
|
|
|
return getSize(HAVE_UNCHECKED);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t desiredAvailable() const
|
|
|
|
{
|
|
|
|
return getSize(DESIRED_AVAILABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t haveTotal() const
|
|
|
|
{
|
|
|
|
return haveVerified() + haveUnverified();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t totalSize() const
|
|
|
|
{
|
|
|
|
return getSize(TOTAL_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t sizeWhenDone() const
|
|
|
|
{
|
|
|
|
return getSize(SIZE_WHEN_DONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t leftUntilDone() const
|
|
|
|
{
|
|
|
|
return getSize(LEFT_UNTIL_DONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t pieceSize() const
|
|
|
|
{
|
|
|
|
return getSize(PIECE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasMetadata() const
|
|
|
|
{
|
|
|
|
return getDouble(METADATA_PERCENT_DONE) >= 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMagnet() const
|
|
|
|
{
|
|
|
|
return magnetTorrent;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pieceCount() const
|
|
|
|
{
|
|
|
|
return getInt(PIECE_COUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
double ratio() const
|
|
|
|
{
|
|
|
|
return getDouble(RATIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
double percentComplete() const
|
|
|
|
{
|
2017-05-01 09:55:29 +00:00
|
|
|
return totalSize() != 0 ? haveTotal() / static_cast<double>(totalSize()) : 0;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double percentDone() const
|
|
|
|
{
|
|
|
|
return getDouble(PERCENT_DONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
double metadataPercentDone() const
|
|
|
|
{
|
|
|
|
return getDouble(METADATA_PERCENT_DONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t downloadedEver() const
|
|
|
|
{
|
|
|
|
return getSize(DOWNLOADED_EVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t uploadedEver() const
|
|
|
|
{
|
|
|
|
return getSize(UPLOADED_EVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t failedEver() const
|
|
|
|
{
|
|
|
|
return getSize(FAILED_EVER);
|
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
int compareTracker(Torrent const&) const;
|
|
|
|
int compareSeedRatio(Torrent const&) const;
|
|
|
|
int compareRatio(Torrent const&) const;
|
|
|
|
int compareETA(Torrent const&) const;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
bool hasETA() const
|
|
|
|
{
|
|
|
|
return getETA() >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getETA() const
|
|
|
|
{
|
|
|
|
return getInt(ETA);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime lastActivity() const
|
|
|
|
{
|
|
|
|
return getDateTime(DATE_ACTIVITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime lastStarted() const
|
|
|
|
{
|
|
|
|
return getDateTime(DATE_STARTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime dateAdded() const
|
|
|
|
{
|
|
|
|
return getDateTime(DATE_ADDED);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime dateCreated() const
|
|
|
|
{
|
|
|
|
return getDateTime(DATE_CREATED);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime manualAnnounceTime() const
|
|
|
|
{
|
|
|
|
return getDateTime(MANUAL_ANNOUNCE_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canManualAnnounce() const
|
|
|
|
{
|
|
|
|
return isReadyToTransfer() && (manualAnnounceTime() <= QDateTime::currentDateTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
int peersWeAreDownloadingFrom() const
|
|
|
|
{
|
|
|
|
return getInt(PEERS_SENDING_TO_US);
|
|
|
|
}
|
|
|
|
|
|
|
|
int webseedsWeAreDownloadingFrom() const
|
|
|
|
{
|
|
|
|
return getInt(WEBSEEDS_SENDING_TO_US);
|
|
|
|
}
|
|
|
|
|
|
|
|
int peersWeAreUploadingTo() const
|
|
|
|
{
|
|
|
|
return getInt(PEERS_GETTING_FROM_US);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isUploading() const
|
|
|
|
{
|
|
|
|
return peersWeAreUploadingTo() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int connectedPeers() const
|
|
|
|
{
|
|
|
|
return getInt(PEERS_CONNECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
int connectedPeersAndWebseeds() const
|
|
|
|
{
|
|
|
|
return connectedPeers() + getInt(WEBSEEDS_SENDING_TO_US);
|
|
|
|
}
|
|
|
|
|
|
|
|
Speed downloadSpeed() const
|
|
|
|
{
|
|
|
|
return Speed::fromBps(getSize(DOWNLOAD_SPEED));
|
|
|
|
}
|
|
|
|
|
|
|
|
Speed uploadSpeed() const
|
|
|
|
{
|
|
|
|
return Speed::fromBps(getSize(UPLOAD_SPEED));
|
|
|
|
}
|
|
|
|
|
|
|
|
double getVerifyProgress() const
|
|
|
|
{
|
|
|
|
return getDouble(PERCENT_VERIFIED);
|
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool hasFileSubstring(QString const& substr) const;
|
|
|
|
bool hasTrackerSubstring(QString const& substr) const;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
Speed uploadLimit() const
|
|
|
|
{
|
|
|
|
return Speed::fromKBps(getInt(UP_LIMIT));
|
|
|
|
}
|
|
|
|
|
|
|
|
Speed downloadLimit() const
|
|
|
|
{
|
|
|
|
return Speed::fromKBps(getInt(DOWN_LIMIT));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool uploadIsLimited() const
|
|
|
|
{
|
|
|
|
return getBool(UP_LIMITED);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool downloadIsLimited() const
|
|
|
|
{
|
|
|
|
return getBool(DOWN_LIMITED);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool honorsSessionLimits() const
|
|
|
|
{
|
|
|
|
return getBool(HONORS_SESSION_LIMITS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int peerLimit() const
|
|
|
|
{
|
|
|
|
return getInt(PEER_LIMIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
double seedRatioLimit() const
|
|
|
|
{
|
|
|
|
return getDouble(SEED_RATIO_LIMIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
tr_ratiolimit seedRatioMode() const
|
|
|
|
{
|
|
|
|
return static_cast<tr_ratiolimit>(getInt(SEED_RATIO_MODE));
|
|
|
|
}
|
|
|
|
|
|
|
|
int seedIdleLimit() const
|
|
|
|
{
|
|
|
|
return getInt(SEED_IDLE_LIMIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
tr_idlelimit seedIdleMode() const
|
|
|
|
{
|
|
|
|
return static_cast<tr_idlelimit>(getInt(SEED_IDLE_MODE));
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackerStatsList trackerStats() const
|
|
|
|
{
|
|
|
|
return myValues[TRACKERSTATS].value<TrackerStatsList>();
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList trackers() const
|
|
|
|
{
|
|
|
|
return myValues[TRACKERS].value<QStringList>();
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList hosts() const
|
|
|
|
{
|
|
|
|
return myValues[HOSTS].value<QStringList>();
|
|
|
|
}
|
|
|
|
|
|
|
|
PeerList peers() const
|
|
|
|
{
|
|
|
|
return myValues[PEERS].value<PeerList>();
|
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
FileList const& files() const
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
return myFiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
int queuePosition() const
|
|
|
|
{
|
|
|
|
return getInt(QUEUE_POSITION);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isStalled() const
|
|
|
|
{
|
|
|
|
return getBool(IS_STALLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString activityString() const;
|
|
|
|
|
|
|
|
tr_torrent_activity getActivity() const
|
|
|
|
{
|
|
|
|
return static_cast<tr_torrent_activity>(getInt(ACTIVITY));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isFinished() const
|
|
|
|
{
|
|
|
|
return getBool(IS_FINISHED);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPaused() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_STOPPED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWaitingToVerify() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_CHECK_WAIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isVerifying() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_CHECK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDownloading() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_DOWNLOAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWaitingToDownload() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_DOWNLOAD_WAIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSeeding() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_SEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWaitingToSeed() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_SEED_WAIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isReadyToTransfer() const
|
|
|
|
{
|
|
|
|
return getActivity() == TR_STATUS_DOWNLOAD || getActivity() == TR_STATUS_SEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isQueued() const
|
|
|
|
{
|
|
|
|
return isWaitingToDownload() || isWaitingToSeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void notifyComplete() const;
|
|
|
|
|
|
|
|
void update(tr_variant* dict);
|
|
|
|
|
|
|
|
void setMagnet(bool magnet)
|
|
|
|
{
|
|
|
|
magnetTorrent = magnet;
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon getMimeTypeIcon() const
|
|
|
|
{
|
|
|
|
return getIcon(MIME_ICON);
|
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
static KeyList const& getInfoKeys();
|
|
|
|
static KeyList const& getStatKeys();
|
|
|
|
static KeyList const& getExtraStatKeys();
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void torrentChanged(int id);
|
|
|
|
void torrentCompleted(int id);
|
|
|
|
|
|
|
|
private:
|
2015-06-12 22:12:12 +00:00
|
|
|
enum Group
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
INFO, // info fields that only need to be loaded once
|
|
|
|
STAT, // commonly-used stats that should be refreshed often
|
|
|
|
STAT_EXTRA, // rarely used; only refresh if details dialog is open
|
|
|
|
DERIVED // doesn't come from RPC
|
2015-06-12 22:12:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Property
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int id;
|
|
|
|
tr_quark key;
|
|
|
|
int type;
|
|
|
|
int group;
|
2015-06-12 22:12:12 +00:00
|
|
|
};
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private:
|
|
|
|
int getInt(int key) const;
|
|
|
|
bool getBool(int key) const;
|
|
|
|
QTime getTime(int key) const;
|
|
|
|
QIcon getIcon(int key) const;
|
|
|
|
double getDouble(int key) const;
|
|
|
|
qulonglong getSize(int key) const;
|
|
|
|
QString getString(int key) const;
|
|
|
|
QDateTime getDateTime(int key) const;
|
|
|
|
|
|
|
|
bool setInt(int key, int value);
|
|
|
|
bool setBool(int key, bool value);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool setIcon(int key, QIcon const&);
|
2017-04-19 12:04:45 +00:00
|
|
|
bool setDouble(int key, double);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool setString(int key, char const*);
|
2017-04-19 12:04:45 +00:00
|
|
|
bool setSize(int key, qulonglong);
|
2017-04-20 16:02:19 +00:00
|
|
|
bool setDateTime(int key, QDateTime const&);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* getMimeTypeString() const;
|
2017-04-19 12:04:45 +00:00
|
|
|
void updateMimeIcon();
|
|
|
|
|
|
|
|
static KeyList buildKeyList(Group group);
|
|
|
|
|
|
|
|
private:
|
2017-04-20 16:02:19 +00:00
|
|
|
Prefs const& myPrefs;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
QVariant myValues[PROPERTY_COUNT];
|
|
|
|
bool magnetTorrent;
|
2013-09-14 22:45:04 +00:00
|
|
|
FileList myFiles;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
static Property myProperties[];
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
Q_DECLARE_METATYPE(Torrent const*)
|