Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 20899 → Rev 20941

/branches/Version14x/Scribus/scribus/storyeditor.cpp
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,14 → 505,13
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);
}
521,18 → 518,15
 
void SEditor::focusInEvent(QFocusEvent *e)
{
QTextCursor tc(textCursor());
if (StoredSel)
if (SelStack.count() > 0)
{
tc.setPosition(SelParaStart);
tc.setPosition(SelParaEnd, QTextCursor::KeepAnchor);
StoredSel = false;
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);
}
else
{
tc.setPosition(qMin(SelParaStart, StyledText.length()));
}
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)
if (SelStack.count())
{
textCursor().setPosition(SelParaStart);
textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor);
StoredSel = false;
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)
if (SelStack.count())
{
textCursor().setPosition(SelParaStart);
textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor);
StoredSel = false;
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();
/branches/Version14x/Scribus/scribus/storyeditor.h
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