diff options
author | Tayou <31988415+TayouVR@users.noreply.github.com> | 2023-08-07 10:32:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-07 10:32:38 +0200 |
commit | 9afa7cc91fd889b146c609c6a59f7f7b3d995d9f (patch) | |
tree | 20ef3bd30beedca4995875485e468ee323d52096 /launcher/pathmatcher | |
parent | b572f75dbaad61cf305f1fd4f60ba94d74bfa3fa (diff) | |
parent | 75c7df46a7022a46d447bb96fbde619e5d65db05 (diff) | |
download | PrismLauncher-9afa7cc91fd889b146c609c6a59f7f7b3d995d9f.tar.gz PrismLauncher-9afa7cc91fd889b146c609c6a59f7f7b3d995d9f.tar.bz2 PrismLauncher-9afa7cc91fd889b146c609c6a59f7f7b3d995d9f.zip |
Merge branch 'develop' into icon-indexing
Signed-off-by: Tayou <31988415+TayouVR@users.noreply.github.com>
Diffstat (limited to 'launcher/pathmatcher')
-rw-r--r-- | launcher/pathmatcher/FSTreeMatcher.h | 20 | ||||
-rw-r--r-- | launcher/pathmatcher/IPathMatcher.h | 11 | ||||
-rw-r--r-- | launcher/pathmatcher/MultiMatcher.h | 23 | ||||
-rw-r--r-- | launcher/pathmatcher/RegexpMatcher.h | 28 |
4 files changed, 32 insertions, 50 deletions
diff --git a/launcher/pathmatcher/FSTreeMatcher.h b/launcher/pathmatcher/FSTreeMatcher.h index b84af294..52f1404d 100644 --- a/launcher/pathmatcher/FSTreeMatcher.h +++ b/launcher/pathmatcher/FSTreeMatcher.h @@ -1,21 +1,15 @@ #pragma once -#include "IPathMatcher.h" #include <SeparatorPrefixTree.h> #include <QRegularExpression> +#include "IPathMatcher.h" -class FSTreeMatcher : public IPathMatcher -{ -public: - virtual ~FSTreeMatcher() {}; - FSTreeMatcher(SeparatorPrefixTree<'/'> & tree) : m_fsTree(tree) - { - } +class FSTreeMatcher : public IPathMatcher { + public: + virtual ~FSTreeMatcher(){}; + FSTreeMatcher(SeparatorPrefixTree<'/'>& tree) : m_fsTree(tree) {} - bool matches(const QString &string) const override - { - return m_fsTree.covers(string); - } + bool matches(const QString& string) const override { return m_fsTree.covers(string); } - SeparatorPrefixTree<'/'> & m_fsTree; + SeparatorPrefixTree<'/'>& m_fsTree; }; diff --git a/launcher/pathmatcher/IPathMatcher.h b/launcher/pathmatcher/IPathMatcher.h index 192782d7..8121de5c 100644 --- a/launcher/pathmatcher/IPathMatcher.h +++ b/launcher/pathmatcher/IPathMatcher.h @@ -1,13 +1,12 @@ #pragma once -#include <memory> #include <QString> +#include <memory> -class IPathMatcher -{ -public: +class IPathMatcher { + public: typedef std::shared_ptr<IPathMatcher> Ptr; -public: + public: virtual ~IPathMatcher(){}; - virtual bool matches(const QString &string) const = 0; + virtual bool matches(const QString& string) const = 0; }; diff --git a/launcher/pathmatcher/MultiMatcher.h b/launcher/pathmatcher/MultiMatcher.h index 8bc1b6ee..10159580 100644 --- a/launcher/pathmatcher/MultiMatcher.h +++ b/launcher/pathmatcher/MultiMatcher.h @@ -1,26 +1,21 @@ -#include "IPathMatcher.h" #include <SeparatorPrefixTree.h> #include <QRegularExpression> +#include "IPathMatcher.h" -class MultiMatcher : public IPathMatcher -{ -public: - virtual ~MultiMatcher() {}; - MultiMatcher() - { - } - MultiMatcher &add(Ptr add) +class MultiMatcher : public IPathMatcher { + public: + virtual ~MultiMatcher(){}; + MultiMatcher() {} + MultiMatcher& add(Ptr add) { m_matchers.append(add); return *this; } - virtual bool matches(const QString &string) const override + virtual bool matches(const QString& string) const override { - for(auto iter: m_matchers) - { - if(iter->matches(string)) - { + for (auto iter : m_matchers) { + if (iter->matches(string)) { return true; } } diff --git a/launcher/pathmatcher/RegexpMatcher.h b/launcher/pathmatcher/RegexpMatcher.h index 825d488c..fe4aee6a 100644 --- a/launcher/pathmatcher/RegexpMatcher.h +++ b/launcher/pathmatcher/RegexpMatcher.h @@ -1,36 +1,30 @@ -#include "IPathMatcher.h" #include <QRegularExpression> +#include "IPathMatcher.h" -class RegexpMatcher : public IPathMatcher -{ -public: - virtual ~RegexpMatcher() {}; - RegexpMatcher(const QString ®exp) +class RegexpMatcher : public IPathMatcher { + public: + virtual ~RegexpMatcher(){}; + RegexpMatcher(const QString& regexp) { m_regexp.setPattern(regexp); m_onlyFilenamePart = !regexp.contains('/'); } - RegexpMatcher &caseSensitive(bool cs = true) + RegexpMatcher& caseSensitive(bool cs = true) { - if(cs) - { + if (cs) { m_regexp.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - } - else - { + } else { m_regexp.setPatternOptions(QRegularExpression::NoPatternOption); } return *this; } - virtual bool matches(const QString &string) const override + virtual bool matches(const QString& string) const override { - if(m_onlyFilenamePart) - { + if (m_onlyFilenamePart) { auto slash = string.lastIndexOf('/'); - if(slash != -1) - { + if (slash != -1) { auto part = string.mid(slash + 1); return m_regexp.match(part).hasMatch(); } |