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
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
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
31QT_BEGIN_NAMESPACE
32
33class QDesignerFormWindowInterface;
34class QUndoStack;
35class QMenu;
36
37namespace qdesigner_internal {
38
39class Connection;
40class ConnectionEdit;
41
43{
44public:
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); }
58 };
60};
61
63{
64public:
67 virtual ~Connection() = default;
68
70 {
71 return (type == EndPoint::Source ? m_source : m_target);
72 }
73
75 {
77 }
78
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
97 void setLabel(EndPoint::Type type, const QString &text);
101
102 ConnectionEdit *edit() const { return m_edit; }
103
104 virtual void inserted() {}
105 virtual void removed() {}
106
107private:
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();
124 bool ground() const;
125 QRect groundRect() const;
126};
127
129{
131public:
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); }
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
152 {
154 }
155
156signals:
164
165public 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();
176
177protected:
186
188 virtual void modifyConnection(Connection *con);
189
190 virtual QWidget *widgetAt(const QPoint &pos) const;
191 virtual void createContextMenu(QMenu &menu);
193 QRect widgetRect(QWidget *w) const;
194
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; }
205
206 void findObjectsUnderMouse(const QPoint &pos);
207
208private:
209 void startConnection(QWidget *source, 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;
223
224
228
229 Connection *m_tmp_con; // the connection we are currently editing
234
240
241private:
242 friend class Connection;
245 friend class SetEndPointCommand;
246};
247
249{
250public:
253
254 bool mergeWith(const QUndoCommand *) override { return false; }
255
256 ConnectionEdit *edit() const { return m_edit; }
257
258private:
260};
261
263{
264public:
266 void redo() override;
267 void undo() override;
268private:
270};
271
281
282} // namespace qdesigner_internal
283
284QT_END_NAMESPACE
285
286#endif // CONNECTIONEDIT_H
static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form)
static QString buddy(QLabel *label, QDesignerFormEditorInterface *core)
static constexpr auto buddyPropertyC
#define QT_BUDDYEDITOR_EXPORT
friend class QWidget
Definition qpainter.h:432
void setBackground(QWidget *background) override
QDesignerFormWindowInterface * formWindow() const
void endConnection(QWidget *target, const QPoint &pos) override
void widgetRemoved(QWidget *w) override
QWidget * widgetAt(const QPoint &pos) const override
Connection * createConnection(QWidget *source, QWidget *destination) override
void createContextMenu(QMenu &menu) override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static QUndoCommand * createBuddyCommand(QDesignerFormWindowInterface *fw, QLabel *label, QWidget *buddy)
#define QDESIGNER_SHARED_EXPORT