Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdesigner_formwindowcommand.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
5
#
include
"qdesigner_formwindowcommand_p.h"
6
#
include
"qdesigner_objectinspector_p.h"
7
#
include
"layout_p.h"
8
9
#
include
<
QtDesigner
/
abstractformeditor
.
h
>
10
#
include
<
QtDesigner
/
abstractformwindow
.
h
>
11
#
include
<
QtDesigner
/
abstractobjectinspector
.
h
>
12
#
include
<
QtDesigner
/
abstractactioneditor
.
h
>
13
#
include
<
QtDesigner
/
abstractmetadatabase
.
h
>
14
#
include
<
QtDesigner
/
propertysheet
.
h
>
15
#
include
<
QtDesigner
/
abstractpropertyeditor
.
h
>
16
#
include
<
QtDesigner
/
qextensionmanager
.
h
>
17
18
#
include
<
QtCore
/
qvariant
.
h
>
19
#
include
<
QtWidgets
/
qwidget
.
h
>
20
#
include
<
QtWidgets
/
qlabel
.
h
>
21
22
QT_BEGIN_NAMESPACE
23
24
using
namespace
Qt::StringLiterals;
25
26
namespace
qdesigner_internal
{
27
28
// ---- QDesignerFormWindowCommand ----
29
QDesignerFormWindowCommand
::
QDesignerFormWindowCommand
(
const
QString
&
description
,
30
QDesignerFormWindowInterface
*
formWindow
,
31
QUndoCommand
*
parent
)
32
:
QUndoCommand
(
description
,
parent
),
33
m_formWindow
(
formWindow
)
34
{
35
}
36
37
QDesignerFormWindowInterface
*
QDesignerFormWindowCommand
::
formWindow
()
const
38
{
39
return
m_formWindow
;
40
}
41
42
QDesignerFormEditorInterface
*
QDesignerFormWindowCommand
::
core
()
const
43
{
44
if
(
QDesignerFormWindowInterface
*
fw
=
formWindow
())
45
return
fw
->
core
();
46
47
return
nullptr
;
48
}
49
50
void
QDesignerFormWindowCommand
::
undo
()
51
{
52
cheapUpdate
();
53
}
54
55
void
QDesignerFormWindowCommand
::
redo
()
56
{
57
cheapUpdate
();
58
}
59
60
void
QDesignerFormWindowCommand
::
cheapUpdate
()
61
{
62
if
(
core
()->
objectInspector
())
63
core
()->
objectInspector
()->
setFormWindow
(
formWindow
());
64
65
if
(
core
()->
actionEditor
())
66
core
()->
actionEditor
()->
setFormWindow
(
formWindow
());
67
}
68
69
QDesignerPropertySheetExtension
*
QDesignerFormWindowCommand
::
propertySheet
(
QObject
*
object
)
const
70
{
71
return
qt_extension
<
QDesignerPropertySheetExtension
*>(
formWindow
()->
core
()->
extensionManager
(),
object
);
72
}
73
74
void
QDesignerFormWindowCommand
::
updateBuddies
(
QDesignerFormWindowInterface
*
form
,
75
const
QString
&
old_name
,
76
const
QString
&
new_name
)
77
{
78
QExtensionManager
*
extensionManager
=
form
->
core
()->
extensionManager
();
79
80
const
auto
label_list
=
form
->
findChildren
<
QLabel
*>();
81
if
(
label_list
.
isEmpty
())
82
return
;
83
84
const
QString
buddyProperty
= u"buddy"_s;
85
const
QByteArray
oldNameU8
=
old_name
.
toUtf8
();
86
const
QByteArray
newNameU8
=
new_name
.
toUtf8
();
87
88
for
(
QLabel
*
label
:
label_list
) {
89
if
(
QDesignerPropertySheetExtension
*
sheet
=
90
qt_extension
<
QDesignerPropertySheetExtension
*>(
extensionManager
,
label
)) {
91
const
int
idx
=
sheet
->
indexOf
(
buddyProperty
);
92
if
(
idx
!= -1) {
93
const
QByteArray
oldBuddy
=
sheet
->
property
(
idx
).
toByteArray
();
94
if
(
oldBuddy
==
oldNameU8
)
95
sheet
->
setProperty
(
idx
,
newNameU8
);
96
}
97
}
98
}
99
}
100
101
void
QDesignerFormWindowCommand
::
selectUnmanagedObject
(
QObject
*
unmanagedObject
)
102
{
103
// Keep selection in sync
104
if
(
QDesignerObjectInspector
*
oi
=
qobject_cast
<
QDesignerObjectInspector
*>(
core
()->
objectInspector
())) {
105
oi
->
clearSelection
();
106
oi
->
selectObject
(
unmanagedObject
);
107
}
108
core
()->
propertyEditor
()->
setObject
(
unmanagedObject
);
109
}
110
111
}
// namespace qdesigner_internal
112
113
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:66
qttools
src
designer
src
lib
shared
qdesigner_formwindowcommand.cpp
Generated on Mon Nov 11 2024 00:53:01 for Qt by
1.12.0