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

📄 widgetdatabase.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    r = new WidgetDatabaseRecord;    r->iconSet = "tabwidget.png";    r->name = "QDesignerTabWidget";    r->group = widgetGroup( "Temp" );    r->isContainer = TRUE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "tabwidget.png";    r->name = "QDesignerWidget";    r->group = widgetGroup( "Temp" );    r->isContainer = TRUE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "tabwidget.png";    r->name = "QDesignerDialog";    r->group = widgetGroup( "Temp" );    r->isContainer = TRUE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "";    r->name = "QMainWindow";    r->includeFile = "qmainwindow.h";    r->group = widgetGroup( "Temp" );    r->isContainer = TRUE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "";    r->name = "QDesignerAction";    r->includeFile = "qaction.h";    r->group = widgetGroup( "Temp" );    r->isContainer = FALSE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "";    r->name = "QDesignerActionGroup";    r->includeFile = "qaction.h";    r->group = widgetGroup( "Temp" );    r->isContainer = FALSE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "";    r->name = "QScrollView";    r->includeFile = "qscrollview.h";    r->group = widgetGroup( "Temp" );    r->isContainer = TRUE;    append( r );#ifndef QT_NO_SQL    r = new WidgetDatabaseRecord;    r->iconSet = "";    r->name = "QDataBrowser";    r->includeFile = "qdatabrowser.h";    r->group = widgetGroup( "Database" );    r->toolTip = "Data Browser";    r->iconSet = "databrowser.png";    r->isContainer = TRUE;    append( r );    r = new WidgetDatabaseRecord;    r->iconSet = "";    r->name = "QDataView";    r->includeFile = "qdataview.h";    r->group = widgetGroup( "Database" );    r->toolTip = "Data View";    r->iconSet = "dataview.png";    r->isContainer = TRUE;    append( r );#endif#ifndef UIC    setupPlugins();#endif}void WidgetDatabase::setupPlugins(){    if ( plugins_set_up )	return;    plugins_set_up = TRUE;    QStringList widgets = widgetManager()->featureList();    for ( QStringList::Iterator it = widgets.begin(); it != widgets.end(); ++it ) {	if ( hasWidget( *it ) )	    continue;	WidgetDatabaseRecord *r = new WidgetDatabaseRecord;	WidgetInterface *iface = 0;	widgetManager()->queryInterface( *it, &iface );	if ( !iface )	    continue;#ifndef UIC	QIconSet icon = iface->iconSet( *it );	if ( !icon.pixmap().isNull() )	    r->icon = new QIconSet( icon );#endif	QString grp = iface->group( *it );	if ( grp.isEmpty() )	    grp = "3rd party widgets";	r->group = widgetGroup( grp );	r->toolTip = iface->toolTip( *it );	r->whatsThis = iface->whatsThis( *it );	r->includeFile = iface->includeFile( *it );	r->isContainer = iface->isContainer( *it );	r->name = *it;	r->isPlugin = TRUE;	append( r );	iface->release();    }}/*!  Returns the number of elements in the widget database.*/int WidgetDatabase::count(){    setupDataBase( -1 );    return dbcount;}/*!  Returns the id at which the ids of custom widgets start.*/int WidgetDatabase::startCustom(){    setupDataBase( -1 );    return dbcustom;}/*!  Returns the iconset which represents the class registered as \a id.*/QIconSet WidgetDatabase::iconSet( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return QIconSet();#if !defined(UIC) && !defined(RESOURCE)    if ( !r->icon ) {	if ( r->iconSet.isEmpty() )	    return QIconSet();	QPixmap pix = QPixmap::fromMimeSource( r->iconSet );	if ( pix.isNull() )	    pix = QPixmap( r->iconSet );	r->icon = new QIconSet( pix );    }    return *r->icon;#else    return QIconSet();#endif}/*!  Returns the classname of the widget which is registered as \a id.*/QString WidgetDatabase::className( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return QString::null;    return r->name;}/*!  Returns the group the widget registered as \a id belongs to.*/QString WidgetDatabase::group( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return QString::null;    return r->group;}/*!  Returns the tooltip text of the widget which is registered as \a id.*/QString WidgetDatabase::toolTip( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return QString::null;    return r->toolTip;}/*!  Returns the what's this? text of the widget which is registered as \a id.*/QString WidgetDatabase::whatsThis( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return QString::null;    return r->whatsThis;}/*!  Returns the include file if the widget which is registered as \a id.*/QString WidgetDatabase::includeFile( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return QString::null;    if ( r->includeFile.isNull() )	return r->name.lower() + ".h";    return r->includeFile;}/*!  Returns whether the widget registered as \a id is a form.*/bool WidgetDatabase::isForm( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return FALSE;    return r->isForm;}/*!  Returns whether the widget registered as \a id can have children.*/bool WidgetDatabase::isContainer( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return FALSE;    return r->isContainer || r->isForm;}bool WidgetDatabase::isCommon( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return FALSE;    return r->isCommon;}QString WidgetDatabase::createWidgetName( int id ){    setupDataBase( id );    QString n = className( id );    if ( n == "QLayoutWidget" )	n = "Layout";    if ( n[ 0 ] == 'Q' )	n = n.mid( 1 );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return n;    n += QString::number( ++r->nameCounter );    return n;}/*!  Returns the id for \a name or -1 if \a name is unknown. */int WidgetDatabase::idFromClassName( const QString &name ){    setupDataBase( -1 );    if ( name.isEmpty() )	return 0;    int *i = className2Id->find( name );    if ( i )	return *i;    if ( name == "FormWindow" )	return idFromClassName( "QLayoutWidget" );#ifdef UIC    setupDataBase( -2 );    i = className2Id->find( name );    if ( i )	return *i;#endif    return -1;}bool WidgetDatabase::hasWidget( const QString &name ){    return className2Id->find( name ) != 0;}WidgetDatabaseRecord *WidgetDatabase::at( int index ){    if ( index < 0 )	return 0;    if ( index >= dbcustom && index < dbcustomcount )	return db[ index ];    if ( index < dbcount )	return db[ index ];    return 0;}void WidgetDatabase::insert( int index, WidgetDatabaseRecord *r ){    if ( index < 0 || index >= dbsize )	return;    db[ index ] = r;    className2Id->insert( r->name, new int( index ) );    if ( index < dbcustom )	dbcount = QMAX( dbcount, index );}void WidgetDatabase::append( WidgetDatabaseRecord *r ){    if ( !was_in_setup )	setupDataBase( -1 );    insert( dbcount++, r );}QString WidgetDatabase::widgetGroup( const QString &g ){    if ( wGroups->find( g ) == -1 )	wGroups->append( g );    return g;}bool WidgetDatabase::isGroupEmpty( const QString &grp ){    WidgetDatabaseRecord *r = 0;    for ( int i = 0; i < dbcount; ++i ) {	if ( !( r = db[ i ] ) )	    continue;	if ( r->group == grp )	    return FALSE;    }    return TRUE;}QString WidgetDatabase::widgetGroup( int i ){    setupDataBase( -1 );    if ( i >= 0 && i < (int)wGroups->count() )	return wGroups->at( i );    return QString::null;}int WidgetDatabase::numWidgetGroups(){    setupDataBase( -1 );    return wGroups->count();}bool WidgetDatabase::isGroupVisible( const QString &g ){    setupDataBase( -1 );    return invisibleGroups->find( g ) == -1;}int WidgetDatabase::addCustomWidget( WidgetDatabaseRecord *r ){    insert( dbcustomcount++, r );    return dbcustomcount - 1;}void WidgetDatabase::customWidgetClassNameChanged( const QString &oldName,						   const QString &newName ){    int id = idFromClassName( oldName );    if ( id == -1 )	return;    WidgetDatabaseRecord *r = db[ id ];    r->name = newName;    className2Id->remove( oldName );    className2Id->insert( newName, new int( id ) );}bool WidgetDatabase::isCustomWidget( int id ){    if ( id >= dbcustom && id < dbcustomcount )	return TRUE;    return FALSE;}bool WidgetDatabase::isCustomPluginWidget( int id ){    setupDataBase( id );    WidgetDatabaseRecord *r = at( id );    if ( !r )	return FALSE;    return r->isPlugin;}bool WidgetDatabase::isWhatsThisLoaded(){    return whatsThisLoaded;}void WidgetDatabase::loadWhatsThis( const QString &docPath ){    QString whatsthisFile = docPath + "/whatsthis";    QFile f( whatsthisFile );    if ( !f.open( IO_ReadOnly ) )	return;    QTextStream ts( &f );    while ( !ts.atEnd() ) {	QString s = ts.readLine();	QStringList l = QStringList::split( " | ", s );	int id = idFromClassName( l[ 1 ] );	WidgetDatabaseRecord *r = at( id );	if ( r )	    r->whatsThis = l[ 0 ];    }    whatsThisLoaded = TRUE;}// ### Qt 3.1: make these publically accessible via QWidgetDatabase API#if defined(UIC)bool dbnounload = FALSE;QStringList *dbpaths = 0;#elseextern QString *qwf_plugin_dir;#endifQPluginManager<WidgetInterface> *widgetManager(){    if ( !widgetPluginManager ) {	QString pluginDir = "/designer";#if !defined(UIC)	if ( qwf_plugin_dir )	    pluginDir = *qwf_plugin_dir;#endif	widgetPluginManager = new QPluginManager<WidgetInterface>( IID_Widget, QApplication::libraryPaths(), pluginDir );	cleanup_manager.add( &widgetPluginManager );#if defined(UIC)	if ( dbnounload )	    widgetPluginManager->setAutoUnload( FALSE );	if ( dbpaths ) {	    QStringList::ConstIterator it = dbpaths->begin();	    for ( ; it != dbpaths->end(); ++it )		widgetPluginManager->addLibraryPath( *it );	}#endif    }    return widgetPluginManager;}

⌨️ 快捷键说明

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