Fix: QComboBox rwSetting: Selecting first item didn't work with blank initial value [5641] Bug Number: 5641 Release notes (y/n): Yes For Release Nums: 6.7, and maybe 6.6.6 Gnats 5641: Combo Box Settings (e.g. in Model Reports or Scripts config): Selecting first item doesn't always work Note: In case we want to apply this fix to the 6.6 release, this commit is being made to a temporary git branch on top of the current Release_66 head. See branch: Bug5641_66. ----------------------- Problem Description: ----------------------- Three RiverWare features make use of a "property editor design" for presenting a list of configuration settings. These are: Model Reports, Scripts, and Output Canvases. There are several ways in which setting value editing is implemented. The settings which: (a) make use of a "combo box" (aka "option menu") for picking among a limited set of valid values, and (b) which are initially created with a blank value (i.e. not among the set of valid values) have a problem. For new instances (having a blank value), selecting the first (or only) item among the valid set of values HAS NO EFFECT. The setting remains blank. This problem applies at least to these settings: (1) Model Reports: Plot Page, Name (picked among the set of existing saved Plot Pages). (2) Model Reports: Chart, Name (picked among the set of existing Chart output devices). (3) Scripts: Execute DMI, DMI Name (picked among the set of existing DMIs). This can be demonstrated with this sequence of operations, e.g. in an empty model. (1) Create a (trivial) DMI: ... Workspace Menu: DMI >> DMI Manager ... DMI >> New DMI. (2) Create a Script: ... Workspace Menu: Scripts >> Script Manager ... Edit >> Add Script ... (3) In the Script Editor Dialog ... Add Action: Execute DMI ... (4) In the bottom panel, click in the "Value" column of the DMI Name and attempt to select the only item in the combo box, or just click away. Either should result in the single DMI instance name being assigned to the DMI Name property. But notice that it remains blank. ------------------ Fix Description: ------------------ A solution to this problem has been devised. Note that rwSettingTree:: EnumeratedTextEditor is a Qt4 QComboBox subclass. (A) Changes to the rwSettingTree::EnumeratedTextEditor::initSignals() method: (1) No longer connect from the QComboBox currentIndexChanged(const QString&) signal. (2) Connect to the QComboBox "activated(int)" signal. (3) Connect to the QComboBox's QLineEdit's "returnPressed()" signal. (B) In the rwSettingTree::EnumeratedTextEditor class, override the QComboBox::showPopup() virtual method to set an internal flag to indicate the method is currently executing, and call the base class method after setting, and before clearing that flag. (C) In the rwSettingTree::EnumeratedTextEditor class, override the focusOutEvent(QFocusEvent*) event handler (virtual from QWidget). Unless the 'showPopup()' method is active (see prior item), perform edit-finished processing. Then, unconditionally call the base class method. ---