Changeset View
Changeset View
Standalone View
Standalone View
src/runnermanager.cpp
Show All 15 Lines | |||||
16 | * You should have received a copy of the GNU Library General Public | 16 | * You should have received a copy of the GNU Library General Public | ||
17 | * License along with this program; if not, write to the | 17 | * License along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., | 18 | * Free Software Foundation, Inc., | ||
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "runnermanager.h" | 22 | #include "runnermanager.h" | ||
23 | 23 | | |||
24 | #include <QElapsedTimer> | ||||
24 | #include <QMutex> | 25 | #include <QMutex> | ||
25 | #include <QTimer> | 26 | #include <QTimer> | ||
26 | #include <QCoreApplication> | 27 | #include <QCoreApplication> | ||
27 | #include <qstandardpaths.h> | 28 | #include <qstandardpaths.h> | ||
28 | #include "krunner_debug.h" | 29 | #include "krunner_debug.h" | ||
29 | 30 | | |||
30 | #include <ksharedconfig.h> | 31 | #include <ksharedconfig.h> | ||
31 | #include <kplugininfo.h> | 32 | #include <kplugininfo.h> | ||
Show All 37 Lines | 62 | : q(parent), | |||
69 | singleRunnerWasLoaded(false) | 70 | singleRunnerWasLoaded(false) | ||
70 | { | 71 | { | ||
71 | matchChangeTimer.setSingleShot(true); | 72 | matchChangeTimer.setSingleShot(true); | ||
72 | delayTimer.setSingleShot(true); | 73 | delayTimer.setSingleShot(true); | ||
73 | 74 | | |||
74 | QObject::connect(&matchChangeTimer, SIGNAL(timeout()), q, SLOT(matchesChanged())); | 75 | QObject::connect(&matchChangeTimer, SIGNAL(timeout()), q, SLOT(matchesChanged())); | ||
75 | QObject::connect(&context, SIGNAL(matchesChanged()), q, SLOT(scheduleMatchesChanged())); | 76 | QObject::connect(&context, SIGNAL(matchesChanged()), q, SLOT(scheduleMatchesChanged())); | ||
76 | QObject::connect(&delayTimer, SIGNAL(timeout()), q, SLOT(unblockJobs())); | 77 | QObject::connect(&delayTimer, SIGNAL(timeout()), q, SLOT(unblockJobs())); | ||
78 | | ||||
79 | // Set up tracking of the last time matchesChanged was signalled | ||||
80 | lastMatchChangeSignalled.start(); | ||||
81 | QObject::connect(q, &RunnerManager::matchesChanged, q, [&] { lastMatchChangeSignalled.restart(); }); | ||||
77 | } | 82 | } | ||
78 | 83 | | |||
79 | ~RunnerManagerPrivate() | 84 | ~RunnerManagerPrivate() | ||
80 | { | 85 | { | ||
81 | KConfigGroup config = configGroup(); | 86 | KConfigGroup config = configGroup(); | ||
82 | context.save(config); | 87 | context.save(config); | ||
83 | } | 88 | } | ||
84 | 89 | | |||
85 | void scheduleMatchesChanged() | 90 | void scheduleMatchesChanged() | ||
86 | { | 91 | { | ||
87 | matchChangeTimer.start(100); | 92 | if(lastMatchChangeSignalled.hasExpired(250)) { | ||
93 | matchChangeTimer.stop(); | ||||
94 | emit q->matchesChanged(context.matches()); | ||||
95 | } else { | ||||
96 | matchChangeTimer.start(250 - lastMatchChangeSignalled.elapsed()); | ||||
97 | } | ||||
88 | } | 98 | } | ||
89 | 99 | | |||
90 | void matchesChanged() | 100 | void matchesChanged() | ||
91 | { | 101 | { | ||
92 | emit q->matchesChanged(context.matches()); | 102 | emit q->matchesChanged(context.matches()); | ||
93 | } | 103 | } | ||
94 | 104 | | |||
95 | void loadConfiguration() | 105 | void loadConfiguration() | ||
▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Line(s) | 322 | #endif | |||
425 | // Delay in ms before slow runners are allowed to run | 435 | // Delay in ms before slow runners are allowed to run | ||
426 | static const int slowRunDelay = 400; | 436 | static const int slowRunDelay = 400; | ||
427 | 437 | | |||
428 | RunnerManager *q; | 438 | RunnerManager *q; | ||
429 | QueryMatch deferredRun; | 439 | QueryMatch deferredRun; | ||
430 | RunnerContext context; | 440 | RunnerContext context; | ||
431 | QTimer matchChangeTimer; | 441 | QTimer matchChangeTimer; | ||
432 | QTimer delayTimer; // Timer to control when to run slow runners | 442 | QTimer delayTimer; // Timer to control when to run slow runners | ||
443 | QElapsedTimer lastMatchChangeSignalled; | ||||
433 | QHash<QString, AbstractRunner*> runners; | 444 | QHash<QString, AbstractRunner*> runners; | ||
434 | QHash<QString, QString> advertiseSingleRunnerIds; | 445 | QHash<QString, QString> advertiseSingleRunnerIds; | ||
435 | AbstractRunner* currentSingleRunner; | 446 | AbstractRunner* currentSingleRunner; | ||
436 | QSet<QSharedPointer<FindMatchesJob> > searchJobs; | 447 | QSet<QSharedPointer<FindMatchesJob> > searchJobs; | ||
437 | QSet<QSharedPointer<FindMatchesJob> > oldSearchJobs; | 448 | QSet<QSharedPointer<FindMatchesJob> > oldSearchJobs; | ||
438 | KConfigGroup conf; | 449 | KConfigGroup conf; | ||
439 | QStringList enabledCategories; | 450 | QStringList enabledCategories; | ||
440 | QString singleModeRunnerId; | 451 | QString singleModeRunnerId; | ||
▲ Show 20 Lines • Show All 401 Lines • Show Last 20 Lines |