r20940 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Tue Feb 9 12:21:15 UTC 2016
Author: jghali
Date: Tue Feb 9 12:21:15 2016
New Revision: 20940
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20940
Log:
#13688: Text highliting in Story Editor disappears after changing font
Modified:
trunk/Scribus/scribus/ui/storyeditor.cpp
trunk/Scribus/scribus/ui/storyeditor.h
Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20940&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp Tue Feb 9 12:21:15 2016
@@ -262,9 +262,7 @@
setCurrentDocument(docc);
parentStoryEditor=parentSE;
wasMod = false;
- StoredSel = false;
SelCharStart = 0;
- SelParaStart = 0;
StyledText.clear();
document()->setUndoRedoEnabled(true);
viewport()->setAcceptDrops(false);
@@ -504,32 +502,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);
}
@@ -687,7 +681,8 @@
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);
@@ -880,11 +875,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);
@@ -899,11 +899,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();
@@ -919,7 +924,7 @@
if (end > start)
StyledText.removeChars(start, end-start);
textCursor().setPosition(start);
- StoredSel = false;
+ SelStack.clear();
}
void SEditor::setEffects(int effects)
@@ -3019,8 +3024,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: trunk/Scribus/scribus/ui/storyeditor.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20940&path=/trunk/Scribus/scribus/ui/storyeditor.h
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.h (original)
+++ trunk/Scribus/scribus/ui/storyeditor.h Tue Feb 9 12:21:15 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>
@@ -156,9 +158,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