|
| 1 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | + |
| 3 | +#include "menuitemmodel.h" |
| 4 | + |
| 5 | +using namespace scratchcpp::uicomponents; |
| 6 | + |
| 7 | +MenuItemModel::MenuItemModel(QObject *parent) : |
| 8 | + QObject(parent) |
| 9 | +{ |
| 10 | +} |
| 11 | + |
| 12 | +const QString &MenuItemModel::text() const |
| 13 | +{ |
| 14 | + return m_text; |
| 15 | +} |
| 16 | + |
| 17 | +void MenuItemModel::setText(const QString &newText) |
| 18 | +{ |
| 19 | + if (m_text == newText) |
| 20 | + return; |
| 21 | + |
| 22 | + m_text = newText; |
| 23 | + emit textChanged(); |
| 24 | +} |
| 25 | + |
| 26 | +MenuModel *MenuItemModel::submenu() const |
| 27 | +{ |
| 28 | + return m_submenu; |
| 29 | +} |
| 30 | + |
| 31 | +void MenuItemModel::setSubmenu(MenuModel *newSubmenu) |
| 32 | +{ |
| 33 | + if (m_submenu == newSubmenu) |
| 34 | + return; |
| 35 | + |
| 36 | + m_submenu = newSubmenu; |
| 37 | + emit submenuChanged(); |
| 38 | +} |
| 39 | + |
| 40 | +bool MenuItemModel::isSeparator() const |
| 41 | +{ |
| 42 | + return m_isSeparator; |
| 43 | +} |
| 44 | + |
| 45 | +void MenuItemModel::setIsSeparator(bool newIsSeparator) |
| 46 | +{ |
| 47 | + if (m_isSeparator == newIsSeparator) |
| 48 | + return; |
| 49 | + |
| 50 | + m_isSeparator = newIsSeparator; |
| 51 | + emit isSeparatorChanged(); |
| 52 | +} |
| 53 | + |
| 54 | +bool MenuItemModel::checkable() const |
| 55 | +{ |
| 56 | + return m_checkable; |
| 57 | +} |
| 58 | + |
| 59 | +void MenuItemModel::setCheckable(bool newCheckable) |
| 60 | +{ |
| 61 | + if (m_checkable == newCheckable) |
| 62 | + return; |
| 63 | + |
| 64 | + m_checkable = newCheckable; |
| 65 | + emit checkableChanged(); |
| 66 | +} |
| 67 | + |
| 68 | +bool MenuItemModel::checked() const |
| 69 | +{ |
| 70 | + return m_checked; |
| 71 | +} |
| 72 | + |
| 73 | +void MenuItemModel::setChecked(bool newChecked) |
| 74 | +{ |
| 75 | + if (m_checked == newChecked) |
| 76 | + return; |
| 77 | + |
| 78 | + m_checked = newChecked; |
| 79 | + emit checkedChanged(); |
| 80 | +} |
| 81 | + |
| 82 | +bool MenuItemModel::enabled() const |
| 83 | +{ |
| 84 | + return m_enabled; |
| 85 | +} |
| 86 | + |
| 87 | +void MenuItemModel::setEnabled(bool newEnabled) |
| 88 | +{ |
| 89 | + if (m_enabled == newEnabled) |
| 90 | + return; |
| 91 | + |
| 92 | + m_enabled = newEnabled; |
| 93 | + emit enabledChanged(); |
| 94 | +} |
0 commit comments