mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 16:58:06 -06:00
Code optimization
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#define __BITTORRENT_H__
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QUrl>
|
||||
#include <QStringList>
|
||||
#ifdef DISABLE_GUI
|
||||
@@ -76,20 +75,19 @@ public:
|
||||
static QBtSession* instance();
|
||||
static void drop();
|
||||
~QBtSession();
|
||||
QTorrentHandle getTorrentHandle(QString hash) const;
|
||||
QTorrentHandle getTorrentHandle(const QString &hash) const;
|
||||
std::vector<libtorrent::torrent_handle> getTorrents() const;
|
||||
bool isFilePreviewPossible(QString fileHash) const;
|
||||
bool isFilePreviewPossible(const QString& hash) const;
|
||||
qreal getPayloadDownloadRate() const;
|
||||
qreal getPayloadUploadRate() const;
|
||||
libtorrent::session_status getSessionStatus() const;
|
||||
int getListenPort() const;
|
||||
qreal getRealRatio(QString hash) const;
|
||||
QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const;
|
||||
qreal getRealRatio(const QString& hash) const;
|
||||
QHash<QString, TrackerInfos> getTrackersInfo(const QString &hash) const;
|
||||
bool hasActiveTorrents() const;
|
||||
bool hasDownloadingTorrents() const;
|
||||
//int getMaximumActiveDownloads() const;
|
||||
//int getMaximumActiveTorrents() const;
|
||||
int loadTorrentPriority(QString hash);
|
||||
inline QStringList getConsoleMessages() const { return consoleMessages; }
|
||||
inline QStringList getPeerBanMessages() const { return peerBanMessages; }
|
||||
inline libtorrent::session* getSession() const { return s; }
|
||||
@@ -106,16 +104,16 @@ public slots:
|
||||
QTorrentHandle addMagnetUri(QString magnet_uri, bool resumed=false);
|
||||
void loadSessionState();
|
||||
void saveSessionState();
|
||||
void downloadFromUrl(QString url);
|
||||
void deleteTorrent(QString hash, bool delete_local_files = false);
|
||||
void downloadFromUrl(const QString &url);
|
||||
void deleteTorrent(const QString &hash, bool delete_local_files = false);
|
||||
void startUpTorrents();
|
||||
void recheckTorrent(QString hash);
|
||||
void recheckTorrent(const QString &hash);
|
||||
void useAlternativeSpeedsLimit(bool alternative);
|
||||
qlonglong getETA(const QString& hash) const;
|
||||
/* Needed by Web UI */
|
||||
void pauseAllTorrents();
|
||||
void pauseTorrent(QString hash);
|
||||
void resumeTorrent(QString hash);
|
||||
void pauseTorrent(const QString &hash);
|
||||
void resumeTorrent(const QString &hash);
|
||||
void resumeAllTorrents();
|
||||
/* End Web UI */
|
||||
void preAllocateAllFiles(bool b);
|
||||
@@ -165,11 +163,11 @@ public slots:
|
||||
void recursiveTorrentDownload(const QTorrentHandle &h);
|
||||
|
||||
private:
|
||||
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString::null, QString root_folder=QString::null);
|
||||
bool loadFastResumeData(QString hash, std::vector<char> &buf);
|
||||
void loadTorrentSettings(QTorrentHandle h);
|
||||
void loadTorrentTempData(QTorrentHandle h, QString savePath, bool magnet);
|
||||
libtorrent::add_torrent_params initializeAddTorrentParams(QString hash);
|
||||
QString getSavePath(const QString &hash, bool fromScanDir = false, QString filePath = QString::null, QString root_folder=QString::null);
|
||||
bool loadFastResumeData(const QString &hash, std::vector<char> &buf);
|
||||
void loadTorrentSettings(QTorrentHandle &h);
|
||||
void loadTorrentTempData(QTorrentHandle &h, QString savePath, bool magnet);
|
||||
libtorrent::add_torrent_params initializeAddTorrentParams(const QString &hash);
|
||||
libtorrent::entry generateFilePriorityResumeData(boost::intrusive_ptr<libtorrent::torrent_info> &t, const std::vector<int> &fp);
|
||||
|
||||
private slots:
|
||||
@@ -178,27 +176,27 @@ private slots:
|
||||
void processBigRatios();
|
||||
void exportTorrentFiles(QString path);
|
||||
void saveTempFastResumeData();
|
||||
void sendNotificationEmail(QTorrentHandle h);
|
||||
void autoRunExternalProgram(QTorrentHandle h, bool async=true);
|
||||
void sendNotificationEmail(const QTorrentHandle &h);
|
||||
void autoRunExternalProgram(const QTorrentHandle &h, bool async=true);
|
||||
void cleanUpAutoRunProcess(int);
|
||||
void mergeTorrents(QTorrentHandle h_ex, boost::intrusive_ptr<libtorrent::torrent_info> t);
|
||||
void exportTorrentFile(QTorrentHandle h);
|
||||
void mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<libtorrent::torrent_info> t);
|
||||
void exportTorrentFile(const QTorrentHandle &h);
|
||||
void initWebUi();
|
||||
void handleIPFilterParsed(int ruleCount);
|
||||
void handleIPFilterError();
|
||||
|
||||
signals:
|
||||
void addedTorrent(const QTorrentHandle& h);
|
||||
void deletedTorrent(QString hash);
|
||||
void deletedTorrent(const QString &hash);
|
||||
void torrentAboutToBeRemoved(const QTorrentHandle &h);
|
||||
void pausedTorrent(const QTorrentHandle& h);
|
||||
void resumedTorrent(const QTorrentHandle& h);
|
||||
void finishedTorrent(const QTorrentHandle& h);
|
||||
void fullDiskError(const QTorrentHandle& h, QString msg);
|
||||
void trackerError(QString hash, QString time, QString msg);
|
||||
void trackerError(const QString &hash, QString time, QString msg);
|
||||
void trackerAuthenticationRequired(const QTorrentHandle& h);
|
||||
void newDownloadedTorrent(QString path, QString url);
|
||||
void updateFileSize(QString hash);
|
||||
void updateFileSize(const QString &hash);
|
||||
void downloadFromUrlFailure(QString url, QString reason);
|
||||
void torrentFinishedChecking(const QTorrentHandle& h);
|
||||
void metadataReceived(const QTorrentHandle &h);
|
||||
@@ -219,7 +217,7 @@ private:
|
||||
libtorrent::session *s;
|
||||
QPointer<QTimer> timerAlerts;
|
||||
QPointer<BandwidthScheduler> bd_scheduler;
|
||||
QMap<QUrl, QPair<QString, QString> > savepathLabel_fromurl;
|
||||
QHash<QUrl, QPair<QString, QString> > savepathLabel_fromurl;
|
||||
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||
QHash<QString, QString> savePathsToRemove;
|
||||
QStringList torrentsToPausedAfterChecking;
|
||||
|
||||
Reference in New Issue
Block a user