• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaCore

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • core
runnermodel.h
Go to the documentation of this file.
1 /*
2  Copyright 2011 Aaron Seigo <aseigo@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef RUNNERMODEL_H
21 #define RUNNERMODEL_H
22 
23 #include <QAbstractListModel>
24 #include <QStringList>
25 
26 namespace Plasma
27 {
28  class RunnerManager;
29  class QueryMatch;
30 } // namespace Plasma
31 
32 class QTimer;
33 
39 class RunnerModel : public QAbstractListModel
40 {
41  Q_OBJECT
42 
46  Q_PROPERTY(QString query WRITE scheduleQuery READ currentQuery NOTIFY queryChanged)
47 
48 
51  Q_PROPERTY(QStringList runners WRITE setRunners READ runners NOTIFY runnersChanged)
52 
56  Q_PROPERTY(int count READ count NOTIFY countChanged)
57 
61  Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
62 
63 public:
67  enum Roles {
68  Type = Qt::UserRole + 1,
69  Label,
70  Icon,
71  Relevance,
72  Data,
73  Id,
74  SubText,
75  Enabled,
76  RunnerId,
77  RunnerName,
78  Actions
79  };
80 
81  RunnerModel(QObject *parent = 0);
82 
83  QString currentQuery() const;
84 
85  QStringList runners() const;
86  void setRunners(const QStringList &allowedRunners);
87 
88  Q_SCRIPTABLE void run(int row);
89 
90  bool isRunning() const;
91 
92  int rowCount(const QModelIndex&) const;
93  int count() const;
94  QVariant data(const QModelIndex&, int) const;
95 
96 public Q_SLOTS:
97  void scheduleQuery(const QString &query);
98 
99 Q_SIGNALS:
100  void queryChanged();
101  void countChanged();
102  void runnersChanged();
103  void runningChanged(bool running);
104 
105 private Q_SLOTS:
106  void startQuery();
107 
108 private:
109  bool createManager();
110 
111 private Q_SLOTS:
112  void matchesChanged(const QList<Plasma::QueryMatch> &matches);
113  void queryHasFinished();
114 
115 private:
116  Plasma::RunnerManager *m_manager;
117  QList<Plasma::QueryMatch> m_matches;
118  QStringList m_pendingRunnersList;
119  QString m_singleRunnerId;
120  QString m_pendingQuery;
121  QTimer *m_startQueryTimer;
122  QTimer *m_runningChangedTimeout;
123  bool m_running;
124 };
125 
126 #endif
QModelIndex
RunnerModel::runnersChanged
void runnersChanged()
RunnerModel::SubText
Definition: runnermodel.h:74
RunnerModel::Actions
Definition: runnermodel.h:78
RunnerModel::Label
Definition: runnermodel.h:69
RunnerModel::RunnerModel
RunnerModel(QObject *parent=0)
Definition: runnermodel.cpp:30
RunnerModel::Type
Definition: runnermodel.h:68
RunnerModel::Relevance
Definition: runnermodel.h:71
RunnerModel::Enabled
Definition: runnermodel.h:75
RunnerModel::count
int count() const
RunnerModel
This model provides bindings to use KRunner from QML.
Definition: runnermodel.h:39
RunnerModel::rowCount
int rowCount(const QModelIndex &) const
Definition: runnermodel.cpp:62
RunnerModel::running
bool running
Definition: runnermodel.h:61
QTimer
QObject
QAbstractListModel
RunnerModel::Id
Definition: runnermodel.h:73
RunnerModel::currentQuery
QString currentQuery() const
Definition: runnermodel.cpp:157
QString
QList< Plasma::QueryMatch >
QStringList
RunnerModel::Icon
Definition: runnermodel.h:70
RunnerModel::data
QVariant data(const QModelIndex &, int) const
Definition: runnermodel.cpp:115
RunnerModel::queryChanged
void queryChanged()
RunnerModel::scheduleQuery
void scheduleQuery(const QString &query)
Definition: runnermodel.cpp:162
RunnerModel::RunnerId
Definition: runnermodel.h:76
RunnerModel::Roles
Roles
of the model, they will be accessible from delegates
Definition: runnermodel.h:67
RunnerModel::Data
Definition: runnermodel.h:72
RunnerModel::isRunning
bool isRunning() const
Definition: runnermodel.cpp:110
RunnerModel::RunnerName
Definition: runnermodel.h:77
RunnerModel::runners
QStringList runners() const
RunnerModel::query
QString query
Definition: runnermodel.h:46
RunnerModel::run
Q_SCRIPTABLE void run(int row)
Definition: runnermodel.cpp:103
QObject::parent
QObject * parent() const
RunnerModel::countChanged
void countChanged()
RunnerModel::setRunners
void setRunners(const QStringList &allowedRunners)
Definition: runnermodel.cpp:77
RunnerModel::runningChanged
void runningChanged(bool running)
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaCore

Skip menu "PlasmaCore"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal