save/restore collapsed state
git-svn-id: svn://db.shs.com.ru/libs@16 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -665,6 +665,13 @@ bool KX_Pult::calculateExpression(int i, QVector<int> trace) {
|
|||||||
trace << i;
|
trace << i;
|
||||||
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
|
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
|
||||||
QString expr = ti->text(2);
|
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());
|
//ti->setToolTip(2, QString());
|
||||||
if (!eval.check(expr)) {
|
if (!eval.check(expr)) {
|
||||||
markError(ti, eval.error());
|
markError(ti, eval.error());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake .
|
#cmake .
|
||||||
make install $@
|
#make install $@
|
||||||
for d in 'qad_widgets' 'qad_utils' 'qad_graphic' 'qad_sql_table' 'qad_application' 'qad_blockview' 'touch_widgets'; do
|
for d in 'qad_widgets' 'qad_utils' 'qad_graphic' 'qad_sql_table' 'qad_application' 'qad_blockview' 'touch_widgets'; do
|
||||||
cd $d
|
cd $d
|
||||||
qmake
|
qmake
|
||||||
|
|||||||
@@ -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;
|
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;
|
//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.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit;
|
||||||
line_x_min.setValue(selrect.left());
|
if (!line_x_min.hasFocus()) line_x_min.setValue(selrect.left());
|
||||||
line_x_max.setValue(selrect.right());
|
if (!line_x_max.hasFocus()) line_x_max.setValue(selrect.right());
|
||||||
line_y_min.setValue(selrect.bottom());
|
if (!line_y_min.hasFocus()) line_y_min.setValue(selrect.bottom());
|
||||||
line_y_max.setValue(selrect.top());
|
if (!line_y_max.hasFocus()) line_y_max.setValue(selrect.top());
|
||||||
if (!isFit) {
|
if (!isFit) {
|
||||||
line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
|
line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
|
||||||
line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
|
line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ protected:
|
|||||||
void setCurrentAction(GraphicAction action);
|
void setCurrentAction(GraphicAction action);
|
||||||
void findGraphicsRect(double start_x = 0., double end_x = 0., double start_y = 0., double end_y = 0.);
|
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 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 drawGraphics();
|
||||||
void drawGrid();
|
void drawGrid();
|
||||||
void drawGuides();
|
void drawGuides();
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
||||||
prev_lc = auto_comp_pl = -1;
|
prev_lc = auto_comp_pl = -1;
|
||||||
|
textCode = textLines = 0;
|
||||||
|
timer = 0;
|
||||||
_ignore_focus_out = false;
|
_ignore_focus_out = false;
|
||||||
es_line.format.setBackground(QColor(240, 245, 240));
|
es_line.format.setBackground(QColor(240, 245, 240));
|
||||||
es_line.format.setProperty(QTextFormat::FullWidthSelection, true);
|
es_line.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||||
@@ -52,6 +54,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
|||||||
textLines->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
textLines->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
textLines->viewport()->setAutoFillBackground(false);
|
textLines->viewport()->setAutoFillBackground(false);
|
||||||
textLines->viewport()->setCursor(Qt::ArrowCursor);
|
textLines->viewport()->setCursor(Qt::ArrowCursor);
|
||||||
|
textLines->viewport()->installEventFilter(this);
|
||||||
textLines->setFixedWidth(textLines->fontMetrics().width(" "));
|
textLines->setFixedWidth(textLines->fontMetrics().width(" "));
|
||||||
setLayout(new QBoxLayout(QBoxLayout::BottomToTop));
|
setLayout(new QBoxLayout(QBoxLayout::BottomToTop));
|
||||||
layout()->setContentsMargins(0, 0, 0, 0);
|
layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
@@ -164,6 +167,20 @@ QChar QCodeEdit::pairChar(QChar c) {
|
|||||||
|
|
||||||
|
|
||||||
bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
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<QPoint&>(((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) {
|
if (o == &completer) {
|
||||||
//qDebug() << o << e;
|
//qDebug() << o << e;
|
||||||
if (e->type() == QEvent::WindowActivate)
|
if (e->type() == QEvent::WindowActivate)
|
||||||
@@ -171,127 +188,137 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
//qDebug() << e;
|
//qDebug() << e;
|
||||||
return QWidget::eventFilter(o, e);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
if (o == textCode->viewport()) {
|
if (textCode) {
|
||||||
if (e->type() == QEvent::MouseButtonPress)
|
if (o == textCode->viewport()) {
|
||||||
completer.hide();
|
if (e->type() == QEvent::MouseButtonPress)
|
||||||
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();
|
completer.hide();
|
||||||
break;
|
return QWidget::eventFilter(o, e);
|
||||||
case Qt::Key_Up:
|
}
|
||||||
if (completer.isVisible()) {
|
if (o == textCode) {
|
||||||
previousCompletition();
|
//qDebug() << o << e;
|
||||||
return true;
|
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->text().isEmpty())
|
||||||
if (ke->modifiers().testFlag(Qt::AltModifier)) {
|
kc = ke->text()[0];
|
||||||
copyLineUp();
|
if (kc == '.') {
|
||||||
return true;
|
completer.hide();
|
||||||
}
|
|
||||||
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));
|
QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||||
break;
|
} else {
|
||||||
case Qt::Key_Return:
|
if ((kc.isLetterOrNumber() || kc.toLatin1() == '_') && completer.isVisible())
|
||||||
if (completer.isVisible()) {
|
QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||||
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;
|
break;
|
||||||
case Qt::Key_D:
|
case QEvent::FocusOut:
|
||||||
if (ke->modifiers().testFlag(Qt::ControlModifier)) {
|
if (_ignore_focus_out) {
|
||||||
completer.hide();
|
_ignore_focus_out = false;
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case QEvent::Hide:
|
||||||
|
case QEvent::HideToParent:
|
||||||
|
case QEvent::MouseButtonPress:
|
||||||
|
//qDebug() << e;
|
||||||
|
completer.hide();
|
||||||
default: break;
|
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);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::timerEvent(QTimerEvent * ) {
|
||||||
|
parse();
|
||||||
|
emit parseRequest();
|
||||||
|
killTimer(timer);
|
||||||
|
timer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::applyExtraSelection() {
|
void QCodeEdit::applyExtraSelection() {
|
||||||
textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected << es_custom);
|
textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected << es_custom);
|
||||||
}
|
}
|
||||||
@@ -563,6 +590,8 @@ void QCodeEdit::autoIndent() {
|
|||||||
|
|
||||||
|
|
||||||
void QCodeEdit::updateLines() {
|
void QCodeEdit::updateLines() {
|
||||||
|
if (timer > 0) killTimer(timer);
|
||||||
|
timer = startTimer(500);
|
||||||
textCode->setTabStopWidth(textCode->fontMetrics().width(" "));
|
textCode->setTabStopWidth(textCode->fontMetrics().width(" "));
|
||||||
int lc = textCode->document()->lineCount();
|
int lc = textCode->document()->lineCount();
|
||||||
if (prev_lc == lc) return;
|
if (prev_lc == lc) return;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ protected:
|
|||||||
typedef QList<ACPair> ACList;
|
typedef QList<ACPair> ACList;
|
||||||
|
|
||||||
virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const {return ACList();}
|
virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const {return ACList();}
|
||||||
|
virtual void parse() {}
|
||||||
ACList wordsCompletitionList(const QString & written) const;
|
ACList wordsCompletitionList(const QString & written) const;
|
||||||
static int skipRange(const QString & s, int pos, QChar oc, QChar cc, QChar sc = QChar());
|
static int skipRange(const QString & s, int pos, QChar oc, QChar cc, QChar sc = QChar());
|
||||||
static int skipCWord(const QString & s, int pos);
|
static int skipCWord(const QString & s, int pos);
|
||||||
@@ -69,10 +70,11 @@ private:
|
|||||||
QTextEdit::ExtraSelection es_line;
|
QTextEdit::ExtraSelection es_line;
|
||||||
QList<QTextEdit::ExtraSelection> es_selected, es_custom;
|
QList<QTextEdit::ExtraSelection> es_selected, es_custom;
|
||||||
QMap<int, ACClass> ac_classes;
|
QMap<int, ACClass> ac_classes;
|
||||||
int prev_lc, auto_comp_pl;
|
int prev_lc, auto_comp_pl, timer;
|
||||||
bool spaces_, _ignore_focus_out;
|
bool spaces_, _ignore_focus_out;
|
||||||
|
|
||||||
bool eventFilter(QObject * o, QEvent * e);
|
bool eventFilter(QObject * o, QEvent * e);
|
||||||
|
void timerEvent(QTimerEvent * );
|
||||||
void applyExtraSelection();
|
void applyExtraSelection();
|
||||||
void nextCompletition();
|
void nextCompletition();
|
||||||
void previousCompletition();
|
void previousCompletition();
|
||||||
@@ -101,6 +103,7 @@ public slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
void parseRequest();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user