Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include <QHash>
26 : #include <qqmlintegration.h>
27 :
28 : #include "propertiespanelabstractmodel.h"
29 :
30 : namespace mu::propertiespanel {
31 : class PropertiesPanelAbstractProxyModel : public PropertiesPanelAbstractModel
32 : {
33 : Q_OBJECT
34 : QML_ELEMENT;
35 : QML_UNCREATABLE("Not creatable from QML")
36 :
37 : Q_PROPERTY(bool isMultiModel READ isMultiModel NOTIFY modelsChanged)
38 : Q_PROPERTY(QVariantList models READ models NOTIFY modelsChanged)
39 : Q_PROPERTY(mu::propertiespanel::PropertiesPanelAbstractModel * firstModel READ firstModel NOTIFY modelsChanged)
40 :
41 : Q_PROPERTY(
42 : mu::propertiespanel::PropertiesPanelAbstractModel::PropertiesPanelModelType defaultSubModelType READ defaultSubModelType NOTIFY
43 : defaultSubModelTypeChanged)
44 :
45 : public:
46 : explicit PropertiesPanelAbstractProxyModel(QObject* parent, const muse::modularity::ContextPtr& iocCtx,
47 : IElementRepositoryService* repository);
48 :
49 : bool isMultiModel() const;
50 : QVariantList models() const;
51 : PropertiesPanelAbstractModel* firstModel() const;
52 :
53 : PropertiesPanelModelType defaultSubModelType() const;
54 :
55 : Q_INVOKABLE mu::propertiespanel::PropertiesPanelAbstractModel* modelByType(PropertiesPanelModelType type) const;
56 :
57 : QList<PropertiesPanelAbstractModel*> modelList() const;
58 :
59 0 : void createProperties() override {}
60 0 : void loadProperties() override {}
61 :
62 : void requestElements() override;
63 : void disconnectAll() override;
64 : bool isEmpty() const override;
65 :
66 : void updateModels(const ElementKeySet& newElementKeySet);
67 : bool shouldUpdateWhenEmpty() const override;
68 : bool shouldUpdateOnEmptyPropertyAndStyleIdSets() const override;
69 :
70 : void onCurrentNotationChanged() override;
71 :
72 : void onNotationChanged(const mu::engraving::PropertyIdSet& changedPropertyIdSet,
73 : const mu::engraving::StyleIdSet& changedStyleIdSet) override;
74 :
75 : public slots:
76 : void setDefaultSubModelType(mu::propertiespanel::PropertiesPanelModelType modelType);
77 :
78 : signals:
79 : void modelsChanged();
80 : void defaultSubModelTypeChanged();
81 :
82 : protected:
83 : void setModels(const QList<PropertiesPanelAbstractModel*>& models);
84 :
85 : private:
86 : QHash<PropertiesPanelModelType, PropertiesPanelAbstractModel*> m_models;
87 : PropertiesPanelModelType m_defaultSubModelType = PropertiesPanelModelType::TYPE_UNDEFINED;
88 : };
89 : }
|