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

Method initEdit

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

Source from the content-addressed store, hash-verified

134}
135
136void InputEditWidgetPrivate::initEdit()
137{
138 edit = new InputEdit(q);
139 edit->setAutoSelectCode(true);
140 InputEditWidget::connect(edit, &InputEdit::textChanged, q, [this]() {
141 auto currentText = edit->toPlainText();
142
143 if (!isAnswering) {
144 if (currentText.isEmpty())
145 sendButton->setEnabled(false);
146 else
147 sendButton->setEnabled(true);
148 }
149
150 q->setFixedHeight(edit->height() + buttonBox->height());
151 auto cursor = edit->textCursor();
152 QString filterText = "";
153 QString strBeforeCursor = "";
154 while (cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor)) {
155 strBeforeCursor = cursor.selectedText();
156 if (strBeforeCursor.endsWith('@')) {
157 q->popupReference();
158 } else if (strBeforeCursor.contains(" ")) {
159 referencePopup->hide();
160 model.setFilterText("");
161 return;
162 } else if (strBeforeCursor.startsWith('@')) {
163 filterText = strBeforeCursor;
164 filterText.remove('@');
165 break;
166 }
167 }
168
169 if (!strBeforeCursor.contains('@')) {
170 referencePopup->hide();
171 return;
172 }
173
174 model.setFilterText(filterText);
175 if (model.getItems().isEmpty())
176 referencePopup->hide();
177 else
178 referencePopup->show();
179 });
180}
181
182void InputEditWidgetPrivate::initButtonBox()
183{

Callers

nothing calls this directly

Calls 15

connectFunction · 0.85
setAutoSelectCodeMethod · 0.80
textCursorMethod · 0.80
endsWithMethod · 0.80
popupReferenceMethod · 0.80
setFilterTextMethod · 0.80
startsWithMethod · 0.80
isEmptyMethod · 0.45
setEnabledMethod · 0.45
selectedTextMethod · 0.45
containsMethod · 0.45
hideMethod · 0.45

Tested by

no test coverage detected