Plasma
runnercontext.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2007 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_RUNNERCONTEXT_H 00021 #define PLASMA_RUNNERCONTEXT_H 00022 00023 #include <QtCore/QList> 00024 #include <QtCore/QObject> 00025 #include <QtCore/QSharedDataPointer> 00026 00027 #include <plasma/plasma_export.h> 00028 00029 class KCompletion; 00030 class KConfigGroup; 00031 00032 namespace Plasma 00033 { 00034 00035 class QueryMatch; 00036 class AbstractRunner; 00037 class RunnerContextPrivate; 00038 00046 class PLASMA_EXPORT RunnerContext : public QObject 00047 { 00048 Q_OBJECT 00049 00050 public: 00051 enum Type { 00052 None = 0, 00053 UnknownType = 1, 00054 Directory = 2, 00055 File = 4, 00056 NetworkLocation = 8, 00057 Executable = 16, 00058 ShellCommand = 32, 00059 Help = 64, 00060 FileSystem = Directory | File | Executable | ShellCommand 00061 }; 00062 00063 Q_DECLARE_FLAGS(Types, Type) 00064 00065 explicit RunnerContext(QObject *parent = 0); 00066 00070 RunnerContext(RunnerContext &other, QObject *parent = 0); 00071 00076 RunnerContext &operator=(const RunnerContext &other); 00077 00078 ~RunnerContext(); 00079 00085 void reset(); 00086 00091 void setQuery(const QString &term); 00092 00096 QString query() const; 00097 00102 Type type() const; 00103 00111 QString mimeType() const; 00112 00131 bool isValid() const; 00132 00140 // trueg: what do we need the term for? It is stored in the context anyway! Plus: matches() does not have a term parameter! 00141 // plus: it is Q_UNUSED 00142 bool addMatches(const QString &term, const QList<QueryMatch> &matches); 00143 00154 // trueg: what do we need the term for? It is stored in the context anyway! Plus: matches() does not have a term parameter! 00155 // plus: it is Q_UNUSED 00156 bool addMatch(const QString &term, const QueryMatch &match); 00157 00168 bool removeMatch(const QString matchId); 00169 00180 bool removeMatches(const QStringList matchIdList); 00181 00187 QList<QueryMatch> matches() const; 00188 00196 QueryMatch match(const QString &id) const; 00197 00205 void setSingleRunnerQueryMode(bool enabled); 00206 00211 bool singleRunnerQueryMode() const; 00212 00223 void restore(const KConfigGroup &config); 00224 00228 void save(KConfigGroup &config); 00229 00238 void run(const QueryMatch &match); 00239 00240 Q_SIGNALS: 00241 void matchesChanged(); 00242 00243 private: 00244 QExplicitlySharedDataPointer<RunnerContextPrivate> d; 00245 }; 00246 00247 } 00248 00249 Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::RunnerContext::Types) 00250 00251 #endif
KDE 4.6 API Reference