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

📄 command.cpp

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// ------------------------------------------------------------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 );}void AddConnectionCommand::unexecute(){    MetaDataBase::removeConnection( formWindow(), connection.sender, connection.signal, connection.receiver, connection.slot );}// ------------------------------------------------------------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 );}void RemoveConnectionCommand::unexecute(){    MetaDataBase::addConnection( formWindow(), connection.sender, connection.signal, connection.receiver, connection.slot );}// ------------------------------------------------------------AddSlotCommand::AddSlotCommand( const QString &name, FormWindow *fw, const QCString &s, const QString &a )    : Command( name, fw ), slot( s ), access( a ){}void AddSlotCommand::execute(){    MetaDataBase::addSlot( formWindow(), slot, access );}void AddSlotCommand::unexecute(){    MetaDataBase::removeSlot( formWindow(), slot, access );}// ------------------------------------------------------------RemoveSlotCommand::RemoveSlotCommand( const QString &name, FormWindow *fw, const QCString &s, const QString &a )    : Command( name, fw ), slot( s ), access( a ){}void RemoveSlotCommand::execute(){    MetaDataBase::removeSlot( formWindow(), slot, access );}void RemoveSlotCommand::unexecute(){    MetaDataBase::addSlot( formWindow(), slot, access );}// ------------------------------------------------------------LowerCommand::LowerCommand( const QString &name, FormWindow *fw, const QWidgetList &w )    : Command( name, fw ), widgets( w ){}void LowerCommand::execute(){    for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {	w->lower();	formWindow()->raiseSelection( w );    }	}void LowerCommand::unexecute(){    for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {	w->raise();	formWindow()->raiseSelection( w );    }}// ------------------------------------------------------------RaiseCommand::RaiseCommand( const QString &name, FormWindow *fw, const QWidgetList &w )    : Command( name, fw ), widgets( w ){}void RaiseCommand::execute(){    for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {	w->raise();	formWindow()->raiseSelection( w );    }	}void RaiseCommand::unexecute(){    for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {	w->lower();	formWindow()->raiseSelection( w );    }}// ------------------------------------------------------------PasteCommand::PasteCommand( const QString &n, FormWindow *fw,			      const QWidgetList &w )    : Command( n, fw ), widgets( w ){}void PasteCommand::execute(){    for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {	w->show();	formWindow()->selectWidget( w );	formWindow()->widgets()->insert( w, w );	formWindow()->mainWindow()->objectHierarchy()->widgetInserted( w );    }}void PasteCommand::unexecute(){    for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {	w->hide();	formWindow()->selectWidget( w, FALSE );	formWindow()->widgets()->remove( w );	formWindow()->mainWindow()->objectHierarchy()->widgetRemoved( w );    } }// ------------------------------------------------------------TabOrderCommand::TabOrderCommand( const QString &n, FormWindow *fw,				  const QWidgetList &ol, const QWidgetList &nl )    : Command( n, fw ), oldOrder( ol ), newOrder( nl ){}void TabOrderCommand::merge( Command *c ){    TabOrderCommand *cmd = (TabOrderCommand*)c;    newOrder = cmd->newOrder;}bool TabOrderCommand::canMerge( Command * ){    return TRUE;}void TabOrderCommand::execute(){    MetaDataBase::setTabOrder( formWindow(), newOrder );}void TabOrderCommand::unexecute(){    MetaDataBase::setTabOrder( formWindow(), oldOrder );}// ------------------------------------------------------------#if defined(Q_FULL_TEMPLATE_INSTANTIATION)bool PopulateListBoxCommand::Item::operator==( const PopulateListBoxCommand::Item& ) const{    return FALSE;}#endifPopulateListBoxCommand::PopulateListBoxCommand( const QString &n, FormWindow *fw,						QListBox *lb, const QValueList<Item> &items )    : Command( n, fw ), newItems( items ), listbox( lb ){    QListBoxItem *i = 0;    for ( i = listbox->firstItem(); i; i = i->next() ) {	Item item;	if ( i->pixmap() )	    item.pix = *i->pixmap();	item.text = i->text();	oldItems.append( item );    }}void PopulateListBoxCommand::execute(){    listbox->clear();    for ( QValueList<Item>::Iterator it = newItems.begin(); it != newItems.end(); ++it ) {	Item i = *it;	if ( !i.pix.isNull() )	    (void)new QListBoxPixmap( listbox, i.pix, i.text );	else	    (void)new QListBoxText( listbox, i.text );    }}void PopulateListBoxCommand::unexecute(){    listbox->clear();    for ( QValueList<Item>::Iterator it = oldItems.begin(); it != oldItems.end(); ++it ) {	Item i = *it;	if ( !i.pix.isNull() )	    (void)new QListBoxPixmap( listbox, i.pix, i.text );	else	    (void)new QListBoxText( listbox, i.text );    }}// ------------------------------------------------------------#if defined(Q_FULL_TEMPLATE_INSTANTIATION)bool PopulateIconViewCommand::Item::operator==( const PopulateIconViewCommand::Item& ) const{    return FALSE;}#endifPopulateIconViewCommand::PopulateIconViewCommand( const QString &n, FormWindow *fw,						  QIconView *iv, const QValueList<Item> &items )    : Command( n, fw ), newItems( items ), iconview( iv ){    QIconViewItem *i = 0;    for ( i = iconview->firstItem(); i; i = i->nextItem() ) {	Item item;	if ( i->pixmap() )	    item.pix = *i->pixmap();	item.text = i->text();	oldItems.append( item );    }}void PopulateIconViewCommand::execute(){    iconview->clear();    for ( QValueList<Item>::Iterator it = newItems.begin(); it != newItems.end(); ++it ) {	Item i = *it;	(void)new QIconViewItem( iconview, i.text, i.pix );    }}void PopulateIconViewCommand::unexecute(){    iconview->clear();    for ( QValueList<Item>::Iterator it = oldItems.begin(); it != oldItems.end(); ++it ) {	Item i = *it;	(void)new QIconViewItem( iconview, i.text, i.pix );    }}// ------------------------------------------------------------PopulateListViewCommand::PopulateListViewCommand( const QString &n, FormWindow *fw,						  QListView *lv, QListView *from )    : Command( n, fw ), listview( lv ){    newItems = new QListView();    newItems->hide();    transferItems( from, newItems );    oldItems = new QListView();    oldItems->hide();    transferItems( listview, oldItems );}void PopulateListViewCommand::execute(){    listview->clear();    transferItems( newItems, listview );}void PopulateListViewCommand::unexecute(){    listview->clear();    transferItems( oldItems, listview );}void PopulateListViewCommand::transferItems( QListView *from, QListView *to ){    QHeader *header = to->header();    while ( header->count() )	to->removeColumn( 0 );    QHeader *h2 = from->header();    for ( int i = 0; i < h2->count(); ++i ) {	to->addColumn( h2->label( i ) );	if ( h2->iconSet( i ) && !h2->iconSet( i )->pixmap().isNull() )	    header->setLabel( i, *h2->iconSet( i ), h2->label( i ) );	header->setResizeEnabled( h2->isResizeEnabled( i ), i );	header->setClickEnabled( h2->isClickEnabled( i ), i );    }    QListViewItemIterator it( from );    QStack<QListViewItem> fromParents, toParents;    fromParents.push( 0 );    toParents.push( 0 );    QStack<QListViewItem> toLasts;    QListViewItem *fromLast = 0;    toLasts.push( 0 );    int cols = from->columns();    to->setSorting( -1 );    from->setSorting( -1 );    for ( ; it.current(); ++it ) {	QListViewItem *i = it.current();	if ( i->parent() == fromParents.top() ) {	    QListViewItem *pi = toParents.top();	    QListViewItem *ni = 0;	    if ( pi )		ni = new QListViewItem( pi, toLasts.top() );	    else		ni = new QListViewItem( to, toLasts.top() );	    for ( int c = 0; c < cols; ++c ) {		ni->setText( c, i->text( c ) );		if ( i->pixmap( c ) )		    ni->setPixmap( c, *i->pixmap( c ) );	    }	    toLasts.pop();	    toLasts.push( ni );	    if ( pi )		pi->setOpen( TRUE );	} else {	    if ( i->parent() == fromLast ) {		fromParents.push( fromLast );		toParents.push( toLasts.top() );		toLasts.push( 0 );		QListViewItem *pi = toParents.top();		QListViewItem *ni = 0;		if ( pi )		    ni = new QListViewItem( pi );		else		    ni = new QListViewItem( to );		for ( int c = 0; c < cols; ++c ) {		    ni->setText( c, i->text( c ) );		    if ( i->pixmap( c ) )			ni->setPixmap( c, *i->pixmap( c ) );		}		toLasts.pop();		toLasts.push( ni );		if ( pi )		    pi->setOpen( TRUE );	    } else {		while ( fromParents.top() != i->parent() ) {		    fromParents.pop();		    toParents.pop();		    toLasts.pop();		}				QListViewItem *pi = toParents.top();		QListViewItem *ni = 0;		if ( pi )		    ni = new QListViewItem( pi, toLasts.top() );		else		    ni = new QListViewItem( to, toLasts.top() );		for ( int c = 0; c < cols; ++c ) {		    ni->setText( c, i->text( c ) );		    if ( i->pixmap( c ) )			ni->setPixmap( c, *i->pixmap( c ) );		}		if ( pi )		    pi->setOpen( TRUE );		toLasts.pop();		toLasts.push( ni );	    }	}	fromLast = i;    }}// ------------------------------------------------------------PopulateMultiLineEditCommand::PopulateMultiLineEditCommand( const QString &n, FormWindow *fw,							    QMultiLineEdit *mle, const QString &txt )    : Command( n, fw ), newText( txt ), mlined( mle ){    oldText = mlined->text();    wasChanged = MetaDataBase::isPropertyChanged( mlined, "text" );}void PopulateMultiLineEditCommand::execute(){    mlined->setText( newText );    MetaDataBase::setPropertyChanged( mlined, "text", TRUE );    formWindow()->emitUpdateProperties( mlined );}void PopulateMultiLineEditCommand::unexecute(){    mlined->setText( oldText );    MetaDataBase::setPropertyChanged( mlined, "text", wasChanged );    formWindow()->emitUpdateProperties( mlined );}

⌨️ 快捷键说明

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