mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Update the UI when trackers or Url seeds are added either via the WebUI or via merging duplicate torrents.
This commit is contained in:
parent
a85b6df314
commit
96d7bfb4ad
@ -389,22 +389,6 @@ QString misc::magnetUriToName(const QString& magnet_uri)
|
|||||||
return toQStringU(p.name);
|
return toQStringU(p.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QUrl> misc::magnetUriToTrackers(const QString& magnet_uri)
|
|
||||||
{
|
|
||||||
QList<QUrl> trackers;
|
|
||||||
add_torrent_params p;
|
|
||||||
error_code ec;
|
|
||||||
parse_magnet_uri(magnet_uri.toUtf8().constData(), p, ec);
|
|
||||||
|
|
||||||
if (ec)
|
|
||||||
return trackers;
|
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator i = p.trackers.begin(), e = p.trackers.end(); i != e; ++i)
|
|
||||||
trackers.push_back(QUrl(toQStringU(*i)));
|
|
||||||
|
|
||||||
return trackers;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString misc::magnetUriToHash(const QString& magnet_uri)
|
QString misc::magnetUriToHash(const QString& magnet_uri)
|
||||||
{
|
{
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
|
@ -89,7 +89,6 @@ namespace misc
|
|||||||
bool isPreviewable(const QString& extension);
|
bool isPreviewable(const QString& extension);
|
||||||
QString magnetUriToName(const QString& magnet_uri);
|
QString magnetUriToName(const QString& magnet_uri);
|
||||||
QString magnetUriToHash(const QString& magnet_uri);
|
QString magnetUriToHash(const QString& magnet_uri);
|
||||||
QList<QUrl> magnetUriToTrackers(const QString& magnet_uri);
|
|
||||||
QString bcLinkToMagnet(QString bc_link);
|
QString bcLinkToMagnet(QString bc_link);
|
||||||
// Take a number of seconds and return an user-friendly
|
// Take a number of seconds and return an user-friendly
|
||||||
// time duration like "1d 2h 10m".
|
// time duration like "1d 2h 10m".
|
||||||
|
@ -1276,76 +1276,95 @@ void QBtSession::loadTorrentTempData(QTorrentHandle &h, QString savePath, bool m
|
|||||||
TorrentPersistentData::instance()->saveTorrentPersistentData(h, fsutils::fromNativePath(savePath), magnet);
|
TorrentPersistentData::instance()->saveTorrentPersistentData(h, fsutils::fromNativePath(savePath), magnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::mergeTorrents(QTorrentHandle& h_ex, const QString& magnet_uri)
|
void QBtSession::mergeTorrents(const QTorrentHandle &h, const QString &magnet_uri)
|
||||||
{
|
{
|
||||||
QString hash = h_ex.hash();
|
QStringList trackers;
|
||||||
QList<QUrl> new_trackers = misc::magnetUriToTrackers(magnet_uri);
|
QStringList urlSeeds;
|
||||||
bool trackers_added = false;
|
add_torrent_params p;
|
||||||
foreach (const QUrl& new_tracker, new_trackers) {
|
boost::system::error_code ec;
|
||||||
bool found = false;
|
|
||||||
std::vector<announce_entry> existing_trackers = h_ex.trackers();
|
|
||||||
foreach (const announce_entry& existing_tracker, existing_trackers) {
|
|
||||||
if (new_tracker == QUrl(existing_tracker.url.c_str())) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
parse_magnet_uri(magnet_uri.toUtf8().constData(), p, ec);
|
||||||
h_ex.add_tracker(announce_entry(new_tracker.toString().toStdString()));
|
|
||||||
trackers_added = true;
|
for (std::vector<std::string>::const_iterator i = p.trackers.begin(), e = p.trackers.end(); i != e; ++i)
|
||||||
emit trackerAdded(new_tracker.toString(), hash);
|
trackers.push_back(misc::toQStringU(*i));
|
||||||
}
|
|
||||||
}
|
#if LIBTORRENT_VERSION_NUM >= 10000
|
||||||
if (trackers_added)
|
for (std::vector<std::string>::const_iterator i = p.url_seeds.begin(), e = p.url_seeds.end(); i != e; ++i)
|
||||||
Logger::instance()->addMessage(tr("Note: new trackers were added to the existing torrent."));
|
urlSeeds.push_back(misc::toQStringU(*i));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mergeTorrents_impl(h, trackers, urlSeeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torrent_info> t) {
|
void QBtSession::mergeTorrents(const QTorrentHandle &h, const boost::intrusive_ptr<torrent_info> t) {
|
||||||
// Check if the torrent contains trackers or url seeds we don't know about
|
QStringList trackers;
|
||||||
// and add them
|
QStringList urlSeeds;
|
||||||
QString hash = h_ex.hash();
|
|
||||||
if (!h_ex.is_valid()) return;
|
foreach (const announce_entry& newTracker, t->trackers())
|
||||||
std::vector<announce_entry> existing_trackers = h_ex.trackers();
|
trackers.append(misc::toQStringU(newTracker.url));
|
||||||
std::vector<announce_entry> new_trackers = t->trackers();
|
|
||||||
bool trackers_added = false;
|
foreach (const web_seed_entry& newUrlSeed, t->web_seeds())
|
||||||
foreach (const announce_entry& new_tracker, new_trackers) {
|
urlSeeds.append(misc::toQStringU(newUrlSeed.url));
|
||||||
std::string new_tracker_url = new_tracker.url;
|
|
||||||
// Check if existing torrent has this tracker
|
mergeTorrents_impl(h, trackers, urlSeeds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QBtSession::mergeTorrents_impl(const QTorrentHandle &h, const QStringList &trackers, const QStringList &urlSeeds)
|
||||||
|
{
|
||||||
|
if (!h.is_valid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString hash = h.hash();
|
||||||
|
QString name = h.name();
|
||||||
|
QStringList addedTrackers;
|
||||||
|
const std::vector<announce_entry> existingTrackers = h.trackers();
|
||||||
|
const QStringList existingUrlSeeds = h.url_seeds();
|
||||||
|
|
||||||
|
foreach (const QString &tracker, trackers) {
|
||||||
|
QUrl trackerUrl(tracker);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach (const announce_entry& existing_tracker, existing_trackers) {
|
|
||||||
if (QUrl(new_tracker_url.c_str()) == QUrl(existing_tracker.url.c_str())) {
|
foreach (const announce_entry &existingTracker, existingTrackers) {
|
||||||
|
QUrl existingTrackerUrl(misc::toQStringU(existingTracker.url));
|
||||||
|
if (trackerUrl == existingTrackerUrl) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
h_ex.add_tracker(announce_entry(new_tracker_url));
|
h.add_tracker(announce_entry(tracker.toUtf8().constData()));
|
||||||
trackers_added = true;
|
addedTrackers.append(tracker);
|
||||||
emit trackerAdded(new_tracker_url.c_str(), hash);
|
Logger::instance()->addMessage(tr("Tracker '%1' was added to torrent '%2'").arg(tracker).arg(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger* const logger = Logger::instance();
|
if (!addedTrackers.empty())
|
||||||
if (trackers_added)
|
emit trackersAdded(addedTrackers, hash);
|
||||||
logger->addMessage(tr("Note: new trackers were added to the existing torrent."));
|
|
||||||
|
|
||||||
bool urlseeds_added = false;
|
if (existingTrackers.empty() && !h.trackers().empty())
|
||||||
const QStringList old_urlseeds = h_ex.url_seeds();
|
emit trackerlessChange(false, hash);
|
||||||
std::vector<web_seed_entry> new_urlseeds = t->web_seeds();
|
|
||||||
|
|
||||||
std::vector<web_seed_entry>::iterator it = new_urlseeds.begin();
|
foreach (const QString &urlSeed, urlSeeds) {
|
||||||
std::vector<web_seed_entry>::iterator itend = new_urlseeds.end();
|
QUrl urlSeedUrl(urlSeed);
|
||||||
for ( ; it != itend; ++it) {
|
bool found = false;
|
||||||
const QString new_url = misc::toQString(it->url.c_str());
|
|
||||||
if (!old_urlseeds.contains(new_url)) {
|
foreach (const QString &existingUrlSeed, existingUrlSeeds) {
|
||||||
urlseeds_added = true;
|
QUrl existingUrlSeedUrl(existingUrlSeed);
|
||||||
h_ex.add_url_seed(new_url);
|
if (urlSeedUrl == existingUrlSeedUrl) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
h.add_url_seed(urlSeed);
|
||||||
|
Logger::instance()->addMessage(tr("URL seed '%1' was added to torrent '%2'").arg(urlSeed).arg(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (urlseeds_added)
|
|
||||||
logger->addMessage(tr("Note: new URL seeds were added to the existing torrent."));
|
h.force_reannounce();
|
||||||
|
emit reloadTrackersAndUrlSeeds(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::exportTorrentFiles(QString path) {
|
void QBtSession::exportTorrentFiles(QString path) {
|
||||||
@ -3141,3 +3160,11 @@ void QBtSession::unhideMagnet(const QString &hash) {
|
|||||||
|
|
||||||
emit addedTorrent(h);
|
emit addedTorrent(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QBtSession::addTrackersAndUrlSeeds(const QString &hash, const QStringList &trackers, const QStringList& urlSeeds)
|
||||||
|
{
|
||||||
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
|
if (h.is_valid())
|
||||||
|
mergeTorrents_impl(h, trackers, urlSeeds);
|
||||||
|
}
|
||||||
|
@ -210,6 +210,7 @@ public slots:
|
|||||||
void banIP(QString ip);
|
void banIP(QString ip);
|
||||||
void recursiveTorrentDownload(const QTorrentHandle &h);
|
void recursiveTorrentDownload(const QTorrentHandle &h);
|
||||||
void unhideMagnet(const QString &hash);
|
void unhideMagnet(const QString &hash);
|
||||||
|
void addTrackersAndUrlSeeds(const QString &hash, const QStringList &trackers, const QStringList& urlSeeds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyEncryptionSettings(libtorrent::pe_settings se);
|
void applyEncryptionSettings(libtorrent::pe_settings se);
|
||||||
@ -258,8 +259,9 @@ private slots:
|
|||||||
void saveTempFastResumeData();
|
void saveTempFastResumeData();
|
||||||
void sendNotificationEmail(const QTorrentHandle &h);
|
void sendNotificationEmail(const QTorrentHandle &h);
|
||||||
void autoRunExternalProgram(const QTorrentHandle &h);
|
void autoRunExternalProgram(const QTorrentHandle &h);
|
||||||
void mergeTorrents(QTorrentHandle& h_ex, boost::intrusive_ptr<libtorrent::torrent_info> t);
|
void mergeTorrents(const QTorrentHandle &h, const boost::intrusive_ptr<libtorrent::torrent_info> t);
|
||||||
void mergeTorrents(QTorrentHandle& h_ex, const QString& magnet_uri);
|
void mergeTorrents(const QTorrentHandle &h, const QString &magnet_uri);
|
||||||
|
void mergeTorrents_impl(const QTorrentHandle &h, const QStringList &trackers, const QStringList& urlSeeds);
|
||||||
void exportTorrentFile(const QTorrentHandle &h, TorrentExportFolder folder = RegularTorrentExportFolder);
|
void exportTorrentFile(const QTorrentHandle &h, TorrentExportFolder folder = RegularTorrentExportFolder);
|
||||||
void handleIPFilterParsed(int ruleCount);
|
void handleIPFilterParsed(int ruleCount);
|
||||||
void handleIPFilterError();
|
void handleIPFilterError();
|
||||||
@ -288,7 +290,9 @@ signals:
|
|||||||
void metadataReceivedHidden(const QTorrentHandle &h);
|
void metadataReceivedHidden(const QTorrentHandle &h);
|
||||||
void stateUpdate(const std::vector<libtorrent::torrent_status> &statuses);
|
void stateUpdate(const std::vector<libtorrent::torrent_status> &statuses);
|
||||||
void statsReceived(const libtorrent::stats_alert&);
|
void statsReceived(const libtorrent::stats_alert&);
|
||||||
void trackerAdded(const QString &tracker, const QString &hash);
|
void trackersAdded(const QStringList &trackers, const QString &hash);
|
||||||
|
void trackerlessChange(bool trackerless, const QString &hash);
|
||||||
|
void reloadTrackersAndUrlSeeds(const QTorrentHandle &h);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
|
@ -214,9 +214,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(search_filter, SIGNAL(textChanged(QString)), transferList, SLOT(applyNameFilter(QString)));
|
connect(search_filter, SIGNAL(textChanged(QString)), transferList, SLOT(applyNameFilter(QString)));
|
||||||
connect(hSplitter, SIGNAL(splitterMoved(int, int)), this, SLOT(writeSettings()));
|
connect(hSplitter, SIGNAL(splitterMoved(int, int)), this, SLOT(writeSettings()));
|
||||||
connect(vSplitter, SIGNAL(splitterMoved(int, int)), this, SLOT(writeSettings()));
|
connect(vSplitter, SIGNAL(splitterMoved(int, int)), this, SLOT(writeSettings()));
|
||||||
connect(properties, SIGNAL(trackerAdded(const QString&, const QString&)), transferListFilters, SLOT(addTracker(const QString&, const QString&)));
|
connect(properties, SIGNAL(trackersAdded(const QStringList &, const QString &)), transferListFilters, SLOT(addTrackers(const QStringList &, const QString &)));
|
||||||
connect(properties, SIGNAL(trackerRemoved(const QString&, const QString&)), transferListFilters, SLOT(removeTracker(const QString&, const QString&)));
|
connect(properties, SIGNAL(trackersRemoved(const QStringList &, const QString &)), transferListFilters, SLOT(removeTrackers(const QStringList &, const QString &)));
|
||||||
connect(QBtSession::instance(), SIGNAL(trackerAdded(const QString&, const QString&)), transferListFilters, SLOT(addTracker(const QString&, const QString&)));
|
connect(properties, SIGNAL(trackerlessChange(bool, const QString &)), transferListFilters, SLOT(changeTrackerless(bool, const QString &)));
|
||||||
|
connect(QBtSession::instance(), SIGNAL(trackersAdded(const QStringList &, const QString &)), transferListFilters, SLOT(addTrackers(const QStringList &, const QString &)));
|
||||||
|
connect(QBtSession::instance(), SIGNAL(trackerlessChange(bool, const QString &)), transferListFilters, SLOT(changeTrackerless(bool, const QString &)));
|
||||||
|
connect(QBtSession::instance(), SIGNAL(reloadTrackersAndUrlSeeds(const QTorrentHandle &)), properties, SLOT(loadTrackers(const QTorrentHandle &)));
|
||||||
|
|
||||||
vboxLayout->addWidget(tabs);
|
vboxLayout->addWidget(tabs);
|
||||||
|
|
||||||
|
@ -111,8 +111,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra
|
|||||||
trackerList = new TrackerList(this);
|
trackerList = new TrackerList(this);
|
||||||
connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp()));
|
connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp()));
|
||||||
connect(trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown()));
|
connect(trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown()));
|
||||||
connect(trackerList, SIGNAL(trackerAdded(const QString&, const QString&)), this, SIGNAL(trackerAdded(const QString&, const QString&)));
|
connect(trackerList, SIGNAL(trackersAdded(const QStringList &, const QString &)), this, SIGNAL(trackersAdded(const QStringList &, const QString &)));
|
||||||
connect(trackerList, SIGNAL(trackerRemoved(const QString&, const QString&)), this, SIGNAL(trackerRemoved(const QString&, const QString&)));
|
connect(trackerList, SIGNAL(trackersRemoved(const QStringList &, const QString &)), this, SIGNAL(trackersRemoved(const QStringList &, const QString &)));
|
||||||
|
connect(trackerList, SIGNAL(trackerlessChange(bool, const QString &)), this, SIGNAL(trackerlessChange(bool, const QString &)));
|
||||||
horizontalLayout_trackers->insertWidget(0, trackerList);
|
horizontalLayout_trackers->insertWidget(0, trackerList);
|
||||||
connect(trackerList->header(), SIGNAL(sectionMoved(int, int, int)), trackerList, SLOT(saveSettings()));
|
connect(trackerList->header(), SIGNAL(sectionMoved(int, int, int)), trackerList, SLOT(saveSettings()));
|
||||||
connect(trackerList->header(), SIGNAL(sectionResized(int, int, int)), trackerList, SLOT(saveSettings()));
|
connect(trackerList->header(), SIGNAL(sectionResized(int, int, int)), trackerList, SLOT(saveSettings()));
|
||||||
@ -239,6 +240,12 @@ void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::loadTrackers(const QTorrentHandle &handle)
|
||||||
|
{
|
||||||
|
if (handle == h)
|
||||||
|
trackerList->loadTrackers();
|
||||||
|
}
|
||||||
|
|
||||||
void PropertiesWidget::updateTorrentInfos(const QTorrentHandle& _h) {
|
void PropertiesWidget::updateTorrentInfos(const QTorrentHandle& _h) {
|
||||||
if (h.is_valid() && h == _h) {
|
if (h.is_valid() && h == _h) {
|
||||||
loadTorrentInfos(h);
|
loadTorrentInfos(h);
|
||||||
|
@ -70,8 +70,9 @@ public:
|
|||||||
QTreeView* getFilesList() const { return filesList; }
|
QTreeView* getFilesList() const { return filesList; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void trackerAdded(const QString &tracker, const QString &hash);
|
void trackersAdded(const QStringList &trackers, const QString &hash);
|
||||||
void trackerRemoved(const QString &tracker, const QString &hash);
|
void trackersRemoved(const QStringList &trackers, const QString &hash);
|
||||||
|
void trackerlessChange(bool trackerless, const QString &hash);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPushButton* getButtonFromIndex(int index);
|
QPushButton* getButtonFromIndex(int index);
|
||||||
@ -101,6 +102,7 @@ public slots:
|
|||||||
void reloadPreferences();
|
void reloadPreferences();
|
||||||
void openDoubleClickedFile(const QModelIndex &);
|
void openDoubleClickedFile(const QModelIndex &);
|
||||||
void updateSavePath(const QTorrentHandle& h);
|
void updateSavePath(const QTorrentHandle& h);
|
||||||
|
void loadTrackers(const QTorrentHandle &handle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openFile(const QModelIndex &index);
|
void openFile(const QModelIndex &index);
|
||||||
|
@ -302,24 +302,8 @@ void TrackerList::askForTrackers() {
|
|||||||
if (!h.is_valid()) return;
|
if (!h.is_valid()) return;
|
||||||
QString hash = h.hash();
|
QString hash = h.hash();
|
||||||
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
|
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
|
||||||
if (!trackers.empty()) {
|
QBtSession::instance()->addTrackersAndUrlSeeds(hash, trackers, QStringList());
|
||||||
if (h.trackers().empty())
|
loadTrackers();
|
||||||
emit trackerRemoved("", hash);
|
|
||||||
|
|
||||||
for (int i=0; i<trackers.count(); i++) {
|
|
||||||
const QString& tracker = trackers[i];
|
|
||||||
if (tracker.trimmed().isEmpty()) continue;
|
|
||||||
announce_entry url(tracker.toStdString());
|
|
||||||
url.tier = (topLevelItemCount() - NB_STICKY_ITEM) + i;
|
|
||||||
h.add_tracker(url);
|
|
||||||
emit trackerAdded(tracker, hash);
|
|
||||||
}
|
|
||||||
// Reannounce to new trackers
|
|
||||||
if (!h.is_paused())
|
|
||||||
h.force_reannounce();
|
|
||||||
// Reload tracker list
|
|
||||||
loadTrackers();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerList::copyTrackerUrl() {
|
void TrackerList::copyTrackerUrl() {
|
||||||
@ -350,7 +334,6 @@ void TrackerList::deleteSelectedTrackers() {
|
|||||||
urls_to_remove << tracker_url;
|
urls_to_remove << tracker_url;
|
||||||
tracker_items.remove(tracker_url);
|
tracker_items.remove(tracker_url);
|
||||||
delete item;
|
delete item;
|
||||||
emit trackerRemoved(tracker_url, hash);
|
|
||||||
}
|
}
|
||||||
// Iterate of trackers and remove selected ones
|
// Iterate of trackers and remove selected ones
|
||||||
std::vector<announce_entry> remaining_trackers;
|
std::vector<announce_entry> remaining_trackers;
|
||||||
@ -364,8 +347,10 @@ void TrackerList::deleteSelectedTrackers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
h.replace_trackers(remaining_trackers);
|
h.replace_trackers(remaining_trackers);
|
||||||
|
if (!urls_to_remove.empty())
|
||||||
|
emit trackersRemoved(urls_to_remove, hash);
|
||||||
if (remaining_trackers.empty())
|
if (remaining_trackers.empty())
|
||||||
emit trackerAdded("", hash);
|
emit trackerlessChange(true, hash);
|
||||||
if (!h.is_paused())
|
if (!h.is_paused())
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
// Reload Trackers
|
// Reload Trackers
|
||||||
@ -407,13 +392,13 @@ void TrackerList::editSelectedTracker() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tracker_url == QUrl(misc::toQString(it->url)) && !match) {
|
if (tracker_url == QUrl(misc::toQStringU(it->url)) && !match) {
|
||||||
announce_entry new_entry(new_tracker_url.toString().toStdString());
|
announce_entry new_entry(new_tracker_url.toString().toUtf8().constData());
|
||||||
new_entry.tier = it->tier;
|
new_entry.tier = it->tier;
|
||||||
match = true;
|
match = true;
|
||||||
*it = new_entry;
|
*it = new_entry;
|
||||||
emit trackerRemoved(tracker_url.toString(), hash);
|
emit trackersRemoved(QStringList(tracker_url.toString()), hash);
|
||||||
emit trackerAdded(new_tracker_url.toString(), hash);
|
emit trackersAdded(QStringList(new_tracker_url.toString()), hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,9 @@ public:
|
|||||||
~TrackerList();
|
~TrackerList();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void trackerAdded(const QString &tracker, const QString &hash);
|
void trackersAdded(const QStringList &trackers, const QString &hash);
|
||||||
void trackerRemoved(const QString &tracker, const QString &hash);
|
void trackersRemoved(const QStringList &trackers, const QString &hash);
|
||||||
|
void trackerlessChange(bool trackerless, const QString &hash);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<QTreeWidgetItem*> getSelectedTrackerItems() const;
|
QList<QTreeWidgetItem*> getSelectedTrackerItems() const;
|
||||||
|
@ -260,7 +260,7 @@ void TrackerFiltersList::addItem(const QTorrentHandle& handle)
|
|||||||
QString hash = handle.hash();
|
QString hash = handle.hash();
|
||||||
std::vector<libtorrent::announce_entry> trackers = handle.trackers();
|
std::vector<libtorrent::announce_entry> trackers = handle.trackers();
|
||||||
for (std::vector<libtorrent::announce_entry>::iterator i = trackers.begin(), e = trackers.end(); i != e; ++i)
|
for (std::vector<libtorrent::announce_entry>::iterator i = trackers.begin(), e = trackers.end(); i != e; ++i)
|
||||||
addItem(misc::toQString(i->url), hash);
|
addItem(misc::toQStringU(i->url), hash);
|
||||||
|
|
||||||
//Check for trackerless torrent
|
//Check for trackerless torrent
|
||||||
if (trackers.size() == 0)
|
if (trackers.size() == 0)
|
||||||
@ -306,7 +306,7 @@ void TrackerFiltersList::removeItem(const QTorrentHandle& handle)
|
|||||||
QString hash = handle.hash();
|
QString hash = handle.hash();
|
||||||
std::vector<libtorrent::announce_entry> trackers = handle.trackers();
|
std::vector<libtorrent::announce_entry> trackers = handle.trackers();
|
||||||
for (std::vector<libtorrent::announce_entry>::iterator i = trackers.begin(), e = trackers.end(); i != e; ++i)
|
for (std::vector<libtorrent::announce_entry>::iterator i = trackers.begin(), e = trackers.end(); i != e; ++i)
|
||||||
removeItem(misc::toQString(i->url), hash);
|
removeItem(misc::toQStringU(i->url), hash);
|
||||||
|
|
||||||
//Check for trackerless torrent
|
//Check for trackerless torrent
|
||||||
if (trackers.size() == 0)
|
if (trackers.size() == 0)
|
||||||
@ -361,6 +361,14 @@ void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString&
|
|||||||
Log::WARNING);
|
Log::WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackerFiltersList::changeTrackerless(bool trackerless, const QString &hash)
|
||||||
|
{
|
||||||
|
if (trackerless)
|
||||||
|
addItem("", hash);
|
||||||
|
else
|
||||||
|
removeItem("", hash);
|
||||||
|
}
|
||||||
|
|
||||||
QString TrackerFiltersList::trackerFromRow(int row) const
|
QString TrackerFiltersList::trackerFromRow(int row) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(row > 1);
|
Q_ASSERT(row > 1);
|
||||||
@ -556,14 +564,21 @@ void TransferListFiltersWidget::addLabel(QString& label)
|
|||||||
Preferences::instance()->addTorrentLabel(label);
|
Preferences::instance()->addTorrentLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::addTracker(const QString &tracker, const QString &hash)
|
void TransferListFiltersWidget::addTrackers(const QStringList &trackers, const QString &hash)
|
||||||
{
|
{
|
||||||
trackerFilters->addItem(tracker, hash);
|
foreach (const QString &tracker, trackers)
|
||||||
|
trackerFilters->addItem(tracker, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::removeTracker(const QString &tracker, const QString &hash)
|
void TransferListFiltersWidget::removeTrackers(const QStringList &trackers, const QString &hash)
|
||||||
{
|
{
|
||||||
trackerFilters->removeItem(tracker, hash);
|
foreach (const QString &tracker, trackers)
|
||||||
|
trackerFilters->removeItem(tracker, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransferListFiltersWidget::changeTrackerless(bool trackerless, const QString &hash)
|
||||||
|
{
|
||||||
|
trackerFilters->changeTrackerless(trackerless, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::showLabelMenu(QPoint)
|
void TransferListFiltersWidget::showLabelMenu(QPoint)
|
||||||
|
@ -113,6 +113,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void handleFavicoDownload(const QString &url, const QString &filePath);
|
void handleFavicoDownload(const QString &url, const QString &filePath);
|
||||||
void handleFavicoFailure(const QString &url, const QString &reason);
|
void handleFavicoFailure(const QString &url, const QString &reason);
|
||||||
|
void changeTrackerless(bool trackerless, const QString &hash);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, QStringList> m_trackers;
|
QHash<QString, QStringList> m_trackers;
|
||||||
@ -149,8 +150,9 @@ public:
|
|||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addTracker(const QString &tracker, const QString &hash);
|
void addTrackers(const QStringList &trackers, const QString &hash);
|
||||||
void removeTracker(const QString &tracker, const QString &hash);
|
void removeTrackers(const QStringList &trackers, const QString &hash);
|
||||||
|
void changeTrackerless(bool trackerless, const QString &hash);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent *event);
|
virtual void resizeEvent(QResizeEvent *event);
|
||||||
|
@ -354,17 +354,9 @@ void WebApplication::action_command_addTrackers()
|
|||||||
QString hash = request().posts["hash"];
|
QString hash = request().posts["hash"];
|
||||||
|
|
||||||
if (!hash.isEmpty()) {
|
if (!hash.isEmpty()) {
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
QString urls = request().posts["urls"];
|
||||||
|
QStringList list = urls.split('\n');
|
||||||
if (h.is_valid() && h.has_metadata()) {
|
QBtSession::instance()->addTrackersAndUrlSeeds(hash, list, QStringList());
|
||||||
QString urls = request().posts["urls"];
|
|
||||||
QStringList list = urls.split('\n');
|
|
||||||
|
|
||||||
foreach (const QString& url, list) {
|
|
||||||
announce_entry e(url.toStdString());
|
|
||||||
h.add_tracker(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user