mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-04 14:42:29 -06: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:
@@ -111,8 +111,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra
|
||||
trackerList = new TrackerList(this);
|
||||
connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp()));
|
||||
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(trackerRemoved(const QString&, const QString&)), this, SIGNAL(trackerRemoved(const QString&, const QString&)));
|
||||
connect(trackerList, SIGNAL(trackersAdded(const QStringList &, const QString &)), this, SIGNAL(trackersAdded(const QStringList &, 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);
|
||||
connect(trackerList->header(), SIGNAL(sectionMoved(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) {
|
||||
if (h.is_valid() && h == _h) {
|
||||
loadTorrentInfos(h);
|
||||
|
||||
@@ -70,8 +70,9 @@ public:
|
||||
QTreeView* getFilesList() const { return filesList; }
|
||||
|
||||
signals:
|
||||
void trackerAdded(const QString &tracker, const QString &hash);
|
||||
void trackerRemoved(const QString &tracker, const QString &hash);
|
||||
void trackersAdded(const QStringList &trackers, const QString &hash);
|
||||
void trackersRemoved(const QStringList &trackers, const QString &hash);
|
||||
void trackerlessChange(bool trackerless, const QString &hash);
|
||||
|
||||
protected:
|
||||
QPushButton* getButtonFromIndex(int index);
|
||||
@@ -101,6 +102,7 @@ public slots:
|
||||
void reloadPreferences();
|
||||
void openDoubleClickedFile(const QModelIndex &);
|
||||
void updateSavePath(const QTorrentHandle& h);
|
||||
void loadTrackers(const QTorrentHandle &handle);
|
||||
|
||||
private:
|
||||
void openFile(const QModelIndex &index);
|
||||
|
||||
@@ -302,24 +302,8 @@ void TrackerList::askForTrackers() {
|
||||
if (!h.is_valid()) return;
|
||||
QString hash = h.hash();
|
||||
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
|
||||
if (!trackers.empty()) {
|
||||
if (h.trackers().empty())
|
||||
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();
|
||||
}
|
||||
QBtSession::instance()->addTrackersAndUrlSeeds(hash, trackers, QStringList());
|
||||
loadTrackers();
|
||||
}
|
||||
|
||||
void TrackerList::copyTrackerUrl() {
|
||||
@@ -350,7 +334,6 @@ void TrackerList::deleteSelectedTrackers() {
|
||||
urls_to_remove << tracker_url;
|
||||
tracker_items.remove(tracker_url);
|
||||
delete item;
|
||||
emit trackerRemoved(tracker_url, hash);
|
||||
}
|
||||
// Iterate of trackers and remove selected ones
|
||||
std::vector<announce_entry> remaining_trackers;
|
||||
@@ -364,8 +347,10 @@ void TrackerList::deleteSelectedTrackers() {
|
||||
}
|
||||
}
|
||||
h.replace_trackers(remaining_trackers);
|
||||
if (!urls_to_remove.empty())
|
||||
emit trackersRemoved(urls_to_remove, hash);
|
||||
if (remaining_trackers.empty())
|
||||
emit trackerAdded("", hash);
|
||||
emit trackerlessChange(true, hash);
|
||||
if (!h.is_paused())
|
||||
h.force_reannounce();
|
||||
// Reload Trackers
|
||||
@@ -407,13 +392,13 @@ void TrackerList::editSelectedTracker() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tracker_url == QUrl(misc::toQString(it->url)) && !match) {
|
||||
announce_entry new_entry(new_tracker_url.toString().toStdString());
|
||||
if (tracker_url == QUrl(misc::toQStringU(it->url)) && !match) {
|
||||
announce_entry new_entry(new_tracker_url.toString().toUtf8().constData());
|
||||
new_entry.tier = it->tier;
|
||||
match = true;
|
||||
*it = new_entry;
|
||||
emit trackerRemoved(tracker_url.toString(), hash);
|
||||
emit trackerAdded(new_tracker_url.toString(), hash);
|
||||
emit trackersRemoved(QStringList(tracker_url.toString()), hash);
|
||||
emit trackersAdded(QStringList(new_tracker_url.toString()), hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,9 @@ public:
|
||||
~TrackerList();
|
||||
|
||||
signals:
|
||||
void trackerAdded(const QString &tracker, const QString &hash);
|
||||
void trackerRemoved(const QString &tracker, const QString &hash);
|
||||
void trackersAdded(const QStringList &trackers, const QString &hash);
|
||||
void trackersRemoved(const QStringList &trackers, const QString &hash);
|
||||
void trackerlessChange(bool trackerless, const QString &hash);
|
||||
|
||||
protected:
|
||||
QList<QTreeWidgetItem*> getSelectedTrackerItems() const;
|
||||
|
||||
Reference in New Issue
Block a user