1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef SIGNALSLOTEDITOR_P_H |
30 | #define SIGNALSLOTEDITOR_P_H |
31 | |
32 | // |
33 | // W A R N I N G |
34 | // ------------- |
35 | // |
36 | // This file is not part of the Qt API. It exists purely as an |
37 | // implementation detail. This header file may change from version to |
38 | // version without notice, or even be removed. |
39 | // |
40 | // We mean it. |
41 | // |
42 | |
43 | #include <QtCore/qstring.h> |
44 | #include <QtCore/qstringlist.h> |
45 | #include <QtCore/qlist.h> |
46 | #include <QtCore/qpointer.h> |
47 | #include <QtCore/qabstractitemmodel.h> |
48 | |
49 | #include <connectionedit_p.h> |
50 | |
51 | QT_BEGIN_NAMESPACE |
52 | |
53 | class QDesignerFormWindowInterface; |
54 | class QDesignerFormEditorInterface; |
55 | class DomConnection; |
56 | |
57 | namespace qdesigner_internal { |
58 | |
59 | class SignalSlotEditor; |
60 | |
61 | class SignalSlotConnection : public Connection |
62 | { |
63 | public: |
64 | explicit SignalSlotConnection(ConnectionEdit *edit, QWidget *source = nullptr, QWidget *target = nullptr); |
65 | |
66 | void setSignal(const QString &signal); |
67 | void setSlot(const QString &slot); |
68 | |
69 | QString sender() const; |
70 | QString receiver() const; |
71 | inline QString signal() const { return m_signal; } |
72 | inline QString slot() const { return m_slot; } |
73 | |
74 | DomConnection *toUi() const; |
75 | |
76 | void updateVisibility() override; |
77 | |
78 | enum State { Valid, ObjectDeleted, InvalidMethod, NotAncestor }; |
79 | State isValid(const QWidget *background) const; |
80 | |
81 | // format for messages, etc. |
82 | QString toString() const; |
83 | |
84 | private: |
85 | QString m_signal, m_slot; |
86 | }; |
87 | |
88 | class ConnectionModel : public QAbstractItemModel |
89 | { |
90 | Q_OBJECT |
91 | public: |
92 | explicit ConnectionModel(QObject *parent = nullptr); |
93 | void setEditor(SignalSlotEditor *editor = nullptr); |
94 | |
95 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; |
96 | QModelIndex parent(const QModelIndex &child) const override; |
97 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
98 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; |
99 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
100 | bool setData(const QModelIndex &index, const QVariant &data, int role = Qt::DisplayRole) override; |
101 | Qt::ItemFlags flags(const QModelIndex &index) const override; |
102 | QVariant (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
103 | |
104 | QModelIndex connectionToIndex(Connection *con) const; |
105 | Connection *indexToConnection(const QModelIndex &index) const; |
106 | void updateAll(); |
107 | |
108 | const SignalSlotConnection *connectionAt(const QModelIndex &index) const; |
109 | static QString columnText(const SignalSlotConnection *con, int column); |
110 | |
111 | private slots: |
112 | void connectionAdded(Connection *con); |
113 | void connectionRemoved(int idx); |
114 | void aboutToRemoveConnection(Connection *con); |
115 | void aboutToAddConnection(int idx); |
116 | void connectionChanged(Connection *con); |
117 | |
118 | private: |
119 | QPointer<SignalSlotEditor> m_editor; |
120 | }; |
121 | |
122 | } // namespace qdesigner_internal |
123 | |
124 | QT_END_NAMESPACE |
125 | |
126 | #endif // SIGNALSLOTEDITOR_P_H |
127 | |