From 75c6b5abcca6cc5a0048c0905b588f1d71f1c9b2 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 4 Sep 2020 18:06:52 +0300 Subject: [PATCH] fix QCodeEdit code complete popup size --- qad/libs/widgets/qcodeedit.cpp | 7 ++++--- qad/libs/widgets/qcodeedit.h | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qad/libs/widgets/qcodeedit.cpp b/qad/libs/widgets/qcodeedit.cpp index 4c72bf4..84575ed 100644 --- a/qad/libs/widgets/qcodeedit.cpp +++ b/qad/libs/widgets/qcodeedit.cpp @@ -1243,7 +1243,7 @@ void QCodeEdit::invokeAutoCompletition(bool force) { hideHelp(); return; } - acl << wordsCompletitionList(scope.second); + if (word_complet) acl << wordsCompletitionList(scope.second); QFont bf(font()); bf.setBold(true); foreach (const ACPair & ac, acl) { @@ -1274,8 +1274,9 @@ void QCodeEdit::invokeAutoCompletition(bool force) { completer->setVisible(true); //qApp->processEvents(); int sz = completer->verticalScrollBar()->width(); - for (int i = 0; i < completer->header()->count(); ++i) - sz += qMax(sz, ((QAbstractItemView*)completer)->sizeHintForColumn(i)); + sz += ((QAbstractItemView*)completer)->viewport()->width(); +// for (int i = 0; i < completer->header()->count(); ++i) +// sz += ((QAbstractItemView*)completer)->sizeHintForColumn(i); completer->resize(sz, fontHeight() * 16); } else completer->hide(); diff --git a/qad/libs/widgets/qcodeedit.h b/qad/libs/widgets/qcodeedit.h index 63059a1..a5e31d8 100644 --- a/qad/libs/widgets/qcodeedit.h +++ b/qad/libs/widgets/qcodeedit.h @@ -38,6 +38,7 @@ class QAD_WIDGETS_EXPORT QCodeEdit: public QWidget Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(bool showSpaces READ showSpaces WRITE setShowSpaces) Q_PROPERTY(bool showLineNumbers READ showLineNumbers WRITE setShowLineNumbers) + Q_PROPERTY(bool wordCompletitionEnabled READ wordCompletitionEnabled WRITE setWordCompletitionEnabled) Q_PROPERTY(QFont editorFont READ editorFont WRITE setEditorFont) public: @@ -72,6 +73,8 @@ public: void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon()) {ac_classes[id] = ACClass(id, ac_class, name, icon);} + bool wordCompletitionEnabled() const {return word_complet;} + protected: typedef QPair StringsPair; typedef QPair > ACPair; @@ -111,6 +114,7 @@ private: QStringList cursor_scope; 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 * ); @@ -124,7 +128,7 @@ private: void clearSearch(); void moveToSearch(); int searchIndFromCursor(); - + private slots: void syncScrolls(); void scrollUp(); @@ -163,7 +167,9 @@ public slots: void searchNext(bool next = true); void searchPrevious(); void hideSearch(); + void setWordCompletitionEnabled(bool on) {word_complet = on;} + signals: void textChanged(); void parseRequest();