From: Guillaume L. <gla...@te...> - 2002-04-01 21:40:46
|
I've just committed what I believe is a better solution for post-command execution refresh. It's quite simple (although the implementation is not complete - I've changed EditView and siblings only). The goal of slotCommandExecuted() is to determine what was changed, and trigger the refresh appropriately. For the first part, I've moved that to the Segment class (and, in the future, other UI-displayed classes - Composition, etc...). For the 2nd part, Qt already gives us a way to trigger refreshes, which is QWidget::update(), which triggers a paintEvent(), which is what EditView::slotCommandExecuted() now calls (but since update() is a slot, we can suppress slotCommandExecuted() and connect to update() directly). In short, I simply mark changes in the base data, and made the views check for these when they repaint. More in details : Segment now carries a vector of RefreshStatus objects (a pompous word for a settable boolean flag with a couple of timeTs), one for each EditView which displays it. (this is not yet finished - it misses a way to dispose of a RefreshStatus) When a Segment is modified (Segment::insert() or Segment::erase()), it updates all its RefreshStatuses. On the UI part, when receiving a paintEvent() a Notation or MatrixView will scan all the segments it displays for their refresh status. If the segment needs to be refreshed, it is. This can be generalized to any base data being displayed on the UI. This method has two advantages : - it's simpler. We don't need to worry about choosing the right type to derive from when creating a new command, and we probably can get rid of some of the command types we have. Plus we don't have to maintain the various slotCommandExecuted(). - it's optimized, and Qt/X11 do the optimisation for us. Several updates() in a row trigger only one paintEvent(), and refreshes happen only on visible views. If a view is iconified of hidden, the refresh doesn't happen until the view is shown. So suppose you're editing in matrix view and have a notation view on the same segment, if that view is iconified then no layout will happen on it until it's de-iconified. One thing this scheme is currently missing is segments deletion. I think we can solve this with a mechanism similar to SegmentObserver, where the segment would notify its viewers that it's being deleted. Also, it seems there's currently a problem with notation edit actions being reflected on the matrix (but the other way around works). I'm not sure what causes it, because it was also present prior to my changes. Thoughts, comments ? (if you really don't like it just tell me and I'll revert it :-). -- Guillaume. http://www.telegraph-road.org |