Warning, file /frameworks/krunner/src/model/runnerresultsmodel_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * This file is part of the KDE Milou Project 0003 * SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@broulik.de> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 * 0007 */ 0008 0009 #pragma once 0010 0011 #include <KConfigGroup> 0012 #include <QAbstractItemModel> 0013 #include <QHash> 0014 #include <QString> 0015 0016 #include <KRunner/QueryMatch> 0017 0018 namespace KRunner 0019 { 0020 class RunnerManager; 0021 } 0022 0023 namespace KRunner 0024 { 0025 class RunnerResultsModel : public QAbstractItemModel 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit RunnerResultsModel(const KConfigGroup &configGroup, KConfigGroup stateConfigGroup, QObject *parent = nullptr); 0031 0032 QString queryString() const; 0033 void setQueryString(const QString &queryString, const QString &runner); 0034 Q_SIGNAL void queryStringChanged(const QString &queryString); 0035 0036 bool querying() const; 0037 Q_SIGNAL void queryingChanged(); 0038 0039 /** 0040 * Clears the model content and resets the runner context, i.e. no new items will appear. 0041 */ 0042 void clear(); 0043 0044 bool run(const QModelIndex &idx); 0045 bool runAction(const QModelIndex &idx, int actionNumber); 0046 0047 int columnCount(const QModelIndex &parent) const override; 0048 int rowCount(const QModelIndex &parent) const override; 0049 0050 QVariant data(const QModelIndex &index, int role) const override; 0051 0052 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0053 QModelIndex parent(const QModelIndex &child) const override; 0054 0055 KRunner::RunnerManager *runnerManager() const; 0056 KRunner::QueryMatch fetchMatch(const QModelIndex &idx) const; 0057 0058 QStringList m_favoriteIds; 0059 Q_SIGNALS: 0060 void queryStringChangeRequested(const QString &queryString, int pos); 0061 0062 void matchesChanged(); 0063 0064 private: 0065 void setQuerying(bool querying); 0066 0067 void onMatchesChanged(const QList<KRunner::QueryMatch> &matches); 0068 0069 KRunner::RunnerManager *m_manager; 0070 0071 QString m_queryString; 0072 bool m_querying = false; 0073 0074 QString m_prevRunner; 0075 0076 bool m_hasMatches = false; 0077 0078 QStringList m_categories; 0079 QHash<QString /*category*/, QList<KRunner::QueryMatch>> m_matches; 0080 }; 0081 0082 } // namespace Milou