[scribus-dev] Tables GSoC - Weekly Report #6

Andreas Vox andreas.vox at googlemail.com
Mon Jul 11 13:56:48 UTC 2011


Hi Elvis!

Yes, listening to the StyleContext is the way to go.
For listening to an Observable you can just derive from this class and
implement ist changed() method:

// in observabe.h:

template<class OBSERVED>
class SCRIBUS_API Observer {
public:
	virtual void changed(OBSERVED) = 0;
	virtual ~Observer() {}
};

or you use 
      bool Observable::connectObserver(QObject* o, const char* slot);
	bool Observable::disconnectObserver(QObject* o, const char* slot =
0);

to connect an Observable to an QObject-observer; in that case deriving from
QObject is enough.
The Observable::update() method will notify both kinds of observers.

/Andreas	

> -----Ursprüngliche Nachricht-----
> Von: Elvis Stansvik [mailto:elvstone at gmail.com]
> Gesendet: Montag, 11. Juli 2011 14:20
> An: Scribus Development Mailing List
> Betreff: Re: [scribus-dev] Tables GSoC - Weekly Report #6
> 
> 2011/7/11 Elvis Stansvik <elvstone at gmail.com>:
> > 2011/7/11 Elvis Stansvik <elvstone at gmail.com>:
> >> 2011/7/11 Elvis Stansvik <elvstone at gmail.com>:
> >>> ...
> >>> ===Question 2===
> >>> I've now finally hit some problems relating to painting outside of
> the
> >>> table frame (before I didn't have any artifacts because of this,
> but
> >>> now they've started to appear sometimes when changing the border
> >>> through UI).
> >>
> >> I should note that this happens when the border reaches a certain
> >> width, probably when it goes outside the area around the frame that
> is
> >> actually repainted. So I really do think the table should never
> paint
> >> outside its frame. Is it OK if I try to implement the offset thing
> >> (and also at the same time finally get around to setting the
> cliprect
> >> properly, I think I did try early on with using the PoLine but it
> >> wasn't working, I'll try again).
> >>
> >> If it is OK, then my old question from the mid-week mini report is
> >> still valid; How can I be notified of style changes? Since the table
> >> needs to have this offset correctly set at all times, it needs to be
> >> notified of the following style changes, whether they came as a
> result
> >> of a change in a parent style or as a change in the locally stored
> >> style used for direct formatting:
> >>
> >> 1) Table top border changes.
> >> 2) Table left border changes.
> >> 3) Cell top border changes (on cells in row 0)
> >> 4) Cell left border changes (on cells in col 0)
> >
> > After some more investigation I realize that it's not possible to
> > listen to individual style changes, but that it's possible to listen
> > to changes in the StyleContext. That means I should be able to listen
> > to the StyleContexts I have for table and cell styles in ScribusDoc
> > (docTableStyles and docCellStyles) to get notified of possible
> changes
> > in relevant parent styles. And for direct formatting I can just
> ensure
> > that the offset is also recalculated when setters are called on
> > PageItem_Table. Does that sound sane?
> >
> > Listening to the style context like that will notify me of all style
> > changes, which is a bit liberal, but it's OK I think since it's not
> > time critical and besided the recalculation of the offsets should be
> > quite quick.
> 
> Many questions at once now. Sorry about that ;) Here's another one; I
> noticed that it's not using regular Qt signals/slots but that
> StyleContext implements Observable<StyleContext>. What requirement are
> there on a class that wants to be an observer in the observer pattern
> implementation in Scribus? Does it need to be a QObject? Or implement
> some Observer interface?
> 
> Elvis
> 
> _______________________________________________
> scribus-dev mailing list
> scribus-dev at lists.scribus.net
> http://lists.scribus.net/mailman/listinfo/scribus-dev




More information about the scribus-dev mailing list