running property
true when at least some runner is not done yet
This commit is contained in:
parent
204946e451
commit
4c79f05a60
@ -30,7 +30,8 @@
|
|||||||
RunnerModel::RunnerModel(QObject *parent)
|
RunnerModel::RunnerModel(QObject *parent)
|
||||||
: QAbstractListModel(parent),
|
: QAbstractListModel(parent),
|
||||||
m_manager(0),
|
m_manager(0),
|
||||||
m_startQueryTimer(new QTimer(this))
|
m_startQueryTimer(new QTimer(this)),
|
||||||
|
m_running(false)
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles.insert(Qt::DisplayRole, "label");
|
roles.insert(Qt::DisplayRole, "label");
|
||||||
@ -86,6 +87,11 @@ void RunnerModel::run(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RunnerModel::isRunning() const
|
||||||
|
{
|
||||||
|
return m_running;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant RunnerModel::data(const QModelIndex &index, int role) const
|
QVariant RunnerModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid() || index.parent().isValid() ||
|
if (!index.isValid() || index.parent().isValid() ||
|
||||||
@ -153,6 +159,8 @@ void RunnerModel::startQuery()
|
|||||||
//kDebug() << "running query" << query;
|
//kDebug() << "running query" << query;
|
||||||
m_manager->launchQuery(m_pendingQuery);
|
m_manager->launchQuery(m_pendingQuery);
|
||||||
emit queryChanged();
|
emit queryChanged();
|
||||||
|
m_running = true;
|
||||||
|
emit runningChanged(true);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,6 +170,8 @@ void RunnerModel::createManager()
|
|||||||
m_manager = new Plasma::RunnerManager(this);
|
m_manager = new Plasma::RunnerManager(this);
|
||||||
connect(m_manager, SIGNAL(matchesChanged(QList<Plasma::QueryMatch>)),
|
connect(m_manager, SIGNAL(matchesChanged(QList<Plasma::QueryMatch>)),
|
||||||
this, SLOT(matchesChanged(QList<Plasma::QueryMatch>)));
|
this, SLOT(matchesChanged(QList<Plasma::QueryMatch>)));
|
||||||
|
connect(m_manager, SIGNAL(queryFinished()),
|
||||||
|
this, SLOT(queryHasFinished()));
|
||||||
|
|
||||||
if (!m_pendingRunnersList.isEmpty()) {
|
if (!m_pendingRunnersList.isEmpty()) {
|
||||||
m_manager->setAllowedRunners(m_pendingRunnersList);
|
m_manager->setAllowedRunners(m_pendingRunnersList);
|
||||||
@ -181,5 +191,11 @@ void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
|
|||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RunnerModel::queryHasFinished()
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
emit runningChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
#include "runnermodel.moc"
|
#include "runnermodel.moc"
|
||||||
|
|
||||||
|
@ -55,6 +55,11 @@ class RunnerModel : public QAbstractListModel
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property bool running: true when queries are in execution
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @enum Roles of the model, they will be accessible from delegates
|
* @enum Roles of the model, they will be accessible from delegates
|
||||||
@ -80,6 +85,8 @@ public:
|
|||||||
|
|
||||||
Q_SCRIPTABLE void run(int row);
|
Q_SCRIPTABLE void run(int row);
|
||||||
|
|
||||||
|
bool isRunning() const;
|
||||||
|
|
||||||
int rowCount(const QModelIndex&) const;
|
int rowCount(const QModelIndex&) const;
|
||||||
int count() const;
|
int count() const;
|
||||||
QVariant data(const QModelIndex&, int) const;
|
QVariant data(const QModelIndex&, int) const;
|
||||||
@ -91,6 +98,7 @@ Q_SIGNALS:
|
|||||||
void queryChanged();
|
void queryChanged();
|
||||||
void countChanged();
|
void countChanged();
|
||||||
void runnersChanged();
|
void runnersChanged();
|
||||||
|
void runningChanged(bool running);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void startQuery();
|
void startQuery();
|
||||||
@ -100,6 +108,7 @@ private:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void matchesChanged(const QList<Plasma::QueryMatch> &matches);
|
void matchesChanged(const QList<Plasma::QueryMatch> &matches);
|
||||||
|
void queryHasFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plasma::RunnerManager *m_manager;
|
Plasma::RunnerManager *m_manager;
|
||||||
@ -107,6 +116,7 @@ private:
|
|||||||
QStringList m_pendingRunnersList;
|
QStringList m_pendingRunnersList;
|
||||||
QString m_pendingQuery;
|
QString m_pendingQuery;
|
||||||
QTimer *m_startQueryTimer;
|
QTimer *m_startQueryTimer;
|
||||||
|
bool m_running;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user