|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 // |
|
43 // W A R N I N G |
|
44 // ------------- |
|
45 // |
|
46 // This file is not part of the Qt API. It exists for the convenience |
|
47 // of Qt Designer. This header |
|
48 // file may change from version to version without notice, or even be removed. |
|
49 // |
|
50 // We mean it. |
|
51 // |
|
52 |
|
53 #ifndef _SIGNALSLOTDIALOG_H |
|
54 #define _SIGNALSLOTDIALOG_H |
|
55 |
|
56 #include "shared_global_p.h" |
|
57 #include <QtCore/QStringList> |
|
58 #include <QtGui/QDialog> |
|
59 #include <QtGui/QStandardItemModel> |
|
60 |
|
61 QT_BEGIN_NAMESPACE |
|
62 |
|
63 class QDesignerFormEditorInterface; |
|
64 class QDesignerFormWindowInterface; |
|
65 class QDesignerDialogGuiInterface; |
|
66 class QDesignerMemberSheet; |
|
67 class QListView; |
|
68 class QToolButton; |
|
69 class QItemSelection; |
|
70 |
|
71 namespace Ui { |
|
72 class SignalSlotDialogClass; |
|
73 } |
|
74 |
|
75 namespace qdesigner_internal { |
|
76 |
|
77 // Dialog data |
|
78 struct SignalSlotDialogData { |
|
79 void clear(); |
|
80 QStringList m_existingMethods; |
|
81 QStringList m_fakeMethods; |
|
82 }; |
|
83 |
|
84 // Internal helper class: A model for signatures that allows for verifying duplicates |
|
85 // (checking signals versus slots and vice versa). |
|
86 class SignatureModel : public QStandardItemModel { |
|
87 Q_OBJECT |
|
88 |
|
89 public: |
|
90 SignatureModel(QObject *parent = 0); |
|
91 virtual bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); |
|
92 |
|
93 signals: |
|
94 void checkSignature(const QString &signature, bool *ok); |
|
95 }; |
|
96 |
|
97 // Internal helper class: Panel for editing method signatures. List view with validator, |
|
98 // add and remove button |
|
99 class SignaturePanel : public QObject { |
|
100 Q_OBJECT |
|
101 |
|
102 public: |
|
103 SignaturePanel(QObject *parent, QListView *listView, QToolButton *addButton, QToolButton *removeButton, const QString &newPrefix); |
|
104 |
|
105 QStringList fakeMethods() const; |
|
106 void setData(const SignalSlotDialogData &d); |
|
107 int count(const QString &signature) const; |
|
108 |
|
109 signals: |
|
110 void checkSignature(const QString &signature, bool *ok); |
|
111 |
|
112 private slots: |
|
113 void slotAdd(); |
|
114 void slotRemove(); |
|
115 void slotSelectionChanged(const QItemSelection &, const QItemSelection &); |
|
116 |
|
117 private: |
|
118 void closeEditor(); |
|
119 |
|
120 const QString m_newPrefix; |
|
121 SignatureModel *m_model; |
|
122 QListView *m_listView; |
|
123 QToolButton *m_removeButton; |
|
124 }; |
|
125 |
|
126 // Dialog for editing signals and slots. |
|
127 // Provides static convenience function |
|
128 // to modify fake signals and slots. They are |
|
129 // handled in 2 ways: |
|
130 // 1) For the MainContainer: Fake signals and slots are stored |
|
131 // in the meta database (per-instance) |
|
132 // 2) For promoted widgets: Fake signals and slots are stored |
|
133 // in the widget database (per-class) |
|
134 // Arguably, we could require the MainContainer to be promoted for that, too, |
|
135 // but that would require entering a header. |
|
136 |
|
137 class QDESIGNER_SHARED_EXPORT SignalSlotDialog : public QDialog { |
|
138 Q_OBJECT |
|
139 |
|
140 public: |
|
141 enum FocusMode { FocusSlots, FocusSignals }; |
|
142 |
|
143 explicit SignalSlotDialog(QDesignerDialogGuiInterface *dialogGui, QWidget *parent = 0, FocusMode m = FocusSlots); |
|
144 virtual ~SignalSlotDialog(); |
|
145 |
|
146 DialogCode showDialog(SignalSlotDialogData &slotData, SignalSlotDialogData &signalData); |
|
147 |
|
148 // Edit fake methods stored in MetaDataBase (per instance, used for main containers) |
|
149 static bool editMetaDataBase(QDesignerFormWindowInterface *fw, QObject *object, QWidget *parent = 0, FocusMode m = FocusSlots); |
|
150 |
|
151 // Edit fake methods of a promoted class stored in WidgetDataBase (synthesizes a widget to obtain existing members). |
|
152 static bool editPromotedClass(QDesignerFormEditorInterface *core, const QString &promotedClassName, QWidget *parent = 0, FocusMode m = FocusSlots); |
|
153 // Edit fake methods of a promoted class stored in WidgetDataBase on a base class instance. |
|
154 static bool editPromotedClass(QDesignerFormEditorInterface *core, QObject *baseObject, QWidget *parent = 0, FocusMode m = FocusSlots); |
|
155 |
|
156 private slots: |
|
157 void slotCheckSignature(const QString &signature, bool *ok); |
|
158 |
|
159 private: |
|
160 // Edit fake methods of a promoted class stored in WidgetDataBase using an instance of the base class. |
|
161 static bool editPromotedClass(QDesignerFormEditorInterface *core, const QString &promotedClassName, QObject *baseObject, QWidget *parent, FocusMode m); |
|
162 |
|
163 const FocusMode m_focusMode; |
|
164 Ui::SignalSlotDialogClass *m_ui; |
|
165 QDesignerDialogGuiInterface *m_dialogGui; |
|
166 SignaturePanel *m_slotPanel; |
|
167 SignaturePanel *m_signalPanel; |
|
168 }; |
|
169 } |
|
170 |
|
171 QT_END_NAMESPACE |
|
172 |
|
173 #endif |