plasma: drop redundant Plasma::QueryMatch type feature

it could be used to sort ala relevance but what would the relevance feature
would be for then?

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-18 00:06:05 +03:00
parent c4c494d705
commit 7683b1d29e
3 changed files with 25 additions and 78 deletions

View file

@ -39,12 +39,11 @@ class QueryMatchPrivate : public QSharedData
public:
QueryMatchPrivate(AbstractRunner *r)
: QSharedData(),
runner(r),
type(QueryMatch::ExactMatch),
relevance(.7),
selAction(0),
enabled(true),
idSetByData(false)
runner(r),
relevance(0.7),
selAction(nullptr),
enabled(true),
idSetByData(false)
{
}
@ -53,7 +52,6 @@ class QueryMatchPrivate : public QSharedData
{
std::lock_guard<std::recursive_mutex> lock(other.mutex);
runner = other.runner;
type = other.type;
relevance = other.relevance;
selAction = other.selAction;
enabled = other.enabled;
@ -65,13 +63,8 @@ class QueryMatchPrivate : public QSharedData
data = other.data;
}
~QueryMatchPrivate()
{
}
mutable std::recursive_mutex mutex;
QWeakPointer<AbstractRunner> runner;
QueryMatch::Type type;
QString id;
QString text;
QString subtext;
@ -79,14 +72,14 @@ class QueryMatchPrivate : public QSharedData
QVariant data;
qreal relevance;
QAction *selAction;
bool enabled : 1;
bool idSetByData : 1;
bool enabled;
bool idSetByData;
};
QueryMatch::QueryMatch(AbstractRunner *runner)
: d(new QueryMatchPrivate(runner))
{
// kDebug() << "new match created";
// kDebug() << "new match created";
}
QueryMatch::QueryMatch(const QueryMatch &other)
@ -100,7 +93,7 @@ QueryMatch::~QueryMatch()
bool QueryMatch::isValid() const
{
return d->runner != 0;
return d->runner != nullptr;
}
QString QueryMatch::id() const
@ -108,20 +101,9 @@ QString QueryMatch::id() const
if (d->id.isEmpty() && d->runner) {
return d->runner.data()->id();
}
return d->id;
}
void QueryMatch::setType(Type type)
{
d->type = type;
}
QueryMatch::Type QueryMatch::type() const
{
return d->type;
}
void QueryMatch::setRelevance(qreal relevance)
{
d->relevance = qMax(qreal(0.0), relevance);
@ -225,21 +207,17 @@ void QueryMatch::setSelectedAction(QAction *action)
bool QueryMatch::operator<(const QueryMatch &other) const
{
if (d->type == other.d->type) {
if (isEnabled() != other.isEnabled()) {
return other.isEnabled();
}
if (d->relevance != other.d->relevance) {
return d->relevance < other.d->relevance;
}
// when resorting to sort by alpha, we want the
// reverse sort order!
return d->text > other.d->text;
if (isEnabled() != other.isEnabled()) {
return other.isEnabled();
}
return d->type < other.d->type;
if (d->relevance != other.d->relevance) {
return d->relevance < other.d->relevance;
}
// when resorting to sort by alpha, we want the
// reverse sort order!
return d->text > other.d->text;
}
QueryMatch &QueryMatch::operator=(const QueryMatch &other)
@ -247,7 +225,6 @@ QueryMatch &QueryMatch::operator=(const QueryMatch &other)
if (d != other.d) {
d = other.d;
}
return *this;
}

View file

@ -45,28 +45,7 @@ class PLASMA_EXPORT QueryMatch
{
public:
/**
* The type of match. Value is important here as it is used for sorting
*/
enum Type {
NoMatch = 0, /**< Null match */
CompletionMatch = 10, /**< Possible completion for the data of the query */
PossibleMatch = 30, /**< Something that may match the query */
InformationalMatch = 50, /**< A purely informational, non-actionable match,
such as the answer to a question or calculation*/
HelperMatch = 70, /**< A match that represents an action not directly related
to activating the given search term, such as a search
in an external tool or a command learning trigger. Helper
matches tend to be generic to the query and should not
be autoactivated just because the user hits "Enter"
while typing. They must be explicitly selected to
be activated, but unlike InformationalMatch cause
an action to be triggered. */
ExactMatch = 100 /**< An exact match to the query */
};
/**
* Constructs a PossibleMatch associated with a given RunnerContext
* and runner.
* Constructs a match associated with a given runner.
*
* @param runner the runner this match belongs to
*/
@ -78,6 +57,7 @@ class PLASMA_EXPORT QueryMatch
QueryMatch(const QueryMatch &other);
~QueryMatch();
QueryMatch &operator=(const QueryMatch &other);
bool operator==(const QueryMatch &other) const;
bool operator!=(const QueryMatch &other) const;
@ -86,7 +66,7 @@ class PLASMA_EXPORT QueryMatch
/**
* @return the runner associated with this action
*/
AbstractRunner *runner() const;
AbstractRunner* runner() const;
/**
* @return true if the match is valid and can therefore be run,
@ -94,16 +74,6 @@ class PLASMA_EXPORT QueryMatch
*/
bool isValid() const;
/**
* Sets the type of match this action represents.
*/
void setType(Type type);
/**
* The type of action this is. Defaults to PossibleMatch.
*/
Type type() const;
/**
* Sets the relevance of this action for the search
* it was created for.

View file

@ -350,7 +350,7 @@ QString RunnerContext::mimeType() const
bool RunnerContext::isValid() const
{
// if our qptr is dirty, we aren't useful anymore
// if the qptr is dirty, it is not valid
LOCK_FOR_READ(d)
const bool valid = (d->q != &(d->s_dummyContext));
UNLOCK(d)
@ -362,7 +362,7 @@ bool RunnerContext::addMatches(const QString &term, const QList<QueryMatch> &mat
Q_UNUSED(term)
if (matches.isEmpty() || !isValid()) {
//Bail out if the query is empty or the qptr is dirty
// bail out if the query is empty or the qptr is dirty
return false;
}
@ -377,7 +377,7 @@ bool RunnerContext::addMatches(const QString &term, const QList<QueryMatch> &mat
d->matchesById.insert(match.id(), &d->matches.at(d->matches.size() - 1));
}
UNLOCK(d);
//kDebug()<< "add matches";
// kDebug()<< "add matches";
// A copied searchContext may share the d pointer,
// we always want to sent the signal of the object that created
// the d pointer
@ -391,7 +391,7 @@ bool RunnerContext::addMatch(const QString &term, const QueryMatch &match)
Q_UNUSED(term)
if (!isValid()) {
// Bail out if the qptr is dirty
// bail out if the qptr is dirty
return false;
}