Loading...
Searching...
No Matches
PresetTreeView.hpp
1#pragma once
2#include <Process/Preset.hpp>
3
4#include <ossia/detail/hash_map.hpp>
5
6#include <QSet>
7#include <QMenu>
8#include <QTreeView>
9
10#include <memory>
11
12#include <score_plugin_library_export.h>
13
14#include <verdigris>
15
16namespace Library
17{
18class PresetItemModel;
19
21class SCORE_PLUGIN_LIBRARY_EXPORT PresetTreeView final : public QTreeView
22{
23 W_OBJECT(PresetTreeView)
24public:
25 explicit PresetTreeView(QWidget* parent = nullptr);
27
28 void setPresetModel(PresetItemModel* model);
29 PresetItemModel* presetModel() const noexcept { return m_model; }
30
32 void selected(std::optional<Process::Preset> p)
33 E_SIGNAL(SCORE_PLUGIN_LIBRARY_EXPORT, selected, p)
35 void doubleClicked(Process::Preset p)
36 E_SIGNAL(SCORE_PLUGIN_LIBRARY_EXPORT, doubleClicked, p)
38 void loadRequested(Process::Preset p)
39 E_SIGNAL(SCORE_PLUGIN_LIBRARY_EXPORT, loadRequested, p)
41 void cancelRequested() E_SIGNAL(SCORE_PLUGIN_LIBRARY_EXPORT, cancelRequested)
42
44 void showCurrentPreset();
46 void newCategory(const QStringList& in);
48 std::unique_ptr<QMenu> contextMenu(const QModelIndex& index);
49
50protected:
51 void mouseDoubleClickEvent(QMouseEvent* event) override;
52 void paintEvent(QPaintEvent* e) override;
53 void contextMenuEvent(QContextMenuEvent* event) override;
54 void keyPressEvent(QKeyEvent* event) override;
55 void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
56 void focusInEvent(QFocusEvent* event) override;
57
58private:
59 QString expansionKey() const;
60 void saveState();
61 void restoreState();
62 void scrollToCurrentLater();
63
64 PresetItemModel* m_model{};
66 ossia::hash_map<QString, QSet<QString>> m_expanded;
68 QString m_currentPath, m_currentName, m_currentCategory;
69 bool m_restoring{};
70};
71}
Definition PresetItemModel.hpp:34
The library's presets of one kind of process, in folders by category.
Definition PresetTreeView.hpp:22
void selected(std::optional< Process::Preset > p)
The current item became this preset, or a folder / nothing.
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
STL namespace.