Homerun and single-runner runners

Aurélien Gâteau agateau at kde.org
Wed Feb 13 10:15:58 UTC 2013


Hi,

I have been working lately on adding better support for single-runner runners 
to Homerun. The code is currently available in the "wip/single-runner" branch 
of Homerun.

This code exposes all runners which advertise single-runner mode as sources. 
When a single-runner is used, Homerun uses the runner default syntax to query 
its content. Any search performed in Homerun search field gets "translated" 
into the runner default syntax.

This means that if I add the "Activities" runner, whose default syntax is 
"activity :q:", then by default Homerun queries the runner for "activity". If 
the user types "work" in the search field, Homerun queries the runner for 
"activity work".

# The plan

In the long term, I hope this makes it possible to drop some of Homerun 
sources and replace them with single-runner runners. Potential candidates are 
(Source => runner):
- Favorite Places => Places
- Recent Documents => Recent Documents
- Power => Powerdevil
- Sessions => Sessions

Some of them need additional work to provide what I would like to feature in 
Homerun, but assuming you agree with this, I believe I can get it done in time 
for KDE SC 4.11.

# Questions

1. Does this sound like a good plan to you?

2. The way single-runners are queried is not very elegant. It looks like this:

QString SingleRunnerModel::prepareSearchTerm(const QString &term)
{
    const char *placeHolder = ":q:";
    Q_ASSERT(m_manager);
    Plasma::RunnerSyntax *syntax = 
				m_manager->singleModeRunner()->defaultSyntax();
    QStringList queries = syntax->exampleQueries();
    Q_ASSERT(!queries.isEmpty());
    QString query = queries.first();
    if (query.contains(placeHolder)) {
        return query.replace(placeHolder, term);
    } else {
        return query + ' ' + term;
    }
}

Is there a better way to do this?

3. I noticed some runners advertise single-runner mode but do not define a 
default syntax. Is it a bug or is there a reason for that?

# Screenshots

- Activities, Kate and KDevelop sessions runners inside Homerun (review 
requests are going to be filed for Kate and KDevelop session runners)

  http://agateau.com/tmp/homerun-single-runners.png

- Configure mode showing single-runner runners (Command line should probably 
not advertise itself as supporting single-runner mode):

  http://agateau.com/tmp/homerun-single-runners-configure.png

Aurélien


More information about the Plasma-devel mailing list