From cf47fa46d9614d8bc2d5b4b9e5a99ecd55edf418 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Mon, 29 Dec 2008 16:15:51 +0000 Subject: implemented #323 git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2958 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/editor/scripteditor.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/modules/editor/scripteditor.cpp') diff --git a/src/modules/editor/scripteditor.cpp b/src/modules/editor/scripteditor.cpp index 1b6ee2841..70534a8e4 100644 --- a/src/modules/editor/scripteditor.cpp +++ b/src/modules/editor/scripteditor.cpp @@ -343,24 +343,25 @@ void KviScriptEditorWidget::keyPressEvent(QKeyEvent * e) // Adapted from QT4 QCompleter example bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E if (!m_pCompleter || !isShortcut) // dont process the shortcut when we have a completer - QTextEdit::keyPressEvent(e); + QTextEdit::keyPressEvent(e); const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier); - if (!m_pCompleter || (ctrlOrShift && e->text().isEmpty())) - return; - static QString eow("~!@#$%^&*()_+{}|:\"<>?,/;'[]\\-="); // end of word - bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift; - QString completionPrefix = textUnderCursor(); + if (!m_pCompleter || (ctrlOrShift && e->text().isEmpty())) + return; + static QString eow("~!@#$%^&*()_+{}|:\"<>?,/;'[]\\-="); // end of word + bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift; + QString completionPrefix = textUnderCursor(); if (!isShortcut && (hasModifier || e->text().isEmpty()|| completionPrefix.length() < 3 || eow.contains(e->text().right(1)))) { - m_pCompleter->popup()->hide(); + m_pCompleter->popup()->hide(); return; - } - if (completionPrefix != m_pCompleter->completionPrefix()) { - m_pCompleter->setCompletionPrefix(completionPrefix); - m_pCompleter->popup()->setCurrentIndex(m_pCompleter->completionModel()->index(0, 0)); - } - QRect cr = cursorRect(); - cr.setWidth(m_pCompleter->popup()->sizeHintForColumn(0)+ m_pCompleter->popup()->verticalScrollBar()->sizeHint().width()); + } + if (completionPrefix != m_pCompleter->completionPrefix()) + { + m_pCompleter->setCompletionPrefix(completionPrefix); + m_pCompleter->popup()->setCurrentIndex(m_pCompleter->completionModel()->index(0, 0)); + } + QRect cr = cursorRect(); + cr.setWidth(m_pCompleter->popup()->sizeHintForColumn(0)+ m_pCompleter->popup()->verticalScrollBar()->sizeHint().width()); m_pCompleter->complete(cr); } -- cgit v1.3.1-10-gc9f91