MCPcopy Create free account
hub / github.com/KDE/kdevelop / updateValue

Method updateValue

plugins/qmljs/navigation/propertypreviewwidget.cpp:107–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void PropertyPreviewWidget::updateValue()
108{
109 QString newValue = view->rootObject()->property("value").toString();
110
111 // set the cursor to the edited range, otherwise the view will jump if we call doc->endEditing()
112 //document->activeView()->setCursorPosition(KTextEditor::Cursor(valueRange.start.line, valueRange.start.column));
113 if (valueRange.end().column() - valueRange.start().column() == newValue.size()) {
114 document->replaceText(valueRange, newValue);
115 }
116 else {
117 // the length of the text changed so don't replace it but remove the old
118 // and insert the new text.
119 KTextEditor::Document::EditingTransaction transaction(document);
120 document->removeText(valueRange);
121 document->insertText(valueRange.start(), newValue);
122
123 valueRange.setRange(
124 valueRange.start(),
125 KTextEditor::Cursor(valueRange.start().line(), valueRange.start().column() + newValue.size())
126 );
127 }
128}
129
130PropertyPreviewWidget::~PropertyPreviewWidget()
131{

Callers

nothing calls this directly

Calls 9

propertyMethod · 0.80
setRangeMethod · 0.80
CursorClass · 0.50
toStringMethod · 0.45
columnMethod · 0.45
endMethod · 0.45
startMethod · 0.45
sizeMethod · 0.45
lineMethod · 0.45

Tested by

no test coverage detected