Skip to content
Snippets Groups Projects
Commit 9d16a6ec authored by Andreas Schenk's avatar Andreas Schenk
Browse files

readded BZDNG-155 that was reverted by BZDNG-256 / fixed BZDNG-238

BZDNG-238 was not completely fixed before. We have to get the position of the
edit start block before we delete anything, as the bug in QT messes up the
edit start block and its position information
parent 89bd9a45
Branches
Tags
No related merge requests found
......@@ -328,6 +328,10 @@ void PythonShellWidget::setup_state_machine_()
single_line->addTransition(new KeyEventTransition(Qt::Key_Up,DNG_ARROW_MODIFIERS,history_up));
single_line->addTransition(new KeyEventTransition(Qt::Key_Down,DNG_ARROW_MODIFIERS,history_down));
KeyEventTransition* clear_all_tr_sl=new KeyEventTransition(Qt::Key_D,Qt::ControlModifier,single_line);
single_line->addTransition(clear_all_tr_sl);
connect(clear_all_tr_sl,SIGNAL(triggered()),this,SLOT(handle_clear_all_()));
//multi line inactive transitions
multi_line_inactive->addTransition(new KeyEventTransition(Qt::Key_Return,
Qt::NoModifier,
......@@ -343,6 +347,10 @@ void PythonShellWidget::setup_state_machine_()
multi_line_inactive->addTransition(tr6);
connect(tr6,SIGNAL(triggered()),this,SLOT(NewLineAtEnd()));
KeyEventTransition* clear_all_tr_mli=new KeyEventTransition(Qt::Key_D,Qt::ControlModifier,single_line);
multi_line_inactive->addTransition(clear_all_tr_mli);
connect(clear_all_tr_mli,SIGNAL(triggered()),this,SLOT(handle_clear_all_()));
multi_line_inactive->addTransition(new KeyEventTransition(Qt::Key_Left,DNG_ARROW_MODIFIERS,multiline_active_state_));
multi_line_inactive->addTransition(new KeyEventTransition(Qt::Key_Right,DNG_ARROW_MODIFIERS,multiline_active_state_));
multi_line_inactive->addTransition(new KeyEventTransition(Qt::Key_Up,DNG_ARROW_MODIFIERS,history_up));
......@@ -395,6 +403,9 @@ void PythonShellWidget::setup_state_machine_()
multiline_active_state_->addTransition(tr8);
connect(tr8,SIGNAL(triggered()),this,SLOT(NewLineAtEnd()));
KeyEventTransition* clear_all_tr_mla=new KeyEventTransition(Qt::Key_D,Qt::ControlModifier,single_line);
multiline_active_state_->addTransition(clear_all_tr_mla);
connect(clear_all_tr_mla,SIGNAL(triggered()),this,SLOT(handle_clear_all_()));
multiline_active_state_->addTransition(new KeyEventTransition(Qt::Key_Escape,Qt::NoModifier,multi_line_inactive));
multiline_active_state_->addTransition(new KeyEventTransition(Qt::Key_Up,Qt::ControlModifier,history_up));
multiline_active_state_->addTransition(new KeyEventTransition(Qt::Key_Down,Qt::ControlModifier,history_down));
......@@ -747,6 +758,12 @@ void PythonShellWidget::handle_completion_()
}
void PythonShellWidget::handle_clear_all_()
{
handle_select_all_rw_();
handle_delete_();
}
void PythonShellWidget::handle_delete_()
{
// BZDNG-238
......@@ -761,13 +778,14 @@ void PythonShellWidget::handle_delete_()
//
// If we emulate the deletion of the text manually all is fine.
QTextCursor cursor=this->textCursor();
int pos=block_edit_start_.position();
if (cursor.hasSelection()) {
cursor.removeSelectedText();
} else {
cursor.deleteChar();
}
QTextCursor tc=this->textCursor();
tc.setPosition(block_edit_start_.position());
tc.setPosition(pos);
block_edit_start_=tc.block();
}
......@@ -776,6 +794,7 @@ void PythonShellWidget::handle_backspace_()
// BZDNG-238
// see above
QTextCursor cursor=this->textCursor();
int pos=block_edit_start_.position();
if (cursor.hasSelection()) {
cursor.removeSelectedText();
} else {
......@@ -784,7 +803,7 @@ void PythonShellWidget::handle_backspace_()
}
}
QTextCursor tc=this->textCursor();
tc.setPosition(block_edit_start_.position());
tc.setPosition(pos);
block_edit_start_=tc.block();
}
......
......@@ -93,6 +93,7 @@ protected slots:
void handle_select_all_rw_();
void handle_delete_();
void handle_backspace_();
void handle_clear_all_();
protected:
virtual void resizeEvent(QResizeEvent* event);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment