Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickdesignersupportstates.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#include "
qquickdesignersupportstates_p.h
"
5
6
#include <private/qquickstategroup_p.h>
7
#include <private/qquickpropertychanges_p.h>
8
9
QT_BEGIN_NAMESPACE
10
11
bool
QQuickDesignerSupportStates::isStateActive
(
QObject
*
object
,
QQmlContext
*
context
)
12
{
13
QQuickState
*stateObject = qobject_cast<QQuickState*>(
object
);
14
15
if
(!stateObject)
16
return
false
;
17
18
QQuickStateGroup
*stateGroup = stateObject->
stateGroup
();
19
20
QQmlProperty
property
(
object
,
QLatin1String
(
"name"
),
context
);
21
22
return
stateObject && stateGroup && stateGroup->
state
() ==
property
.read();
23
}
24
25
void
QQuickDesignerSupportStates::activateState
(
QObject
*
object
,
QQmlContext
*
context
)
26
{
27
QQuickState
*stateObject = qobject_cast<QQuickState*>(
object
);
28
29
if
(!stateObject)
30
return
;
31
32
QQuickStateGroup
*stateGroup = stateObject->
stateGroup
();
33
34
QQmlProperty
property
(
object
,
QLatin1String
(
"name"
),
context
);
35
36
stateGroup->
setState
(
property
.read().toString());
37
}
38
39
void
QQuickDesignerSupportStates::deactivateState
(
QObject
*
object
)
40
{
41
QQuickState
*stateObject = qobject_cast<QQuickState*>(
object
);
42
43
if
(!stateObject)
44
return
;
45
46
QQuickStateGroup
*stateGroup = stateObject->
stateGroup
();
47
48
if
(stateGroup)
49
stateGroup->
setState
(
QString
());
50
}
51
52
bool
QQuickDesignerSupportStates::changeValueInRevertList
(
QObject
*
state
,
QObject
*
target
,
53
const
QQuickDesignerSupport::PropertyName
&propertyName,
54
const
QVariant
&
value
)
55
{
56
QQuickState
*stateObject = qobject_cast<QQuickState*>(
state
);
57
58
if
(!stateObject)
59
return
false
;
60
61
return
stateObject->
changeValueInRevertList
(
target
,
QString::fromUtf8
(propertyName),
value
);
62
}
63
64
bool
QQuickDesignerSupportStates::updateStateBinding
(
QObject
*
state
,
QObject
*
target
,
65
const
QQuickDesignerSupport::PropertyName
&propertyName,
66
const
QString
&expression)
67
{
68
QQuickState
*stateObject = qobject_cast<QQuickState*>(
state
);
69
70
if
(!stateObject)
71
return
false
;
72
73
return
stateObject->
changeValueInRevertList
(
target
,
QString::fromUtf8
(propertyName), expression);
74
}
75
76
bool
QQuickDesignerSupportStates::resetStateProperty
(
QObject
*
state
,
QObject
*
target
,
77
const
QQuickDesignerSupport::PropertyName
&propertyName,
78
const
QVariant
&
/* resetValue */
)
79
{
80
QQuickState
*stateObject = qobject_cast<QQuickState*>(
state
);
81
82
if
(!stateObject)
83
return
false
;
84
85
return
stateObject->
removeEntryFromRevertList
(
target
,
QString::fromUtf8
(propertyName));
86
}
87
88
QT_END_NAMESPACE
89
QByteArray
\inmodule QtCore
Definition
qbytearray.h:57
QObject
\inmodule QtCore
Definition
qobject.h:103
QQmlContext
The QQmlContext class defines a context within a QML engine.
Definition
qqmlcontext.h:25
QQmlProperty
The QQmlProperty class abstracts accessing properties on objects created from QML.
Definition
qqmlproperty.h:23
QQuickDesignerSupportStates::changeValueInRevertList
static bool changeValueInRevertList(QObject *state, QObject *target, const QQuickDesignerSupport::PropertyName &propertyName, const QVariant &value)
Definition
qquickdesignersupportstates.cpp:52
QQuickDesignerSupportStates::resetStateProperty
static bool resetStateProperty(QObject *state, QObject *target, const QQuickDesignerSupport::PropertyName &propertyName, const QVariant &)
Definition
qquickdesignersupportstates.cpp:76
QQuickDesignerSupportStates::isStateActive
static bool isStateActive(QObject *object, QQmlContext *context)
Definition
qquickdesignersupportstates.cpp:11
QQuickDesignerSupportStates::deactivateState
static void deactivateState(QObject *object)
Definition
qquickdesignersupportstates.cpp:39
QQuickDesignerSupportStates::updateStateBinding
static bool updateStateBinding(QObject *state, QObject *target, const QQuickDesignerSupport::PropertyName &propertyName, const QString &expression)
Definition
qquickdesignersupportstates.cpp:64
QQuickDesignerSupportStates::activateState
static void activateState(QObject *object, QQmlContext *context)
Definition
qquickdesignersupportstates.cpp:25
QQuickStateGroup
Definition
qquickstategroup_p.h:24
QQuickStateGroup::state
QString state
Definition
qquickstategroup_p.h:29
QQuickStateGroup::setState
void setState(const QString &)
Definition
qquickstategroup.cpp:289
QQuickState
Definition
qquickstate_p.h:120
QQuickState::stateGroup
QQuickStateGroup * stateGroup() const
Definition
qquickstate.cpp:312
QQuickState::removeEntryFromRevertList
bool removeEntryFromRevertList(QObject *target, const QString &name)
Definition
qquickstate.cpp:386
QQuickState::changeValueInRevertList
bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue)
Definition
qquickstate.cpp:354
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:129
QString::fromUtf8
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition
qstring.cpp:6018
QVariant
\inmodule QtCore
Definition
qvariant.h:65
state
else opt state
[0]
Definition
doc_src_styles.cpp:11
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1590
context
static void * context
Definition
qandroidaudiosource.cpp:42
value
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
Definition
qeglstreamconvenience_p.h:46
target
GLenum target
Definition
qopengles2ext.h:751
qquickdesignersupportstates_p.h
QLatin1String
QLatin1StringView QLatin1String
Definition
qstringfwd.h:31
property
const char property[13]
Definition
qwizard.cpp:101
qtdeclarative
src
quick
designer
qquickdesignersupportstates.cpp
Generated by
1.10.0