Kirigami2

formlayoutattached.cpp
1 /*
2  * SPDX-FileCopyrightText: 2017 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 #include "formlayoutattached.h"
8 #include <QDebug>
9 #include <QQuickItem>
10 
11 FormLayoutAttached::FormLayoutAttached(QObject *parent)
12  : QObject(parent)
13 {
14  m_buddyFor = qobject_cast<QQuickItem *>(parent);
15 }
16 
17 FormLayoutAttached::~FormLayoutAttached()
18 {
19 }
20 
21 void FormLayoutAttached::setLabel(const QString &text)
22 {
23  if (m_label == text) {
24  return;
25  }
26 
27  m_label = text;
28  Q_EMIT labelChanged();
29 }
30 
32 {
33  return m_label;
34 }
35 
36 void FormLayoutAttached::setLabelAlignment(int alignment)
37 {
38  if (m_labelAlignment == alignment) {
39  return;
40  }
41 
42  m_labelAlignment = alignment;
43  Q_EMIT labelAlignmentChanged();
44 }
45 
47 {
48  return m_labelAlignment;
49 }
50 
51 void FormLayoutAttached::setIsSection(bool section)
52 {
53  if (m_isSection == section) {
54  return;
55  }
56 
57  m_isSection = section;
58  Q_EMIT isSectionChanged();
59 }
60 
62 {
63  return m_isSection;
64 }
65 
66 void FormLayoutAttached::setCheckable(bool checkable)
67 {
68  if (checkable == m_checkable) {
69  return;
70  }
71 
72  m_checkable = checkable;
73  Q_EMIT checkableChanged();
74 }
75 
77 {
78  return m_checkable;
79 }
80 
81 void FormLayoutAttached::setChecked(bool checked)
82 {
83  if (checked == m_checked) {
84  return;
85  }
86 
87  m_checked = checked;
88  Q_EMIT checkedChanged();
89 }
90 
91 bool FormLayoutAttached::checked() const
92 {
93  return m_checked;
94 }
95 
96 void FormLayoutAttached::setEnabled(bool enabled)
97 {
98  if (enabled == m_enabled) {
99  return;
100  }
101 
102  m_enabled = enabled;
103  Q_EMIT enabledChanged();
104 }
105 
106 bool FormLayoutAttached::enabled() const
107 {
108  return m_enabled;
109 }
110 
112 {
113  return m_buddyFor;
114 }
115 
116 void FormLayoutAttached::setBuddyFor(QQuickItem *buddyfor)
117 {
118  if (m_buddyFor == buddyfor || !m_buddyFor->isAncestorOf(buddyfor)) {
119  return;
120  }
121 
122  m_buddyFor = buddyfor;
123  Q_EMIT buddyForChanged();
124 }
125 
126 FormLayoutAttached *FormLayoutAttached::qmlAttachedProperties(QObject *object)
127 {
128  return new FormLayoutAttached(object);
129 }
130 
131 #include "moc_formlayoutattached.cpp"
bool enabled
This property holds whether the label and the checkbox of the org::kde::kirigami::FormLayout item rec...
QQuickItem buddyFor
This property can only be used in conjunction with a Kirigami.FormData.label, often in a layout that ...
bool checkable
If true, a checkbox is prepended to the org::kde::kirigami::FormLayout item.
bool isSection
If true, the child item of a org::kde::kirigami::FormLayout becomes a section separator,...
This attached property contains the information for decorating a org::kde::kirigami::FormLayout:
bool checked
This property is true when the checkbox of the org::kde::kirigami::FormLayout item is checked.
QString label
The label for a org::kde::kirigami::FormLayout field.
int labelAlignment
The alignment for the label of a org::kde::kirigami::FormLayout field.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.