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

Method onTextChanged

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

Source from the content-addressed store, hash-verified

288}
289
290void InputEdit::onTextChanged()
291{
292 auto adjustHeight = document()->size().height();
293 if (adjustHeight < minInputEditHeight)
294 setFixedHeight(minInputEditHeight);
295 else if (adjustHeight > maxInputEditHeight)
296 setFixedHeight(maxInputEditHeight);
297 else
298 setFixedHeight(adjustHeight);
299
300 QTextCursor cursor(document());
301 QSet<QString> tagList;
302 int last_pos = 0;
303
304 // bug: tag will removed when send message. and causes the tag to be reset before it is used.
305 // update tag when llm is not running
306 if (ChatManager::instance()->checkRunningState(true))
307 return;
308
309 cursor.setPosition(0);
310 formatList.clear();
311
312 while (!cursor.atEnd()) {
313 cursor.setPosition(last_pos + 1);
314
315 if (last_pos == cursor.position())
316 break;
317 last_pos = cursor.position();
318
319 TagTextFormat format(cursor.charFormat());
320 if (format.objectType() == QTextFormat::UserObject + 1) {
321 const QString &text = format.text();
322
323 if (!text.isEmpty()) {
324 tagList << text;
325 formatList << text;
326
327 if (!formats.contains(text)) {
328 formats[text] = format;
329 Q_EMIT tagAdded(text);
330 }
331 }
332 }
333 }
334
335 Q_FOREACH (const TagTextFormat &f, formats) {
336 if (!tagList.contains(f.text())) {
337 formats.remove(f.text());
338 Q_EMIT tagRemoved(f.text());
339 }
340 }
341}
342
343bool InputEdit::event(QEvent *e)
344{

Callers 1

askForChatMethod · 0.80

Calls 9

documentFunction · 0.85
checkRunningStateMethod · 0.80
setPositionMethod · 0.80
atEndMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
textMethod · 0.45
isEmptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected