handle single mode better
This commit is contained in:
parent
c049c116cf
commit
fb6b4ecc09
@ -76,12 +76,18 @@ void RunnerModel::setRunners(const QStringList &allowedRunners)
|
|||||||
{
|
{
|
||||||
if (m_manager) {
|
if (m_manager) {
|
||||||
m_manager->setAllowedRunners(allowedRunners);
|
m_manager->setAllowedRunners(allowedRunners);
|
||||||
|
|
||||||
//automagically enter single runner mode if there's only 1 allowed runner
|
|
||||||
m_manager->setSingleMode(allowedRunners.count() == 1);
|
|
||||||
emit runnersChanged();
|
emit runnersChanged();
|
||||||
} else {
|
} else {
|
||||||
m_pendingRunnersList = allowedRunners;
|
m_pendingRunnersList = allowedRunners;
|
||||||
|
kDebug() << "runners set" << m_pendingRunnersList.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
// to trigger single runner fun!
|
||||||
|
if (allowedRunners.count() == 1) {
|
||||||
|
m_singleRunnerId = allowedRunners.first();
|
||||||
|
scheduleQuery(QString());
|
||||||
|
} else {
|
||||||
|
m_singleRunnerId.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,24 +158,25 @@ void RunnerModel::scheduleQuery(const QString &query)
|
|||||||
|
|
||||||
void RunnerModel::startQuery()
|
void RunnerModel::startQuery()
|
||||||
{
|
{
|
||||||
if (!m_manager && m_pendingQuery.isEmpty()) {
|
// avoid creating a manager just so we can run nothing
|
||||||
// avoid creating a manager just so we can run nothing
|
// however, if we have one pending runner, then we'll be in single query mode
|
||||||
|
// and a null query is a valid query
|
||||||
|
if (!m_manager && m_pendingRunnersList.count() != 1 && m_pendingQuery.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug() << "booooooo yah!!!!!!!!!!!!!" << query;
|
//kDebug() << "!!!!!!!!!!!!!" << m_pendingQuery << m_manager;
|
||||||
createManager();
|
|
||||||
|
|
||||||
// if (m_pendingQuery != m_manager->query()) {
|
if (createManager() || m_pendingQuery != m_manager->query()) {
|
||||||
//kDebug() << "running query" << query;
|
//kDebug() << "running query" << m_pendingQuery << m_manager;
|
||||||
m_manager->launchQuery(m_pendingQuery);
|
m_manager->launchQuery(m_pendingQuery, m_singleRunnerId);
|
||||||
emit queryChanged();
|
emit queryChanged();
|
||||||
m_running = true;
|
m_running = true;
|
||||||
emit runningChanged(true);
|
emit runningChanged(true);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunnerModel::createManager()
|
bool RunnerModel::createManager()
|
||||||
{
|
{
|
||||||
if (!m_manager) {
|
if (!m_manager) {
|
||||||
m_manager = new Plasma::RunnerManager(this);
|
m_manager = new Plasma::RunnerManager(this);
|
||||||
@ -179,12 +186,14 @@ void RunnerModel::createManager()
|
|||||||
this, SLOT(queryHasFinished()));
|
this, SLOT(queryHasFinished()));
|
||||||
|
|
||||||
if (!m_pendingRunnersList.isEmpty()) {
|
if (!m_pendingRunnersList.isEmpty()) {
|
||||||
m_manager->setAllowedRunners(m_pendingRunnersList);
|
setRunners(m_pendingRunnersList);
|
||||||
m_manager->setSingleMode(m_pendingRunnersList.count() == 1);
|
|
||||||
m_pendingRunnersList.clear();
|
m_pendingRunnersList.clear();
|
||||||
}
|
}
|
||||||
//connect(m_manager, SIGNAL(queryFinished()), this, SLOT(queryFinished()));
|
//connect(m_manager, SIGNAL(queryFinished()), this, SLOT(queryFinished()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
|
void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
|
||||||
|
@ -104,7 +104,7 @@ private Q_SLOTS:
|
|||||||
void startQuery();
|
void startQuery();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createManager();
|
bool createManager();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void matchesChanged(const QList<Plasma::QueryMatch> &matches);
|
void matchesChanged(const QList<Plasma::QueryMatch> &matches);
|
||||||
@ -114,6 +114,7 @@ private:
|
|||||||
Plasma::RunnerManager *m_manager;
|
Plasma::RunnerManager *m_manager;
|
||||||
QList<Plasma::QueryMatch> m_matches;
|
QList<Plasma::QueryMatch> m_matches;
|
||||||
QStringList m_pendingRunnersList;
|
QStringList m_pendingRunnersList;
|
||||||
|
QString m_singleRunnerId;
|
||||||
QString m_pendingQuery;
|
QString m_pendingQuery;
|
||||||
QTimer *m_startQueryTimer;
|
QTimer *m_startQueryTimer;
|
||||||
QTimer *m_runningChangedTimeout;
|
QTimer *m_runningChangedTimeout;
|
||||||
|
Loading…
Reference in New Issue
Block a user