git-svn-id: svn://db.shs.com.ru/libs@342 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -19,7 +19,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
||||
ui = new Ui::QCodeEdit();
|
||||
ui->setupUi(this);
|
||||
ui->widgetSearch->hide();
|
||||
prev_lc = auto_comp_pl = cur_search_ind = -1;
|
||||
prev_lc = auto_comp_pl = cur_search_ind = pos_press = pos_el_press = -1;
|
||||
timer = 0;
|
||||
_ignore_focus_out = _destructor = _replacing = false;
|
||||
_first = true;
|
||||
@@ -277,7 +277,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
if (ui->textLines) {
|
||||
if (o == ui->textLines->viewport()) {
|
||||
if (o == ui->textLines->viewport()) {/*
|
||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease ||
|
||||
e->type() == QEvent::MouseMove || e->type() == QEvent::MouseButtonDblClick) {
|
||||
#if (QT_VERSION < 0x050000)
|
||||
@@ -287,10 +287,42 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
#endif
|
||||
QApplication::sendEvent(ui->textCode->viewport(), e);
|
||||
return true;
|
||||
}
|
||||
if (e->type() == QEvent::Wheel) {
|
||||
}*/
|
||||
QTextCursor tc;
|
||||
int tcpos = 0;
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
tc = ui->textCode->cursorForPosition(((QMouseEvent*)e)->pos());
|
||||
tc.movePosition(QTextCursor::EndOfLine);
|
||||
pos_el_press = tc.anchor();
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
pos_press = tc.anchor();
|
||||
if (!tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor))
|
||||
tc.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
|
||||
ui->textCode->setTextCursor(tc);
|
||||
return true;
|
||||
case QEvent::MouseMove:
|
||||
tc = ui->textCode->cursorForPosition(((QMouseEvent*)e)->pos());
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
if (pos_press == tc.anchor()) {
|
||||
if (!tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor))
|
||||
tc.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
|
||||
ui->textCode->setTextCursor(tc);
|
||||
return true;
|
||||
}
|
||||
if (pos_press < tc.anchor()) {
|
||||
if (!tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor))
|
||||
tc.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
|
||||
}
|
||||
tcpos = tc.position();
|
||||
tc.setPosition(pos_press < tc.anchor() ? pos_press : pos_el_press);
|
||||
tc.setPosition(tcpos, QTextCursor::KeepAnchor);
|
||||
ui->textCode->setTextCursor(tc);
|
||||
return true;
|
||||
case QEvent::Wheel:
|
||||
QApplication::sendEvent(ui->textCode->viewport(), e);
|
||||
return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user