forked from qt-creator/qt-creator
TextEditors: Remove tabSettings() from widget
It's part of the document. Change-Id: I7288b09a0792fdae9c741016594e129f6b21f8e7 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -1704,9 +1704,9 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
|||||||
// Context(FAKEVIM_CONTEXT));
|
// Context(FAKEVIM_CONTEXT));
|
||||||
resetCommandBuffer();
|
resetCommandBuffer();
|
||||||
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
||||||
if (BaseTextEditorWidget *textEditor =
|
if (BaseTextDocument *textDocument =
|
||||||
qobject_cast<BaseTextEditorWidget *>(editor->widget())) {
|
qobject_cast<BaseTextDocument *>(editor->document())) {
|
||||||
m_editorToHandler[editor]->restoreWidget(textEditor->tabSettings().m_tabSize);
|
m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,17 +328,19 @@ void QuickToolBar::setProperty(const QString &propertyName, const QVariant &valu
|
|||||||
m_editor->convertPosition(changeSetPos + changeSetLength, &endLine, &column); //get line
|
m_editor->convertPosition(changeSetPos + changeSetLength, &endLine, &column); //get line
|
||||||
|
|
||||||
if (line > 0) {
|
if (line > 0) {
|
||||||
TextEditor::TabSettings ts = m_editor->editorWidget()->tabSettings();
|
TextEditor::TabSettings ts = m_editor->baseTextDocument()->tabSettings();
|
||||||
QmlJSIndenter indenter;
|
QmlJSIndenter indenter;
|
||||||
indenter.setTabSize(ts.m_tabSize);
|
indenter.setTabSize(ts.m_tabSize);
|
||||||
indenter.setIndentSize(ts.m_indentSize);
|
indenter.setIndentSize(ts.m_indentSize);
|
||||||
|
|
||||||
for (int i=line;i<=endLine;i++) {
|
for (int i=line;i<=endLine;i++) {
|
||||||
QTextBlock start = m_editor->editorWidget()->document()->findBlockByNumber(i);
|
QTextBlock start = m_editor->baseTextDocument()->document()->findBlockByNumber(i);
|
||||||
QTextBlock end = m_editor->editorWidget()->document()->findBlockByNumber(i);
|
QTextBlock end = m_editor->baseTextDocument()->document()->findBlockByNumber(i);
|
||||||
|
|
||||||
if (end.isValid()) {
|
if (end.isValid()) {
|
||||||
const int indent = indenter.indentForBottomLine(m_editor->editorWidget()->document()->begin(), end.next(), QChar::Null);
|
const int indent = indenter.indentForBottomLine(m_editor->baseTextDocument()
|
||||||
|
->document()->begin(),
|
||||||
|
end.next(), QChar::Null);
|
||||||
ts.indentLine(start, indent);
|
ts.indentLine(start, indent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,9 @@ void BarDescriptorEditor::updateCursorPosition()
|
|||||||
const QTextBlock block = cursor.block();
|
const QTextBlock block = cursor.block();
|
||||||
const int line = block.blockNumber() + 1;
|
const int line = block.blockNumber() + 1;
|
||||||
const int column = cursor.position() - block.position();
|
const int column = cursor.position() - block.position();
|
||||||
m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line).arg(editorWidget->sourceWidget()->tabSettings().columnAt(block.text(), column)+1),
|
m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line)
|
||||||
|
.arg(editorWidget->sourceWidget()->baseTextDocument()
|
||||||
|
->tabSettings().columnAt(block.text(), column)+1),
|
||||||
tr("Line: 9999, Col: 999"));
|
tr("Line: 9999, Col: 999"));
|
||||||
if (!block.isVisible())
|
if (!block.isVisible())
|
||||||
editorWidget->sourceWidget()->ensureCursorVisible();
|
editorWidget->sourceWidget()->ensureCursorVisible();
|
||||||
|
|||||||
@@ -1576,7 +1576,8 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
|
|
||||||
int extraBlocks =
|
int extraBlocks =
|
||||||
d->m_autoCompleter->paragraphSeparatorAboutToBeInserted(cursor, tabSettings());
|
d->m_autoCompleter->paragraphSeparatorAboutToBeInserted(cursor,
|
||||||
|
d->m_document->tabSettings());
|
||||||
|
|
||||||
QString previousIndentationString;
|
QString previousIndentationString;
|
||||||
if (tps.m_autoIndent) {
|
if (tps.m_autoIndent) {
|
||||||
@@ -2633,7 +2634,7 @@ QString BaseTextEditorWidgetPrivate::copyBlockSelection()
|
|||||||
QTextCursor cursor = q->textCursor();
|
QTextCursor cursor = q->textCursor();
|
||||||
if (!m_inBlockSelectionMode)
|
if (!m_inBlockSelectionMode)
|
||||||
return selection;
|
return selection;
|
||||||
const TabSettings &ts = q->tabSettings();
|
const TabSettings &ts = m_document->tabSettings();
|
||||||
QTextBlock block = m_blockSelection.firstBlock.block();
|
QTextBlock block = m_blockSelection.firstBlock.block();
|
||||||
QTextBlock lastBlock = m_blockSelection.lastBlock.block();
|
QTextBlock lastBlock = m_blockSelection.lastBlock.block();
|
||||||
bool textInserted = false;
|
bool textInserted = false;
|
||||||
@@ -2681,7 +2682,7 @@ void BaseTextEditorWidgetPrivate::removeBlockSelection(const QString &text)
|
|||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
|
|
||||||
const TabSettings &ts = q->tabSettings();
|
const TabSettings &ts = m_document->tabSettings();
|
||||||
QTextBlock block = m_blockSelection.firstBlock.block();
|
QTextBlock block = m_blockSelection.firstBlock.block();
|
||||||
QTextBlock lastBlock = m_blockSelection.lastBlock.block();
|
QTextBlock lastBlock = m_blockSelection.lastBlock.block();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -2968,7 +2969,7 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
&& blockFS.position() <= d->m_findScopeEnd.block().position()) {
|
&& blockFS.position() <= d->m_findScopeEnd.block().position()) {
|
||||||
QTextLayout *layout = blockFS.layout();
|
QTextLayout *layout = blockFS.layout();
|
||||||
QString text = blockFS.text();
|
QString text = blockFS.text();
|
||||||
const TabSettings &ts = tabSettings();
|
const TabSettings &ts = d->m_document->tabSettings();
|
||||||
qreal spacew = QFontMetricsF(font()).width(QLatin1Char(' '));
|
qreal spacew = QFontMetricsF(font()).width(QLatin1Char(' '));
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@@ -3075,7 +3076,7 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
o.format = range.format;
|
o.format = range.format;
|
||||||
if (i == blockSelectionIndex) {
|
if (i == blockSelectionIndex) {
|
||||||
QString text = block.text();
|
QString text = block.text();
|
||||||
const TabSettings &ts = tabSettings();
|
const TabSettings &ts = d->m_document->tabSettings();
|
||||||
o.start = ts.positionAtColumn(text, d->m_blockSelection.firstVisualColumn);
|
o.start = ts.positionAtColumn(text, d->m_blockSelection.firstVisualColumn);
|
||||||
o.length = ts.positionAtColumn(text, d->m_blockSelection.lastVisualColumn) - o.start;
|
o.length = ts.positionAtColumn(text, d->m_blockSelection.lastVisualColumn) - o.start;
|
||||||
}
|
}
|
||||||
@@ -3127,7 +3128,7 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
&& block.position() >= d->m_blockSelection.firstBlock.block().position()
|
&& block.position() >= d->m_blockSelection.firstBlock.block().position()
|
||||||
&& block.position() <= d->m_blockSelection.lastBlock.block().position()) {
|
&& block.position() <= d->m_blockSelection.lastBlock.block().position()) {
|
||||||
QString text = block.text();
|
QString text = block.text();
|
||||||
const TabSettings &ts = tabSettings();
|
const TabSettings &ts = d->m_document->tabSettings();
|
||||||
qreal spacew = QFontMetricsF(font()).width(QLatin1Char(' '));
|
qreal spacew = QFontMetricsF(font()).width(QLatin1Char(' '));
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@@ -4035,17 +4036,18 @@ void BaseTextEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
if (e->modifiers() & Qt::AltModifier) {
|
if (e->modifiers() & Qt::AltModifier) {
|
||||||
if (!d->m_inBlockSelectionMode) {
|
if (!d->m_inBlockSelectionMode) {
|
||||||
d->m_blockSelection.fromSelection(tabSettings(), textCursor());
|
d->m_blockSelection.fromSelection(d->m_document->tabSettings(), textCursor());
|
||||||
d->m_inBlockSelectionMode = true;
|
d->m_inBlockSelectionMode = true;
|
||||||
} else {
|
} else {
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
|
|
||||||
// get visual column
|
// get visual column
|
||||||
int column = tabSettings().columnAt(cursor.block().text(), cursor.positionInBlock());
|
int column = d->m_document->tabSettings().columnAt(
|
||||||
|
cursor.block().text(), cursor.positionInBlock());
|
||||||
if (cursor.positionInBlock() == cursor.block().length()-1)
|
if (cursor.positionInBlock() == cursor.block().length()-1)
|
||||||
column += (e->pos().x() - cursorRect().center().x())/QFontMetricsF(font()).width(QLatin1Char(' '));
|
column += (e->pos().x() - cursorRect().center().x())/QFontMetricsF(font()).width(QLatin1Char(' '));
|
||||||
d->m_blockSelection.moveAnchor(cursor.blockNumber(), column);
|
d->m_blockSelection.moveAnchor(cursor.blockNumber(), column);
|
||||||
setTextCursor(d->m_blockSelection.selection(tabSettings()));
|
setTextCursor(d->m_blockSelection.selection(d->m_document->tabSettings()));
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4413,11 +4415,6 @@ void BaseTextEditorWidget::toggleBlockVisible(const QTextBlock &block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const TabSettings &BaseTextEditorWidget::tabSettings() const
|
|
||||||
{
|
|
||||||
return d->m_document->tabSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseTextEditorWidget::setLanguageSettingsId(Core::Id settingsId)
|
void BaseTextEditorWidget::setLanguageSettingsId(Core::Id settingsId)
|
||||||
{
|
{
|
||||||
d->m_tabSettingsId = settingsId;
|
d->m_tabSettingsId = settingsId;
|
||||||
@@ -5229,7 +5226,7 @@ void BaseTextEditorWidget::rewrapParagraph()
|
|||||||
{
|
{
|
||||||
const int paragraphWidth = marginSettings().m_marginColumn;
|
const int paragraphWidth = marginSettings().m_marginColumn;
|
||||||
const QRegExp anyLettersOrNumbers = QRegExp(QLatin1String("\\w"));
|
const QRegExp anyLettersOrNumbers = QRegExp(QLatin1String("\\w"));
|
||||||
const int tabSize = tabSettings().m_tabSize;
|
const int tabSize = d->m_document->tabSettings().m_tabSize;
|
||||||
|
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
@@ -5300,7 +5297,8 @@ void BaseTextEditorWidget::rewrapParagraph()
|
|||||||
QString spacing;
|
QString spacing;
|
||||||
|
|
||||||
if (commonPrefix.isEmpty()) {
|
if (commonPrefix.isEmpty()) {
|
||||||
spacing = tabSettings().indentationString(0, indentLevel, textCursor().block());
|
spacing = d->m_document->tabSettings().indentationString(
|
||||||
|
0, indentLevel, textCursor().block());
|
||||||
} else {
|
} else {
|
||||||
spacing = commonPrefix;
|
spacing = commonPrefix;
|
||||||
indentLevel = commonPrefix.length();
|
indentLevel = commonPrefix.length();
|
||||||
@@ -6107,7 +6105,9 @@ void BaseTextEditor::updateCursorPosition()
|
|||||||
const QTextBlock block = cursor.block();
|
const QTextBlock block = cursor.block();
|
||||||
const int line = block.blockNumber() + 1;
|
const int line = block.blockNumber() + 1;
|
||||||
const int column = cursor.position() - block.position();
|
const int column = cursor.position() - block.position();
|
||||||
m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line).arg(m_editorWidget->tabSettings().columnAt(block.text(), column)+1),
|
m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line)
|
||||||
|
.arg(baseTextDocument()->tabSettings().columnAt(block.text(),
|
||||||
|
column)+1),
|
||||||
tr("Line: 9999, Col: 999"));
|
tr("Line: 9999, Col: 999"));
|
||||||
m_contextHelpId.clear();
|
m_contextHelpId.clear();
|
||||||
|
|
||||||
@@ -6258,7 +6258,7 @@ bool BaseTextEditorWidget::inFindScope(int selectionStart, int selectionEnd)
|
|||||||
if (block != document()->findBlock(selectionEnd))
|
if (block != document()->findBlock(selectionEnd))
|
||||||
return false;
|
return false;
|
||||||
QString text = block.text();
|
QString text = block.text();
|
||||||
const TabSettings &ts = tabSettings();
|
const TabSettings &ts = d->m_document->tabSettings();
|
||||||
int startPosition = ts.positionAtColumn(text, d->m_findScopeVerticalBlockSelectionFirstColumn);
|
int startPosition = ts.positionAtColumn(text, d->m_findScopeVerticalBlockSelectionFirstColumn);
|
||||||
int endPosition = ts.positionAtColumn(text, d->m_findScopeVerticalBlockSelectionLastColumn);
|
int endPosition = ts.positionAtColumn(text, d->m_findScopeVerticalBlockSelectionLastColumn);
|
||||||
if (selectionStart - block.position() < startPosition)
|
if (selectionStart - block.position() < startPosition)
|
||||||
@@ -6273,7 +6273,7 @@ void BaseTextEditorWidget::setBlockSelection(bool on)
|
|||||||
if (d->m_inBlockSelectionMode != on) {
|
if (d->m_inBlockSelectionMode != on) {
|
||||||
d->m_inBlockSelectionMode = on;
|
d->m_inBlockSelectionMode = on;
|
||||||
if (on)
|
if (on)
|
||||||
d->m_blockSelection.fromSelection(tabSettings(), textCursor());
|
d->m_blockSelection.fromSelection(d->m_document->tabSettings(), textCursor());
|
||||||
}
|
}
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
@@ -6287,13 +6287,13 @@ void BaseTextEditorWidget::handleBlockSelection(int diff_row, int diff_col)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!d->m_inBlockSelectionMode) {
|
if (!d->m_inBlockSelectionMode) {
|
||||||
d->m_blockSelection.fromSelection(tabSettings(), textCursor());
|
d->m_blockSelection.fromSelection(d->m_document->tabSettings(), textCursor());
|
||||||
d->m_inBlockSelectionMode = true;
|
d->m_inBlockSelectionMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_blockSelection.moveAnchor(d->m_blockSelection.anchorBlockNumber() + diff_row,
|
d->m_blockSelection.moveAnchor(d->m_blockSelection.anchorBlockNumber() + diff_row,
|
||||||
d->m_blockSelection.anchorColumnNumber() + diff_col);
|
d->m_blockSelection.anchorColumnNumber() + diff_col);
|
||||||
setTextCursor(d->m_blockSelection.selection(tabSettings()));
|
setTextCursor(d->m_blockSelection.selection(d->m_document->tabSettings()));
|
||||||
|
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
|
|
||||||
@@ -6402,12 +6402,12 @@ void BaseTextEditorWidget::transformBlockSelection(TransformationMethod method)
|
|||||||
qSwap(minPos, maxPos);
|
qSwap(minPos, maxPos);
|
||||||
cursor.setPosition(minPos);
|
cursor.setPosition(minPos);
|
||||||
cursor.setPosition(maxPos, QTextCursor::KeepAnchor);
|
cursor.setPosition(maxPos, QTextCursor::KeepAnchor);
|
||||||
d->m_blockSelection.fromSelection(tabSettings(), cursor);
|
d->m_blockSelection.fromSelection(d->m_document->tabSettings(), cursor);
|
||||||
d->m_blockSelection.anchor = anchorPosition;
|
d->m_blockSelection.anchor = anchorPosition;
|
||||||
d->m_inBlockSelectionMode = true;
|
d->m_inBlockSelectionMode = true;
|
||||||
d->m_blockSelection.firstVisualColumn = leftBound;
|
d->m_blockSelection.firstVisualColumn = leftBound;
|
||||||
d->m_blockSelection.lastVisualColumn = rightBound;
|
d->m_blockSelection.lastVisualColumn = rightBound;
|
||||||
setTextCursor(d->m_blockSelection.selection(tabSettings()));
|
setTextCursor(d->m_blockSelection.selection(d->m_document->tabSettings()));
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -369,7 +369,6 @@ public:
|
|||||||
virtual void extraAreaMouseEvent(QMouseEvent *);
|
virtual void extraAreaMouseEvent(QMouseEvent *);
|
||||||
void updateFoldingHighlight(const QPoint &pos);
|
void updateFoldingHighlight(const QPoint &pos);
|
||||||
|
|
||||||
const TabSettings &tabSettings() const;
|
|
||||||
void setLanguageSettingsId(Core::Id settingsId);
|
void setLanguageSettingsId(Core::Id settingsId);
|
||||||
Core::Id languageSettingsId() const;
|
Core::Id languageSettingsId() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user