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