Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2025 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 : #pragma once
23 :
24 : #include <qqmlintegration.h>
25 :
26 : #include <QObject>
27 :
28 : #include "uicomponents/qml/Muse/UiComponents/menuitem.h"
29 :
30 : namespace muse::uicomponents {
31 : namespace TableViewCellType {
32 : Q_NAMESPACE;
33 : QML_ELEMENT;
34 :
35 : enum class Type {
36 : Undefined = 0,
37 : Bool,
38 : Int,
39 : Double,
40 : String,
41 : List,
42 : #ifndef NO_QT_SUPPORT
43 : Color,
44 : #endif
45 :
46 : UserType = 100,
47 : UserTypeEnd = 1000
48 : };
49 :
50 0 : Q_ENUM_NS(Type)
51 : }
52 :
53 : namespace TableViewCellEditMode {
54 : Q_NAMESPACE;
55 : QML_ELEMENT;
56 :
57 : enum class Mode {
58 : StartInEdit = 0,
59 : DoubleClick
60 : };
61 :
62 0 : Q_ENUM_NS(Mode)
63 : }
64 :
65 : class TableViewHeader : public QObject
66 : {
67 : Q_OBJECT
68 : QML_ELEMENT;
69 :
70 : Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
71 :
72 : Q_PROPERTY(muse::uicomponents::TableViewCellType::Type cellType READ cellType NOTIFY cellTypeChanged FINAL)
73 : Q_PROPERTY(muse::uicomponents::TableViewCellEditMode::Mode cellEditMode READ cellEditMode NOTIFY cellEditModeChanged FINAL)
74 :
75 : Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged FINAL)
76 :
77 : Q_PROPERTY(
78 : muse::uicomponents::MenuItemList availableFormats READ availableFormats WRITE setAvailableFormats NOTIFY availableFormatsChanged FINAL)
79 : Q_PROPERTY(QString currentFormatId READ currentFormatId WRITE setCurrentFormatId NOTIFY currentFormatIdChanged FINAL)
80 :
81 : public:
82 : explicit TableViewHeader(QObject* parent = nullptr);
83 :
84 : QString title() const;
85 : void setTitle(const QString& title);
86 :
87 : int preferredWidth() const;
88 : void setPreferredWidth(int width);
89 :
90 : TableViewCellType::Type cellType() const;
91 : void setCellType(TableViewCellType::Type type);
92 :
93 : TableViewCellEditMode::Mode cellEditMode() const;
94 : void setCellEditMode(TableViewCellEditMode::Mode mode);
95 :
96 : MenuItemList availableFormats() const;
97 : void setAvailableFormats(const MenuItemList& formats);
98 :
99 : QString currentFormatId() const;
100 : void setCurrentFormatId(const QString& id);
101 :
102 : signals:
103 : void titleChanged();
104 :
105 : void cellTypeChanged();
106 : void cellEditModeChanged();
107 :
108 : void preferredWidthChanged();
109 :
110 : void availableFormatsChanged();
111 : void currentFormatIdChanged();
112 :
113 : void selectedChanged();
114 :
115 : private:
116 : QString m_title;
117 :
118 : TableViewCellType::Type m_cellType = TableViewCellType::Type::Undefined;
119 : TableViewCellEditMode::Mode m_cellEditMode = TableViewCellEditMode::Mode::StartInEdit;
120 :
121 : int m_preferredWidth = 0;
122 :
123 : MenuItemList m_availableFormats;
124 : QString m_currentFormatId;
125 : };
126 : }
|