I'll try and explain what I think was happening in the original code and what 
I think should happen.

First, the general "inset and popup" philosophy:

When I launch the popup to an inset, I make a local copy or that inset's 
parameters. This is what is made available to the popup. Changes made in the 
popup are to the local copy; only when the Apply or OK buttons are pressed 
are the local changes Applied to the inset.

The External Material popup currently lacks an Apply button, but this can 
easily be added later.

It has three buttons
        Edit file
        View Result
        Update result

which ultimately call
        inset()->editExternal();
        inset()->viewExternal();
        inset()->updateExternal();

Note that these are methods of the Inset, not of its params struct.

So, in order for these methods to be invoked correctly, the inset must first 
be updated with the current contents of the params struct, extracted as 
necessary from the popup's info fields.

Effectively, therefore, these three buttons are
        Apply & Edit file
        Apply & View Result
        Apply & Update result.

This is what happens now (or rather, what happened before I hacked 
FormExternal into a controller and a view and did so incorrectly!)

This clearly doesn't fit in with the general "inset and popup" philosophy in 
which all changes in the popup are to the local copy of the params struct and 
these are Applied to the inset only at the very end through the OK button.

Here's what I propose:
* Only Apply changes to the Inset at the end through pressing OK. This will 
occur if I create this method:

void ControlExternal::applyParamsToInset()
{
        inset()->setFromParams(params());
        lv_.view()->updateInset(inset(), true);
}

* Pressing the "Edit file" button calls editExternal() which should be:

void ControlExternal::editExternal()
{
        // fill the local, controller's copy of the Params struct with
        // the contents of the popup's fields.
        view().apply();

        // Create a local copy of the inset and initialise it with this
        // params struct.
        InsetExternal ie(params());

        ie.editExternal();

        // Can the above command change the inset's params?
        // I don't believe it can, but if so, update the local copy
        params() = ie.params();
}

Similarly for the other two buttons.

Is this correct or have I got hopelessly confused?

Angus

Reply via email to