File indexing completed on 2024-04-28 15:27:41
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "formlayoutattached.h" 0008 #include <QDebug> 0009 #include <QQuickItem> 0010 0011 FormLayoutAttached::FormLayoutAttached(QObject *parent) 0012 : QObject(parent) 0013 { 0014 m_buddyFor = qobject_cast<QQuickItem *>(parent); 0015 } 0016 0017 FormLayoutAttached::~FormLayoutAttached() 0018 { 0019 } 0020 0021 void FormLayoutAttached::setLabel(const QString &text) 0022 { 0023 if (m_label == text) { 0024 return; 0025 } 0026 0027 m_label = text; 0028 Q_EMIT labelChanged(); 0029 } 0030 0031 QString FormLayoutAttached::label() const 0032 { 0033 return m_label; 0034 } 0035 0036 void FormLayoutAttached::setLabelAlignment(int alignment) 0037 { 0038 if (m_labelAlignment == alignment) { 0039 return; 0040 } 0041 0042 m_labelAlignment = alignment; 0043 Q_EMIT labelAlignmentChanged(); 0044 } 0045 0046 int FormLayoutAttached::labelAlignment() const 0047 { 0048 return m_labelAlignment; 0049 } 0050 0051 void FormLayoutAttached::setIsSection(bool section) 0052 { 0053 if (m_isSection == section) { 0054 return; 0055 } 0056 0057 m_isSection = section; 0058 Q_EMIT isSectionChanged(); 0059 } 0060 0061 bool FormLayoutAttached::isSection() const 0062 { 0063 return m_isSection; 0064 } 0065 0066 void FormLayoutAttached::setCheckable(bool checkable) 0067 { 0068 if (checkable == m_checkable) { 0069 return; 0070 } 0071 0072 m_checkable = checkable; 0073 Q_EMIT checkableChanged(); 0074 } 0075 0076 bool FormLayoutAttached::checkable() const 0077 { 0078 return m_checkable; 0079 } 0080 0081 void FormLayoutAttached::setChecked(bool checked) 0082 { 0083 if (checked == m_checked) { 0084 return; 0085 } 0086 0087 m_checked = checked; 0088 Q_EMIT checkedChanged(); 0089 } 0090 0091 bool FormLayoutAttached::checked() const 0092 { 0093 return m_checked; 0094 } 0095 0096 void FormLayoutAttached::setEnabled(bool enabled) 0097 { 0098 if (enabled == m_enabled) { 0099 return; 0100 } 0101 0102 m_enabled = enabled; 0103 Q_EMIT enabledChanged(); 0104 } 0105 0106 bool FormLayoutAttached::enabled() const 0107 { 0108 return m_enabled; 0109 } 0110 0111 QQuickItem *FormLayoutAttached::buddyFor() const 0112 { 0113 return m_buddyFor; 0114 } 0115 0116 void FormLayoutAttached::setBuddyFor(QQuickItem *buddyfor) 0117 { 0118 if (m_buddyFor == buddyfor || !m_buddyFor->isAncestorOf(buddyfor)) { 0119 return; 0120 } 0121 0122 m_buddyFor = buddyfor; 0123 Q_EMIT buddyForChanged(); 0124 } 0125 0126 FormLayoutAttached *FormLayoutAttached::qmlAttachedProperties(QObject *object) 0127 { 0128 return new FormLayoutAttached(object); 0129 } 0130 0131 #include "moc_formlayoutattached.cpp"