fix using custom account-wide proxy when importing feeds

This commit is contained in:
Martin Rotter 2023-04-05 11:24:31 +02:00
parent 8dcf72aa86
commit c41ca13ad1
4 changed files with 11 additions and 9 deletions

View File

@ -20,7 +20,7 @@
FormStandardImportExport::FormStandardImportExport(StandardServiceRoot* service_root, QWidget* parent)
: QDialog(parent), m_ui(new Ui::FormStandardImportExport), m_serviceRoot(service_root) {
m_ui->setupUi(this);
m_model = new FeedsImportExportModel(m_ui->m_treeFeeds);
m_model = new FeedsImportExportModel(service_root, m_ui->m_treeFeeds);
connect(m_model, &FeedsImportExportModel::parsingStarted, this, &FormStandardImportExport::onParsingStarted);
connect(m_model, &FeedsImportExportModel::parsingFinished, this, &FormStandardImportExport::onParsingFinished);
connect(m_model, &FeedsImportExportModel::parsingProgress, this, &FormStandardImportExport::onParsingProgress);

View File

@ -21,8 +21,8 @@
#include <QStack>
#include <QtConcurrentMap>
FeedsImportExportModel::FeedsImportExportModel(QObject* parent)
: AccountCheckSortedModel(parent), m_mode(Mode::Import), m_newRoot(nullptr) {
FeedsImportExportModel::FeedsImportExportModel(StandardServiceRoot* account, QObject* parent)
: AccountCheckSortedModel(parent), m_account(account), m_mode(Mode::Import), m_newRoot(nullptr) {
connect(&m_watcherLookup, &QFutureWatcher<bool>::progressValueChanged, this, [=](int prog) {
emit parsingProgress(prog, m_lookup.size());
@ -279,8 +279,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
QStack<RootItem*> model_items;
QNetworkProxy custom_proxy;
if (sourceModel()->rootItem() != nullptr && sourceModel()->rootItem()->getParentServiceRoot() != nullptr) {
custom_proxy = sourceModel()->rootItem()->getParentServiceRoot()->networkProxy();
if (m_account != nullptr) {
custom_proxy = m_account->networkProxy();
}
model_items.push(m_newRoot);
@ -416,8 +416,8 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data,
m_newRoot = new StandardServiceRoot();
QNetworkProxy custom_proxy;
if (sourceModel()->rootItem() != nullptr && sourceModel()->rootItem()->getParentServiceRoot() != nullptr) {
custom_proxy = sourceModel()->rootItem()->getParentServiceRoot()->networkProxy();
if (m_account != nullptr) {
custom_proxy = m_account->networkProxy();
}
QList<QByteArray> urls = data.split('\n');

View File

@ -10,6 +10,7 @@
#include <QNetworkProxy>
class StandardFeed;
class StandardServiceRoot;
struct FeedLookup {
RootItem* parent;
@ -26,7 +27,7 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
public:
enum class Mode { Import, Export };
explicit FeedsImportExportModel(QObject* parent = nullptr);
explicit FeedsImportExportModel(StandardServiceRoot* account, QObject* parent = nullptr);
virtual ~FeedsImportExportModel();
// Exports to OPML 2.0
@ -53,6 +54,7 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
bool produceFeed(const FeedLookup& feed_lookup);
private:
StandardServiceRoot* m_account;
QMutex m_mtxLookup;
QList<FeedLookup> m_lookup;
RootItem* m_newRoot;

View File

@ -71,7 +71,7 @@ void StandardServiceRoot::start(bool freshly_activated) {
file_to_load = target_opml_file.arg(QSL(DEFAULT_LOCALE));
}
FeedsImportExportModel model;
FeedsImportExportModel model(this);
QString output_msg;
try {