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

📄 converter.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                    if (!customWidget->hasElementExtends())                        customWidget->setElementExtends(QLatin1String("QWidget"));                    QDomElement n3 = n2.firstChild().toElement();                    QString cl;                    QList<DomPropertyData*> ui_property_list;                    while (!n3.isNull()) {                        QString tagName = n3.tagName().toLower();                        if (tagName == QLatin1String("property")) {                            DomPropertyData *p = new DomPropertyData();                            p->read(n3);                            ui_property_list.append(p);                        }                        n3 = n3.nextSibling().toElement();                    }                    if (ui_property_list.size()) {                        DomProperties *properties = new DomProperties();                        properties->setElementProperty(ui_property_list);                        customWidget->setElementProperties(properties);                    }                    ui_customwidget_list.append(customWidget);                }                n2 = n2.nextSibling().toElement();            }        } else if (tagName == QLatin1String("connections")) {            QDomElement n2 = n.firstChild().toElement();            while (!n2.isNull()) {                if (n2.tagName().toLower() == QLatin1String("connection")) {                    DomConnection *connection = new DomConnection;                    connection->read(n2);                    QString signal = fixMethod(connection->elementSignal());                    QString slot = fixMethod(connection->elementSlot());                    connection->setElementSignal(signal);                    connection->setElementSlot(slot);                    ui_connection_list.append(connection);                    ui_connection_lineinfo_list.append(                        QPair<int, int>(n2.lineNumber(), n2.columnNumber()));                }                n2 = n2.nextSibling().toElement();            }        } else if (tagName == QLatin1String("slots")) {            QDomElement n2 = n.firstChild().toElement();            while (!n2.isNull()) {                if (n2.tagName().toLower() == QLatin1String("slot")) {                    QString name = n2.firstChild().toText().data();                    ui_custom_slots.append(fixMethod(Parser::cleanArgs(name)));                }                n2 = n2.nextSibling().toElement();            }        }    }    // validate the connections    for (int i = 0; i < ui_connection_list.size(); ++i) {        DomConnection *conn = ui_connection_list.at(i);        QPair<int, int> lineinfo = ui_connection_lineinfo_list.at(i);        QString sender = conn->elementSender();        QString senderClass = fixClassName(classNameForObjectName(widget, sender));        QString signal = conn->elementSignal();        QString receiver = conn->elementReceiver();        QString receiverClass = fixClassName(classNameForObjectName(widget, receiver));        QString slot = conn->elementSlot();        if (!WidgetInfo::isValidSignal(senderClass, signal)) {            errorInvalidSignal(signal, sender, senderClass,                               lineinfo.first, lineinfo.second);        } else if (!WidgetInfo::isValidSlot(receiverClass, slot)) {            bool resolved = false;            if (objName == receiver) {                // see if it's a custom slot                foreach (QString cs, ui_custom_slots) {                    if (cs == slot) {                        resolved = true;                        break;                    }                }            }            if (!resolved) {                errorInvalidSlot(slot, receiver, receiverClass,                                 lineinfo.first, lineinfo.second);            }        }    }    DomWidget *w = createWidget(widget);    Q_ASSERT(w != 0);    QList<DomWidget*> l = w->elementWidget();    l += ui_toolbars;    l += ui_menubars;    w->setElementWidget(l);    if (ui_action_group_list.size())        w->setElementActionGroup(ui_action_group_list);    if (ui_action_list.size())        w->setElementAction(ui_action_list);    ui->setElementWidget(w);    if (klass.isEmpty())        klass = w->attributeName();    ui->setElementClass(klass);    ui->setElementAuthor(author);    ui->setElementComment(comment);    ui->setElementExportMacro(exportMacro);    if (!ui->elementImages())        ui->setElementPixmapFunction(pixmapFunction);    for (int i=0; i<ui_customwidget_list.size(); ++i) {        QString name = ui_customwidget_list.at(i)->elementClass();        if (candidateCustomWidgets.contains(name))            candidateCustomWidgets.remove(name);    }    QMapIterator<QString, bool> it(candidateCustomWidgets);    while (it.hasNext()) {        it.next();        QString customClass = it.key();        QString baseClass;        if (customClass.endsWith(QLatin1String("ListView")))            baseClass = QLatin1String("Q3ListView");        else if (customClass.endsWith(QLatin1String("ListBox")))            baseClass = QLatin1String("Q3ListBox");        else if (customClass.endsWith(QLatin1String("IconView")))            baseClass = QLatin1String("Q3IconView");        else if (customClass.endsWith(QLatin1String("ComboBox")))            baseClass = QLatin1String("QComboBox");        if (baseClass.isEmpty())            continue;        DomCustomWidget *customWidget = new DomCustomWidget();        customWidget->setElementClass(customClass);        customWidget->setElementExtends(baseClass);        // Magic header generation feature for legacy KDE forms        // (for example, filesharing/advanced/kcm_sambaconf/share.ui)        if (implicitIncludes && isKDEClass(customClass)) {            QString header = customClass.toLower();            header += QLatin1String(".h");            DomHeader *domHeader = new DomHeader;            domHeader->setText(header);            domHeader->setAttributeLocation(QLatin1String("global"));            customWidget->setElementHeader(domHeader);            if (warnHeaderGeneration) {                const QString msg = QString::fromUtf8("Warning: generated header '%1' for class '%2'.").arg(header).arg(customClass);                qWarning(msg.toUtf8().constData());            }        }        ui_customwidget_list.append(customWidget);    }    if (ui_customwidget_list.size()) {        DomCustomWidgets *customWidgets = new DomCustomWidgets();        customWidgets->setElementCustomWidget(ui_customwidget_list);        ui->setElementCustomWidgets(customWidgets);    }    if (ui_tabstops.size()) {        DomTabStops *tabStops = new DomTabStops();        tabStops->setElementTabStop(ui_tabstops);        ui->setElementTabStops(tabStops);    }    if (ui_includes.size()) {        DomIncludes *includes = new DomIncludes();        includes->setElementInclude(ui_includes);        ui->setElementIncludes(includes);    }    if (ui_connection_list.size()) {        DomConnections *connections = new DomConnections();        connections->setElementConnection(ui_connection_list);        ui->setElementConnections(connections);    }    ui->setAttributeStdSetDef(stdsetdef);    if (m_extractImages) {        Option opt;        opt.extractImages = m_extractImages;        opt.qrcOutputFile = m_qrcOutputFile;        CPP::ExtractImages(opt).acceptUI(ui);        ui->clearElementImages();        DomResources *res = ui->elementResources();        if (!res) {            res = new DomResources();        }        DomResource *incl = new DomResource();        incl->setAttributeLocation(m_qrcOutputFile);        QList<DomResource *> inclList = res->elementInclude();        inclList.append(incl);        res->setElementInclude(inclList);        if (!ui->elementResources())            ui->setElementResources(res);    }    return ui;}QString Ui3Reader::fixActionProperties(QList<DomProperty*> &properties,                                       bool isActionGroup){    QString objectName;    QMutableListIterator<DomProperty*> it(properties);    while (it.hasNext()) {        DomProperty *prop = it.next();        QString name = prop->attributeName();        if (name == QLatin1String("name")) {            objectName = prop->elementCstring();        } else if (isActionGroup && name == QLatin1String("exclusive")) {            // continue        } else if (isActionGroup) {            errorInvalidProperty(name, objectName, isActionGroup ? QLatin1String("QActionGroup") : QLatin1String("QAction"), -1, -1);            delete prop;            it.remove();        } else if (name == QLatin1String("menuText")) {            prop->setAttributeName(QLatin1String("text"));        } else if (name == QLatin1String("text")) {            prop->setAttributeName(QLatin1String("iconText"));        } else if (name == QLatin1String("iconSet")) {            prop->setAttributeName(QLatin1String("icon"));        } else if (name == QLatin1String("accel")) {            prop->setAttributeName(QLatin1String("shortcut"));        } else if (name == QLatin1String("toggleAction")) {            prop->setAttributeName(QLatin1String("checkable"));        } else if (name == QLatin1String("on")) {            prop->setAttributeName(QLatin1String("checked"));        } else if (!WidgetInfo::isValidProperty(QLatin1String("QAction"), name)) {            errorInvalidProperty(name, objectName, isActionGroup ? QLatin1String("QActionGroup") : QLatin1String("QAction"), -1, -1);            delete prop;            it.remove();        }    }    return objectName;}void Ui3Reader::fixActionGroup(DomActionGroup *g){    QList<DomActionGroup*> groups = g->elementActionGroup();    for (int i=0; i<groups.size(); ++i) {        fixActionGroup(groups.at(i));    }    QList<DomAction*> actions = g->elementAction();    for (int i=0; i<actions.size(); ++i) {        DomAction *a = actions.at(i);        QList<DomProperty*> properties = a->elementProperty();        QString name = fixActionProperties(properties);        a->setElementProperty(properties);        if (name.size())            a->setAttributeName(name);    }    QList<DomProperty*> properties = g->elementProperty();    QString name = fixActionProperties(properties, true);    g->setElementProperty(properties);    if (name.size())        g->setAttributeName(name);}QString Ui3Reader::fixClassName(const QString &className) const{    return m_porting->renameClass(className);}QString Ui3Reader::fixHeaderName(const QString &headerName) const{    return m_porting->renameHeader(headerName);}DomWidget *Ui3Reader::createWidget(const QDomElement &w, const QString &widgetClass){    DomWidget *ui_widget = new DomWidget;    QString className = widgetClass;    if (className.isEmpty())        className = w.attribute(QLatin1String("class"));    className = fixClassName(className);    if ((className.endsWith(QLatin1String("ListView")) && className != QLatin1String("Q3ListView"))            || (className.endsWith(QLatin1String("ListBox")) && className != QLatin1String("Q3ListBox"))            || (className.endsWith(QLatin1String("ComboBox")) && className != QLatin1String("QComboBox"))            || (className.endsWith(QLatin1String("IconView")) && className != QLatin1String("Q3IconView")))        candidateCustomWidgets.insert(className, true);    bool isMenu = (className == QLatin1String("QMenuBar") || className == QLatin1String("QMenu"));    ui_widget->setAttributeClass(className);

⌨️ 快捷键说明

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