diff --git a/src/core/preferences.cpp b/src/core/preferences.cpp index c37719cbf..8d22869ea 100644 --- a/src/core/preferences.cpp +++ b/src/core/preferences.cpp @@ -1595,6 +1595,13 @@ void Preferences::setTorrentLabels(const QStringList& labels) setValue("TransferListFilters/customLabels", labels); } +void Preferences::addTorrentLabelExternal(const QString &label) +{ + addTorrentLabel(label); + QString toEmit = label; + emit externalLabelAdded(toEmit); +} + void Preferences::addTorrentLabel(const QString& label) { QStringList labels = value("TransferListFilters/customLabels").toStringList(); diff --git a/src/core/preferences.h b/src/core/preferences.h index b44179a5d..58e599bfd 100644 --- a/src/core/preferences.h +++ b/src/core/preferences.h @@ -112,6 +112,7 @@ private slots: signals: void changed(); + void externalLabelAdded(QString&); public: static void initInstance(); @@ -397,6 +398,7 @@ public: #endif QStringList getTorrentLabels() const; void setTorrentLabels(const QStringList& labels); + void addTorrentLabelExternal(const QString &label); void addTorrentLabel(const QString& label); void removeTorrentLabel(const QString& label); bool recursiveDownloadDisabled() const; diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 7750aefd6..99a9bd320 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -346,7 +346,7 @@ void AutomatedRssDownloader::saveEditedRule() rule->setAddPaused(RssDownloadRule::AddPausedState(ui->comboAddPaused->currentIndex())); // Save new label if (!rule->label().isEmpty()) - Preferences::instance()->addTorrentLabel(rule->label()); + Preferences::instance()->addTorrentLabelExternal(rule->label()); rule->setIgnoreDays(ui->spinIgnorePeriod->value()); //rule->setRssFeeds(getSelectedFeeds()); // Save it diff --git a/src/gui/rss/rssdownloadrulelist.cpp b/src/gui/rss/rssdownloadrulelist.cpp index 33ae84ea4..a6ae01776 100644 --- a/src/gui/rss/rssdownloadrulelist.cpp +++ b/src/gui/rss/rssdownloadrulelist.cpp @@ -85,8 +85,12 @@ void RssDownloadRuleList::loadRulesFromVariantHash(const QVariantHash &h) { QVariantHash::ConstIterator it = h.begin(); QVariantHash::ConstIterator itend = h.end(); + QStringList labels = Preferences::instance()->getTorrentLabels(); for ( ; it != itend; ++it) { RssDownloadRulePtr rule = RssDownloadRule::fromVariantHash(it.value().toHash()); + // Hack to readd labels forgotten before fix + if (!labels.contains(rule->label())) + Preferences::instance()->addTorrentLabelExternal(rule->label()); if (rule && !rule->name().isEmpty()) saveRule(rule); } diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 4fa47ae76..9ff5729ac 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -815,6 +815,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi connect(statusLabel, SIGNAL(toggled(bool)), pref, SLOT(setStatusFilterState(const bool))); connect(labelLabel, SIGNAL(toggled(bool)), labelFilters, SLOT(toggleFilter(bool))); connect(labelLabel, SIGNAL(toggled(bool)), pref, SLOT(setLabelFilterState(const bool))); + connect(pref, SIGNAL(externalLabelAdded(QString&)), labelFilters, SLOT(addItem(QString&))); connect(trackerLabel, SIGNAL(toggled(bool)), trackerFilters, SLOT(toggleFilter(bool))); connect(trackerLabel, SIGNAL(toggled(bool)), pref, SLOT(setTrackerFilterState(const bool))); connect(this, SIGNAL(trackerSuccess(const QString &, const QString &)), trackerFilters, SLOT(trackerSuccess(const QString &, const QString &))); diff --git a/src/gui/transferlistfilterswidget.h b/src/gui/transferlistfilterswidget.h index 63babc89e..c5d88d1aa 100644 --- a/src/gui/transferlistfilterswidget.h +++ b/src/gui/transferlistfilterswidget.h @@ -101,7 +101,7 @@ public: private slots: // Redefine addItem() to make sure the list stays sorted - void addItem(QString &label, bool hasTorrent); + void addItem(QString &label, bool hasTorrent = false); void removeItem(const QString &label); void removeSelectedLabel(); void removeUnusedLabels();