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
connectionedit_p.h
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
// Qt-Security score:significant reason:default
4
5
//
6
// W A R N I N G
7
// -------------
8
//
9
// This file is not part of the Qt API. It exists for the convenience
10
// of Qt Designer. This header
11
// file may change from version to version without notice, or even be removed.
12
//
13
// We mean it.
14
//
15
16
17
#
ifndef
CONNECTIONEDIT_H
18
#
define
CONNECTIONEDIT_H
19
20
#
include
"shared_global_p.h"
21
22
#
include
<
QtCore
/
qhash
.
h
>
23
#
include
<
QtCore
/
qlist
.
h
>
24
#
include
<
QtCore
/
qpointer
.
h
>
25
26
#
include
<
QtWidgets
/
qwidget
.
h
>
27
#
include
<
QtGui
/
qpixmap
.
h
>
28
#
include
<
QtGui
/
qpolygon
.
h
>
29
#
include
<
QtGui
/
qundostack
.
h
>
30
31
QT_BEGIN_NAMESPACE
32
33
class
QDesignerFormWindowInterface;
34
class
QUndoStack;
35
class
QMenu;
36
37
namespace
qdesigner_internal
{
38
39
class
Connection;
40
class
ConnectionEdit;
41
42
class
QDESIGNER_SHARED_EXPORT
CETypes
43
{
44
public
:
45
using
ConnectionList
=
QList
<
Connection
*>;
46
using
ConnectionSet
=
QHash
<
Connection
*,
Connection
*> ;
47
using
WidgetSet
=
QHash
<
QWidget
*,
QWidget
*>;
48
49
class
EndPoint
{
50
public
:
51
enum
Type
{
Source
,
Target
};
52
explicit
EndPoint
(
Connection
*
_con
=
nullptr
,
Type
_type
=
Source
) :
con
(
_con
),
type
(
_type
) {}
53
bool
isNull
()
const
{
return
con
==
nullptr
; }
54
bool
operator
== (
const
EndPoint
&
other
)
const
{
return
con
==
other
.
con
&&
type
==
other
.
type
; }
55
bool
operator
!= (
const
EndPoint
&
other
)
const
{
return
!
operator
== (
other
); }
56
Connection
*
con
;
57
Type
type
;
58
};
59
enum
LineDir
{
UpDir
= 0,
DownDir
,
RightDir
,
LeftDir
};
60
};
61
62
class
QDESIGNER_SHARED_EXPORT
Connection
:
public
CETypes
63
{
64
public
:
65
explicit
Connection
(
ConnectionEdit
*
edit
);
66
explicit
Connection
(
ConnectionEdit
*
edit
,
QObject
*
source
,
QObject
*
target
);
67
virtual
~
Connection
() =
default
;
68
69
QObject
*
object
(
EndPoint
::
Type
type
)
const
70
{
71
return
(
type
==
EndPoint
::
Source
?
m_source
:
m_target
);
72
}
73
74
QWidget
*
widget
(
EndPoint
::
Type
type
)
const
75
{
76
return
qobject_cast
<
QWidget
*>(
object
(
type
));
77
}
78
79
QPoint
endPointPos
(
EndPoint
::
Type
type
)
const
;
80
QRect
endPointRect
(
EndPoint
::
Type
)
const
;
81
void
setEndPoint
(
EndPoint
::
Type
type
,
QObject
*
w
,
const
QPoint
&
pos
)
82
{
type
==
EndPoint
::
Source
?
setSource
(
w
,
pos
) :
setTarget
(
w
,
pos
); }
83
84
bool
isVisible
()
const
;
85
virtual
void
updateVisibility
();
86
void
setVisible
(
bool
b
);
87
88
virtual
QRegion
region
()
const
;
89
bool
contains
(
const
QPoint
&
pos
)
const
;
90
virtual
void
paint
(
QPainter
*
p
)
const
;
91
92
void
update
(
bool
update_widgets
=
true
)
const
;
93
void
checkWidgets
();
94
95
QString
label
(
EndPoint
::
Type
type
)
const
96
{
return
type
==
EndPoint
::
Source
?
m_source_label
:
m_target_label
; }
97
void
setLabel
(
EndPoint
::
Type
type
,
const
QString
&
text
);
98
QRect
labelRect
(
EndPoint
::
Type
type
)
const
;
99
QPixmap
labelPixmap
(
EndPoint
::
Type
type
)
const
100
{
return
type
==
EndPoint
::
Source
?
m_source_label_pm
:
m_target_label_pm
; }
101
102
ConnectionEdit
*
edit
()
const
{
return
m_edit
; }
103
104
virtual
void
inserted
() {}
105
virtual
void
removed
() {}
106
107
private
:
108
QPoint
m_source_pos
,
m_target_pos
;
109
QObject
*
m_source
, *
m_target
;
110
QList
<
QPoint
>
m_knee_list
;
111
QPolygonF
m_arrow_head
;
112
ConnectionEdit
*
m_edit
;
113
QString
m_source_label
,
m_target_label
;
114
QPixmap
m_source_label_pm
,
m_target_label_pm
;
115
QRect
m_source_rect
,
m_target_rect
;
116
bool
m_visible
;
117
118
void
setSource
(
QObject
*
source
,
const
QPoint
&
pos
);
119
void
setTarget
(
QObject
*
target
,
const
QPoint
&
pos
);
120
void
updateKneeList
();
121
void
trimLine
();
122
void
updatePixmap
(
EndPoint
::
Type
type
);
123
LineDir
labelDir
(
EndPoint
::
Type
type
)
const
;
124
bool
ground
()
const
;
125
QRect
groundRect
()
const
;
126
};
127
128
class
QDESIGNER_SHARED_EXPORT
ConnectionEdit
:
public
QWidget
,
public
CETypes
129
{
130
Q_OBJECT
131
public
:
132
ConnectionEdit
(
QWidget
*
parent
,
QDesignerFormWindowInterface
*
form
);
133
~
ConnectionEdit
()
override
;
134
135
const
QPointer
<
QWidget
> &
background
()
const
{
return
m_bg_widget
; }
136
137
void
setSelected
(
Connection
*
con
,
bool
sel
);
138
bool
selected
(
const
Connection
*
con
)
const
;
139
140
int
connectionCount
()
const
{
return
m_con_list
.
size
(); }
141
Connection
*
connection
(
int
i
)
const
{
return
m_con_list
.
at
(
i
); }
142
int
indexOfConnection
(
Connection
*
con
)
const
{
return
m_con_list
.
indexOf
(
con
); }
143
144
virtual
void
setSource
(
Connection
*
con
,
const
QString
&
obj_name
);
145
virtual
void
setTarget
(
Connection
*
con
,
const
QString
&
obj_name
);
146
147
QUndoStack
*
undoStack
()
const
{
return
m_undo_stack
; }
148
149
void
clear
();
150
151
void
showEvent
(
QShowEvent
*
/*e*/
)
override
152
{
153
updateBackground
();
154
}
155
156
signals
:
157
void
aboutToAddConnection
(
int
idx
);
158
void
connectionAdded
(
qdesigner_internal
::
Connection
*
con
);
159
void
aboutToRemoveConnection
(
qdesigner_internal
::
Connection
*
con
);
160
void
connectionRemoved
(
int
idx
);
161
void
connectionSelected
(
qdesigner_internal
::
Connection
*
con
);
162
void
widgetActivated
(
QWidget
*
wgt
);
163
void
connectionChanged
(
qdesigner_internal
::
Connection
*
con
);
164
165
public
slots
:
166
void
selectNone
();
167
void
selectAll
();
168
virtual
void
deleteSelected
();
169
virtual
void
setBackground
(
QWidget
*
background
);
170
virtual
void
updateBackground
();
171
virtual
void
widgetRemoved
(
QWidget
*
w
);
172
virtual
void
objectRemoved
(
QObject
*
o
);
173
174
void
updateLines
();
175
void
enableUpdateBackground
(
bool
enable
);
176
177
protected
:
178
void
paintEvent
(
QPaintEvent
*
e
)
override
;
179
void
mouseMoveEvent
(
QMouseEvent
*
e
)
override
;
180
void
mousePressEvent
(
QMouseEvent
*
e
)
override
;
181
void
mouseReleaseEvent
(
QMouseEvent
*
e
)
override
;
182
void
keyPressEvent
(
QKeyEvent
*
e
)
override
;
183
void
mouseDoubleClickEvent
(
QMouseEvent
*
e
)
override
;
184
void
resizeEvent
(
QResizeEvent
*
e
)
override
;
185
void
contextMenuEvent
(
QContextMenuEvent
*
event
)
override
;
186
187
virtual
Connection
*
createConnection
(
QWidget
*
source
,
QWidget
*
target
);
188
virtual
void
modifyConnection
(
Connection
*
con
);
189
190
virtual
QWidget
*
widgetAt
(
const
QPoint
&
pos
)
const
;
191
virtual
void
createContextMenu
(
QMenu
&
menu
);
192
void
addConnection
(
Connection
*
con
);
193
QRect
widgetRect
(
QWidget
*
w
)
const
;
194
195
enum
State
{
Editing
,
Connecting
,
Dragging
};
196
State
state
()
const
;
197
198
virtual
void
endConnection
(
QWidget
*
target
,
const
QPoint
&
pos
);
199
200
const
ConnectionList
&
connectionList
()
const
{
return
m_con_list
; }
201
const
ConnectionSet
&
selection
()
const
{
return
m_sel_con_set
; }
202
Connection
*
takeConnection
(
Connection
*
con
);
203
Connection
*
newlyAddedConnection
() {
return
m_tmp_con
; }
204
void
clearNewlyAddedConnection
();
205
206
void
findObjectsUnderMouse
(
const
QPoint
&
pos
);
207
208
private
:
209
void
startConnection
(
QWidget
*
source
,
const
QPoint
&
pos
);
210
void
continueConnection
(
QWidget
*
target
,
const
QPoint
&
pos
);
211
void
abortConnection
();
212
213
void
startDrag
(
const
EndPoint
&
end_point
,
const
QPoint
&
pos
);
214
void
continueDrag
(
const
QPoint
&
pos
);
215
void
endDrag
(
const
QPoint
&
pos
);
216
void
adjustHotSopt
(
const
EndPoint
&
end_point
,
const
QPoint
&
pos
);
217
Connection
*
connectionAt
(
const
QPoint
&
pos
)
const
;
218
EndPoint
endPointAt
(
const
QPoint
&
pos
)
const
;
219
void
paintConnection
(
QPainter
*
p
,
Connection
*
con
,
220
WidgetSet
*
heavy_highlight_set
,
221
WidgetSet
*
light_highlight_set
)
const
;
222
void
paintLabel
(
QPainter
*
p
,
EndPoint
::
Type
type
,
Connection
*
con
);
223
224
225
QPointer
<
QWidget
>
m_bg_widget
;
226
QUndoStack
*
m_undo_stack
;
227
bool
m_enable_update_background
;
228
229
Connection
*
m_tmp_con
;
// the connection we are currently editing
230
ConnectionList
m_con_list
;
231
bool
m_start_connection_on_drag
;
232
EndPoint
m_end_point_under_mouse
;
233
QPointer
<
QWidget
>
m_widget_under_mouse
;
234
235
EndPoint
m_drag_end_point
;
236
QPoint
m_old_source_pos
,
m_old_target_pos
;
237
ConnectionSet
m_sel_con_set
;
238
const
QColor
m_inactive_color
;
239
const
QColor
m_active_color
;
240
241
private
:
242
friend
class
Connection
;
243
friend
class
AddConnectionCommand
;
244
friend
class
DeleteConnectionsCommand
;
245
friend
class
SetEndPointCommand
;
246
};
247
248
class
QDESIGNER_SHARED_EXPORT
CECommand
:
public
QUndoCommand
,
public
CETypes
249
{
250
public
:
251
explicit
CECommand
(
ConnectionEdit
*
edit
)
252
:
m_edit
(
edit
) {}
253
254
bool
mergeWith
(
const
QUndoCommand
*)
override
{
return
false
; }
255
256
ConnectionEdit
*
edit
()
const
{
return
m_edit
; }
257
258
private
:
259
ConnectionEdit
*
m_edit
;
260
};
261
262
class
QDESIGNER_SHARED_EXPORT
AddConnectionCommand
:
public
CECommand
263
{
264
public
:
265
AddConnectionCommand
(
ConnectionEdit
*
edit
,
Connection
*
con
);
266
void
redo
()
override
;
267
void
undo
()
override
;
268
private
:
269
Connection
*
m_con
;
270
};
271
272
class
QDESIGNER_SHARED_EXPORT
DeleteConnectionsCommand
:
public
CECommand
273
{
274
public
:
275
DeleteConnectionsCommand
(
ConnectionEdit
*
edit
,
const
ConnectionList
&
con_list
);
276
void
redo
()
override
;
277
void
undo
()
override
;
278
private
:
279
ConnectionList
m_con_list
;
280
};
281
282
}
// namespace qdesigner_internal
283
284
QT_END_NAMESPACE
285
286
#
endif
// CONNECTIONEDIT_H
canBeBuddy
static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form)
Definition
buddyeditor.cpp:36
buddy
static QString buddy(QLabel *label, QDesignerFormEditorInterface *core)
Definition
buddyeditor.cpp:56
buddyPropertyC
static constexpr auto buddyPropertyC
Definition
buddyeditor.cpp:34
QT_BUDDYEDITOR_EXPORT
#define QT_BUDDYEDITOR_EXPORT
Definition
buddyeditor_global.h:17
QDesignerPropertySheetExtension
Definition
propertysheet.h:15
QPainter::QWidget
friend class QWidget
Definition
qpainter.h:432
qdesigner_internal::AddConnectionCommand
Definition
connectionedit_p.h:263
qdesigner_internal::BuddyEditor
Definition
buddyeditor.h:23
qdesigner_internal::BuddyEditor::setBackground
void setBackground(QWidget *background) override
Definition
buddyeditor.cpp:189
qdesigner_internal::BuddyEditor::formWindow
QDesignerFormWindowInterface * formWindow() const
Definition
buddyeditor.cpp:113
qdesigner_internal::BuddyEditor::endConnection
void endConnection(QWidget *target, const QPoint &pos) override
Definition
buddyeditor.cpp:220
qdesigner_internal::BuddyEditor::autoBuddy
void autoBuddy()
Definition
buddyeditor.cpp:309
qdesigner_internal::BuddyEditor::widgetRemoved
void widgetRemoved(QWidget *w) override
Definition
buddyeditor.cpp:253
qdesigner_internal::BuddyEditor::widgetAt
QWidget * widgetAt(const QPoint &pos) const override
Definition
buddyeditor.cpp:81
qdesigner_internal::BuddyEditor::createConnection
Connection * createConnection(QWidget *source, QWidget *destination) override
Definition
buddyeditor.cpp:108
qdesigner_internal::BuddyEditor::createContextMenu
void createContextMenu(QMenu &menu) override
Definition
buddyeditor.cpp:389
qdesigner_internal::BuddyEditor::deleteSelected
void deleteSelected() override
Definition
buddyeditor.cpp:286
qdesigner_internal::CECommand
Definition
connectionedit_p.h:249
qdesigner_internal::CETypes
Definition
connectionedit_p.h:43
qdesigner_internal::ConnectionEdit
Definition
connectionedit_p.h:129
qdesigner_internal::Connection
Definition
connectionedit_p.h:63
qdesigner_internal::DeleteConnectionsCommand
Definition
connectionedit_p.h:273
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
qdesigner_internal::createBuddyCommand
static QUndoCommand * createBuddyCommand(QDesignerFormWindowInterface *fw, QLabel *label, QWidget *buddy)
Definition
buddyeditor.cpp:212
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QDESIGNER_SHARED_EXPORT
#define QDESIGNER_SHARED_EXPORT
Definition
shared_global_p.h:33
qdesigner_internal::LayoutProperties::clear
void clear()
Definition
qlayout_widget.cpp:222
qttools
src
designer
src
lib
shared
connectionedit_p.h
Generated on
for Qt by
1.18.0