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 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 |
#include "formbuilderextra_p.h"
|
|
43 |
#include "abstractformbuilder.h"
|
|
44 |
#include "resourcebuilder_p.h"
|
|
45 |
#include "textbuilder_p.h"
|
|
46 |
#include "ui4_p.h"
|
|
47 |
|
|
48 |
#include <QtGui/QLabel>
|
|
49 |
#include <QtGui/QBoxLayout>
|
|
50 |
#include <QtGui/QGridLayout>
|
|
51 |
|
|
52 |
#include <QtCore/QVariant>
|
|
53 |
#include <QtCore/qdebug.h>
|
|
54 |
#include <QtCore/QTextStream>
|
|
55 |
#include <QtCore/QStringList>
|
|
56 |
#include <QtCore/QCoreApplication>
|
|
57 |
|
|
58 |
QT_BEGIN_NAMESPACE
|
|
59 |
|
|
60 |
#ifdef QFORMINTERNAL_NAMESPACE
|
|
61 |
namespace QFormInternal {
|
|
62 |
#endif
|
|
63 |
|
|
64 |
void uiLibWarning(const QString &message) {
|
|
65 |
qWarning("Designer: %s", qPrintable(message));
|
|
66 |
}
|
|
67 |
|
|
68 |
QFormBuilderExtra::QFormBuilderExtra() :
|
|
69 |
m_layoutWidget(false),
|
|
70 |
m_resourceBuilder(0),
|
|
71 |
m_textBuilder(0)
|
|
72 |
{
|
|
73 |
}
|
|
74 |
|
|
75 |
QFormBuilderExtra::~QFormBuilderExtra()
|
|
76 |
{
|
|
77 |
clearResourceBuilder();
|
|
78 |
clearTextBuilder();
|
|
79 |
}
|
|
80 |
|
|
81 |
void QFormBuilderExtra::clear()
|
|
82 |
{
|
|
83 |
m_buddies.clear();
|
|
84 |
m_parentWidget = 0;
|
|
85 |
m_parentWidgetIsSet = false;
|
|
86 |
#ifndef QT_FORMBUILDER_NO_SCRIPT
|
|
87 |
m_FormScriptRunner.clearErrors();
|
|
88 |
m_customWidgetScriptHash.clear();
|
|
89 |
#endif
|
|
90 |
m_buttonGroups.clear();
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
bool QFormBuilderExtra::applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value)
|
|
95 |
{
|
|
96 |
// Store buddies and apply them later on as the widgets might not exist yet.
|
|
97 |
QLabel *label = qobject_cast<QLabel*>(o);
|
|
98 |
if (!label || propertyName != QFormBuilderStrings::instance().buddyProperty)
|
|
99 |
return false;
|
|
100 |
|
|
101 |
m_buddies.insert(label, value.toString());
|
|
102 |
return true;
|
|
103 |
}
|
|
104 |
|
|
105 |
void QFormBuilderExtra::applyInternalProperties() const
|
|
106 |
{
|
|
107 |
if (m_buddies.empty())
|
|
108 |
return;
|
|
109 |
|
|
110 |
const BuddyHash::const_iterator cend = m_buddies.constEnd();
|
|
111 |
for (BuddyHash::const_iterator it = m_buddies.constBegin(); it != cend; ++it )
|
|
112 |
applyBuddy(it.value(), BuddyApplyAll, it.key());
|
|
113 |
}
|
|
114 |
|
|
115 |
bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label)
|
|
116 |
{
|
|
117 |
if (buddyName.isEmpty()) {
|
|
118 |
label->setBuddy(0);
|
|
119 |
return false;
|
|
120 |
}
|
|
121 |
|
|
122 |
const QWidgetList widgets = qFindChildren<QWidget*>(label->topLevelWidget(), buddyName);
|
|
123 |
if (widgets.empty()) {
|
|
124 |
label->setBuddy(0);
|
|
125 |
return false;
|
|
126 |
}
|
|
127 |
|
|
128 |
const QWidgetList::const_iterator cend = widgets.constEnd();
|
|
129 |
for ( QWidgetList::const_iterator it = widgets.constBegin(); it != cend; ++it) {
|
|
130 |
if (applyMode == BuddyApplyAll || !(*it)->isHidden()) {
|
|
131 |
label->setBuddy(*it);
|
|
132 |
return true;
|
|
133 |
}
|
|
134 |
}
|
|
135 |
|
|
136 |
label->setBuddy(0);
|
|
137 |
return false;
|
|
138 |
}
|
|
139 |
|
|
140 |
const QPointer<QWidget> &QFormBuilderExtra::parentWidget() const
|
|
141 |
{
|
|
142 |
return m_parentWidget;
|
|
143 |
}
|
|
144 |
|
|
145 |
bool QFormBuilderExtra::parentWidgetIsSet() const
|
|
146 |
{
|
|
147 |
return m_parentWidgetIsSet;
|
|
148 |
}
|
|
149 |
|
|
150 |
void QFormBuilderExtra::setParentWidget(const QPointer<QWidget> &w)
|
|
151 |
{
|
|
152 |
// Parent widget requires special handling of the geometry property.
|
|
153 |
m_parentWidget = w;
|
|
154 |
m_parentWidgetIsSet = true;
|
|
155 |
}
|
|
156 |
|
|
157 |
#ifndef QT_FORMBUILDER_NO_SCRIPT
|
|
158 |
QFormScriptRunner &QFormBuilderExtra::formScriptRunner()
|
|
159 |
{
|
|
160 |
return m_FormScriptRunner;
|
|
161 |
}
|
|
162 |
|
|
163 |
void QFormBuilderExtra::storeCustomWidgetScript(const QString &className, const QString &script)
|
|
164 |
{
|
|
165 |
m_customWidgetScriptHash.insert(className, script);
|
|
166 |
}
|
|
167 |
|
|
168 |
QString QFormBuilderExtra::customWidgetScript(const QString &className) const
|
|
169 |
{
|
|
170 |
const CustomWidgetScriptHash::const_iterator it = m_customWidgetScriptHash.constFind(className);
|
|
171 |
if ( it == m_customWidgetScriptHash.constEnd())
|
|
172 |
return QString();
|
|
173 |
return it.value();
|
|
174 |
}
|
|
175 |
|
|
176 |
#endif
|
|
177 |
|
|
178 |
void QFormBuilderExtra::storeCustomWidgetBaseClass(const QString &className, const QString &baseClassName)
|
|
179 |
{
|
|
180 |
m_customWidgetBaseClassHash.insert(className, baseClassName);
|
|
181 |
}
|
|
182 |
|
|
183 |
QString QFormBuilderExtra::customWidgetBaseClass(const QString &className) const
|
|
184 |
{
|
|
185 |
const QHash<QString, QString>::const_iterator it = m_customWidgetBaseClassHash.constFind(className);
|
|
186 |
if (it == m_customWidgetBaseClassHash.constEnd())
|
|
187 |
return QString();
|
|
188 |
return it.value();
|
|
189 |
}
|
|
190 |
|
|
191 |
void QFormBuilderExtra::storeCustomWidgetAddPageMethod(const QString &className, const QString &ct)
|
|
192 |
{
|
|
193 |
m_customWidgetAddPageMethodHash.insert(className, ct);
|
|
194 |
}
|
|
195 |
|
|
196 |
QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) const
|
|
197 |
{
|
|
198 |
const QHash<QString, QString>::const_iterator it = m_customWidgetAddPageMethodHash.constFind(className);
|
|
199 |
if (it == m_customWidgetAddPageMethodHash.constEnd())
|
|
200 |
return QString();
|
|
201 |
return it.value();
|
|
202 |
}
|
|
203 |
|
|
204 |
namespace {
|
|
205 |
typedef QHash<const QAbstractFormBuilder *, QFormBuilderExtra *> FormBuilderPrivateHash;
|
|
206 |
}
|
|
207 |
|
|
208 |
Q_GLOBAL_STATIC(FormBuilderPrivateHash, g_FormBuilderPrivateHash)
|
|
209 |
|
|
210 |
QFormBuilderExtra *QFormBuilderExtra::instance(const QAbstractFormBuilder *afb)
|
|
211 |
{
|
|
212 |
FormBuilderPrivateHash &fbHash = *g_FormBuilderPrivateHash();
|
|
213 |
|
|
214 |
FormBuilderPrivateHash::iterator it = fbHash.find(afb);
|
|
215 |
if (it == fbHash.end())
|
|
216 |
it = fbHash.insert(afb, new QFormBuilderExtra);
|
|
217 |
return it.value();
|
|
218 |
}
|
|
219 |
|
|
220 |
void QFormBuilderExtra::removeInstance(const QAbstractFormBuilder *afb)
|
|
221 |
{
|
|
222 |
FormBuilderPrivateHash &fbHash = *g_FormBuilderPrivateHash();
|
|
223 |
|
|
224 |
FormBuilderPrivateHash::iterator it = fbHash.find(afb);
|
|
225 |
if (it != fbHash.end()) {
|
|
226 |
delete it.value();
|
|
227 |
fbHash.erase(it);
|
|
228 |
}
|
|
229 |
}
|
|
230 |
|
|
231 |
void QFormBuilderExtra::setProcessingLayoutWidget(bool processing)
|
|
232 |
{
|
|
233 |
m_layoutWidget = processing;
|
|
234 |
}
|
|
235 |
|
|
236 |
bool QFormBuilderExtra::processingLayoutWidget() const
|
|
237 |
{
|
|
238 |
return m_layoutWidget;
|
|
239 |
}
|
|
240 |
void QFormBuilderExtra::setResourceBuilder(QResourceBuilder *builder)
|
|
241 |
{
|
|
242 |
if (m_resourceBuilder == builder)
|
|
243 |
return;
|
|
244 |
clearResourceBuilder();
|
|
245 |
m_resourceBuilder = builder;
|
|
246 |
}
|
|
247 |
|
|
248 |
QResourceBuilder *QFormBuilderExtra::resourceBuilder() const
|
|
249 |
{
|
|
250 |
return m_resourceBuilder;
|
|
251 |
}
|
|
252 |
|
|
253 |
void QFormBuilderExtra::clearResourceBuilder()
|
|
254 |
{
|
|
255 |
if (m_resourceBuilder) {
|
|
256 |
delete m_resourceBuilder;
|
|
257 |
m_resourceBuilder = 0;
|
|
258 |
}
|
|
259 |
}
|
|
260 |
|
|
261 |
void QFormBuilderExtra::setTextBuilder(QTextBuilder *builder)
|
|
262 |
{
|
|
263 |
if (m_textBuilder == builder)
|
|
264 |
return;
|
|
265 |
clearTextBuilder();
|
|
266 |
m_textBuilder = builder;
|
|
267 |
}
|
|
268 |
|
|
269 |
QTextBuilder *QFormBuilderExtra::textBuilder() const
|
|
270 |
{
|
|
271 |
return m_textBuilder;
|
|
272 |
}
|
|
273 |
|
|
274 |
void QFormBuilderExtra::clearTextBuilder()
|
|
275 |
{
|
|
276 |
if (m_textBuilder) {
|
|
277 |
delete m_textBuilder;
|
|
278 |
m_textBuilder = 0;
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
void QFormBuilderExtra::registerButtonGroups(const DomButtonGroups *domGroups)
|
|
283 |
{
|
|
284 |
typedef QList<DomButtonGroup*> DomButtonGroupList;
|
|
285 |
const DomButtonGroupList domGroupList = domGroups->elementButtonGroup();
|
|
286 |
const DomButtonGroupList::const_iterator cend = domGroupList.constEnd();
|
|
287 |
for (DomButtonGroupList::const_iterator it = domGroupList.constBegin(); it != cend; ++it) {
|
|
288 |
DomButtonGroup *domGroup = *it;
|
|
289 |
m_buttonGroups.insert(domGroup->attributeName(), ButtonGroupEntry(domGroup, 0));
|
|
290 |
}
|
|
291 |
}
|
|
292 |
|
|
293 |
// Utilities for parsing per-cell integer properties that have setters and
|
|
294 |
// getters of the form 'setX(int idx, int value)' and 'x(int index)'
|
|
295 |
// (converting them to comma-separated string lists and back).
|
|
296 |
// Used for layout stretch and grid per-row/column properties.
|
|
297 |
|
|
298 |
// Format a list of cell-properties of one dimension as a ','-separated list
|
|
299 |
template <class Layout>
|
|
300 |
inline QString perCellPropertyToString(const Layout *l, int count, int (Layout::*getter)(int) const)
|
|
301 |
{
|
|
302 |
if (count == 0)
|
|
303 |
return QString();
|
|
304 |
QString rc;
|
|
305 |
{
|
|
306 |
QTextStream str(&rc);
|
|
307 |
for (int i = 0; i < count; i++) {
|
|
308 |
if (i)
|
|
309 |
str << QLatin1Char(',');
|
|
310 |
str << (l->*getter)(i);
|
|
311 |
}
|
|
312 |
}
|
|
313 |
return rc;
|
|
314 |
}
|
|
315 |
|
|
316 |
// Clear the property, set all cells to 0
|
|
317 |
|
|
318 |
template <class Layout>
|
|
319 |
inline void clearPerCellValue(Layout *l, int count, void (Layout::*setter)(int,int), int value = 0)
|
|
320 |
{
|
|
321 |
for (int i = 0; i < count; i++)
|
|
322 |
(l->*setter)(i, value);
|
|
323 |
}
|
|
324 |
|
|
325 |
// Parse and set the property from a comma-separated list
|
|
326 |
|
|
327 |
template <class Layout>
|
|
328 |
inline bool parsePerCellProperty(Layout *l, int count, void (Layout::*setter)(int,int), const QString &s, int defaultValue = 0)
|
|
329 |
{
|
|
330 |
if (s.isEmpty()) {
|
|
331 |
clearPerCellValue(l, count, setter, defaultValue);
|
|
332 |
return true;
|
|
333 |
}
|
|
334 |
const QStringList list = s.split(QLatin1Char(','));
|
|
335 |
if (list.empty()) {
|
|
336 |
clearPerCellValue(l, count, setter, defaultValue);
|
|
337 |
return true;
|
|
338 |
}
|
|
339 |
// Apply all values contained in list
|
|
340 |
const int ac = qMin(count, list.size());
|
|
341 |
bool ok;
|
|
342 |
int i = 0;
|
|
343 |
for ( ; i < ac; i++) {
|
|
344 |
const int value = list.at(i).toInt(&ok);
|
|
345 |
if (!ok || value < 0)
|
|
346 |
return false;
|
|
347 |
(l->*setter)(i, value);
|
|
348 |
}
|
|
349 |
// Clear rest
|
|
350 |
for ( ; i < count; i++)
|
|
351 |
(l->*setter)(i, defaultValue);
|
|
352 |
return true;
|
|
353 |
}
|
|
354 |
|
|
355 |
// Read and write stretch
|
|
356 |
static QString msgInvalidStretch(const QString &objectName, const QString &stretch)
|
|
357 |
{
|
|
358 |
//: Parsing layout stretch values
|
|
359 |
return QCoreApplication::translate("FormBuilder", "Invalid stretch value for '%1': '%2'").arg(objectName, stretch);
|
|
360 |
}
|
|
361 |
|
|
362 |
QString QFormBuilderExtra::boxLayoutStretch(const QBoxLayout *box)
|
|
363 |
{
|
|
364 |
return perCellPropertyToString(box, box->count(), &QBoxLayout::stretch);
|
|
365 |
}
|
|
366 |
|
|
367 |
bool QFormBuilderExtra::setBoxLayoutStretch(const QString &s, QBoxLayout *box)
|
|
368 |
{
|
|
369 |
const bool rc = parsePerCellProperty(box, box->count(), &QBoxLayout::setStretch, s);
|
|
370 |
if (!rc)
|
|
371 |
uiLibWarning(msgInvalidStretch(box->objectName(), s));
|
|
372 |
return rc;
|
|
373 |
}
|
|
374 |
|
|
375 |
void QFormBuilderExtra::clearBoxLayoutStretch(QBoxLayout *box)
|
|
376 |
{
|
|
377 |
clearPerCellValue(box, box->count(), &QBoxLayout::setStretch);
|
|
378 |
}
|
|
379 |
|
|
380 |
QString QFormBuilderExtra::gridLayoutRowStretch(const QGridLayout *grid)
|
|
381 |
{
|
|
382 |
return perCellPropertyToString(grid, grid->rowCount(), &QGridLayout::rowStretch);
|
|
383 |
}
|
|
384 |
|
|
385 |
bool QFormBuilderExtra::setGridLayoutRowStretch(const QString &s, QGridLayout *grid)
|
|
386 |
{
|
|
387 |
const bool rc = parsePerCellProperty(grid, grid->rowCount(), &QGridLayout::setRowStretch, s);
|
|
388 |
if (!rc)
|
|
389 |
uiLibWarning(msgInvalidStretch(grid->objectName(), s));
|
|
390 |
return rc;
|
|
391 |
}
|
|
392 |
|
|
393 |
void QFormBuilderExtra::clearGridLayoutRowStretch(QGridLayout *grid)
|
|
394 |
{
|
|
395 |
clearPerCellValue(grid, grid->rowCount(), &QGridLayout::setRowStretch);
|
|
396 |
}
|
|
397 |
|
|
398 |
QString QFormBuilderExtra::gridLayoutColumnStretch(const QGridLayout *grid)
|
|
399 |
{
|
|
400 |
return perCellPropertyToString(grid, grid->columnCount(), &QGridLayout::columnStretch);
|
|
401 |
}
|
|
402 |
|
|
403 |
bool QFormBuilderExtra::setGridLayoutColumnStretch(const QString &s, QGridLayout *grid)
|
|
404 |
{
|
|
405 |
const bool rc = parsePerCellProperty(grid, grid->columnCount(), &QGridLayout::setColumnStretch, s);
|
|
406 |
if (!rc)
|
|
407 |
uiLibWarning(msgInvalidStretch(grid->objectName(), s));
|
|
408 |
return rc;
|
|
409 |
}
|
|
410 |
|
|
411 |
void QFormBuilderExtra::clearGridLayoutColumnStretch(QGridLayout *grid)
|
|
412 |
{
|
|
413 |
clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnStretch);
|
|
414 |
}
|
|
415 |
|
|
416 |
// Read and write grid layout row/column size limits
|
|
417 |
|
|
418 |
static QString msgInvalidMinimumSize(const QString &objectName, const QString &ms)
|
|
419 |
{
|
|
420 |
//: Parsing grid layout minimum size values
|
|
421 |
return QCoreApplication::translate("FormBuilder", "Invalid minimum size for '%1': '%2'").arg(objectName, ms);
|
|
422 |
}
|
|
423 |
|
|
424 |
QString QFormBuilderExtra::gridLayoutRowMinimumHeight(const QGridLayout *grid)
|
|
425 |
{
|
|
426 |
return perCellPropertyToString(grid, grid->rowCount(), &QGridLayout::rowMinimumHeight);
|
|
427 |
}
|
|
428 |
|
|
429 |
bool QFormBuilderExtra::setGridLayoutRowMinimumHeight(const QString &s, QGridLayout *grid)
|
|
430 |
{
|
|
431 |
const bool rc = parsePerCellProperty(grid, grid->rowCount(), &QGridLayout::setRowMinimumHeight, s);
|
|
432 |
if (!rc)
|
|
433 |
uiLibWarning(msgInvalidMinimumSize(grid->objectName(), s));
|
|
434 |
return rc;
|
|
435 |
}
|
|
436 |
|
|
437 |
void QFormBuilderExtra::clearGridLayoutRowMinimumHeight(QGridLayout *grid)
|
|
438 |
{
|
|
439 |
clearPerCellValue(grid, grid->rowCount(), &QGridLayout::setRowMinimumHeight);
|
|
440 |
}
|
|
441 |
|
|
442 |
QString QFormBuilderExtra::gridLayoutColumnMinimumWidth(const QGridLayout *grid)
|
|
443 |
{
|
|
444 |
return perCellPropertyToString(grid, grid->columnCount(), &QGridLayout::columnMinimumWidth);
|
|
445 |
}
|
|
446 |
|
|
447 |
bool QFormBuilderExtra::setGridLayoutColumnMinimumWidth(const QString &s, QGridLayout *grid)
|
|
448 |
{
|
|
449 |
const bool rc = parsePerCellProperty(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth, s);
|
|
450 |
if (!rc)
|
|
451 |
uiLibWarning(msgInvalidMinimumSize(grid->objectName(), s));
|
|
452 |
return rc;
|
|
453 |
}
|
|
454 |
|
|
455 |
void QFormBuilderExtra::clearGridLayoutColumnMinimumWidth(QGridLayout *grid)
|
|
456 |
{
|
|
457 |
clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth);
|
|
458 |
}
|
|
459 |
|
|
460 |
// ------------ QFormBuilderStrings
|
|
461 |
|
|
462 |
QFormBuilderStrings::QFormBuilderStrings() :
|
|
463 |
buddyProperty(QLatin1String("buddy")),
|
|
464 |
cursorProperty(QLatin1String("cursor")),
|
|
465 |
objectNameProperty(QLatin1String("objectName")),
|
|
466 |
trueValue(QLatin1String("true")),
|
|
467 |
falseValue(QLatin1String("false")),
|
|
468 |
horizontalPostFix(QLatin1String("Horizontal")),
|
|
469 |
separator(QLatin1String("separator")),
|
|
470 |
defaultTitle(QLatin1String("Page")),
|
|
471 |
titleAttribute(QLatin1String("title")),
|
|
472 |
labelAttribute(QLatin1String("label")),
|
|
473 |
toolTipAttribute(QLatin1String("toolTip")),
|
|
474 |
whatsThisAttribute(QLatin1String("whatsThis")),
|
|
475 |
flagsAttribute(QLatin1String("flags")),
|
|
476 |
iconAttribute(QLatin1String("icon")),
|
|
477 |
pixmapAttribute(QLatin1String("pixmap")),
|
|
478 |
textAttribute(QLatin1String("text")),
|
|
479 |
currentIndexProperty(QLatin1String("currentIndex")),
|
|
480 |
toolBarAreaAttribute(QLatin1String("toolBarArea")),
|
|
481 |
toolBarBreakAttribute(QLatin1String("toolBarBreak")),
|
|
482 |
dockWidgetAreaAttribute(QLatin1String("dockWidgetArea")),
|
|
483 |
marginProperty(QLatin1String("margin")),
|
|
484 |
spacingProperty(QLatin1String("spacing")),
|
|
485 |
leftMarginProperty(QLatin1String("leftMargin")),
|
|
486 |
topMarginProperty(QLatin1String("topMargin")),
|
|
487 |
rightMarginProperty(QLatin1String("rightMargin")),
|
|
488 |
bottomMarginProperty(QLatin1String("bottomMargin")),
|
|
489 |
horizontalSpacingProperty(QLatin1String("horizontalSpacing")),
|
|
490 |
verticalSpacingProperty(QLatin1String("verticalSpacing")),
|
|
491 |
sizeHintProperty(QLatin1String("sizeHint")),
|
|
492 |
sizeTypeProperty(QLatin1String("sizeType")),
|
|
493 |
orientationProperty(QLatin1String("orientation")),
|
|
494 |
styleSheetProperty(QLatin1String("styleSheet")),
|
|
495 |
qtHorizontal(QLatin1String("Qt::Horizontal")),
|
|
496 |
qtVertical(QLatin1String("Qt::Vertical")),
|
|
497 |
currentRowProperty(QLatin1String("currentRow")),
|
|
498 |
tabSpacingProperty(QLatin1String("tabSpacing")),
|
|
499 |
qWidgetClass(QLatin1String("QWidget")),
|
|
500 |
lineClass(QLatin1String("Line")),
|
|
501 |
geometryProperty(QLatin1String("geometry")),
|
|
502 |
scriptWidgetVariable(QLatin1String("widget")),
|
|
503 |
scriptChildWidgetsVariable(QLatin1String("childWidgets"))
|
|
504 |
{
|
|
505 |
itemRoles.append(qMakePair(Qt::FontRole, QString::fromLatin1("font")));
|
|
506 |
itemRoles.append(qMakePair(Qt::TextAlignmentRole, QString::fromLatin1("textAlignment")));
|
|
507 |
itemRoles.append(qMakePair(Qt::BackgroundRole, QString::fromLatin1("background")));
|
|
508 |
itemRoles.append(qMakePair(Qt::ForegroundRole, QString::fromLatin1("foreground")));
|
|
509 |
itemRoles.append(qMakePair(Qt::CheckStateRole, QString::fromLatin1("checkState")));
|
|
510 |
|
|
511 |
foreach (const RoleNName &it, itemRoles)
|
|
512 |
treeItemRoleHash.insert(it.second, it.first);
|
|
513 |
|
|
514 |
itemTextRoles.append(qMakePair(qMakePair(Qt::EditRole, Qt::DisplayPropertyRole),
|
|
515 |
textAttribute)); // This must be first for the loop below
|
|
516 |
itemTextRoles.append(qMakePair(qMakePair(Qt::ToolTipRole, Qt::ToolTipPropertyRole),
|
|
517 |
toolTipAttribute));
|
|
518 |
itemTextRoles.append(qMakePair(qMakePair(Qt::StatusTipRole, Qt::StatusTipPropertyRole),
|
|
519 |
QString::fromLatin1("statusTip")));
|
|
520 |
itemTextRoles.append(qMakePair(qMakePair(Qt::WhatsThisRole, Qt::WhatsThisPropertyRole),
|
|
521 |
whatsThisAttribute));
|
|
522 |
|
|
523 |
// Note: this skips the first item!
|
|
524 |
QList<TextRoleNName>::const_iterator it = itemTextRoles.constBegin(), end = itemTextRoles.constEnd();
|
|
525 |
while (++it != end)
|
|
526 |
treeItemTextRoleHash.insert(it->second, it->first);
|
|
527 |
}
|
|
528 |
|
|
529 |
const QFormBuilderStrings &QFormBuilderStrings::instance()
|
|
530 |
{
|
|
531 |
static const QFormBuilderStrings rc;
|
|
532 |
return rc;
|
|
533 |
}
|
|
534 |
|
|
535 |
#ifdef QFORMINTERNAL_NAMESPACE
|
|
536 |
} // namespace QFormInternal
|
|
537 |
#endif
|
|
538 |
|
|
539 |
QT_END_NAMESPACE
|