Jürgen Spitzmüller wrote:
Abdelrazak Younes wrote:
I understand but I still don't like the scanning... :-)

I don't like it either. But I don't see an alternative yet.

We could just provide the feature if the label is not deeper than one-level. If the user wants to deeply bury the label inside nested insets, then he will miss the feature.
In other word:

if (parent().lyxCode() == InsetBase::CAPTION_CODE)
  name = from_ascii(static_cast<InsetCaption const &>(parent()).type());

if (parent().lyxCode() == InsetBase::OPTARG_CODE
    && parent().parent().lyxCode() == InsetBase::CAPTION_CODE)
  name = from_ascii(
     static_cast<InsetCaption const &>(parent().parent()).type());

The tree-like approach brings very clean and understandable code IMO.

Abdel.

PS: I have a patch mostly ready for that.

Reply via email to