On Friday 02 August 2002 2:42 pm, Dekel Tsur wrote:
> On Fri, Aug 02, 2002 at 12:37:11PM +0100, Angus Leeming wrote:
> > However...
> >
> > I think I've come to the opposite conclusion. If we overload addPreview
> > then things like tables could generate a preview of the entire table if
> > they so desired.
>
> If you want to preview a table, you can always overload addPreview.
> But you don't need there a code to iterate over the cells.

Sorry, I don't follow. How do I know outside addPreview if this particular 
inset has added a Preview or not. Perhaps it should return true if it does 
so. Then we'd have code so:

void Previews::generateBufferPreviews(Buffer const & buffer) const
{
        PreviewLoader & ploader = loader(&buffer);

        Buffer::inset_iterator it  = buffer.inset_const_iterator_begin();
        Buffer::inset_iterator end = buffer.inset_const_iterator_end();

        for (; it != end; ++it) {
                if (!(*it)->addPreview(ploader)) {
                        // iterate over insets contained by *(*it).
                        InsetIterator it2 = (*it)->begin_insets();
                        InsetIterator end 2  = (*it)->end_insets();
                        for (; it2 != end2; ++it2) {
                                if (!it2->addPreview(ploader)) {
                                        // do the same thing again
                                }
                        }
                }
        }

        ploader.startLoading();
}

Ok, so we'd have a recursive function call for the inner loops, but I don't 
think that this is cleaner than overloading (maybe three?) 
InsetXXX::addPreview methods.

Angus

Reply via email to