score-plugin-lv2/LV2/Library.hpp
1 #pragma once
2 #include <LV2/ApplicationPlugin.hpp>
3 #include <LV2/EffectModel.hpp>
4 #include <Library/LibraryInterface.hpp>
5 #include <Library/ProcessesItemModel.hpp>
6 
7 namespace LV2
8 {
10 {
11  SCORE_CONCRETE("570f0b92-a091-47ff-a5c3-a585e07df2bf")
12  void setup(Library::ProcessesItemModel& model, const score::GUIApplicationContext& ctx)
13  override
14  {
15  const auto& key = LV2::ProcessFactory{}.concreteKey();
16  QModelIndex node = model.find(key);
17  if(node == QModelIndex{})
18  {
19  return;
20  }
21  auto& parent = *reinterpret_cast<Library::ProcessNode*>(node.internalPointer());
22 
23  auto& plug = ctx.applicationPlugin<LV2::ApplicationPlugin>();
24  auto& world = plug.lilv;
25 
26  auto plugs = world.get_all_plugins();
27 
28  ossia::flat_map<QString, QVector<QString>> categories;
29 
30  auto it = plugs.begin();
31  while(!plugs.is_end(it))
32  {
33  auto plug = plugs.get(it);
34  const auto class_name = plug.get_class().get_label().as_string();
35  const auto plug_name = plug.get_name().as_string();
36  categories[class_name].push_back(plug_name);
37  it = plugs.next(it);
38  }
39 
40  for(auto& category : categories)
41  {
42  // Already sorted through the map
43  auto& cat = parent.emplace_back(
44  Library::ProcessData{Process::ProcessData{{}, category.first, {}}, {}, {}},
45  &parent);
46  for(auto& plug : category.second)
47  {
48  Library::addToLibrary(
49  cat, Library::ProcessData{Process::ProcessData{key, plug, plug}, {}, {}});
50  }
51  }
52  }
53 };
54 }
Definition: score-plugin-lv2/LV2/ApplicationPlugin.hpp:24
Definition: score-plugin-lv2/LV2/Library.hpp:10
Definition: LibraryInterface.hpp:22
Definition: ProcessesItemModel.hpp:45
Definition: EffectFactory.hpp:14
Definition: ProcessesItemModel.hpp:32
Definition: ProcessMimeSerialization.hpp:38
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15
T & applicationPlugin() const
Access a specific application plug-in instance.
Definition: GUIApplicationContext.hpp:69