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

📄 command.cpp

📁 Trolltech公司发布的基于C++图形开发环境
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{    if ( !layout )	return;    formWindow()->clearSelection( FALSE );    layout->doLayout();    formWindow()->mainWindow()->objectHierarchy()->rebuild();    MetaDataBase::setSpacing( WidgetFactory::containerOfWidget( lb ), spacing );    MetaDataBase::setMargin( WidgetFactory::containerOfWidget( lb ), margin );}// ------------------------------------------------------------MacroCommand::MacroCommand( const QString &n, FormWindow *fw,			    const QPtrList<Command> &cmds )    : Command( n, fw ), commands( cmds ){}void MacroCommand::execute(){    for ( Command *c = commands.first(); c; c = commands.next() )	c->execute();}void MacroCommand::unexecute(){    for ( Command *c = commands.last(); c; c = commands.prev() )	c->unexecute();}// ------------------------------------------------------------AddTabPageCommand::AddTabPageCommand( const QString &n, FormWindow *fw,				      QTabWidget *tw, const QString &label )    : Command( n, fw ), tabWidget( tw ), tabLabel( label ){    tabPage = new QDesignerWidget( formWindow(), tabWidget, "TabPage" );    tabPage->hide();    index = -1;    MetaDataBase::addEntry( tabPage );}void AddTabPageCommand::execute(){    if ( index == -1 )	index = ( (QDesignerTabWidget*)tabWidget )->count();    tabWidget->insertTab( tabPage, tabLabel, index );    tabWidget->showPage( tabPage );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );}void AddTabPageCommand::unexecute(){    tabWidget->removePage( tabPage );    tabPage->hide();    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );}// ------------------------------------------------------------MoveTabPageCommand::MoveTabPageCommand( const QString &n, FormWindow *fw,				      QTabWidget *tw, QWidget* page, const QString& label, int nIndex, int oIndex )    : Command( n, fw ), tabWidget( tw ), tabPage( page ), tabLabel( label ){    newIndex = nIndex;    oldIndex = oIndex;}void MoveTabPageCommand::execute(){    ((QDesignerTabWidget*)tabWidget )->removePage( tabPage );    ((QDesignerTabWidget*)tabWidget )->insertTab( tabPage, tabLabel, newIndex );    ((QDesignerTabWidget*)tabWidget )->showPage( tabPage );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );}void MoveTabPageCommand::unexecute(){    ((QDesignerTabWidget*)tabWidget )->removePage( tabPage );    ((QDesignerTabWidget*)tabWidget )->insertTab( tabPage, tabLabel, oldIndex );    ((QDesignerTabWidget*)tabWidget )->showPage( tabPage );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );}// ------------------------------------------------------------DeleteTabPageCommand::DeleteTabPageCommand( const QString &n, FormWindow *fw,					    QTabWidget *tw, QWidget *page )    : Command( n, fw ), tabWidget( tw ), tabPage( page ){    tabLabel = ( (QDesignerTabWidget*)tabWidget )->pageTitle();    index = ( (QDesignerTabWidget*)tabWidget )->currentPage();}void DeleteTabPageCommand::execute(){    tabWidget->removePage( tabPage );    tabPage->hide();    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );}void DeleteTabPageCommand::unexecute(){    tabWidget->insertTab( tabPage, tabLabel, index );    tabWidget->showPage( tabPage );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );}// ------------------------------------------------------------AddWidgetStackPageCommand::AddWidgetStackPageCommand( const QString &n, FormWindow *fw,						      QDesignerWidgetStack *ws )    : Command( n, fw ), widgetStack( ws ){    stackPage = new QDesignerWidget( formWindow(), widgetStack, "WStackPage" );    stackPage->hide();    index = -1;    MetaDataBase::addEntry( stackPage );}void AddWidgetStackPageCommand::execute(){    index = widgetStack->insertPage( stackPage, index );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( 0 );}void AddWidgetStackPageCommand::unexecute(){    index = widgetStack->removePage( stackPage );    stackPage->hide();    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->tabsChanged( 0 );}DeleteWidgetStackPageCommand::DeleteWidgetStackPageCommand( const QString &n, FormWindow *fw,							    QDesignerWidgetStack *ws, QWidget *page )    : Command( n, fw), widgetStack( ws ), stackPage( page ){    index = -1;}void DeleteWidgetStackPageCommand::execute(){    index = widgetStack->removePage( stackPage );    stackPage->hide();    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->widgetRemoved( stackPage );}void DeleteWidgetStackPageCommand::unexecute(){    index = widgetStack->insertPage( stackPage, index );    widgetStack->raiseWidget( stackPage );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->widgetInserted( stackPage );}// ------------------------------------------------------------AddWizardPageCommand::AddWizardPageCommand( const QString &n, FormWindow *fw,					    QWizard *w, const QString &label, int i, bool s )    : Command( n, fw ), wizard( w ), pageLabel( label ){    page = new QDesignerWidget( formWindow(), wizard, "WizardPage" );    page->hide();    index = i;    show = s;    MetaDataBase::addEntry( page );}void AddWizardPageCommand::execute(){    if ( index == -1 )	index = wizard->pageCount();    wizard->insertPage( page, pageLabel, index );    if ( show )	( (QDesignerWizard*)wizard )->setCurrentPage( ( (QDesignerWizard*)wizard )->pageNum( page ) );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}void AddWizardPageCommand::unexecute(){    wizard->removePage( page );    page->hide();    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}// ------------------------------------------------------------DeleteWizardPageCommand::DeleteWizardPageCommand( const QString &n, FormWindow *fw,						  QWizard *w, int i, bool s )    : Command( n, fw ), wizard( w ), index( i ){    show = s;}void DeleteWizardPageCommand::execute(){    page = wizard->page( index );    pageLabel = wizard->title( page );    wizard->removePage( page );    page->hide();    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}void DeleteWizardPageCommand::unexecute(){    wizard->insertPage( page, pageLabel, index );    if ( show )	( (QDesignerWizard*)wizard )->setCurrentPage( ( (QDesignerWizard*)wizard )->pageNum( page ) );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}// ------------------------------------------------------------RenameWizardPageCommand::RenameWizardPageCommand( const QString &n, FormWindow *fw,						  QWizard *w, int i, const QString& name )    : Command( n, fw ), wizard( w ), index( i ), label( name ){}void RenameWizardPageCommand::execute(){    page = wizard->page( index );    QString oldLabel = wizard->title( page );    wizard->setTitle( page, label );    label = oldLabel;    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );}void RenameWizardPageCommand::unexecute(){    execute();}// ------------------------------------------------------------SwapWizardPagesCommand::SwapWizardPagesCommand( const QString &n, FormWindow *fw, QWizard *w, int i1, int i2 )    : Command( n, fw ), wizard( w ), index1( i1 ), index2( i2 ){}void SwapWizardPagesCommand::execute(){    QWidget *page1 = wizard->page( index1 );    QWidget *page2 = wizard->page( index2 );    QString page1Label = wizard->title( page1 );    QString page2Label = wizard->title( page2 );    wizard->removePage( page1 );    wizard->removePage( page2 );    wizard->insertPage( page1, page1Label, index2 );    wizard->insertPage( page2, page2Label, index1 );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}void SwapWizardPagesCommand::unexecute(){    execute();}// ------------------------------------------------------------MoveWizardPageCommand::MoveWizardPageCommand( const QString &n, FormWindow *fw, QWizard *w, int i1, int i2 )    : Command( n, fw ), wizard( w ), index1( i1 ), index2( i2 ){}void MoveWizardPageCommand::execute(){    QWidget *page = wizard->page( index1 );    QString pageLabel = wizard->title( page );    wizard->removePage( page );    wizard->insertPage( page, pageLabel, index2 );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}void MoveWizardPageCommand::unexecute(){    // ###FIX: index1 may be the wrong place    QWidget *page = wizard->page( index2 );    QString pageLabel = wizard->title( page );    wizard->removePage( page );    wizard->insertPage( page, pageLabel, index1 );    formWindow()->emitUpdateProperties( formWindow()->currentWidget() );    formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );}// ------------------------------------------------------------AddConnectionCommand::AddConnectionCommand( const QString &name, FormWindow *fw,					    MetaDataBase::Connection c )    : Command( name, fw ), connection( c ){}void AddConnectionCommand::execute(){    MetaDataBase::addConnection( formWindow(), connection.sender,				 connection.signal, connection.receiver, connection.slot );    if ( connection.receiver == formWindow()->mainContainer() )	formWindow()->mainWindow()->propertyeditor()->eventList()->setup();}void AddConnectionCommand::unexecute(){    MetaDataBase::removeConnection( formWindow(), connection.sender,				    connection.signal, connection.receiver, connection.slot );    if ( connection.receiver == formWindow()->mainContainer() )	formWindow()->mainWindow()->propertyeditor()->eventList()->setup();}// ------------------------------------------------------------RemoveConnectionCommand::RemoveConnectionCommand( const QString &name, FormWindow *fw,						  MetaDataBase::Connection c )    : Command( name, fw ), connection( c ){}void RemoveConnectionCommand::execute(){    MetaDataBase::removeConnection( formWindow(), connection.sender,				    connection.signal, connection.receiver, connection.slot );    if ( connection.receiver == formWindow()->mainContainer() )	formWindow()->mainWindow()->propertyeditor()->eventList()->setup();}void RemoveConnectionCommand::unexecute(){    MetaDataBase::addConnection( formWindow(), connection.sender,				 connection.signal, connection.receiver, connection.slot );    if ( connection.receiver == formWindow()->mainContainer() )	formWindow()->mainWindow()->propertyeditor()->eventList()->setup();}// ------------------------------------------------------------AddFunctionCommand::AddFunctionCommand( const QString &name, FormWindow *fw, const QCString &f,					const QString& spec, const QString &a, const QString &t,					const QString &l, const QString &rt )    : Command( name, fw ), function( f ), specifier( spec ), access( a ), functionType( t ), language( l ),      returnType( rt ){}void AddFunctionCommand::execute(){    MetaDataBase::addFunction( formWindow(), function, specifier, access, functionType, language, returnType );    formWindow()->mainWindow()->functionsChanged();    if ( formWindow()->formFile() )	formWindow()->formFile()->setModified( TRUE );}void AddFunctionCommand::unexecute(){    MetaDataBase::removeFunction( formWindow(), function, specifier, access, functionType,  language, returnType );    formWindow()->mainWindow()->functionsChanged();    if ( formWindow()->formFile() )	formWindow()->formFile()->setModified( TRUE );}// ------------------------------------------------------------ChangeFunctionAttribCommand::ChangeFunctionAttribCommand( const QString &name, FormWindow *fw, MetaDataBase::Function f,							  const QString &on, const QString &os,							  const QString &oa, const QString &ot, const QString &ol,							  const QString &ort )    : Command( name, fw ), oldName( on ), oldSpec( os ), oldAccess( oa ),      oldType( ot ), oldLang( ol ), oldReturnType( ort ){	    newName = f.function;	    newSpec = f.specifier;	    newAccess = f.access;	    newType = f.type;	    newLang = f.language;	    newReturnType = f.returnType;}void ChangeFunctionAttribCommand::execute(){    MetaDataBase::changeFunctionAttributes( formWindow(), oldName, newName, newSpec, newAccess,					    newType, newLang, newReturnType );    formWindow()->formFile()->functionNameChanged( oldName, newName );    formWindow()->formFile()->functionRetTypeChanged( newName, oldReturnType, newReturnType );    formWindow()->mainWindow()->functionsChanged();    if ( formWindow()->formFile() )	formWindow()->formFile()->setModified( TRUE );}void ChangeFunctionAttribCommand::unexecute(){

⌨️ 快捷键说明

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