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
abstractwidgetdatabase.cpp
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
5#include <QtCore/qdebug.h>
6#include <qalgorithms.h>
7
9
11
12/*!
13 \class QDesignerWidgetDataBaseInterface
14 \brief The QDesignerWidgetDataBaseInterface class provides an interface that is used to
15 access and modify \QD's widget database.
16 \inmodule QtDesigner
17 \internal
18*/
19
20/*!
21 Constructs an interface to the widget database with the given \a parent.
22*/
23QDesignerWidgetDataBaseInterface::QDesignerWidgetDataBaseInterface(QObject *parent)
24 : QObject(parent)
25{
26}
27
28/*!
29 Destroys the interface to the widget database.
30*/
31QDesignerWidgetDataBaseInterface::~QDesignerWidgetDataBaseInterface()
32{
33 qDeleteAll(m_items);
34}
35
36/*!
37
38*/
39int QDesignerWidgetDataBaseInterface::count() const
40{
41 return m_items.size();
42}
43
44/*!
45*/
46QDesignerWidgetDataBaseItemInterface *QDesignerWidgetDataBaseInterface::item(int index) const
47{
48 return index != -1 ? m_items.at(index) : 0;
49}
50
51/*!
52*/
53int QDesignerWidgetDataBaseInterface::indexOf(QDesignerWidgetDataBaseItemInterface *item) const
54{
55 return m_items.indexOf(item);
56}
57
58/*!
59*/
60void QDesignerWidgetDataBaseInterface::insert(int index, QDesignerWidgetDataBaseItemInterface *item)
61{
62 if (debugAbstractWidgetDataBase)
63 qDebug() << "insert at " << index << ' ' << item->name() << " derived from " << item->extends();
64
65 m_items.insert(index, item);
66}
67
68/*!
69*/
70void QDesignerWidgetDataBaseInterface::append(QDesignerWidgetDataBaseItemInterface *item)
71{
72 if (debugAbstractWidgetDataBase)
73 qDebug() << "append " << item->name() << " derived from " << item->extends();
74 m_items.append(item);
75}
76
77/*!
78*/
79QDesignerFormEditorInterface *QDesignerWidgetDataBaseInterface::core() const
80{
81 return nullptr;
82}
83
84/*!
85*/
86int QDesignerWidgetDataBaseInterface::indexOfClassName(const QString &name, bool) const
87{
88 const int itemCount = count();
89 for (int i=0; i<itemCount; ++i) {
90 const QDesignerWidgetDataBaseItemInterface *entry = item(i);
91 if (entry->name() == name)
92 return i;
93 }
94
95 return -1;
96}
97
98/*!
99*/
100int QDesignerWidgetDataBaseInterface::indexOfObject(QObject *object, bool) const
101{
102 if (!object)
103 return -1;
104
105 const QString className = QString::fromUtf8(object->metaObject()->className());
106 return indexOfClassName(className);
107}
108
109/*!
110*/
111bool QDesignerWidgetDataBaseInterface::isContainer(QObject *object, bool resolveName) const
112{
113 if (const QDesignerWidgetDataBaseItemInterface *i = item(indexOfObject(object, resolveName)))
114 return i->isContainer();
115 return false;
116}
117
118/*!
119*/
120bool QDesignerWidgetDataBaseInterface::isCustom(QObject *object, bool resolveName) const
121{
122 if (const QDesignerWidgetDataBaseItemInterface *i = item(indexOfObject(object, resolveName)))
123 return i->isCustom();
124 return false;
125}
126
127/*!
128 \fn void QDesignerWidgetDataBaseInterface::changed()
129
130 This signal is emitted ...
131*/
132
133
134// Doc: No implementation - an abstract class
135
136/*!
137 \class QDesignerWidgetDataBaseItemInterface
138 \brief The QDesignerWidgetDataBaseItemInterface class provides an interface that is used to
139 access individual items in \QD's widget database.
140 \inmodule QtDesigner
141 \internal
142
143 This class enables individual items in the widget database to be accessed and modified.
144 Changes to the widget database itself are made through the QDesignerWidgetDataBaseInterface
145 class.
146*/
147
148/*!
149 \fn virtual QDesignerWidgetDataBaseItemInterface::~QDesignerWidgetDataBaseItemInterface()
150
151 Destroys the interface.
152*/
153
154/*!
155 \fn virtual QString QDesignerWidgetDataBaseItemInterface::name() const = 0
156
157 Returns the name of the widget.
158*/
159
160/*!
161 \fn virtual void QDesignerWidgetDataBaseItemInterface::setName(const QString &name) = 0
162*/
163
164/*!
165 \fn virtual QString QDesignerWidgetDataBaseItemInterface::group() const = 0
166
167 Returns the name of the group that the widget belongs to.
168*/
169
170/*!
171 \fn virtual void QDesignerWidgetDataBaseItemInterface::setGroup(const QString &group) = 0
172*/
173
174/*!
175 \fn virtual QString QDesignerWidgetDataBaseItemInterface::toolTip() const = 0
176
177 Returns the tool tip to be used by the widget.
178*/
179
180/*!
181 \fn virtual void QDesignerWidgetDataBaseItemInterface::setToolTip(const QString &toolTip) = 0
182*/
183
184/*!
185 \fn virtual QString QDesignerWidgetDataBaseItemInterface::whatsThis() const = 0
186
187 Returns the "What's This?" help for the widget.
188*/
189
190/*!
191 \fn virtual void QDesignerWidgetDataBaseItemInterface::setWhatsThis(const QString &whatsThis) = 0
192*/
193
194/*!
195 \fn virtual QString QDesignerWidgetDataBaseItemInterface::includeFile() const = 0
196
197 Returns the name of the include file that the widget needs when being built from source.
198*/
199
200/*!
201 \fn virtual void QDesignerWidgetDataBaseItemInterface::setIncludeFile(const QString &includeFile) = 0
202*/
203
204/*!
205 \fn virtual QIcon QDesignerWidgetDataBaseItemInterface::icon() const = 0
206
207 Returns the icon used to represent the item.
208*/
209
210/*!
211 \fn virtual void QDesignerWidgetDataBaseItemInterface::setIcon(const QIcon &icon) = 0
212*/
213
214/*!
215 \fn virtual bool QDesignerWidgetDataBaseItemInterface::isCompat() const = 0
216
217 Returns true if this type of widget is provided for compatibility purposes (e.g. Qt3Support
218 widgets); otherwise returns false.
219
220 \sa setCompat()
221*/
222
223/*!
224 \fn virtual void QDesignerWidgetDataBaseItemInterface::setCompat(bool compat) = 0
225
226 If \a compat is true, the widget is handled as a compatibility widget; otherwise it is
227 handled normally by \QD.
228
229 \sa isCompat()
230*/
231
232/*!
233 \fn virtual bool QDesignerWidgetDataBaseItemInterface::isContainer() const = 0
234
235 Returns true if this widget is intended to be used to hold other widgets; otherwise returns
236 false.
237
238 \sa setContainer()
239*/
240
241/*!
242 \fn virtual void QDesignerWidgetDataBaseItemInterface::setContainer(bool container) = 0
243
244 If \a container is true, the widget can be used to hold other widgets in \QD; otherwise
245 \QD will refuse to let the user place other widgets inside it.
246
247 \sa isContainer()
248*/
249
250/*!
251 \fn virtual bool QDesignerWidgetDataBaseItemInterface::isCustom() const = 0
252
253 Returns true if the widget is a custom widget; otherwise return false if it is a standard
254 Qt widget.
255
256 \sa setCustom()
257*/
258
259/*!
260 \fn virtual void QDesignerWidgetDataBaseItemInterface::setCustom(bool custom) = 0
261
262 If \a custom is true, the widget is handled specially by \QD; otherwise it is handled as
263 a standard Qt widget.
264
265 \sa isCustom()
266*/
267
268/*!
269 \fn virtual QString QDesignerWidgetDataBaseItemInterface::pluginPath() const = 0
270
271 Returns the path to use for the widget plugin.
272*/
273
274/*!
275 \fn virtual void QDesignerWidgetDataBaseItemInterface::setPluginPath(const QString &path) = 0
276*/
277
278/*!
279 \fn virtual bool QDesignerWidgetDataBaseItemInterface::isPromoted() const = 0
280
281 Returns true if the widget is promoted; otherwise returns false.
282
283 Promoted widgets are those that represent custom widgets, but which are represented in
284 \QD by either standard Qt widgets or readily-available custom widgets.
285
286 \sa setPromoted()
287*/
288
289/*!
290 \fn virtual void QDesignerWidgetDataBaseItemInterface::setPromoted(bool promoted) = 0
291
292 If \a promoted is true, the widget is handled as a promoted widget by \QD and will use
293 a placeholder widget to represent it; otherwise it is handled as a standard widget.
294
295 \sa isPromoted()
296*/
297
298/*!
299 \fn virtual QString QDesignerWidgetDataBaseItemInterface::extends() const = 0
300
301 Returns the name of the widget that the item extends.
302*/
303
304/*!
305 \fn virtual void QDesignerWidgetDataBaseItemInterface::setExtends(const QString &s) = 0
306*/
307
308/*!
309 \fn virtual void QDesignerWidgetDataBaseItemInterface::setDefaultPropertyValues(const QList<QVariant> &list) = 0
310
311 Sets the default property values for the widget to the given \a list.
312*/
313
314/*!
315 \fn virtual QList<QVariant> QDesignerWidgetDataBaseItemInterface::defaultPropertyValues() const = 0
316
317 Returns a list of default values to be used as properties for the item.
318*/
319
320QT_END_NAMESPACE
@ debugAbstractWidgetDataBase
Combined button and popup list for selecting options.