[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: KOffice 1.3.1
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2004-04-13 15:54:55
Message-ID: 200404131754.55540.t.zachmann () zagge ! de
[Download RAW message or body]

Hello all,

as Lukáš ask me to backport my latest patch that fixes the redrawing of lines 
in kpresenter here is the patch. 
Please review. If it is still possible to get it in, I will commit it tomorrow 
morning. 

Lukáš if this is to late please apply the patch if you like.

The patch also fixes a compile problem introduced by Karl-Heinz exportPage 
patch.

Haver a nice day

Thorsten 

["redrawlines.diff" (text/x-diff)]

Index: kprcanvas.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprcanvas.h,v
retrieving revision 1.143.2.3
diff -u -3 -p -r1.143.2.3 kprcanvas.h
--- kprcanvas.h	13 Apr 2004 11:26:21 -0000	1.143.2.3
+++ kprcanvas.h	13 Apr 2004 15:51:38 -0000
@@ -1,6 +1,7 @@
 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
 /* This file is part of the KDE project
    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
+   Copyright (C) 2002-2004 Thorsten Zachmann <zachmann@kde.org>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -27,6 +28,8 @@
 #include <qpicture.h>
 #include <qvaluelist.h>
 #include <qpixmap.h>
+#include <qpointarray.h>
+#include <qvaluevector.h>
 
 #include <koRuler.h>
 #include <koQueryTrader.h>
@@ -569,7 +572,10 @@ private:
     bool drawContour;
     double startAngle;
     ModifyType modType;
-    unsigned int oldMx, oldMy;
+    /**
+     * Saves the last mouse position during mouse move events.
+     */
+    QPoint m_savedMousePos;
 
     KPObject *resizeObjNum, *editNum, *rotateNum;
 
@@ -577,6 +583,20 @@ private:
     KPresenterView *m_view;
     bool editMode, goingBack, drawMode;
     bool drawLineInDrawMode;
+    
+    /**
+     * Save the lines drawed in drawMode. 
+     * This is used for paint events.
+     * Used in drawing mode.
+     */
+    QValueVector<QPointArray> m_drawModeLines;
+
+    /**
+     * Index into the QPointArray for the next point of the line in draw mode.
+     * Used in drawing mode.
+     */
+    int m_drawModeLineIndex;
+    
     bool mouseSelectedObject;
     unsigned int currPresPage, currPresStep, subPresStep;
     unsigned int oldPresPage, oldPresStep, oldSubPresStep;
Index: kprcanvas.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprcanvas.cc,v
retrieving revision 1.377.2.8
diff -u -3 -p -r1.377.2.8 kprcanvas.cc
--- kprcanvas.cc	13 Apr 2004 11:26:20 -0000	1.377.2.8
+++ kprcanvas.cc	13 Apr 2004 15:51:53 -0000
@@ -1,6 +1,7 @@
 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
 /* This file is part of the KDE project
    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
+   Copyright (C) 2002-2004 Thorsten Zachmann <zachmann@kde.org>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -317,6 +318,19 @@ void KPrCanvas::paintEvent( QPaintEvent*
             }
 
         }
+        else
+        {
+            if ( drawMode && m_drawModeLines.count() )
+            {
+                bufPainter.save();
+                bufPainter.setPen( m_view->kPresenterDoc()->presPen() );
+                for ( int i = 0; i < m_drawModeLines.count(); ++i )
+                {
+                  bufPainter.drawPolyline( m_drawModeLines[i] );
+                }
+                bufPainter.restore();
+            }
+        }
         bufPainter.end();
 
         bitBlt( this, paintEvent->rect().topLeft(), &buffer, paintEvent->rect() );
@@ -570,8 +584,7 @@ void KPrCanvas::mousePressEvent( QMouseE
 
     KPObject *kpobject = 0;
 
-    oldMx = contentsPoint.x();
-    oldMy = contentsPoint.y();
+    m_savedMousePos = contentsPoint;
 
     QPoint rasterPoint=applyGrid( e->pos(), true );
 
@@ -1073,8 +1086,6 @@ void KPrCanvas::mousePressEvent( QMouseE
             setToolEditMode( TEM_MOUSE );
         }
     } else {
-        oldMx = e->x();
-        oldMy = e->y();
         if ( e->button() == LeftButton ) {
             if ( presMenu->isVisible() ) {
                 presMenu->hide();
@@ -1083,6 +1094,9 @@ void KPrCanvas::mousePressEvent( QMouseE
                 if ( drawMode ) {
                     setCursor( KPresenterUtils::penCursor() );
                     drawLineInDrawMode = true;
+                    m_drawModeLineIndex = 0;
+                    m_drawModeLines.append( QPointArray() );
+                    m_drawModeLines[m_drawModeLines.count() - 1].putPoints( \
m_drawModeLineIndex++, 1, e->x(), e->y() );  }
                 else
                     m_view->screenNext();
@@ -1171,6 +1185,7 @@ void KPrCanvas::mouseReleaseEvent( QMous
 
     if ( drawMode ) {
         drawLineInDrawMode = false;
+        m_drawModeLines[m_drawModeLines.count() - 1].putPoints( \
m_drawModeLineIndex++, 1, contentsPoint.x(), contentsPoint.y() );  return;
     }
     bool state = m_view->kPresenterDoc()->snapToGrid();
@@ -1551,6 +1566,9 @@ void KPrCanvas::mouseReleaseEvent( QMous
 void KPrCanvas::mouseMoveEvent( QMouseEvent *e )
 {
     QPoint contentsPoint( e->pos().x()+diffx(), e->pos().y()+diffy() );
+    int oldMx = m_savedMousePos.x();
+    int oldMy = m_savedMousePos.y();
+    m_savedMousePos = contentsPoint;
     KoPoint docPoint = m_view->zoomHandler()->unzoomPoint( contentsPoint );
     if(m_currentTextObjectView)
     {
@@ -1658,9 +1676,6 @@ void KPrCanvas::mouseMoveEvent( QMouseEv
                     }
 
                     resizeObject( modType, mx - oldMx, my - oldMy );
-
-                    oldMx = e->x()+diffx();
-                    oldMy = e->y()+diffy();
                 }
             } break;
             case TEM_ZOOM : {
@@ -2003,9 +2018,8 @@ void KPrCanvas::mouseMoveEvent( QMouseEv
         p.begin( this );
         p.setPen( m_view->kPresenterDoc()->presPen() );
         p.drawLine( oldMx, oldMy, e->x(), e->y() );
-        oldMx = e->x();
-        oldMy = e->y();
         p.end();
+        m_drawModeLines[m_drawModeLines.count() - 1].putPoints( \
m_drawModeLineIndex++, 1, e->x(), e->y() );  }
 
     if ( !editMode && !drawMode && !presMenu->isVisible() && fillBlack )
@@ -2448,9 +2462,9 @@ bool KPrCanvas::exportPage( int nPage,
             if( !bLocalFile ){
                 if( res ){
 #if KDE_IS_VERSION(3,1,90)
-                    res = KIO::NetAccess::upload( this, tmpFile->name(), fileURL );
-#else
                     res = KIO::NetAccess::upload( tmpFile->name(), fileURL, this );
+#else
+                    res = KIO::NetAccess::upload( tmpFile->name(), fileURL );
 #endif
                 }
             }
@@ -3208,6 +3222,9 @@ bool KPrCanvas::pNext( bool )
 
     goingBack = false;
 
+    // clear drawed lines
+    m_drawModeLines.clear();
+
     //kdDebug(33001) << "\n-------\nKPrCanvas::pNext currPresStep=" << currPresStep \
<< " subPresStep=" << subPresStep << endl;  
     // First try to go one sub-step further, if any object requires it
@@ -3369,6 +3386,9 @@ bool KPrCanvas::pPrev( bool /*manual*/ )
     goingBack = true;
     subPresStep = 0;
 
+    // clear drawed lines
+    m_drawModeLines.clear();
+
     if ( (int)currPresStep > *presStepList.begin() ) {
         QValueList<int>::ConstIterator it = presStepList.find( currPresStep );
         currPresStep = *( --it );
@@ -5022,6 +5042,9 @@ void KPrCanvas::slotGotoPage()
 void KPrCanvas::gotoPage( int pg )
 {
     if ( pg != static_cast<int>( currPresPage ) ) {
+        // clear drawed lines
+        m_drawModeLines.clear();
+
         currPresPage = pg;
         kdDebug(33001) << "Page::gotoPage currPresPage=" << currPresPage << endl;
         slideListIterator = slideList.find( currPresPage );



_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
https://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