Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/designer/src/lib/uilib/formbuilder.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the Qt Designer of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5858
    5959    \brief The QFormBuilder class is used to dynamically construct
    60     user interfaces from .ui files at run-time.
     60    user interfaces from files at run-time.
    6161
    6262    \inmodule QtDesigner
    6363
    6464    The QFormBuilder class provides a mechanism for dynamically
    65     creating user interfaces at run-time, based on \c{.ui} files
     65    creating user interfaces at run-time, based on files
    6666    created with \QD. For example:
    6767
     
    121121QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget)
    122122{
    123     QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false);
     123    QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
     124    if (!fb->parentWidgetIsSet())
     125        fb->setParentWidget(parentWidget);
     126    // Is this a QLayoutWidget with a margin of 0: Not a known page-based
     127    // container and no method for adding pages registered.
     128    fb->setProcessingLayoutWidget(false);
    124129    if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative()
    125130            && parentWidget
     
    145150            && !qobject_cast<QDockWidget *>(parentWidget)
    146151#endif
    147             )
    148         QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(true);
     152        ) {
     153        const QString parentClassName = QLatin1String(parentWidget->metaObject()->className());
     154        if (!fb->isCustomWidgetContainer(parentClassName))
     155            fb->setProcessingLayoutWidget(true);
     156    }
    149157    return QAbstractFormBuilder::create(ui_widget, parentWidget);
    150158}
     
    228236    if (qobject_cast<QDialog *>(w))
    229237        w->setParent(parentWidget);
    230 
    231     if (!fb->rootWidget())
    232         fb->setRootWidget(w);
    233238
    234239    return w;
     
    370375QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
    371376{
     377
    372378    // Is this a temporary layout widget used to represent QLayout hierarchies in Designer?
    373379    // Set its margins to 0.
    374     bool layoutWidget = QFormBuilderExtra::instance(this)->processingLayoutWidget();
     380    bool layoutWidget = ->processingLayoutWidget();
    375381    QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
    376382    if (layoutWidget) {
     
    393399
    394400        l->setContentsMargins(left, top, right, bottom);
    395         QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false);
     401        ->setProcessingLayoutWidget(false);
    396402    }
    397403    return l;
     
    526532    \internal
    527533*/
     534
    528535void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties)
    529536{
     
    543550
    544551        const QString attributeName = (*it)->attributeName();
    545         if (o == fb->rootWidget() && attributeName == strings.geometryProperty) {
    546             // apply only the size for the rootWidget
    547             fb->rootWidget()->resize(qvariant_cast<QRect>(v).size());
     552        const bool isWidget = o->isWidgetType();
     553        if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) {
     554            // apply only the size part of a geometry for the root widget
     555            static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size());
    548556        } else if (fb->applyPropertyInternally(o, attributeName, v)) {
    549         } else if (!qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) {
     557        } else if (!qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) {
    550558            // ### special-casing for Line (QFrame) -- try to fix me
    551559            o->setProperty("frameShape", v); // v is of QFrame::Shape enum
Note: See TracChangeset for help on using the changeset viewer.