2 #include <Process/ProcessFactory.hpp>
3 #include <Process/ProcessMimeSerialization.hpp>
5 #include <Library/LibrarySettings.hpp>
7 #include <score/application/ApplicationContext.hpp>
8 #include <score/model/tree/TreeNode.hpp>
9 #include <score/model/tree/TreeNodeItemModel.hpp>
10 #include <score/tools/File.hpp>
11 #include <score/tools/std/Optional.hpp>
12 #include <score/tools/std/StringHash.hpp>
14 #include <ossia/detail/hash_map.hpp>
19 #include <nano_observer.hpp>
20 #include <score_plugin_library_export.h>
26 struct GUIApplicationContext;
39 SCORE_PLUGIN_LIBRARY_EXPORT
44 ,
public Nano::Observer
47 using QAbstractItemModel::beginInsertRows;
48 using QAbstractItemModel::endInsertRows;
50 using QAbstractItemModel::beginRemoveRows;
51 using QAbstractItemModel::endRemoveRows;
56 QModelIndex find(
const Process::ProcessModelFactory::ConcreteKey& k);
62 int columnCount(
const QModelIndex& parent)
const override;
63 QVariant data(
const QModelIndex& index,
int role)
const override;
65 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
66 Qt::ItemFlags flags(
const QModelIndex& index)
const override;
69 QStringList mimeTypes()
const override;
70 QMimeData* mimeData(
const QModelIndexList& indexes)
const override;
71 Qt::DropActions supportedDragActions()
const override;
89 std::string libraryFolderPath{};
90 ossia::hash_map<QString, Library::ProcessNode*> categories;
99 libraryFolderPath = libraryFolder.absolutePath().toStdString();
104 auto parentFolder = file.dir().dirName();
105 if(
auto it = categories.find(parentFolder); it != categories.end())
107 Library::addToLibrary(*it->second, std::move(pdata));
111 if(file.dir() == libraryFolder)
113 Library::addToLibrary(*parent, std::move(pdata));
117 auto& category = Library::addToLibrary(
119 Library::addToLibrary(category, std::move(pdata));
120 categories[parentFolder] = &category;
128 = QString::fromUtf8(file.parentDirName.data(), file.parentDirName.size());
129 if(
auto it = categories.find(parentFolder); it != categories.end())
131 Library::addToLibrary(*it->second, std::move(pdata));
135 if(file.absolutePath == libraryFolderPath)
137 Library::addToLibrary(*parent, std::move(pdata));
141 auto& category = Library::addToLibrary(
143 Library::addToLibrary(category, std::move(pdata));
144 categories[parentFolder] = &category;
163 W_REGISTER_ARGTYPE(std::optional<Library::ProcessData>)
Definition: ProcessesItemModel.hpp:45
Definition: LibrarySettings.hpp:46
The ProcessFactory class.
Definition: score-lib-process/Process/ProcessFactory.hpp:35
Definition: TreeNodeItemModel.hpp:38
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ProcessesItemModel.hpp:32
Definition: ProcessesItemModel.hpp:86
Definition: ProcessMimeSerialization.hpp:38
Used to access all the application-wide state and structures.
Definition: ApplicationContext.hpp:24
T & settings() const
Access a specific Settings model instance.
Definition: ApplicationContext.hpp:40
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15
Definition: lib/score/tools/File.hpp:20