⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cppwriteinitialization.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                       << parentWidget << "->indexOf(" << varName << "), " << trCall(ptoolTip->elementString()) << ");\n";        }#endif // QT_NO_TOOLTIP    } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QTabWidget"))) {        QString icon;        if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) {            icon += QLatin1String(", ");            icon += pixCall(picon);        }        m_output << m_option.indent << parentWidget << "->addTab(" << varName << icon << ", " << "QString());\n";        m_refreshOut << m_option.indent << parentWidget << "->setTabText("                   << parentWidget << "->indexOf(" << varName << "), " << trCall(title) << ");\n";#ifndef QT_NO_TOOLTIP        if (const DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) {            m_refreshOut << m_option.indent << parentWidget << "->setTabToolTip("                       << parentWidget << "->indexOf(" << varName << "), " << trCall(ptoolTip->elementString()) << ");\n";        }#endif // QT_NO_TOOLTIP    } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("Q3Wizard"))) {        m_output << m_option.indent << parentWidget << "->addPage(" << varName << ", " << trCall(title) << ");\n";        m_refreshOut << m_option.indent << parentWidget << "->setTitle("                   << varName << ", " << trCall(title) << ");\n";    }    if (node->elementLayout().isEmpty())        m_layoutChain.pop();}void WriteInitialization::acceptLayout(DomLayout *node){    const QString className = node->attributeClass();    const QString varName = m_driver->findOrInsertLayout(node);    const DomPropertyMap properties = propertyMap(node->elementProperty());    const bool oldLayoutProperties = properties.constFind(QLatin1String("margin")) != properties.constEnd();    bool isGroupBox = false;    if (m_widgetChain.top()) {        const QString parentWidget = m_widgetChain.top()->attributeClass();        if (!m_layoutChain.top() && (m_uic->customWidgetsInfo()->extends(parentWidget, QLatin1String("Q3GroupBox"))                        || m_uic->customWidgetsInfo()->extends(parentWidget, QLatin1String("Q3ButtonGroup")))) {            const QString parent = m_driver->findOrInsertWidget(m_widgetChain.top());            isGroupBox = true;            // special case for group box            m_output << m_option.indent << parent << "->setColumnLayout(0, Qt::Vertical);\n";            QString objectName = parent;            objectName += "->layout()";            int marginType = Use43UiFile;            if (oldLayoutProperties)                marginType = m_layoutMarginType;            m_LayoutDefaultHandler.writeProperties(m_option.indent,                                     objectName, properties, marginType, false, m_output);        }    }    m_output << m_option.indent << varName << " = new " << className << '(';    if (!m_layoutChain.top() && !isGroupBox)        m_output << m_driver->findOrInsertWidget(m_widgetChain.top());    m_output << ");\n";    if (isGroupBox) {        const QString tempName = m_driver->unique(QLatin1String("boxlayout"));        m_output << m_option.indent << "QBoxLayout *" << tempName << " = qobject_cast<QBoxLayout *>(" <<                    m_driver->findOrInsertWidget(m_widgetChain.top()) << "->layout());\n";        m_output << m_option.indent << "if (" << tempName << ")\n";        m_output << m_option.indent << "    " << tempName << "->addLayout(" << varName << ");\n";    }    if (isGroupBox) {        m_output << m_option.indent << varName << "->setAlignment(Qt::AlignTop);\n";    }  else {        // Suppress margin on a read child layout        const bool suppressMarginDefault = m_layoutChain.top();        int marginType = Use43UiFile;        if (oldLayoutProperties)            marginType = m_layoutMarginType;        m_LayoutDefaultHandler.writeProperties(m_option.indent, varName, properties, marginType, suppressMarginDefault, m_output);    }    m_layoutMarginType = SubLayoutMargin;    DomPropertyList propList = node->elementProperty();    if (m_layoutWidget) {        bool left, top, right, bottom;        left = top = right = bottom = false;        for (int i = 0; i < propList.size(); ++i) {            const DomProperty *p = propList.at(i);            const QString propertyName = p->attributeName();            if (propertyName == QLatin1String("leftMargin") && p->kind() == DomProperty::Number)                left = true;            else if (propertyName == QLatin1String("topMargin") && p->kind() == DomProperty::Number)                top = true;            else if (propertyName == QLatin1String("rightMargin") && p->kind() == DomProperty::Number)                right = true;            else if (propertyName == QLatin1String("bottomMargin") && p->kind() == DomProperty::Number)                bottom = true;        }        if (!left) {            DomProperty *p = new DomProperty();            p->setAttributeName(QLatin1String("leftMargin"));            p->setElementNumber(0);            propList.append(p);        }        if (!top) {            DomProperty *p = new DomProperty();            p->setAttributeName(QLatin1String("topMargin"));            p->setElementNumber(0);            propList.append(p);        }        if (!right) {            DomProperty *p = new DomProperty();            p->setAttributeName(QLatin1String("rightMargin"));            p->setElementNumber(0);            propList.append(p);        }        if (!bottom) {            DomProperty *p = new DomProperty();            p->setAttributeName(QLatin1String("bottomMargin"));            p->setElementNumber(0);            propList.append(p);        }        m_layoutWidget = false;    }    writeProperties(varName, className, propList, WritePropertyIgnoreMargin|WritePropertyIgnoreSpacing);    m_layoutChain.push(node);    TreeWalker::acceptLayout(node);    m_layoutChain.pop();}void WriteInitialization::acceptSpacer(DomSpacer *node){    m_output << m_option.indent << m_driver->findOrInsertSpacer(node) << " = ";    writeSpacerItem(node, m_output);    m_output << ";\n";}void WriteInitialization::acceptLayoutItem(DomLayoutItem *node){    TreeWalker::acceptLayoutItem(node);    DomLayout *layout = m_layoutChain.top();    if (!layout)        return;    const QString layoutName = m_driver->findOrInsertLayout(layout);    QString opt;    if (layout->attributeClass() == QLatin1String("QGridLayout")) {        const int row = node->attributeRow();        const int col = node->attributeColumn();        int rowSpan = 1;        if (node->hasAttributeRowSpan())            rowSpan = node->attributeRowSpan();        int colSpan = 1;        if (node->hasAttributeColSpan())            colSpan = node->attributeColSpan();        opt = QString::fromLatin1(", %1, %2, %3, %4").arg(row).arg(col).arg(rowSpan).arg(colSpan);    }    // figure out "add" method    m_output << "\n" << m_option.indent << layoutName << "->";    switch (node->kind()) {    case DomLayoutItem::Widget:        m_output << "addWidget" <<  '(' << m_driver->findOrInsertLayoutItem(node);        break;    case DomLayoutItem::Layout:        m_output << "addLayout" <<  '(' << m_driver->findOrInsertLayoutItem(node);        break;    case DomLayoutItem::Spacer:        m_output << "addItem" << '(' << m_driver->findOrInsertLayoutItem(node);        break;    case DomLayoutItem::Unknown:        Q_ASSERT( 0 );        break;    }    m_output << opt << ");\n\n";}void WriteInitialization::acceptActionGroup(DomActionGroup *node){    const QString actionName = m_driver->findOrInsertActionGroup(node);    QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());    if (m_actionGroupChain.top())        varName = m_driver->findOrInsertActionGroup(m_actionGroupChain.top());    m_output << m_option.indent << actionName << " = new QActionGroup(" << varName << ");\n";    writeProperties(actionName, QLatin1String("QActionGroup"), node->elementProperty());    m_actionGroupChain.push(node);    TreeWalker::acceptActionGroup(node);    m_actionGroupChain.pop();}void WriteInitialization::acceptAction(DomAction *node){    if (node->hasAttributeMenu())        return;    const QString actionName = m_driver->findOrInsertAction(node);    m_registeredActions.insert(actionName, node);    QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());    if (m_actionGroupChain.top())        varName = m_driver->findOrInsertActionGroup(m_actionGroupChain.top());    m_output << m_option.indent << actionName << " = new QAction(" << varName << ");\n";    writeProperties(actionName, QLatin1String("QAction"), node->elementProperty());}void WriteInitialization::acceptActionRef(DomActionRef *node){    QString actionName = node->attributeName();    const bool isSeparator = actionName == QLatin1String("separator");    bool isMenu = false;    QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());    if (actionName.isEmpty() || !m_widgetChain.top()) {        return;    } else if (m_driver->actionGroupByName(actionName)) {        return;    } else if (DomWidget *w = m_driver->widgetByName(actionName)) {        isMenu = m_uic->isMenu(w->attributeClass());        bool inQ3ToolBar = m_uic->customWidgetsInfo()->extends(m_widgetChain.top()->attributeClass(), QLatin1String("Q3ToolBar"));        if (!isMenu && inQ3ToolBar) {            m_actionOut << m_option.indent << actionName << "->setParent(" << varName << ");\n";            return;        }    } else if (!(m_driver->actionByName(actionName) || isSeparator)) {        fprintf(stderr, "Warning: action `%s' not declared\n", actionName.toLatin1().data());        return;    }    if (m_widgetChain.top() && isSeparator) {        // separator is always reserved!        m_actionOut << m_option.indent << varName << "->addSeparator();\n";        return;    }    if (isMenu)        actionName += QLatin1String("->menuAction()");    m_actionOut << m_option.indent << varName << "->addAction(" << actionName << ");\n";}void WriteInitialization::writeProperties(const QString &varName,                                          const QString &className,                                          const DomPropertyList &lst,                                          unsigned flags){    const bool isTopLevel = m_widgetChain.count() == 1;    if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) {        DomPropertyMap properties = propertyMap(lst);        if (properties.contains(QLatin1String("control"))) {            DomProperty *p = properties.value(QLatin1String("control"));            m_output << m_option.indent << varName << "->setControl(QString::fromUtf8("                   << fixString(toString(p->elementString()), m_option.indent) << "));\n";        }    }    DomWidget *buttonGroupWidget = findWidget(QLatin1String("Q3ButtonGroup"));    QString indent;    if (!m_widgetChain.top()) {        indent = QLatin1String("    ");        m_output << m_option.indent << "if (" << varName << "->objectName().isEmpty())\n";    }    m_output << m_option.indent << indent << varName << "->setObjectName(QString::fromUtf8(" << fixString(varName, m_option.indent) << "));\n";    int leftMargin, topMargin, rightMargin, bottomMargin;    leftMargin = topMargin = rightMargin = bottomMargin = -1;    bool frameShadowEncountered = false;    for (int i=0; i<lst.size(); ++i) {        const DomProperty *p = lst.at(i);        const QString propertyName = p->attributeName();        QString propertyValue;        // special case for the property `geometry': Do not use position        if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) {            const DomRect *r = p->elementRect();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -