Short Descrip: Better handling: invalidated accts wrt AggObj Linking stucture Bug Number: 4101 Release notes (y/n): Yes For Release Nums: 5.3 Gnats 4101: OpenObj dialog lets you create illegal accounts Better Title: Open Obj Dlg: Change in AggObj Linking Structure quietly invalidates existing Accounts. When the user changes an AggObj's linking structure, if that results in an invalid account, the user is given the choice to abort the linking structure change. If the user chooses to allow that linking structure change, when subsequently saving the model, the invalid account is not written out to the model file, and an error is reported. Being that an Aggregate Object's linking structure is encoded via a method category selection, the validity of existing accounts with respect to a change of the AggObject's linking structure is based on a new virtual method mechanism defined in this virtual SimObj method: virtual QList accountsViolatingMethodSel ( const QString& category, const QString& method) const; Initially (for Gnats 4101), this virtual method has a non-null implemenation only for the EngrObjs/AggDiversionSite class. Repeated inline character string constants for AggObj Linking Structure "methods" were replaced with symbols: const QString ELEM_LINKING_STRUCTURE_NONE ("noStructure"); const QString ELEM_LINKING_STRUCTURE_SEQUENTIAL ("sequentialStructure"); const QString ELEM_LINKING_STRUCTURE_LUMPED ("lumpedStructure"); Related fixes: (1) OpenObj Dlg for an AggObj, Accounts Tab: Adding an Account to the top-level AggObj showed the Account treeview item at the top-level. But loading a model having that showed such an Account treeview item at the 2nd level. I realized that the former case was a bug, introduced by an incorrect change in callback handling. That's now fixed. (2) If the user proceeded with a problematic linking structure change (which results in an existing account becoming "invalid"), the invalid account was NOT being dropped from the subsequently saved model file. This was causing an aborted load when loading that saved model file -- because of the invalid account. Now, such an account is NOT written out to the model file, but an error is reporting during the save (which does not prevent the completion of the save operation). ------------------- Sim/SimObj.hpp Sim/SimObj.Acct.cpp ------------------- New public methods: virtual QList accountsViolatingMethodSel ( const QString& category, const QString& method) const; virtual bool accountViolatesMethodSel ( const Account*, const QString& category, const QString& method, QString& retErrMessage) const { return (false); } QList getAccounts() const; Unrelated correction (return type): OLD: virtual bool aggObjElementsNumAccounts() const { return (0); } NEW: virtual int aggObjElementsNumAccounts() const { return (0); } Change to method: bool SimObj::saveAccounts(cwostream &os) const ... Before writing out each Account, check to see if the existance of ... that account is inconsistent (illegal) with the current AggObj ... linking structure (special method selection). If it is, report an ... error, and refrain from writing out the account. ---------------------------------- EngrObjs/AggDiversionSite.hpp EngrObjs/AggDiversionSite.Acct.cpp ---------------------------------- Implementation of new SimObj virtual methods: QList accountsViolatingMethodSel ( const QString& category, const QString& method) const; bool accountViolatesMethodSel ( const Account*, const QString& category, const QString& method, QString& retErrMessage) const; ------------------------------ EngrObjs/WaterUser.Globals.cpp ------------------------------ Redundant Link Structure "Mirror" Category Methods made non-redundant (i.e. defined in terms of libEngrObjsGlobals symbols): // Link Structure Mirror Category Methods: const QString WU_NO_STRUCT (ELEM_LINKING_STRUCTURE_NONE); const QString WU_SEQUENTIAL_STRUCT (ELEM_LINKING_STRUCTURE_SEQUENTIAL); const QString WU_LUMPED_STRUCT (ELEM_LINKING_STRUCTURE_LUMPED); ------------------------------- EngrObjs/libEngrObjsGlobals.hpp EngrObjs/libEngrObjsGlobals.cpp ------------------------------- New method name symbols: // Aggregate Object Linking Structure Method Names const QString ELEM_LINKING_STRUCTURE_NONE ("noStructure"); const QString ELEM_LINKING_STRUCTURE_SEQUENTIAL ("sequentialStructure"); const QString ELEM_LINKING_STRUCTURE_LUMPED ("lumpedStructure"); ----------------------------- EngrObjs/AggDiversionSite.cpp EngrObjs/WaterUser.Acct.cpp ----------------------------- Use of new Aggregate Object Linking Structure Method Name SYMBOLS instead of redundant inline character string constants. --------------------------------- Q3GUI/OpenObjectDlg.hpp Q3GUI/OpenObjectDlg.cpp Q3GUI/OpenObjectDlg.ListItems.cpp --------------------------------- New private method: bool okToChangeLinkingStruct (const QString& methName) const; Change to method: void OpenObjectDlg::accountAdded (Account*) ... For AggObj's, place ALL Account treeview items at the 2nd level. Change to method: void OpenObjectDlg::changeLinkStructure (QAction*) ... Confirm the linking structure change ALSO with the new method, ... okToChangeLinkingStruct(). If the linking structure invalidates ... any existing Accounts, give the user the choice to proceed or not. ... And if not, restore the original linking structure radion button ... state. ------------------------- Sim/AggregateObj.hpp Sim/AggregateObj.cpp Sim/AggregateObj.Acct.cpp ------------------------- Correction in virtual method return type. (Virtual from SimObj): OLD: virtual bool aggObjElementsNumAccounts() const { return (0); } NEW: virtual int aggObjElementsNumAccounts() const { return (0); } Added public method: QList getAllAccounts() const; ------------------ Sim/libSimMsgs.hpp Sim/libSimMsgs.cpp ------------------ Added message: { MSG_ACCTOBJ_METH_CONFL_DROP, "Dropping Account. %s" }, --------------------------- Accounting/AccountTable.hpp Accounting/AccountTable.cpp --------------------------- Added method: QList getAccounts() const; ---