Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSS defer matching articles for rules until idle. Closes #6166. #6177

Closed
wants to merge 5 commits into from

Conversation

magao
Copy link
Contributor

@magao magao commented Jan 1, 2017

This is one of a series of pull requests designed to improve the responsiveness of the UI. This pull request addresses #6166.

Currently when editing an RSS rule each modification (e.g. each keypress in "Must Contain") results in immediately matching articles to populate the tree. This matching can take a long time - seconds is not uncommon, and can be a lot longer (one of my filters takes ~1 minute) - during which no further input is accepted.

This pull requests delays the article matching until there has been at least 1 second without any changes to the rule. This allows typing, etc without delay and makes for a much more responsive UI.

This pull request also adds a processing indicator while the articles are being matched:

rss_matching

Note: this pull request includes a commit (ee0359c) which has been factored out to allow all the pull requests I am submitting to merge without conflicts.

@magao
Copy link
Contributor Author

magao commented Jan 8, 2017

Rebased on top of #6212 and uncrustified.

@sledgehammer999 sledgehammer999 added the RSS RSS-related issues/changes label Jan 18, 2017
// Set the loading icon and allow it to be displayed
ui->treeMatchingLoading->setPixmap(QIcon(":/icons/loading.png").pixmap(16, 16));
m_updateMatchingArticlesDeferrals.ref();
// Need to have a 1ms delay here or we don't get the screen update - not sure why
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because UI updates happen after control has returned to the mainloop.
So instead of the timer+return I think you can safely do:

QCoreApplication::instance()->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);

@@ -521,12 +522,36 @@ void AutomatedRssDownloader::handleFeedCheckStateChange(QListWidgetItem *feed_it
void AutomatedRssDownloader::updateMatchingArticles()
{
ui->treeMatchingArticles->clear();
saveEditedRule();
m_updateMatchingArticlesDeferrals.ref();
QTimer::singleShot(1000, this, SLOT(deferredUpdateMatchingArticles()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will create a multitude of temporary QTimers. If I read it correctly it will create one for each keystroke.
Instead do this. In the class constructor create a member Timer. Set its property to singleshot and its interval to 1000ms.
Then in this function/slot, just call start() on the timer. If it is already running it will be restarted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I'll change it to work that way. Qt newbie ...

@magao
Copy link
Contributor Author

magao commented Jan 22, 2017

@sledgehammer999 Rebased on top of master. Changed to use a single timer for the 1-second delay before matching, and to use processEvents() to show the processing icon.

Also added a few closely-related changes:

  1. Don't select the first rule in the list when opening the dialog (otherwise it starts matching on that immediately).

  2. Sort matched articles ascending.

  3. Don't have duplicates in the tree (e.g. if multiple rules are selected and an article matches more that one).


foreach (const QListWidgetItem *rule_item, ui->listRules->selectedItems()) {
Rss::DownloadRulePtr rule = m_editableRuleList->getRule(rule_item->text());
if (rule) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curly brackets aren't needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same - must not have re-run uncrustify.

@@ -47,10 +50,35 @@
#include "ui_automatedrssdownloader.h"
#include "automatedrssdownloader.h"

class AutomatedRssDownloader::DownloadRuleListMatchState
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the usefulness of this class. Why not just make the QTimer and QSet privatemembers of the AutomatedRssDownloader class?
I read the next commit too, but I still don't see the benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more useful for PR #6178 (200a815) which has to hold a lot more state. By including it in these commits it makes for more straightforward diffs IMO. But I'm happy to move them to AutomatedRssDownloader if you'd prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll probably respond tomorrow. Today, I am not in a state where I can read complex PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems - I can rework it on the weekend if needed. Working on things today because it's a public holiday here today (Australia Day).

AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager> &manager, QWidget *parent)
: QDialog(parent),
ui(new Ui::AutomatedRssDownloader),
m_manager(manager), m_editedRule(0)
m_manager(manager), m_editedRule(0),
m_ruleMatcher(new AutomatedRssDownloader::DownloadRuleListMatchState())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something went wrong with uncrustify.
The initialization list should look like this:

AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager> &manager, QWidget *parent)
     : QDialog(parent)
     , ui(new Ui::AutomatedRssDownloader)
     , m_manager(manager)
     , m_editedRule(0)
     , m_ruleMatcher(new AutomatedRssDownloader::DownloadRuleListMatchState())
{
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must not have re-run uncrustify on this - I'll do so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take note that the lines that you didn't chagne in this diff are also wrong in the initialization list.
(comma goes in the start to reduce noise in the diff when adding new fields)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that uncrustify doesn't fix that initialisation list - you might want to look at the uncrustify.cfg.

I'll fix it here manually.

@magao
Copy link
Contributor Author

magao commented Jan 28, 2017

@sledgehammer999 Rebased on top of master, added an uncrustify commit before all the other commits and ran uncrustify for each commit.

@magao
Copy link
Contributor Author

magao commented Feb 5, 2017

This PR is on hold until #6326 and #6345 have been reviewed and (preferably) merged (there are merge conflicts due to changing some of the same code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RSS RSS-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants