Angus Leeming <[EMAIL PROTECTED]> writes:

| I'm thinking of adding a new variable to class Inset:
| 
| class Inset {
|       bool isInserted() const { return inserted_; }
|       bool inserted_;
| }

I don't like it, and do not see why this is needed.



| The strategy I outline below is for an InsetCitation, but I think that it also
| holds true for other insets and so the variable should go in the top level
| class. Thoughts?
| 
| Angus
| 
| =============================================================
| Here's the reasoning:
| 
| When a new Inset is created this variable (Inset::inserted_) is false. It is set
| to true in  LyXParagraph::InsertInset() once the inset is inserted into the
| insetlist.
| 
| This allows us to call the citation dialog from LyXFunc::Dispatch (when
| creating a new InsetCitation):
|       case LFUN_INSERT_CITATION:
|               owner->getDialogs()->showCitation( new InsetCitation(argument) );
|               break;
| 
| and from BufferView::Pimpl::workAreaButtonRelease (when launching the citation
| dialog for an existing InsetCitation)
|       switch( inset_hit->LyxCode() ) {
|       case Inset::CITATION_CODE:
|               owner_->getDialogs()->showCitation( inset_hit );
|               break;
|       default:
|               inset_hit->Edit(bv_, x, y, button);
|               break;
|       }
| 
| The Dialogs::showCitation signal is connected to 
| void FormCitation::showInset( InsetCitation * inset )
| 
| interrogation of inset->isInserted() will allow the dialog to decide what to do
| with the inset in the callback functions called when the Ok or Cancel buttons
| are pressed. 

Should be possible to decide even without that flag.

- on cancel just do nothing
- on ok/apply update the inset with the information in the dialog

I belive that only opon return (in lyxfunc) from the dialogs with the
new info in set in the inset should it be included into the document.

You can have a stateflag on showCitation if you want to.

| Ie, if the inset contains some data, then a new inset must be inserted in the
| insetlist
| If, however, it is empty, then a new inset should be simply deleted,
| whilst an old one should be removed from the insetlist.

no, sometimes empty insets should be allowed... fex inseturl or
citations used for placeholders. (I am going to reference somthing
here but I don't know what yet)

        Lgb


Reply via email to