| 134 | } |
| 135 | |
| 136 | void 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 | |
| 182 | void InputEditWidgetPrivate::initButtonBox() |
| 183 | { |
nothing calls this directly
no test coverage detected