}
};
-class SpaceCompleter : public QCompleter {
-protected:
- QString pathFromIndex(const QModelIndex &index) const override
- {
- QString completion = QCompleter::pathFromIndex(index);
- return completion + ' ';
- }
-};
-
#endif //FEATHER_COMPONENTS_H
tc.movePosition(QTextCursor::Left);
tc.movePosition(QTextCursor::EndOfWord);
tc.insertText(completion.right(extra));
+ if (this->document()->characterAt(tc.position()) != ' ') {
+ tc.insertText(" ");
+ }
setTextCursor(tc);
}
}
void TextEdit::keyPressEvent(QKeyEvent *e) {
- if (c && c->popup()->isVisible()) {
- // The following keys are forwarded by the completer to the widget
- switch (e->key()) {
- case Qt::Key_Enter:
- case Qt::Key_Return:
- case Qt::Key_Escape:
- case Qt::Key_Tab:
- case Qt::Key_Backtab:
- e->ignore();
- return; // let the completer do default behavior
- default:
- break;
- }
+ if (c) {
+ if (c->popup()->isVisible()) {
+ // The following keys are forwarded by the completer to the widget
+ switch (e->key()) {
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Escape:
+ case Qt::Key_Tab:
+ case Qt::Key_Backtab:
+ e->ignore();
+ return; // let the completer do default behavior
+ default:
+ break;
+ }
+ }
+ else {
+ // Never insert a tab char if we have a completer
+ if (e->key() == Qt::Key_Tab) {
+ e->accept();
+ return;
+ }
+ }
}
const bool isShortcut = (e->modifiers().testFlag(Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E