Commit bd144ab0 authored by David Schulz's avatar David Schulz

Editor: TabSettings: Make some functions static.

Change-Id: I99597a22b333c44346eb890ebe615193bdbe66d6
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent a6c81584
......@@ -581,7 +581,6 @@ void BaseTextEditorWidgetPrivate::foldLicenseHeader()
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
QTC_ASSERT(documentLayout, return);
QTextBlock block = doc->firstBlock();
const TabSettings &ts = m_document->tabSettings();
while (block.isValid() && block.isVisible()) {
QString text = block.text();
if (BaseTextDocumentLayout::canFold(block) && block.next().isVisible()) {
......@@ -593,7 +592,7 @@ void BaseTextEditorWidgetPrivate::foldLicenseHeader()
break;
}
}
if (ts.firstNonSpace(text) < text.size())
if (TabSettings::firstNonSpace(text) < text.size())
break;
block = block.next();
}
......@@ -5937,14 +5936,13 @@ QMimeData *BaseTextEditorWidget::createMimeDataFromSelection() const
selstart.setPosition(cursor.selectionStart());
QTextCursor selend = cursor;
selend.setPosition(cursor.selectionEnd());
const TabSettings &ts = d->m_document->tabSettings();
bool startOk = ts.cursorIsAtBeginningOfLine(selstart);
bool startOk = TabSettings::cursorIsAtBeginningOfLine(selstart);
bool multipleBlocks = (selend.block() != selstart.block());
if (startOk && multipleBlocks) {
selstart.movePosition(QTextCursor::StartOfBlock);
if (ts.cursorIsAtBeginningOfLine(selend))
if (TabSettings::cursorIsAtBeginningOfLine(selend))
selend.movePosition(QTextCursor::StartOfBlock);
cursor.setPosition(selstart.position());
cursor.setPosition(selend.position(), QTextCursor::KeepAnchor);
......
......@@ -87,7 +87,7 @@ void TabSettings::fromMap(const QString &prefix, const QVariantMap &map)
map.value(prefix + QLatin1String(paddingModeKey), m_continuationAlignBehavior).toInt();
}
bool TabSettings::cursorIsAtBeginningOfLine(const QTextCursor &cursor) const
bool TabSettings::cursorIsAtBeginningOfLine(const QTextCursor &cursor)
{
QString text = cursor.block().text();
int fns = firstNonSpace(text);
......@@ -106,7 +106,7 @@ int TabSettings::lineIndentPosition(const QString &text) const
return i - (column % m_indentSize);
}
int TabSettings::firstNonSpace(const QString &text) const
int TabSettings::firstNonSpace(const QString &text)
{
int i = 0;
while (i < text.size()) {
......@@ -128,7 +128,7 @@ int TabSettings::indentationColumn(const QString &text) const
return columnAt(text, firstNonSpace(text));
}
int TabSettings::maximumPadding(const QString &text) const
int TabSettings::maximumPadding(const QString &text)
{
int fns = firstNonSpace(text);
int i = fns;
......@@ -141,7 +141,7 @@ int TabSettings::maximumPadding(const QString &text) const
}
int TabSettings::trailingWhitespaces(const QString &text) const
int TabSettings::trailingWhitespaces(const QString &text)
{
int i = 0;
while (i < text.size()) {
......@@ -152,7 +152,7 @@ int TabSettings::trailingWhitespaces(const QString &text) const
return i;
}
void TabSettings::removeTrailingWhitespace(QTextCursor cursor, QTextBlock &block) const
void TabSettings::removeTrailingWhitespace(QTextCursor cursor, QTextBlock &block)
{
if (const int trailing = trailingWhitespaces(block.text())) {
cursor.setPosition(block.position() + block.length() - 1);
......@@ -213,7 +213,7 @@ int TabSettings::positionAtColumn(const QString &text, int column, int *offset)
return i;
}
int TabSettings::spacesLeftFromPosition(const QString &text, int position) const
int TabSettings::spacesLeftFromPosition(const QString &text, int position)
{
int i = position;
while (i > 0) {
......
......@@ -68,27 +68,27 @@ public:
void fromMap(const QString &prefix, const QVariantMap &map);
int lineIndentPosition(const QString &text) const;
int firstNonSpace(const QString &text) const;
inline bool onlySpace(const QString &text) const { return firstNonSpace(text) == text.length(); }
int columnAt(const QString &text, int position) const;
int positionAtColumn(const QString &text, int column, int *offset = 0) const;
int spacesLeftFromPosition(const QString &text, int position) const;
int indentedColumn(int column, bool doIndent = true) const;
QString indentationString(int startColumn, int targetColumn, const QTextBlock &currentBlock = QTextBlock()) const;
QString indentationString(const QString &text) const;
int indentationColumn(const QString &text) const;
int maximumPadding(const QString &text) const;
bool cursorIsAtBeginningOfLine(const QTextCursor &cursor) const;
static int maximumPadding(const QString &text);
void indentLine(QTextBlock block, int newIndent, int padding = 0) const;
void reindentLine(QTextBlock block, int delta) const;
int trailingWhitespaces(const QString &text) const;
void removeTrailingWhitespace(QTextCursor cursor, QTextBlock &block) const;
bool isIndentationClean(const QTextBlock &block) const;
bool guessSpacesForTabs(const QTextBlock &block) const;
static int firstNonSpace(const QString &text);
static inline bool onlySpace(const QString &text) { return firstNonSpace(text) == text.length(); }
static int spacesLeftFromPosition(const QString &text, int position);
static bool cursorIsAtBeginningOfLine(const QTextCursor &cursor);
static int trailingWhitespaces(const QString &text);
static void removeTrailingWhitespace(QTextCursor cursor, QTextBlock &block);
TabPolicy m_tabPolicy;
int m_tabSize;
int m_indentSize;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment