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(); |