Undo and Redo
Patrick Julien
freak at codepimps.org
Thu Oct 9 19:06:53 CEST 2003
On October 9, 2003 06:55 am, Boudewijn Rempt wrote:
> Okay... This is curious.
>
> The following snippet correctly implements undo/redo. The funny thing is,
> when I press the mouse button, nothing seems to happen -- the display is
> not getting updated. When I undo and then redo the 'test' action, the red
> square _does_ appear.
>
> void KisToolTest::mousePress(QMouseEvent *e)
> {
> Q_INT32 x = e->pos().x();
> Q_INT32 y = e->pos().y();
> KisImageSP img = m_view -> currentImg();
> if (img) {
> KisPaintDeviceSP device = img -> activeDevice();
> if (device) {
> KisPainter p( device );
> p.beginTransaction( "Test" );
> p.fillRect( x, y, 10, 10, KoColor(QColor( "red" )) );
> m_doc->addCommand(p.endTransaction());
> device->anchor();
> }
> }
OK, didn't have anything to invalidate a region in a device? If not, you
should probably add this to KisPainter directly, i.e. KisPainter calls it
instead of client code.
> m_view -> updateCanvas(x, y, 10, 10);
> }
>
> Oh, and this appears on the console:
>
> kdecore (KAction): WARNING: KAction::updateShortcut(): name = "edit_undo",
> cut = Ctrl+Z; No KAccel, probably missing a parent collection
>
> When using the 'tool'.
More information about the kimageshop
mailing list