PresetItemModel.hpp
1 #pragma once
2 #include <Process/Preset.hpp>
3 
4 #include <QAbstractItemModel>
5 #include <QSortFilterProxyModel>
6 
7 namespace score
8 {
9 struct GUIApplicationContext;
10 }
11 
12 namespace Library
13 {
14 class PresetFilterProxy;
15 class PresetItemModel final : public QAbstractItemModel
16 {
17 public:
18  PresetItemModel(const score::GUIApplicationContext& ctx, QObject* parent);
19 
20  std::vector<Process::Preset>& presets;
21 
22  bool savePreset(const Process::ProcessModel& proc);
23 
24 private:
25  QModelIndex index(int row, int column, const QModelIndex& parent) const override;
26 
27  QModelIndex parent(const QModelIndex& child) const override;
28  int rowCount(const QModelIndex& parent) const override;
29  int columnCount(const QModelIndex& parent) const override;
30  QVariant data(const QModelIndex& index, int role) const override;
31 
32  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
33 
34  bool dropMimeData(
35  const QMimeData* data, Qt::DropAction act, int row, int col,
36  const QModelIndex& parent) override;
37  bool canDropMimeData(
38  const QMimeData* data, Qt::DropAction act, int row, int col,
39  const QModelIndex& parent) const override;
40 
41  QMimeData* mimeData(const QModelIndexList& indexes) const override;
42  Qt::DropActions supportedDragActions() const override;
43  Qt::DropActions supportedDropActions() const override;
44  Qt::ItemFlags flags(const QModelIndex& index) const override;
45 
46  friend class PresetFilterProxy;
47 };
48 
49 class PresetFilterProxy final : public QSortFilterProxyModel
50 {
51 public:
52  using QSortFilterProxyModel::invalidate;
53  using QSortFilterProxyModel::QSortFilterProxyModel;
54 
55  Process::ProcessIdentifier currentFilter{};
56 
57 private:
58  bool filterAcceptsRow(int srcRow, const QModelIndex& srcParent) const override;
59 };
60 }
Definition: PresetItemModel.hpp:50
Definition: PresetItemModel.hpp:16
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: Preset.hpp:11
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15