MacroCommand *LocaleConfigMoney::buildCommand() { MacroCommand *m = new MacroCommand(); if ( m_locale->currencySymbolExplicit() != m_edMonCurSym->text() ) { m->addCommand( new ModifyCurrencySymolCmd( m_locale, m_edMonCurSym->text() ) ); } if (m_locale->monetaryDecimalPlaces() != m_inMonFraDig->value()) { m->addCommand( new ModifyCurrencyFractionalDigitsCmd( m_locale, m_inMonFraDig->value() ) ); } debugPlan<<"buildCommand:"<<m->isEmpty(); if ( m->isEmpty() ) { delete m; return 0; } return m; }
KUndo2Command *LocaleConfigMoneyDialog::buildCommand( Project &project ) { MacroCommand *m = new ModifyProjectLocaleCmd( project, kundo2_i18n( "Modify currency settings" ) ); MacroCommand *cmd = m_panel->buildCommand(); if (cmd) { m->addCommand(cmd); } if ( m->isEmpty() ) { delete m; return 0; } return m; }
MacroCommand *RequestResourcesPanel::buildCommand() { Task *t = m_view->task(); if ( t == 0 ) { return 0; } MacroCommand *cmd = new MacroCommand( i18nc( "(qtundo-format)", "Modify resource allocations" ) ); /*Project *p = */m_view->project(); const QMap<const Resource*, ResourceRequest*> &rmap = m_view->resourceCache(); // First remove all that should be removed for( QMap<const Resource*, ResourceRequest*>::const_iterator rit = rmap.constBegin(); rit != rmap.constEnd(); ++rit ) { if ( rit.value()->units() == 0 ) { ResourceRequest *rr = t->requests().find( rit.key() ); if ( rr ) { cmd->addCommand( new RemoveResourceRequestCmd( rr->parent(), rr ) ); } } } QMap<const ResourceGroup*, ResourceGroupRequest*> groups; // Add/modify const QMap<const ResourceGroup*, ResourceGroupRequest*> &gmap = m_view->groupCache(); for( QMap<const ResourceGroup*, ResourceGroupRequest*>::const_iterator git = gmap.constBegin(); git != gmap.constEnd(); ++git ) { ResourceGroupRequest *gr = t->requests().find( git.key() ); if ( gr == 0 ) { if ( git.value()->units() > 0 ) { gr = new ResourceGroupRequest( const_cast<ResourceGroup*>( git.key() ), git.value()->units() ); cmd->addCommand( new AddResourceGroupRequestCmd( *t, gr ) ); groups[ git.key() ] = gr; } // else nothing } else { cmd->addCommand( new ModifyResourceGroupRequestUnitsCmd( gr, gr->units(), git.value()->units() ) ); } } for( QMap<const Resource*, ResourceRequest*>::const_iterator rit = rmap.constBegin(); rit != rmap.constEnd(); ++rit ) { Resource *resource = const_cast<Resource*>( rit.key() ); ResourceGroup *group = resource->parentGroup(); if ( rit.value()->units() > 0 ) { ResourceRequest *rr = t->requests().find( resource ); if ( rr == 0 ) { ResourceGroupRequest *gr = t->requests().find( group ); if ( gr == 0 ) { if ( groups.contains( group ) ) { gr = groups[ group ]; } else { gr = new ResourceGroupRequest( group, 0 ); groups[ group ] = gr; cmd->addCommand( new AddResourceGroupRequestCmd( *t, gr ) ); } } ResourceRequest *rr = new ResourceRequest( resource, rit.value()->units() ); rr->setRequiredResources( rit.value()->requiredResources() ); cmd->addCommand( new AddResourceRequestCmd( gr, rr ) ); } else { if ( rit.value()->units() != rr->units() ) { cmd->addCommand( new ModifyResourceRequestUnitsCmd( rr, rr->units(), rit.value()->units() ) ); } if ( rit.value()->requiredResources() != rr->requiredResources() ) { cmd->addCommand( new ModifyResourceRequestRequiredCmd( rr, rit.value()->requiredResources() ) ); } } } } if ( cmd->isEmpty() ) { delete cmd; return 0; } return cmd; }