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

List:       koffice-devel
Subject:    [PATCH] Re: kword frameUnderMouse bug ?
From:       Frank Dekervel <Frank.dekervel () student ! kuleuven ! ac ! Be>
Date:       2002-02-27 14:42:40
[Download RAW message or body]

Hello,

this patch should fix inline frame selection in kword.
please review (was this the best place to fix the problem ?)

selection works now completely as one could expect, 
but frameUnderMouse now went from linear in the worst case to quadratic in 
the worst case. Maybe we could make it linear again, but is it worth it ?

greetings,
Frank


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

Index: kwdoc.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwdoc.cc,v
retrieving revision 1.330
diff -u -2 -d -p -b -r1.330 kwdoc.cc
--- kwdoc.cc	2002/02/22 23:30:31	1.330
+++ kwdoc.cc	2002/02/27 14:38:55
@@ -2373,4 +2373,7 @@ KWFrame * KWDocument::frameUnderMouse( c
     {
         KWFrameSet *frameSet = fit.current();
+	// only consider non-inline frames.
+	if (frameSet->isFloating())
+		continue;
         if ( !frameSet->isVisible() || frameSet->isRemoveableHeader() )
             continue;
@@ -2386,4 +2389,44 @@ KWFrame * KWDocument::frameUnderMouse( c
         if ( frame )
         {
+	    // now we iteratively search for inline frames in the found non-inline frame.
+
+	    // the frameset we're looking in.
+	    KWFrameSet *parentFrameSet= frameSet;
+	    bool still_searching=true;
+            while(still_searching) {
+		QPtrListIterator<KWFrameSet> frs = framesetsIterator();
+		still_searching=false;
+
+		for (frs.toLast();  frs.current(); --frs) {
+
+			// find all floating framesets that have parentFrameSet as parent.
+			KWFrameSet *frsFrameSet = frs.current();
+			if (!frsFrameSet->isFloating())
+				continue;
+			if (frsFrameSet->anchorFrameset() != parentFrameSet)
+				continue;
+			// endless loop.
+			if (frsFrameSet == parentFrameSet)
+				qWarning("WARNING frsFrameSet == parentFrameSet. probably you will see this a lot of times :D");
+
+
+			// is this the border of an inline frame ? exit directly, no need to do further interations.
+			KWFrame *frsFrame = frsFrameSet->frameByBorder(nPoint);
+			if (frsFrame) {
+				if (border) *border=true;
+				return frsFrame;
+			}
+
+			// is this in the body of an inline frame ? so this frame is already a 'better match' than
+			// the old frame, but we keep searching.
+			frsFrame = frsFrameSet->frameAtPos(docPoint.x(),docPoint.y());
+			if (frsFrame) {
+				parentFrameSet=frsFrameSet;
+				frame=frsFrame;
+				still_searching=true;
+			}
+		}
+	    }
+
             if ( border ) *border = false;
             return frame;

_______________________________________________
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