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 : #include "tableviewheader.h"
23 :
24 : using namespace muse::uicomponents;
25 :
26 0 : TableViewHeader::TableViewHeader(QObject* parent)
27 0 : : QObject(parent)
28 : {
29 0 : }
30 :
31 0 : QString TableViewHeader::title() const
32 : {
33 0 : return m_title;
34 : }
35 :
36 0 : void TableViewHeader::setTitle(const QString& title)
37 : {
38 0 : if (m_title == title) {
39 0 : return;
40 : }
41 :
42 0 : m_title = title;
43 0 : emit titleChanged();
44 : }
45 :
46 0 : int TableViewHeader::preferredWidth() const
47 : {
48 0 : return m_preferredWidth;
49 : }
50 :
51 0 : void TableViewHeader::setPreferredWidth(int width)
52 : {
53 0 : if (m_preferredWidth == width) {
54 0 : return;
55 : }
56 :
57 0 : m_preferredWidth = width;
58 0 : emit preferredWidthChanged();
59 : }
60 :
61 0 : TableViewCellType::Type TableViewHeader::cellType() const
62 : {
63 0 : return m_cellType;
64 : }
65 :
66 0 : void TableViewHeader::setCellType(TableViewCellType::Type type)
67 : {
68 0 : if (m_cellType == type) {
69 0 : return;
70 : }
71 :
72 0 : m_cellType = type;
73 0 : emit cellTypeChanged();
74 : }
75 :
76 0 : TableViewCellEditMode::Mode TableViewHeader::cellEditMode() const
77 : {
78 0 : return m_cellEditMode;
79 : }
80 :
81 0 : void TableViewHeader::setCellEditMode(TableViewCellEditMode::Mode mode)
82 : {
83 0 : if (m_cellEditMode == mode) {
84 0 : return;
85 : }
86 :
87 0 : m_cellEditMode = mode;
88 0 : emit cellEditModeChanged();
89 : }
90 :
91 0 : MenuItemList TableViewHeader::availableFormats() const
92 : {
93 0 : return m_availableFormats;
94 : }
95 :
96 0 : void TableViewHeader::setAvailableFormats(const MenuItemList& formats)
97 : {
98 0 : if (m_availableFormats == formats) {
99 0 : return;
100 : }
101 :
102 0 : m_availableFormats = formats;
103 0 : emit availableFormatsChanged();
104 : }
105 :
106 0 : QString TableViewHeader::currentFormatId() const
107 : {
108 0 : return m_currentFormatId;
109 : }
110 :
111 0 : void TableViewHeader::setCurrentFormatId(const QString& id)
112 : {
113 0 : if (m_currentFormatId == id) {
114 0 : return;
115 : }
116 :
117 0 : for (muse::uicomponents::MenuItem* item : std::as_const(m_availableFormats)) {
118 0 : item->setChecked(item->id() == id);
119 : }
120 :
121 0 : m_currentFormatId = id;
122 0 : emit currentFormatIdChanged();
123 : }
|