[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: kpresenter patch
From: Thorsten Zachmann <t.zachmann () zagge ! de>
Date: 2003-10-14 17:41:52
[Download RAW message or body]
Hello all
I forgot the patch so here is it again
On Tuesday 14 October 2003 10:17, Thorsten Zachmann wrote:
> On Tuesday 14 October 2003 10:07, David Faure wrote:
> > On Tuesday 14 October 2003 09:33, Thorsten Zachmann wrote:
> > > On Tuesday 14 October 2003 09:24, David Faure wrote:
> > > > On Tuesday 14 October 2003 08:25, Thorsten Zachmann wrote:
> > > > > Hello all,
> > > > >
> > > > > The attached patch solves two differnet problems:
> > > > >
> > > > > 1. After moving an object and undo the action the positions before
> > > > > the move and after the undo are not the same. The problem is caused
> > > > > by using screen resolution instead the real resolution for creating
> > > > > the undo command. 2. [...]
> > > >
> > > > Looks fine.
> > > > Not sure why we need the "bounding rect for key move" though...
> > > > Ah it's the original position, so that moving it 10 times with a key,
> > > > only records one move?
> > >
> > > Yes that's the reason.
> >
> > But then only the topleft corner is needed, no?
>
> Yes, only the topleft corner is used. I will change that and post a new
> patch then.
The new patch is attached, it uses now a a KoPoint instead of a KoRect. I'll
commit it tomorrow if you think it is ok.
Thorsten
PS: additionaly it also fixes a problem of moving headers or footers in the
undo.
["patch55" (text/x-diff)]
Index: kprcanvas.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprcanvas.cc,v
retrieving revision 1.375
diff -u -3 -p -r1.375 kprcanvas.cc
--- kprcanvas.cc 13 Oct 2003 04:15:10 -0000 1.375
+++ kprcanvas.cc 14 Oct 2003 17:31:00 -0000
@@ -536,7 +536,7 @@ void KPrCanvas::mousePressEvent( QMouseE
{
if(!m_view->koDocument()->isReadWrite())
return;
- m_initBoundingRect =objectSelectedBoundingRect();
+ moveStartPosMouse = objectSelectedBoundingRect().topLeft();
QPoint contentsPoint( e->pos().x()+diffx(), e->pos().y()+diffy() );
KoPoint docPoint = m_view->zoomHandler()->unzoomPoint( contentsPoint );
if(m_currentTextObjectView)
@@ -701,7 +701,7 @@ void KPrCanvas::mousePressEvent( QMouseE
if ( !(e->state() & ShiftButton)) {
selectObj( kpobject );
raiseObject( kpobject );
- m_initBoundingRect = objectSelectedBoundingRect();
+ moveStartPosMouse = objectSelectedBoundingRect().topLeft();
}
else
deSelectObj( kpobject );
@@ -1252,17 +1252,15 @@ void KPrCanvas::mouseReleaseEvent( QMous
case MT_MOVE: {
if ( firstX != mx || firstY != my ) {
KMacroCommand *macro=0L;
- KoRect newPos( objectSelectedBoundingRect() );
- int \
x=m_view->zoomHandler()->zoomItX(newPos.x()-m_initBoundingRect.x());
- int y=m_view->zoomHandler()->zoomItY( \
newPos.y()-m_initBoundingRect.y());
- KCommand *cmd=m_activePage->moveObject(m_view,x,y);
+ KoPoint move( objectSelectedBoundingRect().topLeft() - \
moveStartPosMouse ); + KCommand *cmd=m_activePage->moveObject(m_view, \
move.x(), move.y()); if(cmd)
{
if ( !macro )
macro=new KMacroCommand(i18n("Move Objects"));
macro->addCommand(cmd);
}
- cmd=stickyPage()->moveObject(m_view,x,y);
+ cmd=stickyPage()->moveObject(m_view, move.x(), move.y());
if(cmd)
{
if ( !macro )
@@ -2218,8 +2216,7 @@ void KPrCanvas::keyPressEvent( QKeyEvent
if ( !m_keyPressEvent )
{
- firstX = m_view->zoomHandler()->zoomItX(m_boundingRect.x());
- firstY = m_view->zoomHandler()->zoomItY(m_boundingRect.y());
+ moveStartPosKey = m_boundingRect.topLeft();
}
switch ( e->key() ) {
case Key_Up:
@@ -2258,8 +2255,7 @@ void KPrCanvas::keyPressEvent( QKeyEvent
if ( !m_keyPressEvent )
{
- firstX = m_view->zoomHandler()->zoomItX(m_boundingRect.x());
- firstY = m_view->zoomHandler()->zoomItY(m_boundingRect.y());
+ moveStartPosKey = m_boundingRect.topLeft();
}
switch ( e->key() ) {
case Key_Up:
@@ -2279,7 +2275,7 @@ void KPrCanvas::keyPressEvent( QKeyEvent
break;
case Key_Left:
m_keyPressEvent = true;
- moveObject( -offsety, 0, false );
+ moveObject( -offsetx, 0, false );
m_origBRect = m_boundingRect;
break;
case Key_Delete: case Key_Backspace:
@@ -2345,16 +2341,15 @@ void KPrCanvas::keyReleaseEvent( QKeyEve
if ( !e->isAutoRepeat() )
{
KMacroCommand *macro=0L;
- int x=(m_view->zoomHandler()->zoomItX(m_boundingRect.x()) - \
firstX);
- int y=(m_view->zoomHandler()->zoomItY(m_boundingRect.y()) - \
firstY);
- KCommand *cmd=m_activePage->moveObject(m_view,x,y);
+ KoPoint move( m_boundingRect.topLeft() - moveStartPosKey);
+ KCommand *cmd=m_activePage->moveObject(m_view, move.x(), \
move.y()); if(cmd)
{
if ( ! macro )
macro=new KMacroCommand(i18n("Move Objects"));
macro->addCommand(cmd);
}
- cmd=stickyPage()->moveObject(m_view,x,y);
+ cmd=stickyPage()->moveObject(m_view, move.x(), move.y());
if(cmd)
{
if ( ! macro )
Index: kprcanvas.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprcanvas.h,v
retrieving revision 1.141
diff -u -3 -p -r1.141 kprcanvas.h
--- kprcanvas.h 13 Oct 2003 04:15:10 -0000 1.141
+++ kprcanvas.h 14 Oct 2003 17:31:02 -0000
@@ -570,7 +570,8 @@ private:
KoRect m_boundingRect; // when moving object(s)
KoPoint m_hotSpot; // when moving frame(s)
- KoRect m_initBoundingRect;
+ KoPoint moveStartPosMouse; // start position for move with mouse
+ KoPoint moveStartPosKey; // start position for move with key
int m_tmpHelpPoint;
KoPoint tmpHelpPointPos;
Index: kprpage.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprpage.cc,v
retrieving revision 1.227
diff -u -3 -p -r1.227 kprpage.cc
--- kprpage.cc 27 Aug 2003 14:45:40 -0000 1.227
+++ kprpage.cc 14 Oct 2003 17:31:14 -0000
@@ -3051,7 +3051,7 @@ bool KPrPage::savePicture( KPresenterVie
}
// move object for releasemouseevent
-KCommand *KPrPage::moveObject(KPresenterView *_view,int diffx,int diffy)
+KCommand *KPrPage::moveObject(KPresenterView *_view, double diffx, double diffy)
{
bool createCommand=false;
MoveByCmd *moveByCmd=0L;
@@ -3060,19 +3060,21 @@ KCommand *KPrPage::moveObject(KPresenter
QPtrListIterator<KPObject> it( m_objectList );
for ( ; it.current() ; ++it )
{
+ //don't move a header/footer
+ if ( it.current() == m_doc->header() || it.current() == m_doc->footer())
+ continue;
if ( it.current()->isSelected() && !it.current()->isProtect())
{
_objects.append( it.current() );
QRect br = \
_view->zoomHandler()->zoomRect(it.current()->getBoundingRect() );
- br.moveBy( diffx, diffy );
+ br.moveBy( _view->zoomHandler()->zoomItX( diffx ), \
_view->zoomHandler()->zoomItY( diffy ) ); m_doc->repaint( br ); // Previous position
m_doc->repaint( it.current() ); // New position
createCommand=true;
}
}
if(createCommand) {
- moveByCmd = new MoveByCmd( i18n( "Move Objects" ),
- KoPoint( _view->zoomHandler()->unzoomItX \
(diffx),_view->zoomHandler()->unzoomItY( diffy) ), + moveByCmd = new \
MoveByCmd( i18n( "Move Objects" ), KoPoint( diffx, diffy ), _objects, m_doc,this );
int pos=m_doc->pageList().findRef(this);
Index: kprpage.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprpage.h,v
retrieving revision 1.103
diff -u -3 -p -r1.103 kprpage.h
--- kprpage.h 27 Aug 2003 14:45:40 -0000 1.103
+++ kprpage.h 14 Oct 2003 17:31:15 -0000
@@ -263,7 +263,7 @@ public:
bool chPic( KPresenterView *_view);
//return command when we move object
- KCommand *moveObject(KPresenterView *_view, int diffx,int diffy);
+ KCommand *moveObject(KPresenterView *_view, double diffx, double diffy);
KCommand *moveObject(KPresenterView *m_view,const KoPoint &_move,bool key);
KCommand *rotateObj(float _newAngle, bool addAngle=false);
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic