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

📄 formwindow.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    case POINTER_TOOL:	if ( propertyWidget && !isMainContainer( propertyWidget ) && !isWidgetSelected( propertyWidget ) )	    emitShowProperties( mainContainer() );	restoreCursors( this, this );	break;    case ORDER_TOOL:	if ( mainWindow()->formWindow() == this ) {	    mainWindow()->statusBar()->message( tr( "Click widgets to change the tab order...") );	    orderedWidgets.clear();	    showOrderIndicators();	    if ( mainWindow()->formWindow() == this )		emitShowProperties( mainContainer() );	    setCursorToAll( ArrowCursor, this );	}	break;    case CONNECT_TOOL:    case BUDDY_TOOL:	if ( currTool == CONNECT_TOOL )	    mainWindow()->statusBar()->message( tr( "Drag a line to create a connection...") );	else	    mainWindow()->statusBar()->message( tr( "Drag a line to set a buddy...") );	setCursorToAll( CrossCursor, this );	if ( mainWindow()->formWindow() == this )	    emitShowProperties( mainContainer() );	break;    default:	mainWindow()->statusBar()->message( tr( "Click on the form to insert a %1..." ).arg( WidgetDatabase::toolTip( currTool ).lower() ) );	setCursorToAll( CrossCursor, this );	if ( mainWindow()->formWindow() == this )	    emitShowProperties( mainContainer() );	break;    }}void FormWindow::showOrderIndicators(){    hideOrderIndicators();    orderIndicators.setAutoDelete( TRUE );    QObjectList *l = mainContainer()->queryList( "QWidget" );    stackedWidgets = MetaDataBase::tabOrder( this );    if ( l ) {	int order = 1;	for ( QObject *o = l->first(); o; o = l->next() ) {	    QWidget* w = (QWidget*) o;	    if ( w->isShown() &&		 insertedWidgets[ (void*)w ]  &&		 w->focusPolicy() != NoFocus ) {		OrderIndicator* ind = new OrderIndicator( order++, w, this );		orderIndicators.append( ind );		if ( stackedWidgets.findRef( w ) == -1 )		    stackedWidgets.append( w );	    }	}	delete l;    }    updateOrderIndicators();}void FormWindow::hideOrderIndicators(){    orderIndicators.clear();}void FormWindow::updateOrderIndicators(){    int order = 1;    for ( QWidget *w = stackedWidgets.first(); w; w = stackedWidgets.next() ) {	for ( OrderIndicator* i = orderIndicators.first(); i; i = orderIndicators.next() )	    i->setOrder( order, w );	order++;    }}void FormWindow::repositionOrderIndicators(){    for ( OrderIndicator* i = orderIndicators.first(); i; i = orderIndicators.next() )	i->reposition();}void FormWindow::updateUndoInfo(){    commandHistory()->emitUndoRedo();}bool FormWindow::checkCustomWidgets(){    QStringList missingCustomWidgets;    QPtrDictIterator<QWidget> it( insertedWidgets );    for ( ; it.current(); ++it ) {	if ( it.current()->isA( "CustomWidget" ) ) {	    QString className = WidgetFactory::classNameOf( it.current() );	    if ( !MetaDataBase::hasCustomWidget( className ) )		missingCustomWidgets << className;	}    }    if ( !missingCustomWidgets.isEmpty() ) {	QString txt = tr( "The following custom widgets are used in '%1',\n"			  "but are not known to Qt Designer:\n" ).arg( name() );	for ( QStringList::Iterator sit = missingCustomWidgets.begin(); sit != missingCustomWidgets.end(); ++sit )	    txt += "   " + *sit + "\n";	txt += "If you save this form and generate code for it using uic, \n"	       "the generated code will not compile.\n"	       "Do you want to save this form now?";	if ( QMessageBox::information( mainWindow(), tr( "Save Form" ), txt ) == 1 )	    return FALSE;    }    return TRUE;}void FormWindow::setPropertyShowingBlocked( bool b ){    propShowBlocked = b;}bool FormWindow::isPropertyShowingBlocked() const{    return propShowBlocked;}int FormWindow::numSelectedWidgets() const{    return usedSelections.count();}QString FormWindow::copy(){    CHECK_MAINWINDOW_VALUE( QString::null );    Resource resource( mainWindow() );    resource.setWidget( this );    return resource.copy();}void FormWindow::lowerWidgets(){    QWidgetList widgets;    QPtrDictIterator<WidgetSelection> it( usedSelections );    for ( ; it.current(); ++it )	widgets.append( it.current()->widget() );    LowerCommand *cmd = new LowerCommand( tr( "Lower" ), this, widgets );    cmd->execute();    commandHistory()->addCommand( cmd );}static void find_accel( const QString &txt, QMap<QChar, QWidgetList > &accels, QWidget *w ){    int i = txt.find( "&" );    if ( i == -1 )	return;    QChar c = txt[ i + 1 ];    if ( c.isNull() || c == '&' )	return;    c = c.lower();    QMap<QChar, QWidgetList >::Iterator it = accels.find( c );    if ( it == accels.end() ) {	QWidgetList wl;	wl.append( w );	accels.insert( c, wl );    } else {	QWidgetList *wl = &*it;	wl->append( w );    }}void FormWindow::checkAccels(){    CHECK_MAINWINDOW;    QMap<QChar, QWidgetList > accels;    QObjectList *l = mainContainer()->queryList( "QWidget" );    if ( l ) {	for ( QObject *o = l->first(); o; o = l->next() ) {	    if ( ( (QWidget*)o )->isVisibleTo( this ) &&		 insertedWidgets[ (void*)o ] ) {		QWidget *w = (QWidget*)o;		const QMetaProperty* text =		    w->metaObject()->property( w->metaObject()->findProperty( "text", TRUE ), TRUE );		const QMetaProperty* title =		    w->metaObject()->property( w->metaObject()->findProperty( "title", TRUE ), TRUE );		const QMetaProperty* pageTitle =		    w->metaObject()->property( w->metaObject()->findProperty( "pageTitle", TRUE ), TRUE );		if ( text )		    find_accel( w->property( "text" ).toString(), accels, w );		if ( title )		    find_accel( w->property( "title" ).toString(), accels, w );		if ( pageTitle )		    find_accel( w->property( "pageTitle" ).toString(), accels, w );	    }	}	delete l;    }    bool ok = TRUE;    QWidget *wid;    for ( QMap<QChar, QWidgetList >::Iterator it = accels.begin(); it != accels.end(); ++it ) {	if ( (*it).count() > 1 ) {	    ok = FALSE;	    switch ( QMessageBox::information( mainWindow(), tr( "Check Accelerators" ),					       tr( "Accelerator '%1' is used %2 times."						   ).arg( it.key().upper() ).arg( (*it).count() ),					       tr( "&Select" ),					       tr( "&Cancel" ), QString::null, 2 ) ) {	    case 0: // select		clearSelection( FALSE );		for ( wid = (*it).first(); wid; wid = (*it).next() )		    selectWidget( wid, TRUE );		return;	    case 1: // cancel		return;	    }	}    }    if ( ok )	QMessageBox::information( mainWindow(), tr( "Check Accelerators" ),				  tr( "No accelerator is used more than once." ) );}void FormWindow::raiseWidgets(){    QWidgetList widgets;    QPtrDictIterator<WidgetSelection> it( usedSelections );    for ( ; it.current(); ++it )	widgets.append( it.current()->widget() );    RaiseCommand *cmd = new RaiseCommand( tr( "Raise" ), this, widgets );    cmd->execute();    commandHistory()->addCommand( cmd );}void FormWindow::paste( const QString &cb, QWidget *parent ){    CHECK_MAINWINDOW;    Resource resource( mainWindow() );    resource.setWidget( this );    resource.paste( cb, parent );}void FormWindow::selectAll(){    checkedSelectionsForMove = FALSE;    blockSignals( TRUE );    QObjectList *l = mainContainer()->queryList( "QWidget" );    if ( l ) {	for ( QObject *o = l->first(); o; o = l->next() ) {	    if ( ( (QWidget*)o )->isVisibleTo( this ) &&		 insertedWidgets[ (void*)o ] ) {		selectWidget( (QWidget*)o );	    }	}	delete l;    }    blockSignals( FALSE );    emitSelectionChanged();    if ( propertyWidget )	emitShowProperties( propertyWidget );    emitSelectionChanged();}void FormWindow::layoutHorizontal(){    QWidgetList widgets( selectedWidgets() );    LayoutHorizontalCommand *cmd = new LayoutHorizontalCommand( tr( "Lay out horizontally" ),								this, mainContainer(), 0, widgets );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutVertical(){    QWidgetList widgets( selectedWidgets() );    LayoutVerticalCommand *cmd = new LayoutVerticalCommand( tr( "Lay out vertically" ),							    this, mainContainer(), 0, widgets );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutHorizontalSplit(){    QWidgetList widgets( selectedWidgets() );    LayoutHorizontalSplitCommand *cmd = new LayoutHorizontalSplitCommand( tr( "Lay out horizontally (in splitter)" ),									  this, mainContainer(), 0, widgets );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutVerticalSplit(){    QWidgetList widgets( selectedWidgets() );    LayoutVerticalSplitCommand *cmd = new LayoutVerticalSplitCommand( tr( "Lay out vertically (in splitter)" ),								      this, mainContainer(), 0, widgets );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutGrid(){    int xres = grid().x();    int yres = grid().y();    QWidgetList widgets( selectedWidgets() );    LayoutGridCommand *cmd = new LayoutGridCommand( tr( "Lay out in a grid" ),						    this, mainContainer(), 0, widgets, xres, yres );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutHorizontalContainer( QWidget *w ){    if ( w == this )	w = mainContainer();    QObjectList *l = (QObjectList*)WidgetFactory::containerOfWidget(w)->children();    if ( !l )	return;    QWidgetList widgets;    for ( QObject *o = l->first(); o; o = l->next() ) {	if ( o->isWidgetType() &&	     ( (QWidget*)o )->isVisibleTo( this ) &&	     insertedWidgets.find( (QWidget*)o ) )	    widgets.append( (QWidget*)o );    }    LayoutHorizontalCommand *cmd = new LayoutHorizontalCommand( tr( "Lay out children horizontally" ),								this, mainContainer(), w, widgets );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutVerticalContainer( QWidget *w ){    if ( w == this )	w = mainContainer();    QObjectList *l = (QObjectList*)WidgetFactory::containerOfWidget(w)->children();    if ( !l )	return;    QWidgetList widgets;    for ( QObject *o = l->first(); o; o = l->next() ) {	if ( o->isWidgetType() &&	     ( (QWidget*)o )->isVisibleTo( this ) &&	     insertedWidgets.find( (QWidget*)o ) )	    widgets.append( (QWidget*)o );    }    LayoutVerticalCommand *cmd = new LayoutVerticalCommand( tr( "Lay out children vertically" ),							    this, mainContainer(), w, widgets );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::layoutGridContainer( QWidget *w ){    if ( w == this )	w = mainContainer();    int xres = grid().x();    int yres = grid().y();    QObjectList *l = (QObjectList*)WidgetFactory::containerOfWidget(w)->children();    if ( !l )	return;    QWidgetList widgets;    for ( QObject *o = l->first(); o; o = l->next() ) {	if ( o->isWidgetType() &&	     ( (QWidget*)o )->isVisibleTo( this ) &&	     insertedWidgets.find( (QWidget*)o ) )	    widgets.append( (QWidget*)o );    }    LayoutGridCommand *cmd = new LayoutGridCommand( tr( "Lay out children in a grid" ),						    this, mainContainer(), w, widgets, xres, yres );    clearSelection( FALSE );    commandHistory()->addCommand( cmd );    cmd->execute();}void FormWindow::breakLayout( QWidget *w ){    if ( w == this )	w = mainContainer();    w = WidgetFactory::containerOfWidget( w );    QPtrList<Command> commands;    for (;;) {	if ( !w || w == this )	    break;	if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout &&	     WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( w ) ) ) ) {	    Command *cmd = breakLayoutCommand( w );	    if ( cmd )		commands.insert( 0, cmd );	    if ( !w->inherits( "QLayoutWidget" ) && !w->inherits( "QSplitter" ) )		break;	}	w = w->parentWidget();    }    if ( commands.isEmpty() )	return;    clearSelection( FALSE );    MacroCommand *cmd = new MacroCommand( tr( "Break Layout" ), this, commands );    commandHistory()->addCommand( cmd );    cmd->execute();}BreakLayoutCommand *FormWindow::breakLayoutCommand( QWidget *w ){    CHECK_MAINWINDOW_VALUE( 0 );    QObjectList *l = (QObjectList*)w->children();    if ( !l )	return 0;    QWidgetList widgets;    for ( QObject *o = l->first(); o; o = l->next() ) {	if ( o->isWidgetType() &&	     !mainWindow()->isAToolBarChild( (QWidget*)o ) &&	     ( (QWidget*)o )->isVisibleTo( this ) &&	     insertedWidgets.find( (QWidget*)o ) )	    widg

⌨️ 快捷键说明

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