diff --git a/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml b/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml index 4f71a292a..f7ee39586 100644 --- a/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml +++ b/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml @@ -60,7 +60,7 @@ - + rssguard diff --git a/resources/rssguard.qrc b/resources/rssguard.qrc index ade75da99..6b0b53f60 100644 --- a/resources/rssguard.qrc +++ b/resources/rssguard.qrc @@ -20,6 +20,9 @@ scripts/adblock/adblock-server.js scripts/readability/readabilize-article.js + scripts/filters/blacklist.js + scripts/filters/whitelist.js + graphics/rssguard.ico graphics/rssguard.png diff --git a/resources/scripts/filters/blacklist.js b/resources/scripts/filters/blacklist.js new file mode 100755 index 000000000..df1f2ddf0 --- /dev/null +++ b/resources/scripts/filters/blacklist.js @@ -0,0 +1,15 @@ +// This filter rejects all messages whose title +// is on the blacklist. + +var blacklist = [ + 'abc', + '123' +]; + +function filterMessage() { + if (blacklist.some(i => msg.title.indexOf(i) != -1)) { + return MessageObject.Ignore; + } else { + return MessageObject.Accept; + } +} \ No newline at end of file diff --git a/resources/scripts/filters/whitelist.js b/resources/scripts/filters/whitelist.js new file mode 100755 index 000000000..2834ec011 --- /dev/null +++ b/resources/scripts/filters/whitelist.js @@ -0,0 +1,15 @@ +// This filter accepts only messages whose title +// is on the whitelist. + +var whitelist = [ + 'abc', + '123' +]; + +function filterMessage() { + if (whitelist.some(i => msg.title.indexOf(i) != -1)) { + return MessageObject.Accept; + } else { + return MessageObject.Ignore; + } +} \ No newline at end of file diff --git a/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp b/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp index 86902a15c..14f34a198 100644 --- a/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp +++ b/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp @@ -21,9 +21,11 @@ #include "services/abstract/feed.h" #include "services/abstract/labelsnode.h" -FormMessageFiltersManager::FormMessageFiltersManager(FeedReader* reader, const QList& accounts, QWidget* parent) - : QDialog(parent), m_feedsModel(new AccountCheckSortedModel(this)), m_rootItem(new RootItem()), - m_accounts(accounts), m_reader(reader), m_loadingFilter(false), m_msgModel(new MessagesForFiltersModel(this)) { +FormMessageFiltersManager::FormMessageFiltersManager(FeedReader* reader, + const QList& accounts, + QWidget* parent) + : QDialog(parent), m_feedsModel(new AccountCheckSortedModel(this)), m_rootItem(new RootItem()), m_accounts(accounts), + m_reader(reader), m_loadingFilter(false), m_msgModel(new MessagesForFiltersModel(this)) { m_ui.setupUi(this); std::sort(m_accounts.begin(), m_accounts.end(), [](const ServiceRoot* lhs, const ServiceRoot* rhs) { @@ -47,44 +49,58 @@ FormMessageFiltersManager::FormMessageFiltersManager(FeedReader* reader, const Q m_ui.m_txtScript->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont)); m_ui.m_treeExistingMessages->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); - m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_ISREAD, QHeaderView::ResizeMode::ResizeToContents); - m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_ISIMPORTANT, QHeaderView::ResizeMode::ResizeToContents); - m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_ISDELETED, QHeaderView::ResizeMode::ResizeToContents); - m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_AUTHOR, QHeaderView::ResizeMode::ResizeToContents); - m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_CREATED, QHeaderView::ResizeMode::ResizeToContents); - m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_SCORE, QHeaderView::ResizeMode::ResizeToContents); + m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_ISREAD, + QHeaderView::ResizeMode::ResizeToContents); + m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_ISIMPORTANT, + QHeaderView::ResizeMode::ResizeToContents); + m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_ISDELETED, + QHeaderView::ResizeMode::ResizeToContents); + m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_AUTHOR, + QHeaderView::ResizeMode::ResizeToContents); + m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_CREATED, + QHeaderView::ResizeMode::ResizeToContents); + m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_SCORE, + QHeaderView::ResizeMode::ResizeToContents); m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_TITLE, QHeaderView::ResizeMode::Interactive); m_ui.m_treeExistingMessages->header()->setSectionResizeMode(MFM_MODEL_URL, QHeaderView::ResizeMode::Interactive); connect(m_ui.m_btnDetailedHelp, &QPushButton::clicked, this, []() { qApp->web()->openUrlInExternalBrowser(QSL(MSG_FILTERING_HELP)); }); - connect(m_ui.m_listFilters, &QListWidget::currentRowChanged, - this, &FormMessageFiltersManager::loadFilter); + connect(m_ui.m_listFilters, &QListWidget::currentRowChanged, this, &FormMessageFiltersManager::loadFilter); connect(m_ui.m_btnAddNew, &QPushButton::clicked, this, [this]() { addNewFilter(); }); - connect(m_ui.m_btnRemoveSelected, &QPushButton::clicked, - this, &FormMessageFiltersManager::removeSelectedFilter); + connect(m_ui.m_btnRemoveSelected, &QPushButton::clicked, this, &FormMessageFiltersManager::removeSelectedFilter); connect(m_ui.m_txtTitle, &QLineEdit::textChanged, this, &FormMessageFiltersManager::saveSelectedFilter); connect(m_ui.m_txtScript, &QPlainTextEdit::textChanged, this, &FormMessageFiltersManager::saveSelectedFilter); connect(m_ui.m_btnTest, &QPushButton::clicked, this, &FormMessageFiltersManager::testFilter); connect(m_ui.m_btnBeautify, &QPushButton::clicked, this, &FormMessageFiltersManager::beautifyScript); - connect(m_ui.m_cmbAccounts, static_cast(&QComboBox::currentIndexChanged), + connect(m_ui.m_cmbAccounts, + static_cast(&QComboBox::currentIndexChanged), this, &FormMessageFiltersManager::onAccountChanged); connect(m_ui.m_btnCheckAll, &QPushButton::clicked, m_feedsModel->sourceModel(), &AccountCheckModel::checkAllItems); - connect(m_ui.m_btnUncheckAll, &QPushButton::clicked, m_feedsModel->sourceModel(), &AccountCheckModel::uncheckAllItems); - connect(m_feedsModel->sourceModel(), &AccountCheckModel::checkStateChanged, - this, &FormMessageFiltersManager::onFeedChecked); - connect(m_ui.m_treeFeeds->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &FormMessageFiltersManager::displayMessagesOfFeed); - connect(m_ui.m_btnRunOnMessages, &QPushButton::clicked, - this, &FormMessageFiltersManager::processCheckedFeeds); - connect(m_ui.m_treeExistingMessages, &QTreeView::customContextMenuRequested, - this, &FormMessageFiltersManager::showMessageContextMenu); + connect(m_ui.m_btnUncheckAll, + &QPushButton::clicked, + m_feedsModel->sourceModel(), + &AccountCheckModel::uncheckAllItems); + connect(m_feedsModel->sourceModel(), + &AccountCheckModel::checkStateChanged, + this, + &FormMessageFiltersManager::onFeedChecked); + connect(m_ui.m_treeFeeds->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &FormMessageFiltersManager::displayMessagesOfFeed); + connect(m_ui.m_btnRunOnMessages, &QPushButton::clicked, this, &FormMessageFiltersManager::processCheckedFeeds); + connect(m_ui.m_treeExistingMessages, + &QTreeView::customContextMenuRequested, + this, + &FormMessageFiltersManager::showMessageContextMenu); initializeTestingMessage(); + initializePremadeFilters(); loadFilters(); loadFilter(); loadAccounts(); @@ -110,24 +126,23 @@ ServiceRoot* FormMessageFiltersManager::selectedAccount() const { } void FormMessageFiltersManager::filterMessagesLikeThis(const Message& msg) { - QString filter_script = QSL("function filterMessage() {\n" - " // Adjust the condition to suit your needs.\n" - " var is_message_same =\n" - " msg.isRead == %1 &&\n" - " msg.isImportant == %2 &&\n" - " msg.title == '%3' &&\n" - " msg.url == '%4';\n" - "\n" - " if (is_message_same) {\n" - " return MessageObject.Accept;\n" - " }\n" - " else {\n" - " return MessageObject.Ignore;\n" - " }\n" - "}").arg(QString::number(int(msg.m_isRead)), - QString::number(int(msg.m_isImportant)), - msg.m_title, - msg.m_url); + QString filter_script = + QSL("function filterMessage() {\n" + " // Adjust the condition to suit your needs.\n" + " var is_message_same =\n" + " msg.isRead == %1 &&\n" + " msg.isImportant == %2 &&\n" + " msg.title == '%3' &&\n" + " msg.url == '%4';\n" + "\n" + " if (is_message_same) {\n" + " return MessageObject.Accept;\n" + " }\n" + " else {\n" + " return MessageObject.Ignore;\n" + " }\n" + "}") + .arg(QString::number(int(msg.m_isRead)), QString::number(int(msg.m_isImportant)), msg.m_title, msg.m_url); addNewFilter(filter_script); } @@ -152,11 +167,14 @@ void FormMessageFiltersManager::removeSelectedFilter() { return; } - if (MsgBox::show(this, QMessageBox::Icon::Question, tr("Are you sure?"), - tr("Do you really want to remove selected filter?"), - {}, fltr->name(), - QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, - QMessageBox::StandardButton::No) == QMessageBox::StandardButton::Yes) { + if (MsgBox::show(this, + QMessageBox::Icon::Question, + tr("Are you sure?"), + tr("Do you really want to remove selected filter?"), + {}, + fltr->name(), + QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, + QMessageBox::StandardButton::No) == QMessageBox::StandardButton::Yes) { m_reader->removeMessageFilter(fltr); delete m_ui.m_listFilters->currentItem(); } @@ -174,11 +192,10 @@ void FormMessageFiltersManager::loadFilters() { void FormMessageFiltersManager::addNewFilter(const QString& filter_script) { try { - auto* fltr = m_reader->addMessageFilter( - tr("New article filter"), - filter_script.isEmpty() - ? QSL("function filterMessage() { return MessageObject.Accept; }") - : filter_script); + auto* fltr = m_reader->addMessageFilter(tr("New article filter"), + filter_script.isEmpty() + ? QSL("function filterMessage() { return MessageObject.Accept; }") + : filter_script); auto* it = new QListWidgetItem(fltr->name(), m_ui.m_listFilters); it->setData(Qt::ItemDataRole::UserRole, QVariant::fromValue(fltr)); @@ -186,8 +203,10 @@ void FormMessageFiltersManager::addNewFilter(const QString& filter_script) { m_ui.m_listFilters->setCurrentRow(m_ui.m_listFilters->count() - 1); } catch (const ApplicationException& ex) { - MsgBox::show(this, QMessageBox::Icon::Critical, tr("Error"), - tr("Cannot save new filter, error: '%1'.").arg(ex.message())); + MsgBox::show(this, + QMessageBox::Icon::Critical, + tr("Error"), + tr("Cannot save new filter, error: '%1'.").arg(ex.message())); } } @@ -226,12 +245,9 @@ void FormMessageFiltersManager::testFilter() { QJSEngine filter_engine; QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className()); MessageObject msg_obj(&database, - selected_fd_cat->kind() == RootItem::Kind::Feed - ? selected_fd_cat->customId() - : QString::number(NO_PARENT_CATEGORY), - selectedAccount() != nullptr - ? selectedAccount()->accountId() - : NO_PARENT_CATEGORY, + selected_fd_cat->kind() == RootItem::Kind::Feed ? selected_fd_cat->customId() + : QString::number(NO_PARENT_CATEGORY), + selectedAccount() != nullptr ? selectedAccount()->accountId() : NO_PARENT_CATEGORY, selected_fd_cat->getParentServiceRoot()->labelsNode()->labels(), false); auto* fltr = selectedFilter(); @@ -258,11 +274,11 @@ void FormMessageFiltersManager::testFilter() { try { MessageObject::FilteringAction decision = fltr->filterMessage(&filter_engine); - m_ui.m_txtErrors->setTextColor(decision == MessageObject::FilteringAction::Accept ? Qt::GlobalColor::darkGreen : Qt::GlobalColor::red); + m_ui.m_txtErrors->setTextColor(decision == MessageObject::FilteringAction::Accept ? Qt::GlobalColor::darkGreen + : Qt::GlobalColor::red); - QString answer = tr("Article will be %1.\n\n").arg(decision == MessageObject::FilteringAction::Accept - ? tr("ACCEPTED") - : tr("REJECTED")); + QString answer = tr("Article will be %1.\n\n") + .arg(decision == MessageObject::FilteringAction::Accept ? tr("ACCEPTED") : tr("REJECTED")); answer += tr("Output (modified) article is:\n" " Title = '%1'\n" @@ -271,12 +287,15 @@ void FormMessageFiltersManager::testFilter() { " Is read/important = '%4/%5'\n" " Created on = '%6'\n" " Contents = '%7'\n" - " RAW contents = '%8'").arg(msg.m_title, msg.m_url, msg.m_author, - msg.m_isRead ? tr("yes") : tr("no"), - msg.m_isImportant ? tr("yes") : tr("no"), - QString::number(msg.m_created.toMSecsSinceEpoch()), - msg.m_contents, - msg.m_rawContents); + " RAW contents = '%8'") + .arg(msg.m_title, + msg.m_url, + msg.m_author, + msg.m_isRead ? tr("yes") : tr("no"), + msg.m_isImportant ? tr("yes") : tr("no"), + QString::number(msg.m_created.toMSecsSinceEpoch()), + msg.m_contents, + msg.m_rawContents); m_ui.m_txtErrors->insertPlainText(answer); } @@ -324,7 +343,8 @@ void FormMessageFiltersManager::processCheckedFeeds() { auto labels_in_message = DatabaseQueries::getLabelsForMessage(database, msgs[i], msg_obj.availableLabels()); // Create backup of message. - Message* msg = &msgs[i]; msg->m_assignedLabels = labels_in_message; + Message* msg = &msgs[i]; + msg->m_assignedLabels = labels_in_message; msg->m_rawContents = Message::generateRawAtomContents(*msg); @@ -349,21 +369,22 @@ void FormMessageFiltersManager::processCheckedFeeds() { } } catch (const FilteringException& ex) { - qCriticalNN << LOGSEC_CORE - << "Error when running script when processing existing messages:" + qCriticalNN << LOGSEC_CORE << "Error when running script when processing existing messages:" << QUOTE_W_SPACE_DOT(ex.message()); continue; } if (!msg_backup.m_isRead && msg->m_isRead) { - qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_backup.m_customId << "' was marked as read by message scripts."; + qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_backup.m_customId + << "' was marked as read by message scripts."; read_msgs << *msg; } if (!msg_backup.m_isImportant && msg->m_isImportant) { - qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_backup.m_customId << "' was marked as important by message scripts."; + qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_backup.m_customId + << "' was marked as important by message scripts."; important_msgs << *msg; } @@ -374,10 +395,8 @@ void FormMessageFiltersManager::processCheckedFeeds() { // Label is not there anymore, it was deassigned. lbl->deassignFromMessage(*msg); - qDebugNN << LOGSEC_FEEDDOWNLOADER - << "It was detected that label" << QUOTE_W_SPACE(lbl->customId()) - << "was DEASSIGNED from message" << QUOTE_W_SPACE(msg->m_customId) - << "by message filter(s)."; + qDebugNN << LOGSEC_FEEDDOWNLOADER << "It was detected that label" << QUOTE_W_SPACE(lbl->customId()) + << "was DEASSIGNED from message" << QUOTE_W_SPACE(msg->m_customId) << "by message filter(s)."; } } @@ -387,10 +406,8 @@ void FormMessageFiltersManager::processCheckedFeeds() { // was newly assigned. lbl->assignToMessage(*msg); - qDebugNN << LOGSEC_FEEDDOWNLOADER - << "It was detected that label" << QUOTE_W_SPACE(lbl->customId()) - << "was ASSIGNED to message" << QUOTE_W_SPACE(msg->m_customId) - << "by message filter(s)."; + qDebugNN << LOGSEC_FEEDDOWNLOADER << "It was detected that label" << QUOTE_W_SPACE(lbl->customId()) + << "was ASSIGNED to message" << QUOTE_W_SPACE(msg->m_customId) << "by message filter(s)."; } } @@ -403,8 +420,7 @@ void FormMessageFiltersManager::processCheckedFeeds() { if (!read_msgs.isEmpty()) { // Now we push new read states to the service. if (it->getParentServiceRoot()->onBeforeSetMessagesRead(it, read_msgs, RootItem::ReadStatus::Read)) { - qDebugNN << LOGSEC_FEEDDOWNLOADER - << "Notified services about messages marked as read by message filters."; + qDebugNN << LOGSEC_FEEDDOWNLOADER << "Notified services about messages marked as read by message filters."; } else { qCriticalNN << LOGSEC_FEEDDOWNLOADER @@ -414,9 +430,11 @@ void FormMessageFiltersManager::processCheckedFeeds() { if (!important_msgs.isEmpty()) { // Now we push new read states to the service. - auto list = boolinq::from(important_msgs).select([](const Message& msg) { - return ImportanceChange(msg, RootItem::Importance::Important); - }).toStdList(); + auto list = boolinq::from(important_msgs) + .select([](const Message& msg) { + return ImportanceChange(msg, RootItem::Importance::Important); + }) + .toStdList(); QList chngs = FROM_STD_LIST(QList, list); if (it->getParentServiceRoot()->onBeforeSwitchMessageImportance(it, chngs)) { @@ -538,20 +556,20 @@ void FormMessageFiltersManager::beautifyScript() { QProcess proc_clang_format(this); proc_clang_format.setInputChannelMode(QProcess::InputChannelMode::ManagedInputChannel); - proc_clang_format.setArguments({ "--assume-filename=script.js", "--style=Chromium" }); + proc_clang_format.setArguments({"--assume-filename=script.js", "--style=Chromium"}); #if defined(Q_OS_WIN) - proc_clang_format.setProgram(qApp->applicationDirPath() + QDir::separator() + - QSL("clang-format") + QDir::separator() + - QSL("clang-format.exe")); + proc_clang_format.setProgram(qApp->applicationDirPath() + QDir::separator() + QSL("clang-format") + + QDir::separator() + QSL("clang-format.exe")); #else proc_clang_format.setProgram(QSL("clang-format")); #endif if (!proc_clang_format.open() || proc_clang_format.error() == QProcess::ProcessError::FailedToStart) { - MsgBox::show(this, QMessageBox::Icon::Critical, - tr("Cannot find 'clang-format'"), - tr("Script was not beautified, because 'clang-format' tool was not found.")); + MsgBox::show(this, + QMessageBox::Icon::Critical, + tr("Cannot find 'clang-format'"), + tr("Script was not beautified, because 'clang-format' tool was not found.")); return; } @@ -567,21 +585,47 @@ void FormMessageFiltersManager::beautifyScript() { else { auto err = proc_clang_format.readAllStandardError(); - MsgBox::show(this, QMessageBox::Icon::Critical, - tr("Error"), - tr("Script was not beautified, because 'clang-format' tool thrown error."), - QString(), - err); + MsgBox::show(this, + QMessageBox::Icon::Critical, + tr("Error"), + tr("Script was not beautified, because 'clang-format' tool thrown error."), + QString(), + err); } } else { proc_clang_format.kill(); - MsgBox::show(this, QMessageBox::Icon::Critical, - tr("Beautifier was running for too long time"), - tr("Script was not beautified, is 'clang-format' installed?")); + MsgBox::show(this, + QMessageBox::Icon::Critical, + tr("Beautifier was running for too long time"), + tr("Script was not beautified, is 'clang-format' installed?")); } } +void FormMessageFiltersManager::insertPremadeFilter(QAction* act_filter) { + QString filter_path = QSL(":/scripts/filters/") + act_filter->text(); + + try { + m_ui.m_txtScript->setPlainText(QString::fromUtf8(IOFactory::readFile(filter_path))); + } + catch (...) { + } +} + +void FormMessageFiltersManager::initializePremadeFilters() { + QMenu* mn_filters = new QMenu(this); + + connect(mn_filters, &QMenu::triggered, this, &FormMessageFiltersManager::insertPremadeFilter); + + auto js_files = QDir(QSL(":/scripts/filters")).entryList(); + + for (const QString& js_file : js_files) { + mn_filters->addAction(js_file); + } + + m_ui.m_btnPremadeFilters->setMenu(mn_filters); +} + void FormMessageFiltersManager::initializeTestingMessage() { m_ui.m_cbSampleImportant->setChecked(true); m_ui.m_txtSampleUrl->setText(QSL("https://mynews.com/news/5")); diff --git a/src/librssguard/gui/dialogs/formmessagefiltersmanager.h b/src/librssguard/gui/dialogs/formmessagefiltersmanager.h index 9cdfc94a7..923274b04 100644 --- a/src/librssguard/gui/dialogs/formmessagefiltersmanager.h +++ b/src/librssguard/gui/dialogs/formmessagefiltersmanager.h @@ -15,10 +15,12 @@ class FeedReader; class MessagesForFiltersModel; class FormMessageFiltersManager : public QDialog { - Q_OBJECT + Q_OBJECT public: - explicit FormMessageFiltersManager(FeedReader* reader, const QList& accounts, QWidget* parent = nullptr); + explicit FormMessageFiltersManager(FeedReader* reader, + const QList& accounts, + QWidget* parent = nullptr); virtual ~FormMessageFiltersManager(); MessageFilter* selectedFilter() const; @@ -48,9 +50,12 @@ class FormMessageFiltersManager : public QDialog { // Display filter title/contents. void showFilter(MessageFilter* filter); + void insertPremadeFilter(QAction* act_filter); + private: void loadAccounts(); void beautifyScript(); + void initializePremadeFilters(); void initializeTestingMessage(); RootItem* selectedCategoryFeed() const; diff --git a/src/librssguard/gui/dialogs/formmessagefiltersmanager.ui b/src/librssguard/gui/dialogs/formmessagefiltersmanager.ui index 2a49c30ba..0dde02e32 100644 --- a/src/librssguard/gui/dialogs/formmessagefiltersmanager.ui +++ b/src/librssguard/gui/dialogs/formmessagefiltersmanager.ui @@ -126,23 +126,47 @@ - - - - 0 - 0 - - - - - 300 - 16777215 - - - - Title of article filter - - + + + + + + 0 + 0 + + + + + 300 + 16777215 + + + + Title of article filter + + + + + + + Pre-made filters + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + @@ -430,6 +454,7 @@ m_btnCheckAll m_btnUncheckAll m_txtTitle + m_btnPremadeFilters m_txtScript m_btnTest m_btnRunOnMessages @@ -437,6 +462,14 @@ m_btnDetailedHelp m_twMessages m_treeExistingMessages + m_txtSampleTitle + m_txtSampleUrl + m_txtSampleAuthor + m_txtSampleCreatedOn + m_txtSampleContents + m_cbSampleRead + m_cbSampleImportant + m_txtErrors diff --git a/src/librssguard/services/standard/parsers/feedparser.cpp b/src/librssguard/services/standard/parsers/feedparser.cpp index 834d98787..371451570 100644 --- a/src/librssguard/services/standard/parsers/feedparser.cpp +++ b/src/librssguard/services/standard/parsers/feedparser.cpp @@ -13,8 +13,8 @@ #include -FeedParser::FeedParser(QString data, bool is_xml) : m_isXml(is_xml), m_data(std::move(data)), - m_mrssNamespace(QSL("http://search.yahoo.com/mrss/")) { +FeedParser::FeedParser(QString data, bool is_xml) + : m_isXml(is_xml), m_data(std::move(data)), m_mrssNamespace(QSL("http://search.yahoo.com/mrss/")) { if (m_isXml) { // XML. @@ -109,9 +109,7 @@ QList FeedParser::messages() { messages.append(new_message); } catch (const ApplicationException& ex) { - qDebugNN << LOGSEC_CORE - << "Problem when extracting XML message: " - << ex.message(); + qDebugNN << LOGSEC_CORE << "Problem when extracting XML message: " << ex.message(); } } } @@ -137,9 +135,7 @@ QList FeedParser::messages() { messages.append(new_message); } catch (const ApplicationException& ex) { - qDebugNN << LOGSEC_CORE - << "Problem when extracting JSON message: " - << ex.message(); + qDebugNN << LOGSEC_CORE << "Problem when extracting JSON message: " << ex.message(); } } } @@ -249,8 +245,10 @@ QString FeedParser::xmlRawChild(const QDomElement& container) const { return raw; } -QStringList FeedParser::xmlTextsFromPath(const QDomElement& element, const QString& namespace_uri, - const QString& xml_path, bool only_first) const { +QStringList FeedParser::xmlTextsFromPath(const QDomElement& element, + const QString& namespace_uri, + const QString& xml_path, + bool only_first) const { QStringList paths = xml_path.split('/'); QStringList result; QList current_elements;