File indexing completed on 2024-04-28 07:45:38
0001 /* 0002 SPDX-FileCopyrightText: 2020-2023 Alexander Lohnau <alexander.lohnau@gmx.de> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 #include "abstractrunner.h" 0006 #include "runnersyntax.h" 0007 #include <QReadWriteLock> 0008 #include <QRegularExpression> 0009 #include <optional> 0010 0011 namespace KRunner 0012 { 0013 class AbstractRunnerPrivate 0014 { 0015 public: 0016 explicit AbstractRunnerPrivate(AbstractRunner *r, const KPluginMetaData &data) 0017 : runnerDescription(data) 0018 , translatedName(data.name()) 0019 , runner(r) 0020 , minLetterCount(data.value(QStringLiteral("X-Plasma-Runner-Min-Letter-Count"), 0)) 0021 , hasUniqueResults(data.value(QStringLiteral("X-Plasma-Runner-Unique-Results"), false)) 0022 , hasWeakResults(data.value(QStringLiteral("X-Plasma-Runner-Weak-Results"), false)) 0023 { 0024 if (const QString regexStr = data.value(QStringLiteral("X-Plasma-Runner-Match-Regex")); !regexStr.isEmpty()) { 0025 matchRegex = QRegularExpression(regexStr); 0026 hasMatchRegex = matchRegex.isValid() && !matchRegex.pattern().isEmpty(); 0027 } 0028 } 0029 0030 QReadWriteLock lock; 0031 const KPluginMetaData runnerDescription; 0032 // 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 0033 const QString translatedName; 0034 const AbstractRunner *runner; 0035 QList<RunnerSyntax> syntaxes; 0036 std::optional<bool> suspendMatching; 0037 int minLetterCount = 0; 0038 QRegularExpression matchRegex; 0039 bool hasMatchRegex = false; 0040 const bool hasUniqueResults = false; 0041 const bool hasWeakResults = false; 0042 }; 0043 }