Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
writeincludesbase.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
// Qt-Security score:insignificant reason:build-tool
4
5
#
include
"writeincludesbase.h"
6
#
include
"ui4.h"
7
#
include
<
uic
.
h
>
8
#
include
<
databaseinfo
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
static
const
ClassInfoEntry
qclass_lib_map
[] = {
13
#
define
QT_CLASS_LIB
(
klass
,
module
,
header
)
{
#
klass
,
#
module
,
#
header
}
,
14
#
include
"qclass_lib_map.h"
15
#
undef
QT_CLASS_LIB
16
};
17
18
ClassInfoEntries
classInfoEntries
()
19
{
20
const
ClassInfoEntry
*classLibEnd =
qclass_lib_map
+
sizeof
(
qclass_lib_map
)/
sizeof
(
ClassInfoEntry
);
21
return
{
qclass_lib_map
, classLibEnd};
22
}
23
24
// Base class for implementing a class that determines includes and equivalents
25
// in other languages by implementing doAdd(). It makes sure all dependent
26
// classes are known.
27
WriteIncludesBase
::
WriteIncludesBase
(
Uic
*uic) : m_uic(uic)
28
{
29
}
30
31
void
WriteIncludesBase
::
acceptUI
(DomUI *node)
32
{
33
m_knownClasses.clear();
34
m_laidOut =
false
;
35
36
if
(node->elementIncludes())
37
acceptIncludes
(
node->elementIncludes()
)
;
38
39
// Populate known custom widgets first
40
if
(node->elementCustomWidgets())
41
TreeWalker
::
acceptCustomWidgets
(
node->elementCustomWidgets()
)
;
42
43
add(
QStringLiteral
(
"QApplication"
));
44
add(
QStringLiteral
(
"QVariant"
));
45
46
if
(node->elementButtonGroups())
47
add(
QStringLiteral
(
"QButtonGroup"
));
48
49
TreeWalker
::
acceptUI
(node);
50
}
51
52
void
WriteIncludesBase
::
acceptWidget
(DomWidget *node)
53
{
54
add(node->attributeClass());
55
TreeWalker
::
acceptWidget
(node);
56
}
57
58
void
WriteIncludesBase
::
acceptLayout
(DomLayout *node)
59
{
60
add(node->attributeClass());
61
m_laidOut =
true
;
62
TreeWalker
::
acceptLayout
(node);
63
}
64
65
void
WriteIncludesBase
::
acceptSpacer
(DomSpacer *node)
66
{
67
add(
QStringLiteral
(
"QSpacerItem"
));
68
TreeWalker
::
acceptSpacer
(node);
69
}
70
71
void
WriteIncludesBase
::
acceptProperty
(DomProperty *node)
72
{
73
if
(node->kind() == DomProperty::Date)
74
add(
QStringLiteral
(
"QDate"
));
75
if
(node->kind() == DomProperty::Locale)
76
add(
QStringLiteral
(
"QLocale"
));
77
if
(node->kind() == DomProperty::IconSet)
78
add(
QStringLiteral
(
"QIcon"
));
79
TreeWalker
::
acceptProperty
(node);
80
}
81
82
void
WriteIncludesBase
::add(
const
QString &className,
const
DomCustomWidget *dcw)
83
{
84
if
(className.isEmpty() || m_knownClasses.contains(className))
85
return
;
86
87
m_knownClasses.insert(className);
88
89
const
CustomWidgetsInfo
*cwi = m_uic
->
customWidgetsInfo
(
)
;
90
static
const
QStringList treeViewsWithHeaders = {
91
QStringLiteral
(
"QTreeView"
),
QStringLiteral
(
"QTreeWidget"
),
92
QStringLiteral
(
"QTableView"
),
QStringLiteral
(
"QTableWidget"
)
93
};
94
if
(cwi->extendsOneOf(className, treeViewsWithHeaders))
95
add(
QStringLiteral
(
"QHeaderView"
));
96
97
if
(!m_laidOut && cwi->extends(className,
"QToolBox"
))
98
add(
QStringLiteral
(
"QLayout"
));
// spacing property of QToolBox)
99
100
if
(className ==
QStringLiteral
(
"Line"
)) {
// ### hmm, deprecate me!
101
add(
QStringLiteral
(
"QFrame"
));
102
return
;
103
}
104
105
if
(cwi->extends(className,
"QDialogButtonBox"
))
106
add(
QStringLiteral
(
"QAbstractButton"
));
// for signal "clicked(QAbstractButton*)"
107
108
doAdd(className, dcw);
109
}
110
111
bool
WriteIncludesBase
::extractHeader(QLatin1StringView languageMarker, QString *headerSpec)
112
{
113
// Check for "C++:header.h;Python:Module"
114
const
auto
markerPos = headerSpec->indexOf(languageMarker, Qt::CaseInsensitive);
115
if
(markerPos == -1)
116
return
false
;
117
headerSpec->remove(0, markerPos + languageMarker.size());
118
if
(
const
auto
commaPos = headerSpec->indexOf(u','); commaPos != -1)
119
headerSpec->truncate(commaPos);
120
*headerSpec = headerSpec->trimmed();
121
return
true
;
122
}
123
124
void
WriteIncludesBase
::
acceptCustomWidget
(DomCustomWidget *node)
125
{
126
const
QString className = node->elementClass();
127
if
(!className.isEmpty())
128
add(className, node);
129
}
130
131
void
WriteIncludesBase
::
acceptActionGroup
(DomActionGroup *node)
132
{
133
add(
QStringLiteral
(
"QActionGroup"
));
134
TreeWalker
::
acceptActionGroup
(node);
135
}
136
137
void
WriteIncludesBase
::
acceptAction
(DomAction *node)
138
{
139
add(
QStringLiteral
(
"QAction"
));
140
TreeWalker
::
acceptAction
(node);
141
}
142
143
void
WriteIncludesBase
::
acceptActionRef
(DomActionRef *node)
144
{
145
add(
QStringLiteral
(
"QAction"
));
146
TreeWalker
::
acceptActionRef
(node);
147
}
148
149
QT_END_NAMESPACE
CustomWidgetsInfo
Definition
customwidgetsinfo.h:19
Uic
Definition
uic.h:31
Uic::customWidgetsInfo
const CustomWidgetsInfo * customWidgetsInfo() const
Definition
uic.h:57
WriteIncludesBase
Definition
writeincludesbase.h:37
WriteIncludesBase::WriteIncludesBase
WriteIncludesBase(Uic *uic)
Definition
writeincludesbase.cpp:27
WriteIncludesBase::acceptActionRef
void acceptActionRef(DomActionRef *node) override
Definition
writeincludesbase.cpp:143
WriteIncludesBase::acceptSpacer
void acceptSpacer(DomSpacer *node) override
Definition
writeincludesbase.cpp:65
WriteIncludesBase::acceptCustomWidget
void acceptCustomWidget(DomCustomWidget *node) override
Definition
writeincludesbase.cpp:124
WriteIncludesBase::acceptUI
void acceptUI(DomUI *node) override
Definition
writeincludesbase.cpp:31
WriteIncludesBase::acceptLayout
void acceptLayout(DomLayout *node) override
Definition
writeincludesbase.cpp:58
WriteIncludesBase::acceptWidget
void acceptWidget(DomWidget *node) override
Definition
writeincludesbase.cpp:52
WriteIncludesBase::acceptActionGroup
void acceptActionGroup(DomActionGroup *node) override
Definition
writeincludesbase.cpp:131
WriteIncludesBase::acceptAction
void acceptAction(DomAction *node) override
Definition
writeincludesbase.cpp:137
WriteIncludesBase::acceptProperty
void acceptProperty(DomProperty *node) override
Definition
writeincludesbase.cpp:71
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QStringLiteral
#define QStringLiteral(str)
Definition
qstring.h:1865
ClassInfoEntries
Definition
writeincludesbase.h:26
ClassInfoEntry
Definition
writeincludesbase.h:19
TreeWalker
Definition
treewalker.h:55
TreeWalker::acceptAction
virtual void acceptAction(DomAction *action)
Definition
treewalker.cpp:205
TreeWalker::acceptActionGroup
virtual void acceptActionGroup(DomActionGroup *actionGroup)
Definition
treewalker.cpp:210
TreeWalker::acceptProperty
virtual void acceptProperty(DomProperty *property)
Definition
treewalker.cpp:153
TreeWalker::acceptIncludes
virtual void acceptIncludes(DomIncludes *includes)
Definition
treewalker.cpp:224
TreeWalker::acceptSpacer
virtual void acceptSpacer(DomSpacer *spacer)
Definition
treewalker.cpp:90
TreeWalker::acceptCustomWidgets
virtual void acceptCustomWidgets(DomCustomWidgets *customWidgets)
Definition
treewalker.cpp:194
TreeWalker::acceptActionRef
virtual void acceptActionRef(DomActionRef *actionRef)
Definition
treewalker.cpp:219
TreeWalker::acceptWidget
virtual void acceptWidget(DomWidget *widget)
Definition
treewalker.cpp:62
TreeWalker::acceptUI
virtual void acceptUI(DomUI *ui)
Definition
treewalker.cpp:10
TreeWalker::acceptLayout
virtual void acceptLayout(DomLayout *layout)
Definition
treewalker.cpp:34
classInfoEntries
ClassInfoEntries classInfoEntries()
Definition
writeincludesbase.cpp:18
qclass_lib_map
static QT_BEGIN_NAMESPACE const ClassInfoEntry qclass_lib_map[]
Definition
writeincludesbase.cpp:12
qtbase
src
tools
uic
shared
writeincludesbase.cpp
Generated on
for Qt by
1.18.0