forked from qt-creator/qt-creator
Utils: remove now unused Utils::Text::Replacement
They have been completely replaced by Utils::ChangeSet. Change-Id: I857816c1b2730699ba481da2e271dde358f394f3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -252,26 +252,6 @@ bool utf8AdvanceCodePoint(const char *¤t)
|
||||
return true;
|
||||
}
|
||||
|
||||
void applyReplacements(QTextDocument *doc, const Replacements &replacements)
|
||||
{
|
||||
if (replacements.empty())
|
||||
return;
|
||||
|
||||
int fullOffsetShift = 0;
|
||||
QTextCursor editCursor(doc);
|
||||
editCursor.beginEditBlock();
|
||||
for (const Text::Replacement &replacement : replacements) {
|
||||
editCursor.setPosition(replacement.offset + fullOffsetShift);
|
||||
editCursor.movePosition(QTextCursor::NextCharacter,
|
||||
QTextCursor::KeepAnchor,
|
||||
replacement.length);
|
||||
editCursor.removeSelectedText();
|
||||
editCursor.insertText(replacement.text);
|
||||
fullOffsetShift += replacement.text.length() - replacement.length;
|
||||
}
|
||||
editCursor.endEditBlock();
|
||||
}
|
||||
|
||||
QDebug &operator<<(QDebug &stream, const Position &pos)
|
||||
{
|
||||
stream << "line: " << pos.line << ", column: " << pos.column;
|
||||
|
@@ -49,25 +49,6 @@ public:
|
||||
bool operator!=(const Range &other) const { return !(operator==(other)); }
|
||||
};
|
||||
|
||||
struct Replacement
|
||||
{
|
||||
Replacement() = default;
|
||||
Replacement(int offset, int length, const QString &text)
|
||||
: offset(offset)
|
||||
, length(length)
|
||||
, text(text)
|
||||
{}
|
||||
|
||||
int offset = -1;
|
||||
int length = -1;
|
||||
QString text;
|
||||
|
||||
bool isValid() const { return offset >= 0 && length >= 0; }
|
||||
};
|
||||
using Replacements = std::vector<Replacement>;
|
||||
|
||||
QTCREATOR_UTILS_EXPORT void applyReplacements(QTextDocument *doc, const Replacements &replacements);
|
||||
|
||||
// line is 1-based, column is 0-based
|
||||
QTCREATOR_UTILS_EXPORT bool convertPosition(const QTextDocument *document,
|
||||
int pos,
|
||||
|
Reference in New Issue
Block a user