In tools > Preferences > File Handling > File Formats
my first entry is BMP. Despite the fact that "gimp" is in the viewerCO combo 
box, it is set to Custom and "gimp" is in the text box. What should happen is 
that "gimp" should be set in the combo box. (Note that gimp is just being used 
as an example here.)

This happens because <<"gimp">> is being compared to <<gimp>>. Pasted at the 
end of this email is PrefFileformats::updateViewers(), which does the work. 
PrefFileformats::updateEditors() has the same problem and similar code.

Which is the best solution?

(a) change the source of <<"gimp">> to be <<gimp>>
(b) change the source of <<gimp>> to be <<"gimp">>
(c) leave the two sources the same and change updateComboBox so that it changes 
<<"gimp">> to <<gimp>>
(d) leave the two sources the same and change updateViewers?

[By the "source of <<"gimp">>" I am referring to viewer_alternatives and its 
origins and by "the source of <<gimp>>" I am referring to f.viewer() and its 
origins]

On a different note, and more out of curiosity, would it be a bad idea to 
combine updateViewers() and updateEditors() into one function update(enum 
ViewerOrEditor)?

void PrefFileformats::updateViewers()
{
        Format const f = currentFormat();
        viewerCO->blockSignals(true);
        viewerCO->clear();
        viewerCO->addItem(qt_("None"), QString());
        updateComboBox(viewer_alternatives, f.name(), viewerCO);
        viewerCO->addItem(qt_("Custom"), QString("custom viewer"));
        viewerCO->blockSignals(false);

        int pos = viewerCO->findData(toqstr(f.viewer()));
        if (pos != -1) {
                viewerED->clear();
                viewerED->setEnabled(false);
                viewerCO->setCurrentIndex(pos);
        } else {
                viewerED->setEnabled(true);
                viewerED->setText(toqstr(f.viewer()));
                viewerCO->setCurrentIndex(viewerCO->findData(toqstr("custom 
viewer")));
        }
}


void PrefFileformats::updateEditors()
{
        Format const f = currentFormat();
        editorCO->blockSignals(true);
        editorCO->clear();
        editorCO->addItem(qt_("None"), QString());
        updateComboBox(editor_alternatives, f.name(), editorCO);
        editorCO->addItem(qt_("Custom"), QString("custom editor"));
        editorCO->blockSignals(false);

        int pos = editorCO->findData(toqstr(f.editor()));
        if (pos != -1) {
                editorED->clear();
                editorED->setEnabled(false);
                editorCO->setCurrentIndex(pos);
        } else {
                editorED->setEnabled(true);
                editorED->setText(toqstr(f.editor()));
                editorCO->setCurrentIndex(editorCO->findData(toqstr("custom 
editor")));
        }
}

Thank you,

Scott

Reply via email to