aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/editor/scripteditor.cpp
diff options
context:
space:
mode:
authorGravatar Fabio Bas2008-12-29 16:15:51 +0000
committerGravatar Fabio Bas2008-12-29 16:15:51 +0000
commitcf47fa46d9614d8bc2d5b4b9e5a99ecd55edf418 (patch)
treefac3c1ee84a39d0bfd70846737bf2f1974b962b5 /src/modules/editor/scripteditor.cpp
parentinput editor: don't change font at every paintEvent (diff)
downloadKVIrc-cf47fa46d9614d8bc2d5b4b9e5a99ecd55edf418.tar.gz
KVIrc-cf47fa46d9614d8bc2d5b4b9e5a99ecd55edf418.tar.bz2
KVIrc-cf47fa46d9614d8bc2d5b4b9e5a99ecd55edf418.zip
implemented #323
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2958 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/editor/scripteditor.cpp')
-rw-r--r--src/modules/editor/scripteditor.cpp29
1 files changed, 15 insertions, 14 deletions
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);
}