Loading...
Searching...
No Matches
ProcessEntry.hpp
1#pragma once
2#include <Process/ProcessFactory.hpp>
3#include <Process/ProcessMimeSerialization.hpp>
4
5#include <score/tools/File.hpp>
6
7#include <QIcon>
8#include <QStringList>
9
10#include <memory>
11#include <mutex>
12#include <optional>
13#include <vector>
14
15#include <score_plugin_library_export.h>
16
17namespace score
18{
19struct ApplicationContext;
20}
21
22namespace Library
23{
25{
26 QIcon icon;
27};
28
32{
33 ProcessData data;
34 std::vector<StagedNode> children;
35};
36
40{
41 Process::ProcessModelFactory::ConcreteKey rootKey;
42 QStringList categoryPath;
43 StagedNode node;
44};
45
50inline QStringList categoryPathForFile(
51 const score::PathInfo& file, std::string_view packagesRoot,
52 std::string_view presetsPath) noexcept
53{
54 if(file.absolutePath == packagesRoot || file.absolutePath.ends_with(presetsPath))
55 return {};
56 return {QString::fromUtf8(file.parentDirName.data(), file.parentDirName.size())};
57}
58
63class SCORE_PLUGIN_LIBRARY_EXPORT CategoryPaths
64{
65public:
66 struct Paths
67 {
68 std::string packagesRoot;
69 std::string presets;
70 };
71
73 void init(std::string processName, const score::ApplicationContext& ctx);
74
76 QStringList operator()(const score::PathInfo& file) const noexcept
77 {
78 if(auto p = get())
79 return categoryPathForFile(file, p->packagesRoot, p->presets);
80 return {};
81 }
82
84 std::shared_ptr<const Paths> get() const noexcept
85 {
86 std::lock_guard lock{m_mutex};
87 return m_paths;
88 }
89
90private:
91 mutable std::mutex m_mutex;
92 std::shared_ptr<const Paths> m_paths;
93};
94}
Definition ProcessEntry.hpp:64
std::shared_ptr< const Paths > get() const noexcept
Worker thread: the raw paths, for handlers with custom category logic.
Definition ProcessEntry.hpp:84
QStringList operator()(const score::PathInfo &file) const noexcept
Worker thread: category path for a scanned file.
Definition ProcessEntry.hpp:76
Base toolkit upon which the software is built.
Definition Application.cpp:116
Definition ProcessEntry.hpp:67
Definition ProcessEntry.hpp:25
Definition ProcessEntry.hpp:40
Definition ProcessEntry.hpp:32
Definition ProcessMimeSerialization.hpp:38
Used to access all the application-wide state and structures.
Definition ApplicationContext.hpp:25
Definition lib/score/tools/File.hpp:20