r16621 by craig - #9912: Apply patch to assist with cursor movement between linked frames

scribus-commit scribus-commit at lists.scribus.net
Mon May 23 20:25:03 UTC 2011


Author: craig
Date: Mon May 23 20:25:03 2011
New Revision: 16621

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16621
Log:
#9912: Apply patch to assist with cursor movement between linked frames

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.h

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16621&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Mon May 23 20:25:03 2011
@@ -1045,6 +1045,24 @@
 	Reverse=newReversed;
 }
 
+//return frame where is text end
+PageItem * PageItem::frameTextEnd()
+{
+	PageItem * LastBox = this;
+	if (frameOverflows() && NextBox)
+	{ // text ending in some next frame
+		LastBox = NextBox;
+		while (LastBox != 0 && !LastBox->frameDisplays(itemText.length()-1))
+			LastBox = LastBox->nextInChain();
+	}
+	else if (frameUnderflows() && BackBox)
+	{ //text ending in some previous frame
+		LastBox = BackBox;
+		while (LastBox != 0 && !LastBox->frameDisplays(itemText.length()-1))
+			LastBox = LastBox->prevInChain();
+	}
+	return LastBox;
+}
 
 /// returns true if text overflows
 bool PageItem::frameOverflows() const
@@ -1061,6 +1079,17 @@
 #else
 	return false; // FIXME:NLS
 #endif
+}
+
+/// returns true if text is ending before that frame
+bool PageItem::frameUnderflows() const
+{
+	if (BackBox == NULL)
+		return false;
+	//FIX ME - I have found that condition if frame is empty
+	//and has been linked with previous frame
+	//if you will find any better solution - fix that function
+	return (firstInFrame() > lastInFrame());
 }
 
 int PageItem::firstInFrame() const

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16621&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Mon May 23 20:25:03 2011
@@ -342,8 +342,11 @@
 	virtual void invalidateLayout() { invalid = true; }
 	/// creates valid layout information
 	virtual void layout() {}
+	/// returns frame where is text end
+	PageItem * frameTextEnd();
 	/// returns true if text overflows
 	bool frameOverflows() const;
+	bool frameUnderflows() const;
 	/// returns index of first char displayed in this frame, used to be 0
 	int firstInFrame() const;
 	/// returns index of last char displayed in this frame, used to be MaxChars-1

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16621&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Mon May 23 20:25:03 2011
@@ -2762,6 +2762,39 @@
 
 void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 {
+	if (frameUnderflows())
+	{
+		CPos = itemText.length();
+		m_Doc->view()->Deselect(true);
+		PageItem * jumpFrame = frameTextEnd();
+		if (jumpFrame)
+		{
+			jumpFrame->CPos = CPos;
+			m_Doc->scMW()->selectItemsFromOutlines(jumpFrame);
+			m_Doc->scMW()->setTBvals(jumpFrame);
+			jumpFrame->update();
+			update();
+			switch (k->key())
+			{
+			case Qt::Key_PageDown:
+			case Qt::Key_PageUp:
+			case Qt::Key_End:
+			case Qt::Key_Home:
+			case Qt::Key_Right:
+			case Qt::Key_Left:
+			case Qt::Key_Up:
+			case Qt::Key_Down:
+			case Qt::Key_Delete:
+			case Qt::Key_Backspace:
+				break;
+			default:
+				jumpFrame->handleModeEditKey(k, keyRepeat);
+				jumpFrame->layout();
+				break;
+				}
+			return;
+		}
+	}
 	int oldPos = CPos; // 15-mar-2004 jjsa for cursor movement with Shift + Arrow key
 	int kk = k->key();
 	int as = k->text()[0].unicode();
@@ -2930,7 +2963,7 @@
 							// we position the cursor at the beginning of the next frame
 							// TODO position at the right place in next frame
 							NextBox->CPos = lastInFrame() + 1;
-							view->SelectItemNr(NextBox->ItemNr);
+							m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 						}
 					}
 			}
@@ -2942,7 +2975,7 @@
 					{
 						view->Deselect(true);
 						NextBox->CPos = lastInFrame()+1;
-						view->SelectItemNr(NextBox->ItemNr);
+						m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 					}
 				}
 			}
