Loading...
Searching...
No Matches
ProcessDropHandler.hpp
1#pragma once
2#include <Process/ProcessMimeSerialization.hpp>
3#include <Process/TimeValue.hpp>
4
5#include <score/command/AggregateCommand.hpp>
6#include <score/command/Dispatchers/RuntimeDispatcher.hpp>
7#include <score/plugins/Interface.hpp>
8#include <score/plugins/InterfaceList.hpp>
9#include <score/tools/FilePath.hpp>
10
11#include <ossia/detail/hash_map.hpp>
12
13#include <QByteArray>
14#include <QMimeData>
15
16#include <score_lib_process_export.h>
17
18#include <string>
19
20namespace Process
21{
22class ProcessModel;
23
24class SCORE_LIB_PROCESS_EXPORT ProcessDropHandler : public score::InterfaceBase
25{
26 SCORE_INTERFACE(ProcessDropHandler, "e0908e4a-9e88-4029-9a61-7658cc695152")
27public:
29 {
30 ProcessData creation;
31 std::optional<TimeVal> duration;
32 std::function<void(Process::ProcessModel&, score::Dispatcher&)> setup;
33 };
34
36 {
37 score::FilePath filename;
38 QByteArray data;
39 };
40
42 ~ProcessDropHandler() override;
43
44 void getCustomDrops(
45 std::vector<ProcessDrop>& drops, const QMimeData& mime,
46 const score::DocumentContext& ctx) const noexcept;
47
48 void getMimeDrops(
49 std::vector<ProcessDrop>& drops, const QMimeData& mime, const QString& fmt,
50 const score::DocumentContext& ctx) const noexcept;
51
52 void getFileDrops(
53 std::vector<ProcessDrop>& drops, const QMimeData& mime,
54 const score::FilePath& path, const score::DocumentContext& ctx) const noexcept;
55
56 virtual QSet<QString> mimeTypes() const noexcept;
57 virtual QSet<QString> fileExtensions() const noexcept;
58
59protected:
60 virtual void dropCustom(
61 std::vector<ProcessDrop>& drops, const QMimeData& mime,
62 const score::DocumentContext& ctx) const noexcept;
63
64 virtual void dropPath(
65 std::vector<ProcessDrop>& drops, const score::FilePath& path,
66 const score::DocumentContext& ctx) const noexcept;
67
68 virtual void dropData(
69 std::vector<ProcessDrop>& drops, const DroppedFile& data,
70 const score::DocumentContext& ctx) const noexcept;
71};
72
73class SCORE_LIB_PROCESS_EXPORT ProcessDropHandlerList final
74 : public score::InterfaceList<ProcessDropHandler>
75{
76public:
77 ~ProcessDropHandlerList() override;
78
79 std::vector<ProcessDropHandler::ProcessDrop>
80 getDrop(const QMimeData& mime, const score::DocumentContext& ctx) const noexcept;
81
82 static std::optional<TimeVal>
83 getMaxDuration(const std::vector<ProcessDropHandler::ProcessDrop>&);
84
85private:
86 void initCaches() const;
87 mutable ossia::hash_map<std::string, ProcessDropHandler*> m_perMimeTypes{};
88 mutable ossia::hash_map<std::string, ProcessDropHandler*> m_perFileExtension{};
89 mutable std::size_t m_lastCacheSize{};
90};
91}
Definition ProcessDropHandler.hpp:25
Definition ProcessDropHandler.hpp:75
The Process class.
Definition score-lib-process/Process/Process.hpp:61
Base class for plug-in interfaces.
Definition Interface.hpp:52
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition Application.cpp:90
STL namespace.
Definition ProcessMimeSerialization.hpp:38
Definition ProcessDropHandler.hpp:36
Definition ProcessDropHandler.hpp:29
Definition RuntimeDispatcher.hpp:7
Definition DocumentContext.hpp:18
Definition FilePath.hpp:25