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

📄 uic.cpp

📁 这个是Linux的qt源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    if ( e.tagName() == "item" )	out << "    " << "QPopupMenu *" << e.attribute( "name" ) << ";" << endl;}void Uic::createActionImpl( const QDomElement &n, const QString &parent ){    for ( QDomElement ae = n; !ae.isNull(); ae = ae.nextSibling().toElement() ) {	QString objName = registerObject( getObjectName( ae ) );	if ( ae.tagName() == "action" )	    out << indent << objName << " = new QAction( " << parent << ", \"" << objName << "\" );" << endl;	else if ( ae.tagName() == "actiongroup" )	    out << indent << objName << " = new QActionGroup( " << parent << ", \"" << objName << "\" );" << endl;	else	    continue;	bool subActionsDone = FALSE;	for ( QDomElement n2 = ae.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) {	    if ( n2.tagName() == "property" ) {		bool stdset = stdsetdef;		if ( n2.hasAttribute( "stdset" ) )		    stdset = toBool( n2.attribute( "stdset" ) );		QString prop = n2.attribute("name");		if ( prop == "name" )		    continue;		QString value = setObjectProperty( "QAction", objName, prop, n2.firstChild().toElement(), stdset );		if ( value.isEmpty() )		    continue;		QString call = objName + "->";		if ( stdset ) {		    call += mkStdSet( prop ) + "( ";		} else {		    call += "setProperty( \"" + prop + "\", ";		}		call += value + " );";		if ( n2.firstChild().toElement().tagName() == "string" ) {		    trout << indent << call << endl;		} else {		    out << indent << call << endl;		}	    } else if ( !subActionsDone && ( n2.tagName() == "actiongroup" || n2.tagName() == "action" ) ) {		createActionImpl( n2, objName );		subActionsDone = TRUE;	    }	}    }}QString get_dock( const QString &d ){    if ( d == "0" )	return "DockUnmanaged";    if ( d == "1" )	return "DockTornOff";    if ( d == "2" )	return "DockTop";    if ( d == "3" )	return "DockBottom";    if ( d == "4" )	return "DockRight";    if ( d == "5" )	return "DockLeft";    if ( d == "6" )	return "DockMinimized";    return "";}void Uic::createToolbarImpl( const QDomElement &n, const QString &parentClass, const QString &parent ){    QDomNodeList nl = n.elementsByTagName( "toolbar" );    for ( int i = 0; i < (int) nl.length(); i++ ) {	QDomElement ae = nl.item( i ).toElement();	QString dock = get_dock( ae.attribute( "dock" ) );	QString objName = getObjectName( ae ); 	out << indent << objName << " = new QToolBar( QString(\"\"), this, " << dock << " ); " << endl;	createObjectImpl( ae, parentClass, parent );	for ( QDomElement n2 = ae.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) {	    if ( n2.tagName() == "action" ) {		out << indent << n2.attribute( "name" ) << "->addTo( " << objName << " );" << endl;	    } else if ( n2.tagName() == "separator" ) {		out << indent << objName << "->addSeparator();" << endl;	    } else if ( n2.tagName() == "widget" ) {		if ( n2.attribute( "class" ) != "Spacer" ) {		    createObjectImpl( n2, "QToolBar", objName );		} else {		    QString child = createSpacerImpl( n, parentClass, parent, objName );		    out << indent << "QApplication::sendPostedEvents( " << objName			<< ", QEvent::ChildInserted );" << endl;		    out << indent << objName << "->boxLayout()->addItem( " << child << " );" << endl;		}	    }	}    }}void Uic::createMenuBarImpl( const QDomElement &n, const QString &parentClass, const QString &parent ){    QString objName = getObjectName( n );    out << indent << objName << " = new QMenuBar( this, \"" << objName << "\" );" << endl;    createObjectImpl( n, parentClass, parent );    int i = 0;    QDomElement c = n.firstChild().toElement();    while ( !c.isNull() ) {	if ( c.tagName() == "item" ) {	    QString itemName = c.attribute( "name" );	    out << endl;	    out << indent << itemName << " = new QPopupMenu( this );" << endl;	    createPopupMenuImpl( c, parentClass, itemName );	    out << indent << objName << "->insertItem( QString(\"\"), " << itemName << ", " << i << " );" << endl;	    trout << indent << objName << "->findItem( " << i << " )->setText( " << trcall( c.attribute( "text" ) ) << " );" << endl;	} else if ( c.tagName() == "separator" ) {	    out << endl;	    out << indent << objName << "->insertSeparator( " << i << " );" << endl;	}	c = c.nextSibling().toElement();	i++;    }}void Uic::createPopupMenuImpl( const QDomElement &e, const QString &parentClass, const QString &parent ){    for ( QDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {	if ( n.tagName() == "action" ) {	    QDomElement n2 = n.nextSibling().toElement();	    if ( n2.tagName() == "item" ) { // the action has a sub menu		QString itemName = n2.attribute( "name" );		QString itemText = n2.attribute( "text" );		out << indent << "QPopupMenu *" << itemName << " = new QPopupMenu( this );" << endl;		out << indent << parent << "->setAccel( tr( \"" << n2.attribute( "accel" ) << "\" ), " << endl;		out << indent << indent << parent << "->insertItem( " << n.attribute( "name" ) << "->iconSet(),";		out << trcall( itemText ) << ", " << itemName << " ) );" << endl;		createPopupMenuImpl( n2, parentClass, itemName );		n = n2;	    } else {		out << indent << n.attribute( "name" ) << "->addTo( " << parent << " );" << endl;	    }	} else if ( n.tagName() == "separator" ) {	    out << indent << parent << "->insertSeparator();" << endl;	}    }}/*!  Creates implementation of an listbox item tag.*/QString Uic::createListBoxItemImpl( const QDomElement &e, const QString &parent,				    QString *value ){    QDomElement n = e.firstChild().toElement();    QString txt;    QString com;    QString pix;    while ( !n.isNull() ) {	if ( n.tagName() == "property" ) {	    QString attrib = n.attribute( "name" );	    QVariant v = DomTool::elementToVariant( n.firstChild().toElement(), QVariant() );	    if ( attrib == "text" ) {		txt = v.toString();		com = getComment( n );	    } else if ( attrib == "pixmap" ) {		pix = v.toString();		if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) {		    pix.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );		    pix.append(  QString( externPixmaps ? "\"" : "" ) + " )" );		}	    }	}	n = n.nextSibling().toElement();    }    if ( value )	*value = trcall( txt, com );    if ( pix.isEmpty() ) {	return parent + "->insertItem( " + trcall( txt, com ) + " );";    } else {	return parent + "->insertItem( " + pix + ", " + trcall( txt, com ) + " );";    }}/*!  Creates implementation of an iconview item tag.*/QString Uic::createIconViewItemImpl( const QDomElement &e, const QString &parent ){    QDomElement n = e.firstChild().toElement();    QString txt;    QString com;    QString pix;    while ( !n.isNull() ) {	if ( n.tagName() == "property" ) {	    QString attrib = n.attribute( "name" );	    QVariant v = DomTool::elementToVariant( n.firstChild().toElement(), QVariant() );	    if ( attrib == "text" ) {		txt = v.toString();		com = getComment( n );	    } else if ( attrib == "pixmap" ) {		pix = v.toString();		if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) {		    pix.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );		    pix.append( QString( externPixmaps ? "\"" : "" ) + " )" );		}	    }	}	n = n.nextSibling().toElement();    }    if ( pix.isEmpty() )	return "(void) new QIconViewItem( " + parent + ", " + trcall( txt, com ) + " );";    else	return "(void) new QIconViewItem( " + parent + ", " + trcall( txt, com ) + ", " + pix + " );";}/*!  Creates implementation of an listview item tag.*/QString Uic::createListViewItemImpl( const QDomElement &e, const QString &parent,				     const QString &parentItem ){    QString s;    QDomElement n = e.firstChild().toElement();    bool hasChildren = e.elementsByTagName( "item" ).count() > 0;    QString item;    if ( hasChildren ) {	item = registerObject( "item" );	s = indent + "QListViewItem * " + item + " = ";    } else {	item = "item";	if ( item_used )	    s = indent + item + " = ";	else	    s = indent + "QListViewItem * " + item + " = ";	item_used = TRUE;    }    if ( !parentItem.isEmpty() )	s += "new QListViewItem( " + parentItem + ", " + lastItem + " );\n";    else	s += "new QListViewItem( " + parent + ", " + lastItem + " );\n";    QStringList texts;    QStringList pixmaps;    while ( !n.isNull() ) {	if ( n.tagName() == "property" ) {	    QString attrib = n.attribute("name");	    QVariant v = DomTool::elementToVariant( n.firstChild().toElement(), QVariant() );	    if ( attrib == "text" )		texts << v.toString();	    else if ( attrib == "pixmap" ) {		QString pix = v.toString();		if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) {		    pix.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );		    pix.append( QString( externPixmaps ? "\"" : "" ) + " )" );		}		pixmaps << pix;	    }	} else if ( n.tagName() == "item" ) {	    s += indent + item + "->setOpen( TRUE );\n";	    s += createListViewItemImpl( n, parent, item );	}	n = n.nextSibling().toElement();    }    for ( int i = 0; i < (int)texts.count(); ++i ) {	if ( !texts[ i ].isEmpty() )	    s += indent + item + "->setText( " + QString::number( i ) + ", " + trcall( texts[ i ] ) + " );\n";	if ( !pixmaps[ i ].isEmpty() )	    s += indent + item + "->setPixmap( " + QString::number( i ) + ", " + pixmaps[ i ] + " );\n";    }    lastItem = item;    return s;}/*!  Creates implementation of an listview column tag.*/QString Uic::createListViewColumnImpl( const QDomElement &e, const QString &parent,				       QString *value ){    QDomElement n = e.firstChild().toElement();    QString txt;    QString com;    QString pix;    bool clickable = FALSE, resizable = FALSE;    while ( !n.isNull() ) {	if ( n.tagName() == "property" ) {	    QString attrib = n.attribute("name");	    QVariant v = DomTool::elementToVariant( n.firstChild().toElement(), QVariant() );	    if ( attrib == "text" ) {		txt = v.toString();		com = getComment( n );	    } else if ( attrib == "pixmap" ) {		pix = v.toString();		if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) {		    pix.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );		    pix.append( QString( externPixmaps ? "\"" : "" ) + " )" );		}	    } else if ( attrib == "clickable" )		clickable = v.toBool();	    else if ( attrib == "resizable" || attrib == "resizeable" )		resizable = v.toBool();	}	n = n.nextSibling().toElement();    }    if ( value )	*value = trcall( txt, com );    QString s;    s = indent + parent + "->addColumn( " + trcall( txt, com ) + " );\n";    if ( !pix.isEmpty() )	s += indent + parent + "->header()->setLabel( " + parent + "->header()->count() - 1, " + pix + ", " + trcall( txt, com ) + " );\n";    if ( !clickable )	s += indent + parent + "->header()->setClickEnabled( FALSE, " + parent + "->header()->count() - 1 );\n";    if ( !resizable )	s += indent + parent + "->header()->setResizeEnabled( FALSE, " + parent + "->header()->count() - 1 );\n";    return s;}QString Uic::createTableRowColumnImpl( const QDomElement &e, const QString &parent,				       QString *value ){    QString objClass = getClassName( e.parentNode().toElement() );    QDomElement n = e.firstChild().toElement();    QString txt;    QString com;    QString pix;    QString field;    bool isRow = e.tagName() == "row";    while ( !n.isNull() ) {	if ( n.tagName() == "property" ) {	    QString attrib = n.attribute("name");	    QVariant v = DomTool::elementToVariant( n.firstChild().toElement(), QVariant() );	    if ( attrib == "text" ) {		txt = v.toString();		com = getComment( n );	    } else if ( attrib == "pixmap" ) {		pix = v.toString();		if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) {		    pix.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );		    pix.append( QString( externPixmaps ? "\"" : "" ) + " )" );		}	    } else if ( attrib == "field" )		field = v.toString();	}	n = n.nextSibling().toElement();    }    if ( value )	*value = trcall( txt, com );    // ### This generated code sucks! We have to set the number of

⌨️ 快捷键说明

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