@@ -2980,7 +3013,7 @@
 						view->Deselect(true);
 						// TODO position at the right place in previous frame
 						BackBox->CPos = BackBox->lastInFrame();
-						view->SelectItemNr(BackBox->ItemNr);
+						m_Doc->scMW()->selectItemsFromOutlines(BackBox);
 					}
 			}
 			else
@@ -2990,7 +3023,7 @@
 				{
 					view->Deselect(true);
 					BackBox->CPos = BackBox->lastInFrame();
-					view->SelectItemNr(BackBox->ItemNr);
+					m_Doc->scMW()->selectItemsFromOutlines(BackBox);
 				}
 			}
 		}
@@ -2999,13 +3032,29 @@
 		m_Doc->scMW()->setTBvals(this);
 		break;
 	case Qt::Key_PageUp:
-		CPos = itemText.startOfFrame(CPos);
+		if (CPos == firstInFrame() && BackBox != 0)
+		{
+			view->Deselect(true);
+			BackBox->CPos = BackBox->firstInFrame();
+			m_Doc->scMW()->selectItemsFromOutlines(BackBox);
+			//currItem = currItem->BackBox;
+		}
+		else
+			CPos = itemText.startOfFrame(CPos);
 		if ( buttonModifiers & Qt::ShiftModifier )
 			ExpandSel(-1, oldPos);
 		m_Doc->scMW()->setTBvals(this);
 		break;
 	case Qt::Key_PageDown:
-		CPos = itemText.endOfFrame(CPos);
+		if (!frameDisplays(itemText.length()-1) && CPos >= lastInFrame() && NextBox != 0)
+		{
+			view->Deselect(true);
+			NextBox->CPos = NextBox->lastInFrame();
+			m_Doc->scMW()->selectItemsFromOutlines(NextBox);
+			//currItem = currItem->BackBox;
+		}
+		else
+			CPos = itemText.endOfFrame(CPos);
 		if ( buttonModifiers & Qt::ShiftModifier )
 			ExpandSel(1, oldPos);
 		m_Doc->scMW()->setTBvals(this);
@@ -3035,7 +3084,7 @@
 				{
 					view->Deselect(true);
 					BackBox->CPos = BackBox->lastInFrame();
-					view->SelectItemNr(BackBox->ItemNr);
+					m_Doc->scMW()->selectItemsFromOutlines(BackBox);
 					//currItem = currItem->BackBox;
 				}
 			}
@@ -3095,7 +3144,7 @@
 					{
 						view->Deselect(true);
 						NextBox->CPos = CPos;
-						view->SelectItemNr(NextBox->ItemNr);
+						m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 						//currItem = currItem->NextBox;
 					}
 				}
@@ -3162,6 +3211,17 @@
 		{
 //			m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(CPos-1,0))));
 //			Tinput = false;
+		}
+		if (CPos < firstInFrame())
+		{
+			CPos = firstInFrame();
+			if (BackBox != 0)
+			{
+				view->Deselect(true);
+				BackBox->CPos = BackBox->lastInFrame();
+				m_Doc->scMW()->selectItemsFromOutlines(BackBox);
+				//currItem = currItem->BackBox;
+			}
 		}
 		m_Doc->scMW()->setTBvals(this);
 		update();
@@ -3234,7 +3294,16 @@
 //			view->RefreshItem(this);
 			doUpdate = true;
 		}
-		if (doUpdate) update();
+		if (doUpdate)
+			update();
+		//check if cursor need to jump to next linked frame
+		if (lastInFrame() < (itemText.length() -2) && NextBox != 0)
+		{
+			view->Deselect(true);
+			NextBox->CPos = CPos;
+			m_Doc->scMW()->selectItemsFromOutlines(NextBox);
+			NextBox->update();
+		}
 		break;
 	}
 // 	update();

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16621&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h (original)
+++ trunk/Scribus/scribus/pageitem_textframe.h Mon May 23 20:25:03 2011
@@ -82,6 +82,7 @@
 	virtual void DrawObj_Post(ScPainter *p);
 	virtual void DrawObj_Decoration(ScPainter *p);
 	void drawOverflowMarker(ScPainter *p);
+	void drawUnderflowMarker(ScPainter *p);
 	void drawColumnBorders(ScPainter *p);
 	QRegion availableRegion(QRegion clip);
 




More information about the scribus-commit mailing list