Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
a0faf279
Commit
a0faf279
authored
Jul 19, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delay the automatic completion.
parent
ecdee327
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
5 deletions
+46
-5
src/plugins/cpptools/cppcodecompletion.cpp
src/plugins/cpptools/cppcodecompletion.cpp
+6
-1
src/plugins/texteditor/basetexteditor.cpp
src/plugins/texteditor/basetexteditor.cpp
+31
-3
src/plugins/texteditor/basetexteditor.h
src/plugins/texteditor/basetexteditor.h
+6
-1
src/plugins/texteditor/basetexteditor_p.h
src/plugins/texteditor/basetexteditor_p.h
+3
-0
No files found.
src/plugins/cpptools/cppcodecompletion.cpp
View file @
a0faf279
...
...
@@ -658,7 +658,7 @@ bool CppCodeCompletion::triggersCompletion(TextEditor::ITextEditable *editor)
QChar
characterUnderCursor
=
editor
->
characterAt
(
pos
);
if
(
!
characterUnderCursor
.
isLetterOrNumber
())
{
const
int
startOfName
=
findStartOfName
(
pos
);
if
(
pos
-
startOfName
=
=
3
)
{
if
(
pos
-
startOfName
>
=
3
)
{
const
QChar
firstCharacter
=
editor
->
characterAt
(
startOfName
);
if
(
firstCharacter
.
isLetter
()
||
firstCharacter
==
QLatin1Char
(
'_'
))
{
// Finally check that we're not inside a comment or string (code copied from startOfOperator)
...
...
@@ -1725,6 +1725,11 @@ void CppCodeCompletion::completions(QList<TextEditor::CompletionItem> *completio
}
}
}
if
(
completions
->
size
()
==
1
)
{
if
(
key
==
completions
->
first
().
text
)
completions
->
clear
();
}
}
QList
<
TextEditor
::
CompletionItem
>
CppCodeCompletion
::
removeDuplicates
(
const
QList
<
TextEditor
::
CompletionItem
>
&
items
)
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
a0faf279
...
...
@@ -61,6 +61,7 @@
#include <QtCore/QDebug>
#include <QtCore/QTimer>
#include <QtCore/QTimeLine>
#include <QtCore/QTime>
#include <QtGui/QAbstractTextDocumentLayout>
#include <QtGui/QApplication>
#include <QtGui/QKeyEvent>
...
...
@@ -240,6 +241,11 @@ BaseTextEditor::BaseTextEditor(QWidget *parent)
d
->
m_highlightBlocksTimer
->
setSingleShot
(
true
);
connect
(
d
->
m_highlightBlocksTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
_q_highlightBlocks
()));
d
->
m_requestAutoCompletionTimer
=
new
QTimer
(
this
);
d
->
m_requestAutoCompletionTimer
->
setSingleShot
(
true
);
d
->
m_requestAutoCompletionTimer
->
setInterval
(
500
);
connect
(
d
->
m_requestAutoCompletionTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
_q_requestAutoCompletion
()));
d
->
m_animator
=
0
;
d
->
m_searchResultFormat
.
setBackground
(
QColor
(
0xffef0b
));
...
...
@@ -1380,18 +1386,38 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
setTextCursor
(
cursor
);
}
skip_event:
skip_event:
if
(
!
ro
&&
e
->
key
()
==
Qt
::
Key_Delete
&&
d
->
m_parenthesesMatchingEnabled
)
d
->
m_parenthesesMatchingTimer
->
start
(
50
);
if
(
!
ro
&&
d
->
m_contentsChanged
&&
!
e
->
text
().
isEmpty
()
&&
e
->
text
().
at
(
0
).
isPrint
())
emit
requestAutoCompletion
(
editableInterface
(),
false
);
if
(
!
ro
&&
d
->
m_contentsChanged
&&
!
e
->
text
().
isEmpty
()
&&
e
->
text
().
at
(
0
).
isPrint
())
{
maybeRequestAutoCompletion
(
e
->
text
().
at
(
0
));
}
if
(
e
!=
original_e
)
delete
e
;
}
void
BaseTextEditor
::
maybeRequestAutoCompletion
(
const
QChar
&
ch
)
{
if
(
ch
.
isLetterOrNumber
()
||
ch
==
QLatin1Char
(
'_'
))
{
d
->
m_requestAutoCompletionRevision
=
document
()
->
revision
();
d
->
m_requestAutoCompletionTimer
->
start
();
}
else
{
d
->
m_requestAutoCompletionTimer
->
stop
();
emit
requestAutoCompletion
(
editableInterface
(),
false
);
}
}
void
BaseTextEditor
::
_q_requestAutoCompletion
()
{
d
->
m_requestAutoCompletionTimer
->
stop
();
if
(
d
->
m_requestAutoCompletionRevision
==
document
()
->
revision
())
emit
requestAutoCompletion
(
editableInterface
(),
false
);
}
void
BaseTextEditor
::
insertCodeSnippet
(
const
QTextCursor
&
cursor_arg
,
const
QString
&
snippet
)
{
if
((
snippet
.
count
(
'$'
)
%
2
)
!=
0
)
{
...
...
@@ -1908,6 +1934,8 @@ BaseTextEditorPrivate::BaseTextEditorPrivate()
m_moveLineUndoHack
(
false
),
m_findScopeVerticalBlockSelection
(
0
),
m_highlightBlocksTimer
(
0
),
m_requestAutoCompletionRevision
(
0
),
m_requestAutoCompletionTimer
(
0
),
m_cursorBlockNumber
(
-
1
),
m_inKeyPressEvent
(
false
)
{
...
...
src/plugins/texteditor/basetexteditor.h
View file @
a0faf279
...
...
@@ -496,6 +496,7 @@ signals:
void
requestQuickFix
(
TextEditor
::
ITextEditable
*
editor
);
private:
void
maybeRequestAutoCompletion
(
const
QChar
&
ch
);
void
indentOrUnindent
(
bool
doIndent
);
void
handleHomeKey
(
bool
anchor
);
void
handleBackspaceKey
();
...
...
@@ -527,13 +528,17 @@ private:
void
universalHelper
();
// test function for development
// parentheses matcher
private
slots
:
// auto completion
void
_q_requestAutoCompletion
();
// parentheses matcher
void
_q_matchParentheses
();
void
_q_highlightBlocks
();
void
slotSelectionChanged
();
void
_q_animateUpdate
(
int
position
,
QPointF
lastPos
,
QRectF
rect
);
void
doFoo
();
};
...
...
src/plugins/texteditor/basetexteditor_p.h
View file @
a0faf279
...
...
@@ -263,6 +263,9 @@ public:
BaseTextEditorPrivateHighlightBlocks
m_highlightBlocksInfo
;
QTimer
*
m_highlightBlocksTimer
;
int
m_requestAutoCompletionRevision
;
QTimer
*
m_requestAutoCompletionTimer
;
QPointer
<
BaseTextEditorAnimator
>
m_animator
;
int
m_cursorBlockNumber
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment