1/*
2 SPDX-FileCopyrightText: 2020-2023 Alexander Lohnau <alexander.lohnau@gmx.de>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5#include "abstractrunner.h"
6#include "runnersyntax.h"
7#include <QReadWriteLock>
8#include <QRegularExpression>
9#include <optional>
10
11namespace KRunner
12{
13class AbstractRunnerPrivate
14{
15public:
16 explicit AbstractRunnerPrivate(AbstractRunner *r, const KPluginMetaData &data)
17 : runnerDescription(data)
18 , translatedName(data.name())
19 , runner(r)
20 , minLetterCount(data.value(QStringLiteral("X-Plasma-Runner-Min-Letter-Count"), defaultValue: 0))
21 , hasUniqueResults(data.value(QStringLiteral("X-Plasma-Runner-Unique-Results"), defaultValue: false))
22 , hasWeakResults(data.value(QStringLiteral("X-Plasma-Runner-Weak-Results"), defaultValue: false))
23 {
24 if (const QString regexStr = data.value(QStringLiteral("X-Plasma-Runner-Match-Regex")); !regexStr.isEmpty()) {
25 matchRegex = QRegularExpression(regexStr);
26 hasMatchRegex = matchRegex.isValid() && !matchRegex.pattern().isEmpty();
27 }
28 }
29
30 QReadWriteLock lock;
31 const KPluginMetaData runnerDescription;
32 // We can easily call this a few hundred times for a few queries. Thus just reuse the value and not do a lookup of the translated string every time
33 const QString translatedName;
34 const AbstractRunner *runner;
35 QList<RunnerSyntax> syntaxes;
36 std::optional<bool> suspendMatching;
37 int minLetterCount = 0;
38 QRegularExpression matchRegex;
39 bool hasMatchRegex = false;
40 const bool hasUniqueResults = false;
41 const bool hasWeakResults = false;
42};
43}
44

source code of krunner/src/abstractrunner_p.h