diff --git a/kx_tools/kx_pult.cpp b/kx_tools/kx_pult.cpp index 6b2e62d..340b370 100644 --- a/kx_tools/kx_pult.cpp +++ b/kx_tools/kx_pult.cpp @@ -665,6 +665,13 @@ bool KX_Pult::calculateExpression(int i, QVector trace) { trace << i; QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QString expr = ti->text(2); + if (expr.isEmpty() || expr == "0" || expr == "0,00000000" || expr == "0.00000000") { + markNormal(ti); + calculated << i; + K[i] = 0.; + ti->setText(3, "0"); + return true; + } //ti->setToolTip(2, QString()); if (!eval.check(expr)) { markError(ti, eval.error()); diff --git a/make_libs.sh b/make_libs.sh index d010bb8..f8cdced 100755 --- a/make_libs.sh +++ b/make_libs.sh @@ -1,5 +1,5 @@ -cmake . -make install $@ +#cmake . +#make install $@ for d in 'qad_widgets' 'qad_utils' 'qad_graphic' 'qad_sql_table' 'qad_application' 'qad_blockview' 'touch_widgets'; do cd $d qmake diff --git a/qad_graphic/graphic.cpp b/qad_graphic/graphic.cpp index dcdc164..c468f35 100644 --- a/qad_graphic/graphic.cpp +++ b/qad_graphic/graphic.cpp @@ -1044,10 +1044,10 @@ void Graphic::setRectToLines() { line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = true; //qDebug() << "set to lines" << selrect; line_x_min.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit; - line_x_min.setValue(selrect.left()); - line_x_max.setValue(selrect.right()); - line_y_min.setValue(selrect.bottom()); - line_y_max.setValue(selrect.top()); + if (!line_x_min.hasFocus()) line_x_min.setValue(selrect.left()); + if (!line_x_max.hasFocus()) line_x_max.setValue(selrect.right()); + if (!line_y_min.hasFocus()) line_y_min.setValue(selrect.bottom()); + if (!line_y_max.hasFocus()) line_y_max.setValue(selrect.top()); if (!isFit) { line_x_min.setDefaultText(QString::number(grect.left()).toUpper()); line_x_max.setDefaultText(QString::number(grect.right()).toUpper()); diff --git a/qad_graphic/graphic.h b/qad_graphic/graphic.h index 6f01aac..9757295 100644 --- a/qad_graphic/graphic.h +++ b/qad_graphic/graphic.h @@ -320,7 +320,7 @@ protected: void setCurrentAction(GraphicAction action); void findGraphicsRect(double start_x = 0., double end_x = 0., double start_y = 0., double end_y = 0.); void tick(int index, bool slide = true, bool update = true); - void repaintCanvas(bool force = false) {if (tm.elapsed() < min_repaint_int && !force) return; tm.restart(); canvas->repaint();} + void repaintCanvas(bool force = false) {if (tm.elapsed() < min_repaint_int && !force) return; tm.restart(); canvas->update();} void drawGraphics(); void drawGrid(); void drawGuides(); diff --git a/qad_widgets/qcodeedit.cpp b/qad_widgets/qcodeedit.cpp index cff32aa..b5404eb 100644 --- a/qad_widgets/qcodeedit.cpp +++ b/qad_widgets/qcodeedit.cpp @@ -14,6 +14,8 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { prev_lc = auto_comp_pl = -1; + textCode = textLines = 0; + timer = 0; _ignore_focus_out = false; es_line.format.setBackground(QColor(240, 245, 240)); es_line.format.setProperty(QTextFormat::FullWidthSelection, true); @@ -52,6 +54,7 @@ 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); @@ -164,6 +167,20 @@ QChar QCodeEdit::pairChar(QChar c) { bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { + if (textLines) { + if (o == textLines->viewport()) { + if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease || + e->type() == QEvent::MouseMove || e->type() == QEvent::MouseButtonDblClick) { + const_cast(((QMouseEvent*)e)->pos()) = QPoint(0, ((QMouseEvent*)e)->pos().y()); + QApplication::sendEvent(textCode->viewport(), e); + return true; + } + if (e->type() == QEvent::Wheel) { + QApplication::sendEvent(textCode->viewport(), e); + return true; + } + } + } if (o == &completer) { //qDebug() << o << e; if (e->type() == QEvent::WindowActivate) @@ -171,127 +188,137 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { //qDebug() << e; return QWidget::eventFilter(o, e); } - if (o == textCode->viewport()) { - if (e->type() == QEvent::MouseButtonPress) - completer.hide(); - return QWidget::eventFilter(o, e); - } - if (o == textCode) { - //qDebug() << o << e; - QKeyEvent * ke; - QChar kc(0); - switch (e->type()) { - case QEvent::KeyPress: - ke = (QKeyEvent * )e; - switch (ke->key()) { - case Qt::Key_Space: - if (ke->modifiers().testFlag(Qt::ControlModifier)) { - invokeAutoCompletition(true); - return true; - } - break; - case Qt::Key_Escape: + if (textCode) { + if (o == textCode->viewport()) { + if (e->type() == QEvent::MouseButtonPress) completer.hide(); - break; - case Qt::Key_Up: - if (completer.isVisible()) { - previousCompletition(); - return true; + return QWidget::eventFilter(o, e); + } + if (o == textCode) { + //qDebug() << o << e; + QKeyEvent * ke; + QChar kc(0); + switch (e->type()) { + case QEvent::KeyPress: + ke = (QKeyEvent * )e; + switch (ke->key()) { + case Qt::Key_Space: + if (ke->modifiers().testFlag(Qt::ControlModifier)) { + invokeAutoCompletition(true); + return true; + } + break; + case Qt::Key_Escape: + completer.hide(); + break; + case Qt::Key_Up: + if (completer.isVisible()) { + previousCompletition(); + return true; + } + completer.hide(); + if (ke->modifiers().testFlag(Qt::AltModifier)) { + copyLineUp(); + return true; + } + if (ke->modifiers().testFlag(Qt::ControlModifier) && ke->modifiers().testFlag(Qt::ShiftModifier)) { + moveLineUp(); + return true; + } + break; + case Qt::Key_Down: + if (completer.isVisible()) { + nextCompletition(); + return true; + } + completer.hide(); + if (ke->modifiers().testFlag(Qt::AltModifier)) { + copyLineDown(); + return true; + } + if (ke->modifiers().testFlag(Qt::ControlModifier) && ke->modifiers().testFlag(Qt::ShiftModifier)) { + moveLineDown(); + return true; + } + break; + case Qt::Key_Home: + case Qt::Key_End: + case Qt::Key_PageUp: + case Qt::Key_PageDown: + if (completer.isVisible()) { + qApp->sendEvent(&completer, new QKeyEvent(e->type(), ke->key(), ke->modifiers())); + return true; + } + break; + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Backspace: + case Qt::Key_Delete: + if (completer.isVisible()) + QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false)); + break; + case Qt::Key_Return: + if (completer.isVisible()) { + commitCompletition(); + completer.hide(); + return true; + } + if (textCode->textCursor().selectedText().isEmpty()) + QMetaObject::invokeMethod(this, "autoIndent", Qt::QueuedConnection); + break; + case Qt::Key_Tab: + if (!textCode->textCursor().selectedText().isEmpty()) { + if (ke->modifiers().testFlag(Qt::ShiftModifier)) + deindent(); + else + indent(); + return true; + } + break; + case Qt::Key_D: + if (ke->modifiers().testFlag(Qt::ControlModifier)) { + completer.hide(); + return true; + } + break; + default: break; } - completer.hide(); - if (ke->modifiers().testFlag(Qt::AltModifier)) { - copyLineUp(); - return true; - } - if (ke->modifiers().testFlag(Qt::ControlModifier) && ke->modifiers().testFlag(Qt::ShiftModifier)) { - moveLineUp(); - return true; - } - break; - case Qt::Key_Down: - if (completer.isVisible()) { - nextCompletition(); - return true; - } - completer.hide(); - if (ke->modifiers().testFlag(Qt::AltModifier)) { - copyLineDown(); - return true; - } - if (ke->modifiers().testFlag(Qt::ControlModifier) && ke->modifiers().testFlag(Qt::ShiftModifier)) { - moveLineDown(); - return true; - } - break; - case Qt::Key_Home: - case Qt::Key_End: - case Qt::Key_PageUp: - case Qt::Key_PageDown: - if (completer.isVisible()) { - qApp->sendEvent(&completer, new QKeyEvent(e->type(), ke->key(), ke->modifiers())); - return true; - } - break; - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Backspace: - case Qt::Key_Delete: - if (completer.isVisible()) + if (!ke->text().isEmpty()) + kc = ke->text()[0]; + if (kc == '.') { + completer.hide(); QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false)); - break; - case Qt::Key_Return: - if (completer.isVisible()) { - commitCompletition(); - completer.hide(); - return true; - } - if (textCode->textCursor().selectedText().isEmpty()) - QMetaObject::invokeMethod(this, "autoIndent", Qt::QueuedConnection); - break; - case Qt::Key_Tab: - if (!textCode->textCursor().selectedText().isEmpty()) { - if (ke->modifiers().testFlag(Qt::ShiftModifier)) - deindent(); - else - indent(); - return true; + } else { + if ((kc.isLetterOrNumber() || kc.toLatin1() == '_') && completer.isVisible()) + QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false)); } break; - case Qt::Key_D: - if (ke->modifiers().testFlag(Qt::ControlModifier)) { - completer.hide(); - return true; + case QEvent::FocusOut: + if (_ignore_focus_out) { + _ignore_focus_out = false; + break; } - break; + case QEvent::Hide: + case QEvent::HideToParent: + case QEvent::MouseButtonPress: + //qDebug() << e; + completer.hide(); default: break; } - if (!ke->text().isEmpty()) - kc = ke->text()[0]; - if (kc == '.') { - completer.hide(); - QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false)); - } else { - if ((kc.isLetterOrNumber() || kc.toLatin1() == '_') && completer.isVisible()) - QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false)); - } - break; - case QEvent::FocusOut: - if (_ignore_focus_out) { - _ignore_focus_out = false; - break; - } - case QEvent::Hide: - case QEvent::HideToParent: - case QEvent::MouseButtonPress: - //qDebug() << e; - completer.hide(); - default: break; } } return QWidget::eventFilter(o, e); } +void QCodeEdit::timerEvent(QTimerEvent * ) { + parse(); + emit parseRequest(); + killTimer(timer); + timer = 0; +} + + void QCodeEdit::applyExtraSelection() { textCode->setExtraSelections(QList() << es_line << es_selected << es_custom); } @@ -563,6 +590,8 @@ void QCodeEdit::autoIndent() { void QCodeEdit::updateLines() { + if (timer > 0) killTimer(timer); + timer = startTimer(500); textCode->setTabStopWidth(textCode->fontMetrics().width(" ")); int lc = textCode->document()->lineCount(); if (prev_lc == lc) return; diff --git a/qad_widgets/qcodeedit.h b/qad_widgets/qcodeedit.h index c174c8b..3c99483 100644 --- a/qad_widgets/qcodeedit.h +++ b/qad_widgets/qcodeedit.h @@ -49,6 +49,7 @@ protected: typedef QList ACList; virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const {return ACList();} + virtual void parse() {} ACList wordsCompletitionList(const QString & written) const; static int skipRange(const QString & s, int pos, QChar oc, QChar cc, QChar sc = QChar()); static int skipCWord(const QString & s, int pos); @@ -69,10 +70,11 @@ private: QTextEdit::ExtraSelection es_line; QList es_selected, es_custom; QMap ac_classes; - int prev_lc, auto_comp_pl; + int prev_lc, auto_comp_pl, timer; bool spaces_, _ignore_focus_out; bool eventFilter(QObject * o, QEvent * e); + void timerEvent(QTimerEvent * ); void applyExtraSelection(); void nextCompletition(); void previousCompletition(); @@ -101,6 +103,7 @@ public slots: signals: void textChanged(); + void parseRequest(); };