new setup/teardown api for runners so we don't hang onto tons of data and live connections when not matching
svn path=/trunk/KDE/kdelibs/; revision=1003355
This commit is contained in:
parent
68d9558843
commit
000d79016b
@ -244,6 +244,26 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
||||
*/
|
||||
static QMutex *bigLock();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when matching is about to commence, giving runners
|
||||
* an opportunity to prepare themselves, e.g. loading data sets or preparing
|
||||
* IPC or network connections. This method should be fast so as not to cause
|
||||
* slow downs. Things that take longer or which should be loaded once and
|
||||
* remain extant for the lifespan of the AbstractRunner should be done in init().
|
||||
* @see init()
|
||||
* @since 4.4
|
||||
*/
|
||||
void prepare();
|
||||
|
||||
/**
|
||||
* This signal is emitted when a session of matches is complete, giving runners
|
||||
* the opportunity to tear down anything set up as a result of the prepare()
|
||||
* method.
|
||||
* @since 4.4
|
||||
*/
|
||||
void teardown();
|
||||
|
||||
protected:
|
||||
friend class RunnerManager;
|
||||
friend class RunnerManagerPrivate;
|
||||
|
@ -56,7 +56,8 @@ public:
|
||||
|
||||
RunnerManagerPrivate(RunnerManager *parent)
|
||||
: q(parent),
|
||||
deferredRun(0)
|
||||
deferredRun(0),
|
||||
prepped(false)
|
||||
{
|
||||
matchChangeTimer.setSingleShot(true);
|
||||
delayTimer.setSingleShot(true);
|
||||
@ -218,8 +219,9 @@ public:
|
||||
QHash<QString, AbstractRunner*> runners;
|
||||
QSet<FindMatchesJob*> searchJobs;
|
||||
QSet<FindMatchesJob*> oldSearchJobs;
|
||||
bool loadAll;
|
||||
KConfigGroup config;
|
||||
bool loadAll : 1;
|
||||
bool prepped : 1;
|
||||
};
|
||||
|
||||
/*****************************************************
|
||||
@ -325,13 +327,39 @@ QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
|
||||
return QList<QAction*>();
|
||||
}
|
||||
|
||||
void RunnerManager::setupMatchSession()
|
||||
{
|
||||
if (d->prepped) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (AbstractRunner *runner, d->runners) {
|
||||
emit runner->prepare();
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerManager::matchSessionComplete()
|
||||
{
|
||||
if (!d->prepped) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (AbstractRunner *runner, d->runners) {
|
||||
emit runner->teardown();
|
||||
}
|
||||
|
||||
d->prepped = false;
|
||||
}
|
||||
|
||||
void RunnerManager::launchQuery(const QString &term)
|
||||
{
|
||||
setupMatchSession();
|
||||
launchQuery(term, QString());
|
||||
}
|
||||
|
||||
void RunnerManager::launchQuery(const QString &untrimmedTerm, const QString &runnerName)
|
||||
{
|
||||
setupMatchSession();
|
||||
QString term = untrimmedTerm.trimmed();
|
||||
|
||||
if (d->runners.isEmpty()) {
|
||||
|
@ -105,6 +105,23 @@ class PLASMA_EXPORT RunnerManager : public QObject
|
||||
void reloadConfiguration();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Call this method when the runners should be prepared for a query session.
|
||||
* Call matchSessionComplete when the query session is finished for the time
|
||||
* being.
|
||||
* @since 4.4
|
||||
* @see matchSessionComplete
|
||||
*/
|
||||
void setupMatchSession();
|
||||
|
||||
/**
|
||||
* Call this method when the query session is finished for the time
|
||||
* being.
|
||||
* @since 4.4
|
||||
* @see prepareForMatchSession
|
||||
*/
|
||||
void matchSessionComplete();
|
||||
|
||||
/**
|
||||
* Launch a query, this will create threads and return inmediately.
|
||||
* When the information will be available can be known using the
|
||||
|
Loading…
Reference in New Issue
Block a user