r20941 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Tue Feb 9 12:22:04 UTC 2016
Author: jghali
Date: Tue Feb 9 12:22:04 2016
New Revision: 20941
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20941
Log:
#13688: Text highliting in Story Editor disappears after changing font
Modified:
branches/Version14x/Scribus/scribus/storyeditor.cpp
branches/Version14x/Scribus/scribus/storyeditor.h
Modified: branches/Version14x/Scribus/scribus/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20941&path=/branches/Version14x/Scribus/scribus/storyeditor.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.cpp (original)
+++ branches/Version14x/Scribus/scribus/storyeditor.cpp Tue Feb 9 12:22:04 2016
@@ -257,9 +257,7 @@
setCurrentDocument(docc);
parentStoryEditor=parentSE;
wasMod = false;
- StoredSel = false;
SelCharStart = 0;
- SelParaStart = 0;
StyledText.clear();
document()->setUndoRedoEnabled(true);
viewport()->setAcceptDrops(false);
@@ -507,32 +505,28 @@
QTextCursor tc(textCursor());
if (tc.hasSelection())
{
- SelParaStart = tc.selectionStart();
- SelParaEnd = tc.selectionEnd();
- StoredSel = true;
+ QPair<int, int> selPair = qMakePair(tc.selectionStart(), tc.selectionEnd());
+ SelStack.push(selPair);
}
else
{
- SelParaStart = tc.position();
- StoredSel = false;
+ QPair<int, int> selPair = qMakePair(tc.position(), -1);
+ SelStack.push(selPair);
}
QTextEdit::focusOutEvent(e);
}
void SEditor::focusInEvent(QFocusEvent *e)
{
- QTextCursor tc(textCursor());
- if (StoredSel)
- {
- tc.setPosition(SelParaStart);
- tc.setPosition(SelParaEnd, QTextCursor::KeepAnchor);
- StoredSel = false;
- }
- else
- {
- tc.setPosition(qMin(SelParaStart, StyledText.length()));
- }
- setTextCursor(tc);
+ if (SelStack.count() > 0)
+ {
+ QTextCursor tc(textCursor());
+ QPair<int, int> selPair = SelStack.pop();
+ tc.setPosition(qMin(selPair.first, StyledText.length()));
+ if (selPair.second >= 0)
+ tc.setPosition(selPair.second, QTextCursor::KeepAnchor);
+ setTextCursor(tc);
+ }
QTextEdit::focusInEvent(e);
}
@@ -680,11 +674,10 @@
if (currItem->itemText.cursorPosition() < SelCharStart)
SelCharStart = currItem->itemText.cursorPosition();
SelCharStart -= currItem->itemText.startOfParagraph(newSelParaStart);
- StoredSel = false;
+ if (SelStack.count())
+ SelStack.top().second = -1;
//qDebug() << "SE::loadItemText: cursor";
-// setCursorPosition(SelParaStart, SelCharStart);
emit setProps(newSelParaStart, SelCharStart);
- //SelParaStart = 0;
}
void SEditor::loadText(QString tx, PageItem *currItem)
@@ -872,11 +865,16 @@
void SEditor::updateSel(const ParagraphStyle& newStyle)
{
int PStart, PEnd, SelStart, SelEnd, start;
- if (StoredSel)
- {
- textCursor().setPosition(SelParaStart);
- textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor);
- StoredSel = false;
+ if (SelStack.count())
+ {
+ QTextCursor tc(textCursor());
+ QPair<int, int> selPair = SelStack.pop();
+ if (selPair.second >= 0)
+ {
+ tc.setPosition(selPair.first);
+ tc.setPosition(selPair.second, QTextCursor::KeepAnchor);
+ setTextCursor(tc);
+ }
}
SelStart = textCursor().selectionStart();
PStart = StyledText.nrOfParagraph(SelStart);
@@ -891,11 +889,16 @@
void SEditor::updateSel(const CharStyle& newStyle)
{
- if (StoredSel)
- {
- textCursor().setPosition(SelParaStart);
- textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor);
- StoredSel = false;
+ if (SelStack.count())
+ {
+ QTextCursor tc(textCursor());
+ QPair<int, int> selPair = SelStack.pop();
+ if (selPair.second >= 0)
+ {
+ tc.setPosition(selPair.first);
+ tc.setPosition(selPair.second, QTextCursor::KeepAnchor);
+ setTextCursor(tc);
+ }
}
int start = textCursor().selectionStart();
int end = textCursor().selectionEnd();
@@ -911,7 +914,7 @@
if (end > start)
StyledText.removeChars(start, end-start);
textCursor().setPosition(start);
- StoredSel = false;
+ SelStack.clear();
}
void SEditor::setEffects(int effects)
@@ -2987,8 +2990,7 @@
QTextCursor tCursor = Editor->textCursor();
tCursor.setPosition(pos);
Editor->setTextCursor(tCursor);
- Editor->SelParaStart = pos;
- Editor->SelParaEnd = pos;
+ Editor->SelStack.push(qMakePair(pos, -1));
}
delete dia;
qApp->processEvents();
Modified: branches/Version14x/Scribus/scribus/storyeditor.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20941&path=/branches/Version14x/Scribus/scribus/storyeditor.h
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.h (original)
+++ branches/Version14x/Scribus/scribus/storyeditor.h Tue Feb 9 12:22:04 2016
@@ -41,11 +41,13 @@
#include <QMenuBar>
#include <QMouseEvent>
#include <QPaintEvent>
+#include <QPair>
#include <QPixmap>
#include <QPointer>
#include <QShowEvent>
#include <QSpinBox>
#include <QSplitter>
+#include <QStack>
#include <QStatusBar>
#include <QStringList>
#include <QToolBar>
@@ -128,9 +130,9 @@
QString prevFont;
QString CurrFont;
QString unicodeInputString;
- bool StoredSel;
- int SelParaStart;
- int SelParaEnd;
+
+ QStack< QPair<int, int> > SelStack;
+
int SelCharStart;
int SelCharEnd;
int SuspendContentsChange; // input method
More information about the scribus-commit
mailing list