~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/designer/src/lib/sdk/abstractwidgetdatabase.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

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