Big QCodeEdit update: supports for autocomplete/help hint and custom data. Add dynamic links on Ctrl+mouse by 2 new virtual functions.
This commit is contained in:
@@ -54,7 +54,17 @@ public:
|
||||
Function,
|
||||
Namespace
|
||||
};
|
||||
|
||||
struct QAD_WIDGETS_EXPORT ACEntry {
|
||||
ACEntry(const QString & t = QString(), const QString & n = QString(), const QString & h = QString()):
|
||||
type(t), name(n), hint(h) {declaration_pos = -1; custom_data = 0;}
|
||||
bool isNull() const {return type.isEmpty() && name.isEmpty();}
|
||||
QString type;
|
||||
QString name;
|
||||
QString hint;
|
||||
int declaration_pos;
|
||||
void * custom_data;
|
||||
};
|
||||
|
||||
QTextCursor textCursor() const;
|
||||
QTextDocument * document() const;
|
||||
void setDocument(QTextDocument * doc);
|
||||
@@ -75,19 +85,22 @@ public:
|
||||
|
||||
QPlainTextEdit * textEdit() const;
|
||||
|
||||
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon()) {ac_classes[id] = ACClass(id, ac_class, name, icon);}
|
||||
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon());
|
||||
|
||||
bool wordCompletitionEnabled() const {return word_complet;}
|
||||
|
||||
protected:
|
||||
typedef QPair<QString, QString> StringsPair;
|
||||
typedef QPair<int, QList<StringsPair> > ACPair;
|
||||
typedef QList<ACPair> ACList;
|
||||
typedef QPair<int, QList<ACEntry> > ACSection; // section, ACClass.id -> list of entries
|
||||
typedef QList<ACSection> ACList; // list of sections
|
||||
|
||||
virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const {return ACList();}
|
||||
virtual void parse() {}
|
||||
virtual void documentUnset() {}
|
||||
virtual void documentChanged(QTextDocument * d) {}
|
||||
virtual void linkClicked(ACEntry entry) {}
|
||||
virtual bool linkValidate(ACEntry e) {return true;}
|
||||
|
||||
QString selectArg(QString s, int arg);
|
||||
void raiseHelp(QTextCursor tc, int arg = -1);
|
||||
QTextCursor functionStart(QTextCursor tc, int * arg);
|
||||
@@ -108,30 +121,38 @@ private:
|
||||
QString name;
|
||||
QIcon icon;
|
||||
};
|
||||
enum LabelHelpType {
|
||||
lhMain,
|
||||
lhHint,
|
||||
lhF1
|
||||
};
|
||||
|
||||
QCodeEditCompleter * completer;
|
||||
IconedLabel * lbl_help[2];
|
||||
IconedLabel * lbl_help[3];
|
||||
QFrame * widget_help;
|
||||
QTextEdit::ExtraSelection es_line, es_cursor, es_bracket, es_range, es_search;
|
||||
QTextEdit::ExtraSelection es_line, es_cursor, es_bracket, es_range, es_search, es_link;
|
||||
QList<QTextEdit::ExtraSelection> es_selected, es_custom, es_brackets, es_search_list;
|
||||
QMap<int, ACClass> ac_classes;
|
||||
QStringList cursor_scope;
|
||||
ACEntry link_entry;
|
||||
int prev_lc, auto_comp_pl, timer, cur_search_ind, pos_press, pos_el_press;
|
||||
bool spaces_, _ignore_focus_out, _first, _destructor, _replacing;
|
||||
bool word_complet;
|
||||
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void showEvent(QShowEvent * );
|
||||
void timerEvent(QTimerEvent * );
|
||||
void leaveEvent(QEvent * );
|
||||
void changeEvent(QEvent * e);
|
||||
bool eventFilter(QObject * o, QEvent * e) override;
|
||||
void showEvent(QShowEvent * ) override;
|
||||
void timerEvent(QTimerEvent * ) override;
|
||||
void leaveEvent(QEvent * ) override;
|
||||
void changeEvent(QEvent * e) override;
|
||||
void highlightBrackets();
|
||||
void applyExtraSelection();
|
||||
void clearSearch();
|
||||
void moveToSearch();
|
||||
int searchIndFromCursor();
|
||||
ACEntry findEntryOnCursor(QTextCursor tc, int arg = -1, ACClass * acc = 0, QPair<QStringList, QString> * scope = 0);
|
||||
|
||||
private slots:
|
||||
void _activateLink(QCodeEdit::ACEntry e) {linkClicked(e);}
|
||||
void syncScrolls();
|
||||
void scrollUp();
|
||||
void scrollDown();
|
||||
@@ -144,6 +165,9 @@ private slots:
|
||||
void indent();
|
||||
void deindent();
|
||||
void autoIndent();
|
||||
void showLink();
|
||||
void hideLink();
|
||||
void gotoLink();
|
||||
void invokeAutoCompletition(bool force = false);
|
||||
void commitCompletition();
|
||||
void searchAll();
|
||||
@@ -170,7 +194,6 @@ public slots:
|
||||
void searchPrevious();
|
||||
void hideSearch();
|
||||
void setWordCompletitionEnabled(bool on) {word_complet = on;}
|
||||
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
|
||||
Reference in New Issue
Block a user