From 5f23cbc470fefdd877c5e4b68ac6ee6f815d1d9d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 7 Jun 2010 08:32:41 +0000 Subject: [PATCH] Use libtorrent version.hpp instead of our own DEFINE --- src/advancedsettings.h | 5 ++-- src/bittorrent.cpp | 47 +++++++++++++++++++------------------ src/bittorrent.h | 13 +++++----- src/createtorrent_imp.cpp | 3 ++- src/eventmanager.cpp | 7 +++--- src/options_imp.cpp | 7 +++--- src/preferences.h | 5 ++-- src/previewselect.h | 3 ++- src/propertieswidget.cpp | 7 +++--- src/qtorrenthandle.cpp | 7 +++--- src/qtorrenthandle.h | 5 ++-- src/torrentadditiondlg.h | 5 ++-- src/torrentpersistentdata.h | 3 ++- src/trackerlist.cpp | 5 ++-- src/trackerlist.h | 3 ++- src/transferlistwidget.cpp | 11 +++++---- src/transferlistwidget.h | 5 ++-- 17 files changed, 79 insertions(+), 62 deletions(-) diff --git a/src/advancedsettings.h b/src/advancedsettings.h index 3d952fc32..b5318ec60 100644 --- a/src/advancedsettings.h +++ b/src/advancedsettings.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "preferences.h" enum AdvSettingsCols {PROPERTY, VALUE}; @@ -73,7 +74,7 @@ public slots: Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked()); // Max Half-Open connections Preferences::setMaxHalfOpenConnections(spin_maxhalfopen->value()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Super seeding Preferences::enableSuperSeeding(cb_super_seeding->isChecked()); #endif @@ -164,7 +165,7 @@ protected slots: setItem(SUPER_SEEDING, PROPERTY, new QTableWidgetItem(tr("Strict super seeding"))); cb_super_seeding = new QCheckBox(); connect(cb_super_seeding, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); - #ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 cb_super_seeding->setChecked(Preferences::isSuperSeedingEnabled()); #else cb_super_seeding->setEnabled(false); diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 1ac5e2810..a5d31a223 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -51,7 +51,8 @@ #include "httpserver.h" #include "bandwidthscheduler.h" #include -#ifdef LIBTORRENT_0_15 +#include +#if LIBTORRENT_VERSION_MINOR > 14 #include #endif #include @@ -121,7 +122,7 @@ Bittorrent::Bittorrent() // Enabling plugins //s->add_extension(&create_metadata_plugin); s->add_extension(&create_ut_metadata_plugin); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 s->add_extension(create_lt_trackers_plugin); #endif if(Preferences::isPeXEnabled()) { @@ -141,7 +142,7 @@ Bittorrent::Bittorrent() connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); appendLabelToSavePath = Preferences::appendTorrentLabel(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 appendqBExtension = Preferences::useIncompleteFilesExtension(); #endif connect(m_scanFolders, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&))); @@ -154,7 +155,7 @@ session_proxy Bittorrent::asyncDeletion() { qDebug("Bittorrent session async deletion IN"); exiting = true; // Do some BT related saving -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 saveDHTEntry(); #endif saveSessionState(); @@ -171,7 +172,7 @@ Bittorrent::~Bittorrent() { qDebug("BTSession destructor IN"); if(!exiting) { // Do some BT related saving -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 saveDHTEntry(); #endif saveSessionState(); @@ -281,7 +282,7 @@ void Bittorrent::configureSession() { setDefaultTempPath(QString::null); } setAppendLabelToSavePath(Preferences::appendTorrentLabel()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 setAppendqBExtension(Preferences::useIncompleteFilesExtension()); #endif preAllocateAllFiles(Preferences::preAllocateAllFiles()); @@ -423,7 +424,7 @@ void Bittorrent::configureSession() { sessionSettings.stop_tracker_timeout = 1; //sessionSettings.announce_to_all_trackers = true; sessionSettings.auto_scrape_interval = 1200; // 20 minutes -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 sessionSettings.announce_to_all_trackers = true; sessionSettings.announce_to_all_tiers = true; //uTorrent behavior sessionSettings.auto_scrape_min_interval = 900; // 15 minutes @@ -858,7 +859,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { qDebug("addMagnetURI: using save_path: %s", qPrintable(savePath)); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Skip checking and directly start seeding (new in libtorrent v0.15) if(TorrentTempData::isSeedingMode(hash)){ p.seed_mode=true; @@ -1082,7 +1083,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr qDebug("addTorrent: using save_path: %s", qPrintable(savePath)); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Skip checking and directly start seeding (new in libtorrent v0.15) if(TorrentTempData::isSeedingMode(hash)){ p.seed_mode=true; @@ -1173,7 +1174,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath)); TorrentPersistentData::saveSavePath(hash, savePath); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Append .!qB to incomplete files if(appendqBExtension) appendqBextensionToTorrent(h, true); @@ -1357,7 +1358,7 @@ void Bittorrent::enableLSD(bool b) { void Bittorrent::loadSessionState() { const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state"); if(!QFile::exists(state_path)) return; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 std::vector in; if (load_file(state_path.toLocal8Bit().constData(), in) == 0) { @@ -1378,7 +1379,7 @@ void Bittorrent::loadSessionState() { void Bittorrent::saveSessionState() { qDebug("Saving session state to disk..."); const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state"); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 entry session_state; s->save_state(session_state); std::vector out; @@ -1404,7 +1405,7 @@ void Bittorrent::saveSessionState() { bool Bittorrent::enableDHT(bool b) { if(b) { if(!DHTEnabled) { -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 entry dht_state; const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state"); if(QFile::exists(dht_state_path)) { @@ -1416,7 +1417,7 @@ bool Bittorrent::enableDHT(bool b) { } #endif try { -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 s->start_dht(); #else s->start_dht(dht_state); @@ -1632,7 +1633,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { defaultTempPath = temppath; } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) { if(!h.is_valid() || !h.has_metadata()) return; std::vector fp; @@ -1704,7 +1705,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void Bittorrent::setAppendqBExtension(bool append) { if(appendqBExtension != append) { appendqBExtension = !appendqBExtension; @@ -1932,7 +1933,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { if(h.is_valid()) { emit finishedTorrent(h); const QString &hash = h.hash(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Remove .!qB extension if necessary if(appendqBExtension) appendqBextensionToTorrent(h, false); @@ -2059,7 +2060,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Append .!qB to incomplete files if(appendqBExtension) appendqBextensionToTorrent(h, true); @@ -2089,7 +2090,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 else if (file_completed_alert* p = dynamic_cast(a.get())) { QTorrentHandle h(p->handle); if(appendqBExtension) { @@ -2119,7 +2120,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { QHash trackers_data = trackersInfos.value(h.hash(), QHash()); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); data.last_message = misc::toQString(p->msg); -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 data.verified = false; ++data.fail_count; #endif @@ -2140,7 +2141,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); data.last_message = ""; // Reset error/warning message data.num_peers = p->num_peers; -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 data.fail_count = 0; data.verified = true; #endif @@ -2155,7 +2156,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { const QString &tracker_url = misc::toQString(p->url); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); data.last_message = misc::toQString(p->msg); // Store warning message -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 data.verified = true; data.fail_count = 0; #endif @@ -2388,7 +2389,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { return sessionStatus.payload_upload_rate; } -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 // Save DHT entry to hard drive void Bittorrent::saveDHTEntry() { // Save DHT entry diff --git a/src/bittorrent.h b/src/bittorrent.h index cb53c11da..1de0c6161 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include "qtorrenthandle.h" @@ -63,7 +64,7 @@ public: QString name_or_url; QString last_message; unsigned long num_peers; -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 bool verified; uint fail_count; #endif @@ -74,13 +75,13 @@ public: Q_ASSERT(!name_or_url.isEmpty()); last_message = b.last_message; num_peers = b.num_peers; -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 verified = b.verified; fail_count = b.fail_count; #endif } TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) { -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 fail_count = 0; verified = false; #endif @@ -135,7 +136,7 @@ public slots: void resumeTorrent(QString hash); void resumeAllTorrents(); /* End Web UI */ -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 void saveDHTEntry(); #endif void preAllocateAllFiles(bool b); @@ -163,7 +164,7 @@ public slots: void setAppendLabelToSavePath(bool append); void appendLabelToTorrentSavePath(QTorrentHandle h); void changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void appendqBextensionToTorrent(QTorrentHandle h, bool append); void setAppendqBExtension(bool append); #endif @@ -249,7 +250,7 @@ private: bool queueingEnabled; bool appendLabelToSavePath; bool torrentExport; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool appendqBExtension; #endif QString defaultSavePath; diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index 641f57ef4..17ae24ed0 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -208,7 +209,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path) } QString hash = misc::toQString(t->info_hash()); TorrentTempData::setSavePath(hash, QString::fromLocal8Bit(branch_path)); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Enable seeding mode (do not recheck the files) TorrentTempData::setSeedingMode(hash, true); #endif diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index bc615a5c5..e50bb46e6 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -29,6 +29,7 @@ */ +#include #include "eventmanager.h" #include "bittorrent.h" #include "scannedfoldersmodel.h" @@ -60,7 +61,7 @@ QList EventManager::getPropTrackersInfo(QString hash) const { tracker["url"] = tracker_url; TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); QString error_message = data.last_message.trimmed(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(it->verified) { tracker["status"] = tr("Working"); } else { @@ -171,7 +172,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const { Preferences::setMaxActiveTorrents(m["max_active_torrents"].toInt()); if(m.contains("max_active_uploads")) Preferences::setMaxActiveUploads(m["max_active_uploads"].toInt()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(m.contains("incomplete_files_ext")) Preferences::useIncompleteFilesExtension(m["incomplete_files_ext"].toBool()); #endif @@ -274,7 +275,7 @@ QVariantMap EventManager::getGlobalPreferences() const { data["max_active_downloads"] = Preferences::getMaxActiveDownloads(); data["max_active_torrents"] = Preferences::getMaxActiveTorrents(); data["max_active_uploads"] = Preferences::getMaxActiveUploads(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 data["incomplete_files_ext"] = Preferences::useIncompleteFilesExtension(); #endif // Connection diff --git a/src/options_imp.cpp b/src/options_imp.cpp index f3da992a2..a10d8f5c8 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -283,7 +284,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ } // Tab selection mecanism connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 checkAppendqB->setVisible(false); #endif // Load Advanced settings @@ -403,7 +404,7 @@ void options_imp::saveOptions(){ #endif settings.setValue(QString::fromUtf8("TempPath"), temp_path); settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked()); #endif settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles()); @@ -644,7 +645,7 @@ void options_imp::loadOptions(){ #endif textTempPath->setText(temp_path); checkAppendLabel->setChecked(Preferences::appendTorrentLabel()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension()); #endif checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles()); diff --git a/src/preferences.h b/src/preferences.h index bf5bc686b..01117c68b 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef DISABLE_GUI #include @@ -178,7 +179,7 @@ public: settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 static bool useIncompleteFilesExtension() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool(); @@ -967,7 +968,7 @@ public: return settings.value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString(); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 static bool isSuperSeedingEnabled() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool(); diff --git a/src/previewselect.h b/src/previewselect.h index 59a867cfd..8f6905626 100644 --- a/src/previewselect.h +++ b/src/previewselect.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "ui_preview.h" #include "previewlistdelegate.h" @@ -65,7 +66,7 @@ protected slots: QModelIndex index; QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME); if(selectedIndexes.size() == 0) return; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Flush data h.flush_cache(); #endif diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 9ebb6c04b..9bd407065 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "propertieswidget.h" #include "transferlistwidget.h" #include "torrentpersistentdata.h" @@ -101,7 +102,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi ProgressHLayout_2->insertWidget(1, pieces_availability); // Tracker list trackerList = new TrackerList(this); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 trackerUpButton->setVisible(false); trackerDownButton->setVisible(false); #else @@ -492,7 +493,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { const QString &filename = misc::toQStringU(h.get_torrent_info().file_at(i).path.string()); const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); qDebug("Trying to open file at %s", qPrintable(file_path)); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Flush data h.flush_cache(); #endif @@ -518,7 +519,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { const QString &filename = path_items.join(QDir::separator()); const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); qDebug("Trying to open folder at %s", qPrintable(file_path)); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Flush data h.flush_cache(); #endif diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index e5afb6129..86ac38a3c 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -37,6 +37,7 @@ #include "misc.h" #include "qtorrenthandle.h" #include "torrentpersistentdata.h" +#include #include #include #include @@ -228,7 +229,7 @@ QString QTorrentHandle::save_path() const { return misc::toQString(h.save_path().string()); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool QTorrentHandle::super_seeding() const { Q_ASSERT(h.is_valid()); return h.super_seeding(); @@ -595,7 +596,7 @@ void QTorrentHandle::file_priority(int index, int priority) const { TorrentPersistentData::saveSeedStatus(*this); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void QTorrentHandle::super_seeding(bool on) const { Q_ASSERT(h.is_valid()); h.super_seeding(on); @@ -648,7 +649,7 @@ void QTorrentHandle::set_peer_download_limit(libtorrent::asio::ip::tcp::endpoint void QTorrentHandle::add_tracker(announce_entry const& url) { Q_ASSERT(h.is_valid()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 h.add_tracker(url); #else std::vector trackers = h.trackers(); diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 9f5d6a6d4..122ab780f 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -31,6 +31,7 @@ #ifndef QTORRENTHANDLE_H #define QTORRENTHANDLE_H +#include #include #include @@ -117,7 +118,7 @@ class QTorrentHandle { qlonglong seeding_time() const; std::vector file_priorities() const; bool is_sequential_download() const; - #ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool super_seeding() const; #endif QString creation_date() const; @@ -158,7 +159,7 @@ class QTorrentHandle { void auto_managed(bool) const; void force_recheck() const; void move_storage(QString path) const; - #ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void super_seeding(bool on) const; void flush_cache() const; #endif diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index 9a80ac341..b3098ee5a 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include "bittorrent.h" @@ -108,7 +109,7 @@ public: addInPause->setChecked(true); //addInPause->setEnabled(false); } -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 addInSeed->setVisible(false); #endif } @@ -512,7 +513,7 @@ public slots: TorrentTempData::setFilesPath(hash, files_path); } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Skip file checking and directly start seeding if(addInSeed->isChecked()) { // Check if local file(s) actually exist diff --git a/src/torrentpersistentdata.h b/src/torrentpersistentdata.h index 44d1b2184..e5c501027 100644 --- a/src/torrentpersistentdata.h +++ b/src/torrentpersistentdata.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "qtorrenthandle.h" #include "misc.h" @@ -126,7 +127,7 @@ public: } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 static void setSeedingMode(QString hash,bool seed){ QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QHash all_data = settings.value("torrents-tmp", QHash()).toHash(); diff --git a/src/trackerlist.cpp b/src/trackerlist.cpp index 29d8c3bb0..cc065fb90 100644 --- a/src/trackerlist.cpp +++ b/src/trackerlist.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "trackerlist.h" #include "propertieswidget.h" @@ -93,7 +94,7 @@ void TrackerList::setRowColor(int row, QColor color) { } } -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 void TrackerList::moveSelectionUp() { QTorrentHandle h = properties->getCurrentTorrent(); if(!h.is_valid()) { @@ -241,7 +242,7 @@ void TrackerList::loadTrackers() { } TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); QString error_message = data.last_message.trimmed(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(it->verified) { item->setText(COL_STATUS, tr("Working")); item->setText(COL_MSG, ""); diff --git a/src/trackerlist.h b/src/trackerlist.h index 45ec383fe..e6bce7ba2 100644 --- a/src/trackerlist.h +++ b/src/trackerlist.h @@ -34,6 +34,7 @@ #include #include +#include #include "qtorrenthandle.h" enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG}; @@ -62,7 +63,7 @@ protected: public slots: void setRowColor(int row, QColor color); -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 void moveSelectionUp(); void moveSelectionDown(); #endif diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 27f71b1c1..9d580ec7b 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -38,6 +38,7 @@ #include "GUI.h" #include "preferences.h" #include "deletionconfirmationdlg.h" +#include #include #include #include @@ -932,7 +933,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&){ } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const { const QStringList &hashes = getSelectedTorrentsHashes(); foreach(const QString &hash, hashes) { @@ -1055,7 +1056,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents())); QAction actionCopy_magnet_link(QIcon(QString::fromUtf8(":/Icons/magnet.png")), tr("Copy magnet link"), 0); connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs())); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0); connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding())); #endif @@ -1070,7 +1071,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { // Enable/disable pause/start action given the DL state QModelIndexList selectedIndexes = selectionModel()->selectedRows(); bool has_pause = false, has_start = false, has_preview = false; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool all_same_super_seeding = true; bool super_seeding_mode = false; #endif @@ -1104,7 +1105,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { } } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 else { if(!one_not_seed && all_same_super_seeding && h.has_metadata()) { if(first) { @@ -1155,7 +1156,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { if(one_not_seed) listMenu.addAction(&actionSet_download_limit); listMenu.addAction(&actionSet_upload_limit); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(!one_not_seed && all_same_super_seeding && one_has_metadata) { QIcon ico; if(super_seeding_mode) { diff --git a/src/transferlistwidget.h b/src/transferlistwidget.h index a97e95f1a..86a88370d 100644 --- a/src/transferlistwidget.h +++ b/src/transferlistwidget.h @@ -31,7 +31,8 @@ #ifndef TRANSFERLISTWIDGET_H #define TRANSFERLISTWIDGET_H -#include +#include +#include #include "qtorrenthandle.h" class QStandardItemModel; @@ -106,7 +107,7 @@ protected slots: void updateMetadata(QTorrentHandle &h); void currentChanged(const QModelIndex& current, const QModelIndex&); void resumeTorrent(QTorrentHandle &h); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void toggleSelectedTorrentsSuperSeeding() const; #endif void toggleSelectedTorrentsSequentialDownload() const;