r16620 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:24:55 UTC 2011
Author: craig
Date: Mon May 23 20:24:54 2011
New Revision: 16620
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16620
Log:
#9912: Apply patch to assist with cursor movement between linked frames
Modified:
branches/Version135/Scribus/scribus/pageitem.cpp
branches/Version135/Scribus/scribus/pageitem.h
branches/Version135/Scribus/scribus/pageitem_textframe.cpp
branches/Version135/Scribus/scribus/pageitem_textframe.h
Modified: branches/Version135/Scribus/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16620&path=/branches/Version135/Scribus/scribus/pageitem.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem.cpp Mon May 23 20:24:54 2011
@@ -714,6 +714,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
@@ -730,6 +748,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: branches/Version135/Scribus/scribus/pageitem.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16620&path=/branches/Version135/Scribus/scribus/pageitem.h
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.h (original)
+++ branches/Version135/Scribus/scribus/pageitem.h Mon May 23 20:24:54 2011
@@ -335,8 +335,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: branches/Version135/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16620&path=/branches/Version135/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem_textframe.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem_textframe.cpp Mon May 23 20:24:54 2011
@@ -2678,6 +2678,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();
@@ -2861,7 +2894,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);
}
}
}
@@ -2873,7 +2906,7 @@
{
view->Deselect(true);
NextBox->CPos = lastInFrame()+1;
- view->SelectItemNr(NextBox->ItemNr);
+ m_Doc->scMW()->selectItemsFromOutlines(NextBox);
}
}
}
@@ -2911,7 +2944,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
@@ -2921,7 +2954,7 @@
{
view->Deselect(true);
BackBox->CPos = BackBox->lastInFrame();
- view->SelectItemNr(BackBox->ItemNr);
+ m_Doc->scMW()->selectItemsFromOutlines(BackBox);
}
}
}
@@ -2930,13 +2963,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);
@@ -2966,7 +3015,7 @@
{
view->Deselect(true);
BackBox->CPos = BackBox->lastInFrame();
- view->SelectItemNr(BackBox->ItemNr);
+ m_Doc->scMW()->selectItemsFromOutlines(BackBox);
//currItem = currItem->BackBox;
}
}
@@ -3026,7 +3075,7 @@
{
view->Deselect(true);
NextBox->CPos = CPos;
- view->SelectItemNr(NextBox->ItemNr);
+ m_Doc->scMW()->selectItemsFromOutlines(NextBox);
//currItem = currItem->NextBox;
}
}
@@ -3109,6 +3158,18 @@
{
// m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(CPos-1,0))));
// Tinput = false;
+ }
+ if (CPos < firstInFrame())
+ {
+ CPos = firstInFrame();
+ if (BackBox != 0)
+ {
+ lastUndoAction = PageItem::NOACTION;
+ view->Deselect(true);
+ BackBox->CPos = BackBox->lastInFrame();
+ m_Doc->scMW()->selectItemsFromOutlines(BackBox);
+ //currItem = currItem->BackBox;
+ }
}
m_Doc->scMW()->setTBvals(this);
update();
@@ -3198,7 +3259,17 @@
// 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)
+ {
+ lastUndoAction = PageItem::NOACTION;
+ view->Deselect(true);
+ NextBox->CPos = CPos;
+ m_Doc->scMW()->selectItemsFromOutlines(NextBox);
+ NextBox->update();
+ }
break;
}
// update();
Modified: branches/Version135/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16620&path=/branches/Version135/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem_textframe.h (original)
+++ branches/Version135/Scribus/scribus/pageitem_textframe.h Mon May 23 20:24:54 2011
@@ -83,6 +83,7 @@
virtual void DrawObj_Item(ScPainter *p, QRectF e, double sc);
virtual void DrawObj_Post(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