Summary: | when a function depends on another, propose to delete both instead of refusing to delete the latter | ||
---|---|---|---|
Product: | [Applications] kmplot | Reporter: | koxinga <koxinga> |
Component: | general | Assignee: | Klaus-Dieter M <kd.moeller> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | simple patch |
Description
koxinga
2007-04-02 18:53:23 UTC
Created attachment 20156 [details]
simple patch
SVN commit 649628 by saxton: If the user trys to delete a function, and other functions depend on this function, then give the option of deleting these other functions in addition. Thanks for the good bug report, koxinga. BUG: 143748 M +42 -10 parser.cpp --- trunk/KDE/kdeedu/kmplot/kmplot/parser.cpp #649627:649628 @@ -604,23 +604,55 @@ bool Parser::removeFunction( Function * item ) { - foreach ( Function * it, m_ufkt ) + // Build up a list of functions that need to be removed is this function is removed + QList<Function *> toRemove; + QStringList otherRemoveNames; + QList<Function *> newFunctions; // Added since the last iteration + + toRemove << item; + newFunctions << item; + + while ( ! newFunctions.isEmpty() ) { - if ( it == item ) - continue; + QList<Function *> currentFunctions = newFunctions; + newFunctions.clear(); - if ( it->dependsOn( item ) ) + foreach ( Function *f, currentFunctions ) { - KMessageBox::sorry(0,i18n("This function is depending on an other function")); - return false; + foreach ( Function *other, m_ufkt ) + { + if ( (other==f) || toRemove.contains(other) ) + continue; + + if ( other->dependsOn( f ) ) + { + toRemove << other; + otherRemoveNames << other->name(); + newFunctions << other; + } + } } } - uint const id = item->id(); - m_ufkt.remove(id); - delete item; + if ( toRemove.size() > 1 ) + { + KGuiItem buttonContinue = KStandardGuiItem::cont(); + buttonContinue.setText( i18n("Remove all") ); + + int answer = KMessageBox::warningContinueCancel( 0, i18n( "The function %1 is depended upon by the following functions: %2. These must be removed in addition.", item->name(), otherRemoveNames.join(", ") ), QString(), buttonContinue ); + + if ( answer == KMessageBox::Cancel ) + return false; + } - emit functionRemoved( id ); + foreach ( Function *f, toRemove ) + { + uint id = f->id(); + m_ufkt.remove( id ); + delete f; + emit functionRemoved( id ); + } + return true; } |