save/restore collapsed state

git-svn-id: svn://db.shs.com.ru/libs@16 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
2015-05-26 06:33:44 +00:00
parent 3bd8997ee3
commit 7ba1b12a53
6 changed files with 154 additions and 115 deletions

View File

@@ -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());

View File

@@ -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

View File

@@ -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());

View File

@@ -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();

View File

@@ -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,6 +188,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
//qDebug() << e; //qDebug() << e;
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }
if (textCode) {
if (o == textCode->viewport()) { if (o == textCode->viewport()) {
if (e->type() == QEvent::MouseButtonPress) if (e->type() == QEvent::MouseButtonPress)
completer.hide(); completer.hide();
@@ -288,10 +306,19 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
default: break; 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;

View File

@@ -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();
}; };