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
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15
16#ifndef CONNECTIONEDIT_H
17#define CONNECTIONEDIT_H
18
20
21#include <QtCore/qhash.h>
22#include <QtCore/qlist.h>
23#include <QtCore/qpointer.h>
24
25#include <QtWidgets/qwidget.h>
26#include <QtGui/qpixmap.h>
27#include <QtGui/qpolygon.h>
28#include <QtGui/qundostack.h>
29
30QT_BEGIN_NAMESPACE
31
32class QDesignerFormWindowInterface;
33class QUndoStack;
34class QMenu;
35
36namespace qdesigner_internal {
37
38class Connection;
39class ConnectionEdit;
40
42{
43public:
47
48 class EndPoint {
49 public:
50 enum Type { Source, Target };
51 explicit EndPoint(Connection *_con = nullptr, Type _type = Source) : con(_con), type(_type) {}
52 bool isNull() const { return con == nullptr; }
53 bool operator == (const EndPoint &other) const { return con == other.con && type == other.type; }
54 bool operator != (const EndPoint &other) const { return !operator == (other); }
57 };
59};
60
62{
63public:
66 virtual ~Connection() = default;
67
69 {
70 return (type == EndPoint::Source ? m_source : m_target);
71 }
72
74 {
76 }
77
82
83 bool isVisible() const;
84 virtual void updateVisibility();
85 void setVisible(bool b);
86
87 virtual QRegion region() const;
88 bool contains(const QPoint &pos) const;
89 virtual void paint(QPainter *p) const;
90
91 void update(bool update_widgets = true) const;
92 void checkWidgets();
93
96 void setLabel(EndPoint::Type type, const QString &text);
100
101 ConnectionEdit *edit() const { return m_edit; }
102
103 virtual void inserted() {}
104 virtual void removed() {}
105
106private:
115 bool m_visible;
116
117 void setSource(QObject *source, const QPoint &pos);
118 void setTarget(QObject *target, const QPoint &pos);
119 void updateKneeList();
120 void trimLine();
123 bool ground() const;
124 QRect groundRect() const;
125};
126
128{
130public:
133
134 inline const QPointer<QWidget> &background() const { return m_bg_widget; }
135
136 void setSelected(Connection *con, bool sel);
137 bool selected(const Connection *con) const;
138
139 int connectionCount() const { return m_con_list.size(); }
140 Connection *connection(int i) const { return m_con_list.at(i); }
142
143 virtual void setSource(Connection *con, const QString &obj_name);
144 virtual void setTarget(Connection *con, const QString &obj_name);
145
146 QUndoStack *undoStack() const { return m_undo_stack; }
147
148 void clear();
149
151 {
153 }
154
155signals:
163
164public slots:
165 void selectNone();
166 void selectAll();
167 virtual void deleteSelected();
168 virtual void setBackground(QWidget *background);
169 virtual void updateBackground();
170 virtual void widgetRemoved(QWidget *w);
171 virtual void objectRemoved(QObject *o);
172
173 void updateLines();
175
176protected:
185
187 virtual void modifyConnection(Connection *con);
188
189 virtual QWidget *widgetAt(const QPoint &pos) const;
190 virtual void createContextMenu(QMenu &menu);
192 QRect widgetRect(QWidget *w) const;
193
195 State state() const;
196
197 virtual void endConnection(QWidget *target, const QPoint &pos);
198
199 const ConnectionList &connectionList() const { return m_con_list; }
200 const ConnectionSet &selection() const { return m_sel_con_set; }
204
205 void findObjectsUnderMouse(const QPoint &pos);
206
207private:
208 void startConnection(QWidget *source, const QPoint &pos);
210 void abortConnection();
211
212 void startDrag(const EndPoint &end_point, const QPoint &pos);
213 void continueDrag(const QPoint &pos);
214 void endDrag(const QPoint &pos);
215 void adjustHotSopt(const EndPoint &end_point, const QPoint &pos);
216 Connection *connectionAt(const QPoint &pos) const;
217 EndPoint endPointAt(const QPoint &pos) const;
222
223
227
228 Connection *m_tmp_con; // the connection we are currently editing
233
239
240private:
241 friend class Connection;
244 friend class SetEndPointCommand;
245};
246
248{
249public:
252
253 bool mergeWith(const QUndoCommand *) override { return false; }
254
255 ConnectionEdit *edit() const { return m_edit; }
256
257private:
259};
260
262{
263public:
265 void redo() override;
266 void undo() override;
267private:
269};
270
280
281} // namespace qdesigner_internal
282
283QT_END_NAMESPACE
284
285#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:421
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