MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / InputEdit

Method InputEdit

src/plugins/chat/widgets/inputeditwidget.cpp:251–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251InputEdit::InputEdit(QWidget *parent)
252 : DTextEdit(parent)
253{
254 setMinimumHeight(minInputEditHeight);
255 setFixedHeight(minInputEditHeight);
256 setLineWrapMode(QTextEdit::WidgetWidth);
257 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
258 setAcceptRichText(false);
259 document()->documentLayout()->registerHandler(QTextFormat::UserObject + 1, new TagObjectInterface);
260
261 connect(this, &DTextEdit::textChanged, this, &InputEdit::onTextChanged);
262 connect(ChatCallProxy::instance(), &ChatCallProxy::selectionChanged, this, [=](){
263 if (!autoSelectCode)
264 return;
265 auto editorService = dpfGetService(EditorService);
266 QString currentFile = editorService->currentFile();
267 QString selectedCode = editorService->getSelectedText();
268 if (currentFile.isEmpty() || selectedCode.isEmpty()) {
269 if (!selectedCodeTag.isEmpty())
270 removeTag(selectedCodeTag);
271 this->selectedCode.clear();
272 this->selectedCodeTag.clear();
273 return;
274 }
275
276 Edit::Range selectedRange = editorService->selectionRange(currentFile);
277 QString tagText = QString("%1:L%2C%3-L%4C%5").arg(QFileInfo(currentFile).fileName(),
278 QString::number(selectedRange.start.line + 1),
279 QString::number(selectedRange.start.column + 1),
280 QString::number(selectedRange.end.line + 1),
281 QString::number(selectedRange.end.column + 1));
282
283 removeTag(selectedCodeTag);
284 appendTag(tagText);
285 this->selectedCode = selectedCode;
286 this->selectedCodeTag = tagText;
287 });
288}
289
290void InputEdit::onTextChanged()
291{

Callers

nothing calls this directly

Calls 10

documentFunction · 0.85
connectFunction · 0.85
numberClass · 0.85
fileNameMethod · 0.80
QStringClass · 0.50
registerHandlerMethod · 0.45
currentFileMethod · 0.45
isEmptyMethod · 0.45
clearMethod · 0.45
selectionRangeMethod · 0.45

Tested by

no test coverage detected