summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/texteditoroverlay.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2021-04-22 10:59:32 +0200
committerDavid Schulz <david.schulz@qt.io>2021-05-03 04:11:07 +0000
commitec2449cae43aef0a81f7eeab25ba995515d9bd2f (patch)
tree981ff5bfc56886a3d0df653d7e7d3ffb580d0768 /src/plugins/texteditor/texteditoroverlay.cpp
parent7880950eca95d84b302c36fa2f4a72e6f19ea7d4 (diff)
downloadqt-creator-ec2449cae43aef0a81f7eeab25ba995515d9bd2f.tar.gz
TextEditor: move snippet overlay into own cpp file
Change-Id: I3343d9abf19e4edc7bd88077bf8fe6666a901e1b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/texteditor/texteditoroverlay.cpp')
-rw-r--r--src/plugins/texteditor/texteditoroverlay.cpp78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/plugins/texteditor/texteditoroverlay.cpp b/src/plugins/texteditor/texteditoroverlay.cpp
index 5522a7ef33..41107e39d9 100644
--- a/src/plugins/texteditor/texteditoroverlay.cpp
+++ b/src/plugins/texteditor/texteditoroverlay.cpp
@@ -25,7 +25,6 @@
#include "texteditoroverlay.h"
#include "texteditor.h"
-#include "snippets/snippet.h"
#include <QDebug>
#include <QMap>
@@ -485,80 +484,3 @@ bool TextEditorOverlay::hasFirstSelectionBeginMoved() const
return false;
return m_selections.at(0).m_cursor_begin.position() != m_firstSelectionOriginalBegin;
}
-
-void SnippetOverlay::clear()
-{
- TextEditorOverlay::clear();
- m_equivalentSelections.clear();
- m_manglers.clear();
-}
-
-void SnippetOverlay::mapEquivalentSelections()
-{
- m_equivalentSelections.clear();
- m_equivalentSelections.resize(selections().size());
-
- QMultiMap<QString, int> all;
- for (int i = 0; i < selections().size(); ++i)
- all.insert(selectionText(i).toLower(), i);
-
- const QList<QString> &uniqueKeys = all.uniqueKeys();
- foreach (const QString &key, uniqueKeys) {
- QList<int> indexes;
- const auto cAll = all;
- QMultiMap<QString, int>::const_iterator lbit = cAll.lowerBound(key);
- QMultiMap<QString, int>::const_iterator ubit = cAll.upperBound(key);
- while (lbit != ubit) {
- indexes.append(lbit.value());
- ++lbit;
- }
-
- foreach (int index, indexes)
- m_equivalentSelections[index] = indexes;
- }
-}
-
-void SnippetOverlay::updateEquivalentSelections(const QTextCursor &cursor)
-{
- int selectionIndex = selectionIndexForCursor(cursor);
- if (selectionIndex == -1)
- return;
-
- const QString &currentText = selectionText(selectionIndex);
- const QList<int> &equivalents = m_equivalentSelections.at(selectionIndex);
- foreach (int i, equivalents) {
- if (i == selectionIndex)
- continue;
- const QString &equivalentText = selectionText(i);
- if (currentText != equivalentText) {
- QTextCursor selectionCursor = assembleCursorForSelection(i);
- selectionCursor.joinPreviousEditBlock();
- selectionCursor.removeSelectedText();
- selectionCursor.insertText(currentText);
- selectionCursor.endEditBlock();
- }
- }
-}
-
-void SnippetOverlay::setNameMangler(const QList<NameMangler *> &manglers)
-{
- m_manglers = manglers;
-}
-
-void SnippetOverlay::mangle()
-{
- for (int i = 0; i < m_manglers.count(); ++i) {
- if (!m_manglers.at(i))
- continue;
-
- const QString current = selectionText(i);
- const QString result = m_manglers.at(i)->mangle(current);
- if (result != current) {
- QTextCursor selectionCursor = assembleCursorForSelection(i);
- selectionCursor.joinPreviousEditBlock();
- selectionCursor.removeSelectedText();
- selectionCursor.insertText(result);
- selectionCursor.endEditBlock();
- }
- }
-}