mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
remove redundant QTextCursor::MoveOperation enums [ci reset]
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
aee462b95a
commit
703ef5433e
18 changed files with 39 additions and 237 deletions
|
@ -1290,11 +1290,6 @@ public:
|
||||||
LogicalCoordinates
|
LogicalCoordinates
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CursorMoveStyle {
|
|
||||||
LogicalMoveStyle,
|
|
||||||
VisualMoveStyle
|
|
||||||
};
|
|
||||||
|
|
||||||
enum HitTestAccuracy {
|
enum HitTestAccuracy {
|
||||||
ExactHit,
|
ExactHit,
|
||||||
FuzzyHit
|
FuzzyHit
|
||||||
|
|
|
@ -130,25 +130,25 @@ bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
|
||||||
}
|
}
|
||||||
#ifndef QT_NO_SHORTCUT
|
#ifndef QT_NO_SHORTCUT
|
||||||
if (e == QKeySequence::MoveToNextChar) {
|
if (e == QKeySequence::MoveToNextChar) {
|
||||||
op = QTextCursor::Right;
|
op = QTextCursor::NextCharacter;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::MoveToPreviousChar) {
|
else if (e == QKeySequence::MoveToPreviousChar) {
|
||||||
op = QTextCursor::Left;
|
op = QTextCursor::PreviousCharacter;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::SelectNextChar) {
|
else if (e == QKeySequence::SelectNextChar) {
|
||||||
op = QTextCursor::Right;
|
op = QTextCursor::NextCharacter;
|
||||||
mode = QTextCursor::KeepAnchor;
|
mode = QTextCursor::KeepAnchor;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::SelectPreviousChar) {
|
else if (e == QKeySequence::SelectPreviousChar) {
|
||||||
op = QTextCursor::Left;
|
op = QTextCursor::PreviousCharacter;
|
||||||
mode = QTextCursor::KeepAnchor;
|
mode = QTextCursor::KeepAnchor;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::SelectNextWord) {
|
else if (e == QKeySequence::SelectNextWord) {
|
||||||
op = QTextCursor::WordRight;
|
op = QTextCursor::NextWord;
|
||||||
mode = QTextCursor::KeepAnchor;
|
mode = QTextCursor::KeepAnchor;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::SelectPreviousWord) {
|
else if (e == QKeySequence::SelectPreviousWord) {
|
||||||
op = QTextCursor::WordLeft;
|
op = QTextCursor::PreviousWord;
|
||||||
mode = QTextCursor::KeepAnchor;
|
mode = QTextCursor::KeepAnchor;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::SelectStartOfLine) {
|
else if (e == QKeySequence::SelectStartOfLine) {
|
||||||
|
@ -192,10 +192,10 @@ bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::MoveToNextWord) {
|
else if (e == QKeySequence::MoveToNextWord) {
|
||||||
op = QTextCursor::WordRight;
|
op = QTextCursor::NextWord;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::MoveToPreviousWord) {
|
else if (e == QKeySequence::MoveToPreviousWord) {
|
||||||
op = QTextCursor::WordLeft;
|
op = QTextCursor::PreviousWord;
|
||||||
}
|
}
|
||||||
else if (e == QKeySequence::MoveToEndOfBlock) {
|
else if (e == QKeySequence::MoveToEndOfBlock) {
|
||||||
op = QTextCursor::EndOfBlock;
|
op = QTextCursor::EndOfBlock;
|
||||||
|
@ -1227,7 +1227,7 @@ void QTextControlPrivate::keyPressEvent(QKeyEvent *e)
|
||||||
else if (e == QKeySequence::DeleteEndOfLine) {
|
else if (e == QKeySequence::DeleteEndOfLine) {
|
||||||
QTextBlock block = cursor.block();
|
QTextBlock block = cursor.block();
|
||||||
if (cursor.position() == block.position() + block.length() - 2)
|
if (cursor.position() == block.position() + block.length() - 2)
|
||||||
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
|
||||||
else
|
else
|
||||||
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
||||||
cursor.removeSelectedText();
|
cursor.removeSelectedText();
|
||||||
|
|
|
@ -223,7 +223,7 @@ void QTextCursorPrivate::adjustCursor(QTextCursor::MoveOperation m)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m <= QTextCursor::WordLeft) {
|
if (m <= QTextCursor::PreviousWord) {
|
||||||
if (i < positionChain.size())
|
if (i < positionChain.size())
|
||||||
position = positionChain.at(i)->firstPosition() - 1;
|
position = positionChain.at(i)->firstPosition() - 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -259,7 +259,7 @@ void QTextCursorPrivate::adjustCursor(QTextCursor::MoveOperation m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust to cell boundaries
|
// adjust to cell boundaries
|
||||||
if (m <= QTextCursor::WordLeft) {
|
if (m <= QTextCursor::PreviousWord) {
|
||||||
position = c_position.firstPosition();
|
position = c_position.firstPosition();
|
||||||
if (!before)
|
if (!before)
|
||||||
--position;
|
--position;
|
||||||
|
@ -342,25 +342,10 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
|
||||||
currentCharFormat = -1;
|
currentCharFormat = -1;
|
||||||
bool adjustX = true;
|
bool adjustX = true;
|
||||||
QTextBlock blockIt = block();
|
QTextBlock blockIt = block();
|
||||||
bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle;
|
|
||||||
|
|
||||||
if (!blockIt.isValid())
|
if (!blockIt.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (blockIt.textDirection() == Qt::RightToLeft) {
|
|
||||||
if (op == QTextCursor::WordLeft)
|
|
||||||
op = QTextCursor::NextWord;
|
|
||||||
else if (op == QTextCursor::WordRight)
|
|
||||||
op = QTextCursor::PreviousWord;
|
|
||||||
|
|
||||||
if (!visualMovement) {
|
|
||||||
if (op == QTextCursor::Left)
|
|
||||||
op = QTextCursor::NextCharacter;
|
|
||||||
else if (op == QTextCursor::Right)
|
|
||||||
op = QTextCursor::PreviousCharacter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QTextLayout *layout = blockLayout(blockIt);
|
const QTextLayout *layout = blockLayout(blockIt);
|
||||||
int relativePos = position - blockIt.position();
|
int relativePos = position - blockIt.position();
|
||||||
QTextLine line;
|
QTextLine line;
|
||||||
|
@ -403,10 +388,6 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
|
||||||
case QTextCursor::PreviousCharacter:
|
case QTextCursor::PreviousCharacter:
|
||||||
newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
|
newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
|
||||||
break;
|
break;
|
||||||
case QTextCursor::Left:
|
|
||||||
newPosition = visualMovement ? priv->leftCursorPosition(position)
|
|
||||||
: priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
|
|
||||||
break;
|
|
||||||
case QTextCursor::StartOfWord: {
|
case QTextCursor::StartOfWord: {
|
||||||
if (relativePos == 0)
|
if (relativePos == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -424,7 +405,6 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
|
||||||
// FALL THROUGH!
|
// FALL THROUGH!
|
||||||
}
|
}
|
||||||
case QTextCursor::PreviousWord:
|
case QTextCursor::PreviousWord:
|
||||||
case QTextCursor::WordLeft:
|
|
||||||
newPosition = priv->previousCursorPosition(position, QTextLayout::SkipWords);
|
newPosition = priv->previousCursorPosition(position, QTextLayout::SkipWords);
|
||||||
break;
|
break;
|
||||||
case QTextCursor::Up: {
|
case QTextCursor::Up: {
|
||||||
|
@ -517,12 +497,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
|
||||||
case QTextCursor::NextCharacter:
|
case QTextCursor::NextCharacter:
|
||||||
newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
|
newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
|
||||||
break;
|
break;
|
||||||
case QTextCursor::Right:
|
|
||||||
newPosition = visualMovement ? priv->rightCursorPosition(position)
|
|
||||||
: priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
|
|
||||||
break;
|
|
||||||
case QTextCursor::NextWord:
|
case QTextCursor::NextWord:
|
||||||
case QTextCursor::WordRight:
|
|
||||||
newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords);
|
newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -611,8 +586,8 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
|
||||||
|
|
||||||
if (mode == QTextCursor::KeepAnchor) {
|
if (mode == QTextCursor::KeepAnchor) {
|
||||||
QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
|
QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
|
||||||
if (table && ((op >= QTextCursor::PreviousBlock && op <= QTextCursor::WordLeft)
|
if (table && ((op >= QTextCursor::PreviousBlock && op <= QTextCursor::PreviousWord)
|
||||||
|| (op >= QTextCursor::NextBlock && op <= QTextCursor::WordRight))) {
|
|| (op >= QTextCursor::NextBlock && op <= QTextCursor::NextWord))) {
|
||||||
int oldColumn = table->cellAt(position).column();
|
int oldColumn = table->cellAt(position).column();
|
||||||
|
|
||||||
const QTextTableCell otherCell = table->cellAt(newPosition);
|
const QTextTableCell otherCell = table->cellAt(newPosition);
|
||||||
|
@ -621,7 +596,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
|
||||||
|
|
||||||
int newColumn = otherCell.column();
|
int newColumn = otherCell.column();
|
||||||
if ((oldColumn > newColumn && op >= QTextCursor::End)
|
if ((oldColumn > newColumn && op >= QTextCursor::End)
|
||||||
|| (oldColumn < newColumn && op <= QTextCursor::WordLeft))
|
|| (oldColumn < newColumn && op <= QTextCursor::PreviousWord))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1128,9 +1103,9 @@ void QTextCursor::setPosition(int pos, MoveMode m)
|
||||||
} else { // keep anchor
|
} else { // keep anchor
|
||||||
QTextCursor::MoveOperation op;
|
QTextCursor::MoveOperation op;
|
||||||
if (pos < d->anchor)
|
if (pos < d->anchor)
|
||||||
op = QTextCursor::Left;
|
op = QTextCursor::PreviousCharacter;
|
||||||
else
|
else
|
||||||
op = QTextCursor::Right;
|
op = QTextCursor::NextCharacter;
|
||||||
d->adjustCursor(op);
|
d->adjustCursor(op);
|
||||||
}
|
}
|
||||||
d->setX();
|
d->setX();
|
||||||
|
@ -2547,26 +2522,4 @@ QTextDocument *QTextCursor::document() const
|
||||||
return nullptr; // document went away
|
return nullptr; // document went away
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\enum Qt::CursorMoveStyle
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
This enum describes the movement style available to text cursors. The options
|
|
||||||
are:
|
|
||||||
|
|
||||||
\value LogicalMoveStyle Within a left-to-right text block, decrease cursor
|
|
||||||
position when pressing left arrow key, increase cursor position when pressing
|
|
||||||
the right arrow key. If the text block is right-to-left, the opposite behavior
|
|
||||||
applies.
|
|
||||||
\value VisualMoveStyle Pressing the left arrow key will always cause the cursor
|
|
||||||
to move left, regardless of the text's writing direction. Pressing the right
|
|
||||||
arrow key will always cause the cursor to move right.
|
|
||||||
*/
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,6 @@ public:
|
||||||
PreviousBlock,
|
PreviousBlock,
|
||||||
PreviousCharacter,
|
PreviousCharacter,
|
||||||
PreviousWord,
|
PreviousWord,
|
||||||
Left,
|
|
||||||
WordLeft,
|
|
||||||
|
|
||||||
End,
|
End,
|
||||||
Down,
|
Down,
|
||||||
|
@ -96,8 +94,6 @@ public:
|
||||||
NextBlock,
|
NextBlock,
|
||||||
NextCharacter,
|
NextCharacter,
|
||||||
NextWord,
|
NextWord,
|
||||||
Right,
|
|
||||||
WordRight,
|
|
||||||
|
|
||||||
NextCell,
|
NextCell,
|
||||||
PreviousCell,
|
PreviousCell,
|
||||||
|
|
|
@ -416,29 +416,6 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option)
|
||||||
d->lout->documentChanged(0, 0, d->length());
|
d->lout->documentChanged(0, 0, d->length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
The default cursor movement style is used by all QTextCursor objects
|
|
||||||
created from the document. The default is Qt::LogicalMoveStyle.
|
|
||||||
*/
|
|
||||||
Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const
|
|
||||||
{
|
|
||||||
Q_D(const QTextDocument);
|
|
||||||
return d->defaultCursorMoveStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
Sets the default cursor movement style to the given \a style.
|
|
||||||
*/
|
|
||||||
void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)
|
|
||||||
{
|
|
||||||
Q_D(QTextDocument);
|
|
||||||
d->defaultCursorMoveStyle = style;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QTextDocument::markContentsDirty(int position, int length)
|
\fn void QTextDocument::markContentsDirty(int position, int length)
|
||||||
|
|
||||||
|
|
|
@ -225,9 +225,6 @@ public:
|
||||||
QTextOption defaultTextOption() const;
|
QTextOption defaultTextOption() const;
|
||||||
void setDefaultTextOption(const QTextOption &option);
|
void setDefaultTextOption(const QTextOption &option);
|
||||||
|
|
||||||
Qt::CursorMoveStyle defaultCursorMoveStyle() const;
|
|
||||||
void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void contentsChange(int from, int charsRemoves, int charsAdded);
|
void contentsChange(int from, int charsRemoves, int charsAdded);
|
||||||
void contentsChanged();
|
void contentsChanged();
|
||||||
|
|
|
@ -182,7 +182,6 @@ QTextDocumentPrivate::QTextDocumentPrivate()
|
||||||
|
|
||||||
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
|
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
|
||||||
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||||
defaultCursorMoveStyle = Qt::LogicalMoveStyle;
|
|
||||||
|
|
||||||
indentWidth = 40;
|
indentWidth = 40;
|
||||||
documentMargin = 4;
|
documentMargin = 4;
|
||||||
|
@ -1354,20 +1353,6 @@ int QTextDocumentPrivate::previousCursorPosition(int position, QTextLayout::Curs
|
||||||
return it.layout()->previousCursorPosition(position-start, mode) + start;
|
return it.layout()->previousCursorPosition(position-start, mode) + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QTextDocumentPrivate::leftCursorPosition(int position) const
|
|
||||||
{
|
|
||||||
QTextBlock it = blocksFind(position);
|
|
||||||
int start = it.position();
|
|
||||||
return it.layout()->previousCursorPosition(position-start) + start;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QTextDocumentPrivate::rightCursorPosition(int position) const
|
|
||||||
{
|
|
||||||
QTextBlock it = blocksFind(position);
|
|
||||||
int start = it.position();
|
|
||||||
return it.layout()->nextCursorPosition(position-start) + start;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format)
|
void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format)
|
||||||
{
|
{
|
||||||
beginEditBlock();
|
beginEditBlock();
|
||||||
|
|
|
@ -223,8 +223,6 @@ public:
|
||||||
|
|
||||||
int nextCursorPosition(int position, QTextLayout::CursorMode mode) const;
|
int nextCursorPosition(int position, QTextLayout::CursorMode mode) const;
|
||||||
int previousCursorPosition(int position, QTextLayout::CursorMode mode) const;
|
int previousCursorPosition(int position, QTextLayout::CursorMode mode) const;
|
||||||
int leftCursorPosition(int position) const;
|
|
||||||
int rightCursorPosition(int position) const;
|
|
||||||
|
|
||||||
void changeObjectFormat(QTextObject *group, int format);
|
void changeObjectFormat(QTextObject *group, int format);
|
||||||
|
|
||||||
|
@ -320,7 +318,6 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QTextOption defaultTextOption;
|
QTextOption defaultTextOption;
|
||||||
Qt::CursorMoveStyle defaultCursorMoveStyle;
|
|
||||||
#ifndef QT_NO_CSSPARSER
|
#ifndef QT_NO_CSSPARSER
|
||||||
QCss::StyleSheet parsedDefaultStyleSheet;
|
QCss::StyleSheet parsedDefaultStyleSheet;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -696,9 +696,9 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes()
|
||||||
|
|
||||||
cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat));
|
cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat));
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
|
cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
|
||||||
cursor.mergeCharFormat(currentNode->charFormat);
|
cursor.mergeCharFormat(currentNode->charFormat);
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
compressNextWhitespace = CollapseWhiteSpace;
|
compressNextWhitespace = CollapseWhiteSpace;
|
||||||
|
|
||||||
hasBlock = false;
|
hasBlock = false;
|
||||||
|
|
|
@ -247,7 +247,6 @@ static void init(QTextEngine *e)
|
||||||
{
|
{
|
||||||
e->cacheGlyphs = false;
|
e->cacheGlyphs = false;
|
||||||
e->forceJustification = false;
|
e->forceJustification = false;
|
||||||
e->visualMovement = false;
|
|
||||||
|
|
||||||
e->layoutData = 0;
|
e->layoutData = 0;
|
||||||
|
|
||||||
|
|
|
@ -467,16 +467,10 @@ public:
|
||||||
QPointF position;
|
QPointF position;
|
||||||
bool cacheGlyphs;
|
bool cacheGlyphs;
|
||||||
bool forceJustification;
|
bool forceJustification;
|
||||||
bool visualMovement;
|
|
||||||
|
|
||||||
mutable LayoutData *layoutData;
|
mutable LayoutData *layoutData;
|
||||||
|
|
||||||
inline bool hasFormats() const { return (block.docHandle() || specialData); }
|
inline bool hasFormats() const { return (block.docHandle() || specialData); }
|
||||||
inline bool visualCursorMovement() const
|
|
||||||
{
|
|
||||||
return (visualMovement ||
|
|
||||||
(block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle : false));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SpecialData {
|
struct SpecialData {
|
||||||
int preeditPosition;
|
int preeditPosition;
|
||||||
|
|
|
@ -548,34 +548,6 @@ bool QTextLayout::cacheEnabled() const
|
||||||
return d->cacheGlyphs;
|
return d->cacheGlyphs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
Set the cursor movement style. If the QTextLayout is backed by
|
|
||||||
a document, you can ignore this and use the option in QTextDocument,
|
|
||||||
this option is for widgets like QLineEdit or custom widgets without
|
|
||||||
a QTextDocument. Default value is Qt::LogicalMoveStyle.
|
|
||||||
|
|
||||||
\sa cursorMoveStyle()
|
|
||||||
*/
|
|
||||||
void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style)
|
|
||||||
{
|
|
||||||
d->visualMovement = (style == Qt::VisualMoveStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
The cursor movement style of this QTextLayout. The default is
|
|
||||||
Qt::LogicalMoveStyle.
|
|
||||||
|
|
||||||
\sa setCursorMoveStyle()
|
|
||||||
*/
|
|
||||||
Qt::CursorMoveStyle QTextLayout::cursorMoveStyle() const
|
|
||||||
{
|
|
||||||
return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Begins the layout process.
|
Begins the layout process.
|
||||||
|
|
||||||
|
@ -1150,13 +1122,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
|
||||||
|
|
||||||
qreal x = position.x() + l.cursorToX(cursorPosition);
|
qreal x = position.x() + l.cursorToX(cursorPosition);
|
||||||
|
|
||||||
int itm;
|
int itm = d->findItem(cursorPosition - 1);
|
||||||
if (d->visualCursorMovement()) {
|
|
||||||
if (cursorPosition == sl.from + sl.length)
|
|
||||||
cursorPosition--;
|
|
||||||
itm = d->findItem(cursorPosition);
|
|
||||||
} else
|
|
||||||
itm = d->findItem(cursorPosition - 1);
|
|
||||||
|
|
||||||
QFixed base = sl.base();
|
QFixed base = sl.base();
|
||||||
QFixed descent = sl.descent;
|
QFixed descent = sl.descent;
|
||||||
|
@ -2223,9 +2189,8 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
|
||||||
|
|
||||||
x -= line.x;
|
x -= line.x;
|
||||||
x -= eng->alignLine(line);
|
x -= eng->alignLine(line);
|
||||||
// qDebug("xToCursor: x=%f, cpos=%d", x.toReal(), cpos);
|
// qDebug("xToCursor: x=%f, cpos=%d", x.toReal(), cpos);
|
||||||
|
|
||||||
bool visual = eng->visualCursorMovement();
|
|
||||||
if (x <= 0) {
|
if (x <= 0) {
|
||||||
// left of first item
|
// left of first item
|
||||||
int item = firstItem;
|
int item = firstItem;
|
||||||
|
@ -2246,7 +2211,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
|
||||||
int item = (i + firstItem);
|
int item = (i + firstItem);
|
||||||
QScriptItem &si = eng->layoutData->items[item];
|
QScriptItem &si = eng->layoutData->items[item];
|
||||||
int item_length = eng->length(item);
|
int item_length = eng->length(item);
|
||||||
// qDebug(" item %d, visual %d x_remain=%f", i, item, x.toReal());
|
// qDebug(" item %d, visual %d x_remain=%f", i, item, x.toReal());
|
||||||
|
|
||||||
int start = qMax(line.from - si.position, 0);
|
int start = qMax(line.from - si.position, 0);
|
||||||
int end = qMin(line.from + line_length - si.position, item_length);
|
int end = qMin(line.from + line_length - si.position, item_length);
|
||||||
|
@ -2267,13 +2232,13 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
|
||||||
++g;
|
++g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// qDebug(" start=%d, end=%d, gs=%d, ge=%d item_width=%f", start, end, gs, ge, item_width.toReal());
|
// qDebug(" start=%d, end=%d, gs=%d, ge=%d item_width=%f", start, end, gs, ge, item_width.toReal());
|
||||||
|
|
||||||
if (pos + item_width < x) {
|
if (pos + item_width < x) {
|
||||||
pos += item_width;
|
pos += item_width;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// qDebug(" inside run");
|
// qDebug(" inside run");
|
||||||
if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {
|
if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {
|
||||||
if (cpos == QTextLine::CursorOnCharacter)
|
if (cpos == QTextLine::CursorOnCharacter)
|
||||||
return si.position;
|
return si.position;
|
||||||
|
@ -2311,11 +2276,6 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
|
||||||
++gs;
|
++gs;
|
||||||
}
|
}
|
||||||
if (qAbs(x-pos) < dist) {
|
if (qAbs(x-pos) < dist) {
|
||||||
if (visual) {
|
|
||||||
if (i < nItems - 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return eng->positionInLigature(&si, end, x, pos, -1,
|
return eng->positionInLigature(&si, end, x, pos, -1,
|
||||||
cpos == QTextLine::CursorOnCharacter);
|
cpos == QTextLine::CursorOnCharacter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,6 @@ public:
|
||||||
void setCacheEnabled(bool enable);
|
void setCacheEnabled(bool enable);
|
||||||
bool cacheEnabled() const;
|
bool cacheEnabled() const;
|
||||||
|
|
||||||
void setCursorMoveStyle(Qt::CursorMoveStyle style);
|
|
||||||
Qt::CursorMoveStyle cursorMoveStyle() const;
|
|
||||||
|
|
||||||
void beginLayout();
|
void beginLayout();
|
||||||
void endLayout();
|
void endLayout();
|
||||||
void clearLayout();
|
void clearLayout();
|
||||||
|
|
|
@ -1484,7 +1484,6 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unknown = false;
|
bool unknown = false;
|
||||||
bool visual = cursorMoveStyle() == Qt::VisualMoveStyle;
|
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
}
|
}
|
||||||
|
@ -1549,11 +1548,11 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
|
||||||
#endif
|
#endif
|
||||||
moveCursor(selectionEnd(), false);
|
moveCursor(selectionEnd(), false);
|
||||||
} else {
|
} else {
|
||||||
cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1));
|
cursorForward(0, (layoutDirection() == Qt::LeftToRight ? 1 : -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event == QKeySequence::SelectNextChar) {
|
else if (event == QKeySequence::SelectNextChar) {
|
||||||
cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1));
|
cursorForward(1, (layoutDirection() == Qt::LeftToRight ? 1 : -1));
|
||||||
}
|
}
|
||||||
else if (event == QKeySequence::MoveToPreviousChar) {
|
else if (event == QKeySequence::MoveToPreviousChar) {
|
||||||
#if defined(QT_NO_COMPLETER)
|
#if defined(QT_NO_COMPLETER)
|
||||||
|
@ -1564,11 +1563,11 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
|
||||||
#endif
|
#endif
|
||||||
moveCursor(selectionStart(), false);
|
moveCursor(selectionStart(), false);
|
||||||
} else {
|
} else {
|
||||||
cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1));
|
cursorForward(0, (layoutDirection() == Qt::LeftToRight ? -1 : 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event == QKeySequence::SelectPreviousChar) {
|
else if (event == QKeySequence::SelectPreviousChar) {
|
||||||
cursorForward(1, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1));
|
cursorForward(1, (layoutDirection() == Qt::LeftToRight ? -1 : 1));
|
||||||
}
|
}
|
||||||
else if (event == QKeySequence::MoveToNextWord) {
|
else if (event == QKeySequence::MoveToNextWord) {
|
||||||
if (echoMode() == QLineEdit::Normal)
|
if (echoMode() == QLineEdit::Normal)
|
||||||
|
|
|
@ -143,9 +143,6 @@ public:
|
||||||
int cursorWidth() const { return m_cursorWidth; }
|
int cursorWidth() const { return m_cursorWidth; }
|
||||||
void setCursorWidth(int value) { m_cursorWidth = value; }
|
void setCursorWidth(int value) { m_cursorWidth = value; }
|
||||||
|
|
||||||
Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
|
|
||||||
void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
|
|
||||||
|
|
||||||
void moveCursor(int pos, bool mark = false);
|
void moveCursor(int pos, bool mark = false);
|
||||||
void cursorForward(bool mark, int steps)
|
void cursorForward(bool mark, int steps)
|
||||||
{
|
{
|
||||||
|
|
|
@ -922,46 +922,6 @@ void QLineEdit::setDragEnabled(bool b)
|
||||||
d->dragEnabled = b;
|
d->dragEnabled = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\property QLineEdit::cursorMoveStyle
|
|
||||||
\brief the movement style of cursor in this line edit
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
When this property is set to Qt::VisualMoveStyle, the line edit will use visual
|
|
||||||
movement style. Pressing the left arrow key will always cause the cursor to move
|
|
||||||
left, regardless of the text's writing direction. The same behavior applies to
|
|
||||||
right arrow key.
|
|
||||||
|
|
||||||
When the property is Qt::LogicalMoveStyle (the default), within a LTR text block,
|
|
||||||
increase cursor position when pressing left arrow key, decrease cursor position
|
|
||||||
when pressing the right arrow key. If the text block is right to left, the opposite
|
|
||||||
behavior applies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
Returns the movement style for the cursor in the line edit.
|
|
||||||
*/
|
|
||||||
Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const
|
|
||||||
{
|
|
||||||
Q_D(const QLineEdit);
|
|
||||||
return d->control->cursorMoveStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 4.8
|
|
||||||
|
|
||||||
Sets the movement style for the cursor in the line edit to the given
|
|
||||||
\a style.
|
|
||||||
*/
|
|
||||||
void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style)
|
|
||||||
{
|
|
||||||
Q_D(QLineEdit);
|
|
||||||
d->control->setCursorMoveStyle(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QLineEdit::acceptableInput
|
\property QLineEdit::acceptableInput
|
||||||
\brief whether the input satisfies the inputMask and the
|
\brief whether the input satisfies the inputMask and the
|
||||||
|
|
|
@ -63,7 +63,6 @@ class Q_GUI_EXPORT QLineEdit : public QWidget
|
||||||
Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
|
Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
|
||||||
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
|
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
|
||||||
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
|
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
|
||||||
Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QLineEdit(QWidget* parent = nullptr);
|
explicit QLineEdit(QWidget* parent = nullptr);
|
||||||
|
@ -133,9 +132,6 @@ public:
|
||||||
void setDragEnabled(bool b);
|
void setDragEnabled(bool b);
|
||||||
bool dragEnabled() const;
|
bool dragEnabled() const;
|
||||||
|
|
||||||
void setCursorMoveStyle(Qt::CursorMoveStyle style);
|
|
||||||
Qt::CursorMoveStyle cursorMoveStyle() const;
|
|
||||||
|
|
||||||
QString inputMask() const;
|
QString inputMask() const;
|
||||||
void setInputMask(const QString &inputMask);
|
void setInputMask(const QString &inputMask);
|
||||||
bool hasAcceptableInput() const;
|
bool hasAcceptableInput() const;
|
||||||
|
|
|
@ -177,9 +177,9 @@ void tst_QTextCursor::navigation1()
|
||||||
|
|
||||||
QTextCursor otherCursor(doc);
|
QTextCursor otherCursor(doc);
|
||||||
otherCursor.movePosition(QTextCursor::Start);
|
otherCursor.movePosition(QTextCursor::Start);
|
||||||
otherCursor.movePosition(QTextCursor::Right);
|
otherCursor.movePosition(QTextCursor::NextCharacter);
|
||||||
cursor = otherCursor;
|
cursor = otherCursor;
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
QVERIFY(cursor != otherCursor);
|
QVERIFY(cursor != otherCursor);
|
||||||
otherCursor.insertText("Hey");
|
otherCursor.insertText("Hey");
|
||||||
QVERIFY(cursor.position() == 5);
|
QVERIFY(cursor.position() == 5);
|
||||||
|
@ -195,10 +195,10 @@ void tst_QTextCursor::navigation1()
|
||||||
QVERIFY(doc->toPlainText() == "Hello World");
|
QVERIFY(doc->toPlainText() == "Hello World");
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Start);
|
cursor.movePosition(QTextCursor::Start);
|
||||||
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 6);
|
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, 6);
|
||||||
QVERIFY(cursor.position() == 6);
|
QVERIFY(cursor.position() == 6);
|
||||||
otherCursor = cursor;
|
otherCursor = cursor;
|
||||||
otherCursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 2);
|
otherCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, 2);
|
||||||
otherCursor.deletePreviousChar();
|
otherCursor.deletePreviousChar();
|
||||||
otherCursor.deletePreviousChar();
|
otherCursor.deletePreviousChar();
|
||||||
otherCursor.deletePreviousChar();
|
otherCursor.deletePreviousChar();
|
||||||
|
@ -744,7 +744,7 @@ void tst_QTextCursor::checkFrame1()
|
||||||
QVERIFY(cursor.selectionStart() == 1);
|
QVERIFY(cursor.selectionStart() == 1);
|
||||||
QVERIFY(cursor.selectionEnd() == 1);
|
QVERIFY(cursor.selectionEnd() == 1);
|
||||||
|
|
||||||
// cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
// cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
|
||||||
// QVERIFY(cursor.position() == 2);
|
// QVERIFY(cursor.position() == 2);
|
||||||
// QVERIFY(cursor.selectionStart() == 0);
|
// QVERIFY(cursor.selectionStart() == 0);
|
||||||
// QVERIFY(cursor.selectionEnd() == 2);
|
// QVERIFY(cursor.selectionEnd() == 2);
|
||||||
|
@ -792,7 +792,7 @@ void tst_QTextCursor::checkFrame2()
|
||||||
QVERIFY(cursor.selectionStart() == 1);
|
QVERIFY(cursor.selectionStart() == 1);
|
||||||
QVERIFY(cursor.selectionEnd() == 2);
|
QVERIFY(cursor.selectionEnd() == 2);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
|
cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
|
||||||
QVERIFY(cursor.position() == 0);
|
QVERIFY(cursor.position() == 0);
|
||||||
QVERIFY(cursor.selectionStart() == 0);
|
QVERIFY(cursor.selectionStart() == 0);
|
||||||
QVERIFY(cursor.selectionEnd() == 3);
|
QVERIFY(cursor.selectionEnd() == 3);
|
||||||
|
@ -823,7 +823,7 @@ void tst_QTextCursor::tableMovement()
|
||||||
QVERIFY(cursor.position() == 0);
|
QVERIFY(cursor.position() == 0);
|
||||||
cursor.insertText("AA");
|
cursor.insertText("AA");
|
||||||
QVERIFY(cursor.position() == 2);
|
QVERIFY(cursor.position() == 2);
|
||||||
cursor.movePosition(QTextCursor::Left);
|
cursor.movePosition(QTextCursor::PreviousCharacter);
|
||||||
|
|
||||||
cursor.insertTable(3, 3);
|
cursor.insertTable(3, 3);
|
||||||
QCOMPARE(cursor.position(), 2);
|
QCOMPARE(cursor.position(), 2);
|
||||||
|
@ -831,16 +831,16 @@ void tst_QTextCursor::tableMovement()
|
||||||
cursor.movePosition(QTextCursor::Down);
|
cursor.movePosition(QTextCursor::Down);
|
||||||
QCOMPARE(cursor.position(), 5);
|
QCOMPARE(cursor.position(), 5);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
QCOMPARE(cursor.position(), 6);
|
QCOMPARE(cursor.position(), 6);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Up);
|
cursor.movePosition(QTextCursor::Up);
|
||||||
QCOMPARE(cursor.position(), 3);
|
QCOMPARE(cursor.position(), 3);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
QCOMPARE(cursor.position(), 4);
|
QCOMPARE(cursor.position(), 4);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
QCOMPARE(cursor.position(), 5);
|
QCOMPARE(cursor.position(), 5);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Up);
|
cursor.movePosition(QTextCursor::Up);
|
||||||
|
@ -1133,8 +1133,8 @@ void tst_QTextCursor::blockCharFormatOnSelection()
|
||||||
cursor.movePosition(QTextCursor::NextBlock);
|
cursor.movePosition(QTextCursor::NextBlock);
|
||||||
QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::cyan);
|
QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::cyan);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
cursor.movePosition(QTextCursor::Right);
|
cursor.movePosition(QTextCursor::NextCharacter);
|
||||||
QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
|
QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::NextBlock);
|
cursor.movePosition(QTextCursor::NextBlock);
|
||||||
|
|
Loading…
Add table
Reference in a new issue