0
|
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 tools applications 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 |
#include "widgetinfo.h"
|
|
43 |
|
|
44 |
#include <QMetaEnum>
|
|
45 |
#include <QTextBrowser>
|
|
46 |
#include <QToolBar>
|
|
47 |
#include <QPushButton>
|
|
48 |
#include <QLineEdit>
|
|
49 |
#include <QComboBox>
|
|
50 |
#include <QDial>
|
|
51 |
#include <QSlider>
|
|
52 |
#include <QLCDNumber>
|
|
53 |
#include <QProgressBar>
|
|
54 |
#include <QLabel>
|
|
55 |
#include <QToolBox>
|
|
56 |
#include <QMainWindow>
|
|
57 |
#include <QToolButton>
|
|
58 |
#include <QCheckBox>
|
|
59 |
#include <QRadioButton>
|
|
60 |
#include <QSpinBox>
|
|
61 |
#include <QActionGroup>
|
|
62 |
#include <QSplitter>
|
|
63 |
#include <Q3Frame>
|
|
64 |
#include <QTabWidget>
|
|
65 |
#include <Q3DateEdit>
|
|
66 |
#include <Q3TimeEdit>
|
|
67 |
#include <Q3DateTimeEdit>
|
|
68 |
#include <Q3ListBox>
|
|
69 |
#include <Q3ListView>
|
|
70 |
#include <Q3TextEdit>
|
|
71 |
#include <Q3WidgetStack>
|
|
72 |
#include <Q3Wizard>
|
|
73 |
#include <Q3TextView>
|
|
74 |
#include <Q3MainWindow>
|
|
75 |
#include <Q3GroupBox>
|
|
76 |
#include <Q3ButtonGroup>
|
|
77 |
#include <Q3IconView>
|
|
78 |
#include <Q3ProgressBar>
|
|
79 |
|
|
80 |
QT_BEGIN_NAMESPACE
|
|
81 |
|
|
82 |
WidgetInfo::WidgetInfo()
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
const QMetaObject *WidgetInfo::metaObject(const QString &widgetName)
|
|
87 |
{
|
|
88 |
if (widgetName == QLatin1String("QObject"))
|
|
89 |
return &QObject::staticMetaObject;
|
|
90 |
else if (widgetName == QLatin1String("QToolBar"))
|
|
91 |
return &QToolBar::staticMetaObject;
|
|
92 |
else if (widgetName == QLatin1String("Q3ToolBar"))
|
|
93 |
return &Q3ToolBar::staticMetaObject;
|
|
94 |
else if (widgetName == QLatin1String("QPushButton"))
|
|
95 |
return &QPushButton::staticMetaObject;
|
|
96 |
else if (widgetName == QLatin1String("QToolButton"))
|
|
97 |
return &QToolButton::staticMetaObject;
|
|
98 |
else if (widgetName == QLatin1String("QCheckBox"))
|
|
99 |
return &QCheckBox::staticMetaObject;
|
|
100 |
else if (widgetName == QLatin1String("QRadioButton"))
|
|
101 |
return &QRadioButton::staticMetaObject;
|
|
102 |
else if (widgetName == QLatin1String("QGroupBox")
|
|
103 |
|| widgetName == QLatin1String("Q3GroupBox"))
|
|
104 |
return &Q3GroupBox::staticMetaObject;
|
|
105 |
else if (widgetName == QLatin1String("QButtonGroup")
|
|
106 |
|| widgetName == QLatin1String("Q3ButtonGroup"))
|
|
107 |
return &Q3ButtonGroup::staticMetaObject;
|
|
108 |
else if (widgetName == QLatin1String("QDateEdit"))
|
|
109 |
return &Q3DateEdit::staticMetaObject;
|
|
110 |
else if (widgetName == QLatin1String("QTimeEdit"))
|
|
111 |
return &Q3TimeEdit::staticMetaObject;
|
|
112 |
else if (widgetName == QLatin1String("QDateTimeEdit"))
|
|
113 |
return &Q3DateTimeEdit::staticMetaObject;
|
|
114 |
else if (widgetName == QLatin1String("QListBox")
|
|
115 |
|| widgetName == QLatin1String("Q3ListBox"))
|
|
116 |
return &Q3ListBox::staticMetaObject;
|
|
117 |
else if (widgetName == QLatin1String("QListView") ||
|
|
118 |
widgetName == QLatin1String("Q3ListView"))
|
|
119 |
return &Q3ListView::staticMetaObject;
|
|
120 |
else if (widgetName == QLatin1String("Q3IconView"))
|
|
121 |
return &Q3IconView::staticMetaObject;
|
|
122 |
else if (widgetName == QLatin1String("QLineEdit"))
|
|
123 |
return &QLineEdit::staticMetaObject;
|
|
124 |
else if (widgetName == QLatin1String("QSpinBox"))
|
|
125 |
return &QSpinBox::staticMetaObject;
|
|
126 |
else if (widgetName == QLatin1String("QSplitter"))
|
|
127 |
return &QSplitter::staticMetaObject;
|
|
128 |
else if (widgetName == QLatin1String("QTextEdit") ||
|
|
129 |
widgetName == QLatin1String("Q3TextEdit"))
|
|
130 |
return &Q3TextEdit::staticMetaObject;
|
|
131 |
else if (widgetName == QLatin1String("QLabel"))
|
|
132 |
return &QLabel::staticMetaObject;
|
|
133 |
else if (widgetName == QLatin1String("QTabWidget"))
|
|
134 |
return &QTabWidget::staticMetaObject;
|
|
135 |
else if (widgetName == QLatin1String("QWidgetStack"))
|
|
136 |
return &Q3WidgetStack::staticMetaObject;
|
|
137 |
else if (widgetName == QLatin1String("QComboBox"))
|
|
138 |
return &QComboBox::staticMetaObject;
|
|
139 |
else if (widgetName == QLatin1String("QWidget"))
|
|
140 |
return &QWidget::staticMetaObject;
|
|
141 |
else if (widgetName == QLatin1String("QDialog"))
|
|
142 |
return &QDialog::staticMetaObject;
|
|
143 |
else if (widgetName == QLatin1String("QWizard") ||
|
|
144 |
widgetName == QLatin1String("Q3Wizard"))
|
|
145 |
return &Q3Wizard::staticMetaObject;
|
|
146 |
else if (widgetName == QLatin1String("QLCDNumber"))
|
|
147 |
return &QLCDNumber::staticMetaObject;
|
|
148 |
else if (widgetName == QLatin1String("QProgressBar"))
|
|
149 |
return &QProgressBar::staticMetaObject;
|
|
150 |
else if (widgetName == QLatin1String("Q3ProgressBar"))
|
|
151 |
return &Q3ProgressBar::staticMetaObject;
|
|
152 |
else if (widgetName == QLatin1String("QTextView")
|
|
153 |
|| widgetName == QLatin1String("Q3TextView"))
|
|
154 |
return &Q3TextView::staticMetaObject;
|
|
155 |
else if (widgetName == QLatin1String("QTextBrowser"))
|
|
156 |
return &QTextBrowser::staticMetaObject;
|
|
157 |
else if (widgetName == QLatin1String("QDial"))
|
|
158 |
return &QDial::staticMetaObject;
|
|
159 |
else if (widgetName == QLatin1String("QSlider"))
|
|
160 |
return &QSlider::staticMetaObject;
|
|
161 |
else if (widgetName == QLatin1String("QScrollBar"))
|
|
162 |
return &QScrollBar::staticMetaObject;
|
|
163 |
else if (widgetName == QLatin1String("QFrame"))
|
|
164 |
return &QFrame::staticMetaObject;
|
|
165 |
else if (widgetName == QLatin1String("Q3Frame"))
|
|
166 |
return &Q3Frame::staticMetaObject;
|
|
167 |
else if (widgetName == QLatin1String("QMainWindow"))
|
|
168 |
return &QMainWindow::staticMetaObject;
|
|
169 |
else if (widgetName == QLatin1String("Q3MainWindow"))
|
|
170 |
return &Q3MainWindow::staticMetaObject;
|
|
171 |
else if (widgetName == QLatin1String("QToolBox"))
|
|
172 |
return &QToolBox::staticMetaObject;
|
|
173 |
else if (widgetName == QLatin1String("Line"))
|
|
174 |
return &QFrame::staticMetaObject;
|
|
175 |
else if (widgetName == QLatin1String("TextLabel"))
|
|
176 |
return &QLabel::staticMetaObject;
|
|
177 |
else if (widgetName == QLatin1String("PixmapLabel"))
|
|
178 |
return &QLabel::staticMetaObject;
|
|
179 |
else if (widgetName == QLatin1String("QActionGroup"))
|
|
180 |
return &QActionGroup::staticMetaObject;
|
|
181 |
else if (widgetName == QLatin1String("QAction"))
|
|
182 |
return &QAction::staticMetaObject;
|
|
183 |
|
|
184 |
return 0;
|
|
185 |
}
|
|
186 |
|
|
187 |
bool WidgetInfo::isValidProperty(const QString &className, const QString &name)
|
|
188 |
{
|
|
189 |
const QMetaObject *meta = metaObject(className);
|
|
190 |
if (!meta)
|
|
191 |
return true;
|
|
192 |
|
|
193 |
return meta->indexOfProperty(name.toLatin1()) != -1;
|
|
194 |
}
|
|
195 |
|
|
196 |
bool WidgetInfo::isValidSignal(const QString &className, const QString &name)
|
|
197 |
{
|
|
198 |
const QMetaObject *meta = metaObject(className);
|
|
199 |
if (!meta)
|
|
200 |
return true;
|
|
201 |
|
|
202 |
return meta->indexOfSignal(name.toLatin1()) != -1;
|
|
203 |
}
|
|
204 |
|
|
205 |
bool WidgetInfo::isValidSlot(const QString &className, const QString &name)
|
|
206 |
{
|
|
207 |
const QMetaObject *meta = metaObject(className);
|
|
208 |
if (!meta)
|
|
209 |
return true;
|
|
210 |
|
|
211 |
return meta->indexOfSlot(name.toLatin1()) != -1;
|
|
212 |
}
|
|
213 |
|
|
214 |
bool WidgetInfo::isValidEnumerator(const QString &className, const QString &name)
|
|
215 |
{
|
|
216 |
const QMetaObject *meta = metaObject(className);
|
|
217 |
if (!meta)
|
|
218 |
return true;
|
|
219 |
|
|
220 |
return checkEnumerator(meta, name);
|
|
221 |
}
|
|
222 |
|
|
223 |
bool WidgetInfo::checkEnumerator(const QMetaObject *meta, const QString &name)
|
|
224 |
{
|
|
225 |
for (int i=0; i<meta->enumeratorCount(); ++i)
|
|
226 |
if (checkEnumerator(meta->enumerator(i), name))
|
|
227 |
return true;
|
|
228 |
return false;
|
|
229 |
}
|
|
230 |
|
|
231 |
bool WidgetInfo::checkEnumerator(const QMetaEnum &metaEnum, const QString &name)
|
|
232 |
{
|
|
233 |
return metaEnum.keyToValue(name.toLatin1()) != -1;
|
|
234 |
}
|
|
235 |
|
|
236 |
|
|
237 |
QString WidgetInfo::resolveEnumerator(const QString &className, const QString &name)
|
|
238 |
{
|
|
239 |
const QMetaObject *meta = metaObject(className);
|
|
240 |
if (!meta) {
|
|
241 |
QString e = resolveEnumerator(QLatin1String("QObject"), QLatin1String("Qt::") + name);
|
|
242 |
if (e.size())
|
|
243 |
return e;
|
|
244 |
|
|
245 |
return name;
|
|
246 |
}
|
|
247 |
|
|
248 |
return resolveEnumerator(meta, name);
|
|
249 |
}
|
|
250 |
|
|
251 |
QString WidgetInfo::resolveEnumerator(const QMetaObject *meta, const QString &name)
|
|
252 |
{
|
|
253 |
for (int i=meta->enumeratorCount() - 1; i>=0; --i) {
|
|
254 |
QString e = resolveEnumerator(meta->enumerator(i), name);
|
|
255 |
if (e.size())
|
|
256 |
return e;
|
|
257 |
}
|
|
258 |
|
|
259 |
if (meta != &staticQtMetaObject)
|
|
260 |
return resolveEnumerator(&staticQtMetaObject, name);
|
|
261 |
|
|
262 |
return QString();
|
|
263 |
}
|
|
264 |
|
|
265 |
QString WidgetInfo::resolveEnumerator(const QMetaEnum &metaEnum, const QString &name)
|
|
266 |
{
|
|
267 |
QString scope = QLatin1String(metaEnum.scope());
|
|
268 |
|
|
269 |
QString enumerator = name;
|
|
270 |
int i = enumerator.indexOf(QLatin1String("::"));
|
|
271 |
if (i != -1) {
|
|
272 |
if (scope != enumerator.left(i))
|
|
273 |
return QString();
|
|
274 |
enumerator = enumerator.mid(i + 2);
|
|
275 |
}
|
|
276 |
QByteArray key = enumerator.toLatin1();
|
|
277 |
for (int idx = 0; idx < metaEnum.keyCount(); ++idx) {
|
|
278 |
if (metaEnum.key(idx) == key)
|
|
279 |
return scope + QLatin1String("::") + enumerator;
|
|
280 |
}
|
|
281 |
|
|
282 |
return QString();
|
|
283 |
}
|
|
284 |
|
|
285 |
QT_END_NAMESPACE
|