From 52316d9af5888a574d95b610a216f7d00651928f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 27 May 2015 16:26:16 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@19 a8b55f48-bf90-11e4-a774-851b48703e85 --- CMakeLists.txt | 2 +- qad_widgets/qcodeedit.cpp | 16 ++++++++++++---- qad_widgets/qcodeedit.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9415a82..4eca110 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ foreach(F ${PIP_FOLDERS}) endforeach(F) #message(STATUS "PIP includes = ${PIP_INCLUDES}") -set(LIST_LIBS pip qad_widgets qad_utils qad_application qad_blockview qad_graphic qad_sql_table piqt mbricks kx_tools piqt_tools qglview touch_widgets) +set(LIST_LIBS pip qad_widgets qad_utils qad_application qad_blockview qad_graphic qad_sql_table piqt mbricks kx_tools piqt_tools touch_widgets) foreach(L ${LIST_LIBS}) add_subdirectory(${L}) diff --git a/qad_widgets/qcodeedit.cpp b/qad_widgets/qcodeedit.cpp index b5404eb..b17696a 100644 --- a/qad_widgets/qcodeedit.cpp +++ b/qad_widgets/qcodeedit.cpp @@ -15,8 +15,10 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { prev_lc = auto_comp_pl = -1; textCode = textLines = 0; + timer = 0; _ignore_focus_out = false; + _first = true; es_line.format.setBackground(QColor(240, 245, 240)); es_line.format.setProperty(QTextFormat::FullWidthSelection, true); completer.setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); @@ -24,7 +26,6 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { completer.setColumnCount(2); completer.setRootIsDecorated(false); completer.setHeaderHidden(true); - completer.installEventFilter(this); completer.header()->setDefaultAlignment(Qt::AlignCenter); completer.header()-> #if (QT_VERSION >= 0x050000) @@ -42,8 +43,6 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { textCode->setFrameShape(QFrame::NoFrame); textCode->setLineWrapMode(QPlainTextEdit::NoWrap); textCode->setTabChangesFocus(false); - textCode->installEventFilter(this); - textCode->viewport()->installEventFilter(this); textLines->setFrameShadow(QFrame::Plain); textLines->setFrameShape(QFrame::NoFrame); textLines->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); @@ -54,7 +53,6 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { textLines->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); textLines->viewport()->setAutoFillBackground(false); textLines->viewport()->setCursor(Qt::ArrowCursor); - textLines->viewport()->installEventFilter(this); textLines->setFixedWidth(textLines->fontMetrics().width(" ")); setLayout(new QBoxLayout(QBoxLayout::BottomToTop)); layout()->setContentsMargins(0, 0, 0, 0); @@ -311,6 +309,16 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { } +void QCodeEdit::showEvent(QShowEvent * ) { + if (!_first) return; + _first = false; + completer.installEventFilter(this); + textCode->installEventFilter(this); + textCode->viewport()->installEventFilter(this); + textLines->viewport()->installEventFilter(this); +} + + void QCodeEdit::timerEvent(QTimerEvent * ) { parse(); emit parseRequest(); diff --git a/qad_widgets/qcodeedit.h b/qad_widgets/qcodeedit.h index 3c99483..fd3cff9 100644 --- a/qad_widgets/qcodeedit.h +++ b/qad_widgets/qcodeedit.h @@ -71,9 +71,10 @@ private: QList es_selected, es_custom; QMap ac_classes; int prev_lc, auto_comp_pl, timer; - bool spaces_, _ignore_focus_out; + bool spaces_, _ignore_focus_out, _first; bool eventFilter(QObject * o, QEvent * e); + void showEvent(QShowEvent * ); void timerEvent(QTimerEvent * ); void applyExtraSelection(); void nextCompletition();