#ifndef COMPLETIONPOPUP_H #define COMPLETIONPOPUP_H #include #include #include struct EditorCompletionItem { QString display; QString detail; QString insertText; bool ambiguous = false; }; struct EditorCompletionResult { int replaceStart = 0; int replaceLen = 0; bool hasQualifier = false; // completing behind "name." std::vector items; }; /// Callback that determines the completions for a cursor position in the text using EditorCompletionCallback = std::function; /// List shown below the cursor, it never takes keyboard focus so typing continues in the editor. class CompletionPopup : public QListWidget { Q_OBJECT public: explicit CompletionPopup(QWidget *parent); void setItems(const std::vector &items); void moveSelection(int delta); int currentRow() const { return QListWidget::currentRow(); } void showAt(const QPoint &globalPos); signals: void itemAccepted(int row); }; #endif // COMPLETIONPOPUP_H