KRunner
resultsmodel.cpp
58 // Only check the favorite index if we compare categories. For individual matches, they will always be the same
71 const double favoriteAMultiplicationFactor = (favoriteA ? 1 + ((favoritesCount - favoriteA) * 0.2) : 1);
72 const double typeA = sourceA.data(ResultsModel::CategoryRelevanceRole).toReal() * favoriteAMultiplicationFactor;
73 const double favoriteBMultiplicationFactor = (favoriteB ? 1 + ((favoritesCount - favoriteB) * 0.2) : 1);
74 const double typeB = sourceB.data(ResultsModel::CategoryRelevanceRole).toReal() * favoriteBMultiplicationFactor;
120 connect(sourceModel, &QAbstractItemModel::rowsInserted, this, &CategoryDistributionProxyModel::invalidateFilter);
121 connect(sourceModel, &QAbstractItemModel::rowsMoved, this, &CategoryDistributionProxyModel::invalidateFilter);
122 connect(sourceModel, &QAbstractItemModel::rowsRemoved, this, &CategoryDistributionProxyModel::invalidateFilter);
223 const QModelIndex treeIdx = mapper.mapLeftToRight(sourceModel()->index(sourceRow, 0, sourceParent));
234 explicit ResultsModelPrivate(const KConfigGroup &configGroup, const KConfigGroup &stateConfigGroup, ResultsModel *q)
246 CategoryDistributionProxyModel *const distributionModel = new CategoryDistributionProxyModel(q);
256ResultsModel::ResultsModel(const KConfigGroup &configGroup, const KConfigGroup &stateConfigGroup, QObject *parent)
260 connect(d->resultsModel, &RunnerResultsModel::queryStringChanged, this, &ResultsModel::queryStringChanged);
261 connect(runnerManager(), &RunnerManager::queryingChanged, this, &ResultsModel::queryingChanged);
262 connect(d->resultsModel, &RunnerResultsModel::queryStringChangeRequested, this, &ResultsModel::queryStringChangeRequested);
264 connect(runnerManager(), &RunnerManager::queryingChanged, this, &ResultsModel::queryingChanged);
267 // The matches for the old query string remain on display until the first set of matches arrive for the new query string.
268 // Therefore we must not update the query string inside RunnerResultsModel exactly when the query string changes, otherwise it would
270 // So we only make it aware of the query string change at the time when we receive the first set of matches for the new query string.
275 connect(d->distributionModel, &CategoryDistributionProxyModel::limitChanged, this, &ResultsModel::limitChanged);
296 // While there were lots of optimizations, instantiating plugins, creating threads and AbstractRunner::init is still heavy work
QModelIndex mapLeftToRight(const QModelIndex &index) const
A match returned by an AbstractRunner in response to a given RunnerContext.
Definition querymatch.h:32
A model that exposes and sorts results for a given query.
Definition resultsmodel.h:31
QString singleRunner
The single runner to use for querying in single runner mode.
Definition resultsmodel.h:59
KRunner::QueryMatch getQueryMatch(const QModelIndex &idx) const
Get match for the result at given model index idx.
Definition resultsmodel.cpp:419
Q_INVOKABLE bool runAction(const QModelIndex &idx, int actionNumber)
Run the action actionNumber at given model index idx.
Definition resultsmodel.cpp:396
Q_SIGNAL void runnerManagerChanged()
Q_INVOKABLE void clear()
Clears the model content and resets the runner context, i.e.
Definition resultsmodel.cpp:381
void setRunnerManager(KRunner::RunnerManager *manager)
Definition resultsmodel.cpp:425
void queryStringChangeRequested(const QString &queryString, int pos)
This signal is emitted when a an InformationalMatch is run, and it is advised to update the search te...
Q_INVOKABLE bool run(const QModelIndex &idx)
Run the result at the given model index idx.
Definition resultsmodel.cpp:386
Q_INVOKABLE QMimeData * getMimeData(const QModelIndex &idx) const
Get mime data for the result at given model index idx.
Definition resultsmodel.cpp:406
The RunnerManager class decides what installed runners are runnable, and their ratings.
Definition runnermanager.h:43
QMimeData * mimeDataForMatch(const QueryMatch &match) const
Definition runnermanager.cpp:495
AbstractRunner * runner(const QString &pluginId) const
Finds and returns a loaded runner or a nullptr.
Definition runnermanager.cpp:444
void queryingChanged()
Emitted when the querying status has changed.
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
void rowsRemoved(const QModelIndex &parent, int first, int last)
virtual QHash< int, QByteArray > roleNames() const const override
sourceModel
QVariant data(int role) const const
quintptr internalId() const const
bool isValid() const const
QModelIndex parent() const const
int row() const const
Q_EMITQ_EMIT
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
void setDynamicSortFilter(bool enable)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
void invalidate()
void invalidateFilter()
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const const
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
virtual void sort(int column, Qt::SortOrder order) override
bool isEmpty() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
DescendingOrder
SkipEmptyParts
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
singleShot
int toInt(bool *ok) const const
qreal toReal(bool *ok) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:07:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:07:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.