Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
8fd0777a
Commit
8fd0777a
authored
Nov 18, 2009
by
Roberto Raggi
Browse files
Ensure the document is updated before invoking a quickfix.
parent
8e16ea71
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
8fd0777a
...
...
@@ -1308,6 +1308,14 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol)
return
0
;
}
bool
CPPEditor
::
isOutdated
()
const
{
if
(
m_lastSemanticInfo
.
revision
!=
document
()
->
revision
())
return
true
;
return
false
;
}
SemanticInfo
CPPEditor
::
semanticInfo
()
const
{
return
m_lastSemanticInfo
;
...
...
src/plugins/cppeditor/cppeditor.h
View file @
8fd0777a
...
...
@@ -185,6 +185,7 @@ public:
void
indentInsertedText
(
const
QTextCursor
&
tc
);
bool
isOutdated
()
const
;
SemanticInfo
semanticInfo
()
const
;
public
Q_SLOTS
:
...
...
src/plugins/cppeditor/cppplugin.cpp
View file @
8fd0777a
...
...
@@ -57,10 +57,14 @@
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtCore/QTimer>
#include <QtGui/QMenu>
using
namespace
CppEditor
::
Internal
;
enum
{
QUICKFIX_INTERVAL
=
20
};
//////////////////////////// CppEditorFactory /////////////////////////////
CppEditorFactory
::
CppEditorFactory
(
CppPlugin
*
owner
)
:
...
...
@@ -132,6 +136,11 @@ CppPlugin::CppPlugin() :
{
m_instance
=
this
;
m_quickFixTimer
=
new
QTimer
(
this
);
m_quickFixTimer
->
setInterval
(
20
);
m_quickFixTimer
->
setSingleShot
(
true
);
connect
(
m_quickFixTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
quickFixNow
()));
}
CppPlugin
::~
CppPlugin
()
...
...
@@ -152,12 +161,12 @@ void CppPlugin::initializeEditor(CPPEditor *editor)
TextEditor
::
TextEditorSettings
::
instance
()
->
initializeEditor
(
editor
);
// auto completion
connect
(
editor
,
SIGNAL
(
requestAutoCompletion
(
ITextEditable
*
,
bool
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
(),
SLOT
(
autoComplete
(
ITextEditable
*
,
bool
)));
connect
(
editor
,
SIGNAL
(
requestAutoCompletion
(
TextEditor
::
ITextEditable
*
,
bool
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
(),
SLOT
(
autoComplete
(
TextEditor
::
ITextEditable
*
,
bool
)));
// quick fix
connect
(
editor
,
SIGNAL
(
requestQuickFix
(
ITextEditable
*
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
()
,
SLOT
(
quickFix
(
ITextEditable
*
)));
connect
(
editor
,
SIGNAL
(
requestQuickFix
(
TextEditor
::
ITextEditable
*
)),
this
,
SLOT
(
quickFix
(
TextEditor
::
ITextEditable
*
)));
// method combo box sorting
connect
(
this
,
SIGNAL
(
methodOverviewSortingChanged
(
bool
)),
...
...
@@ -329,6 +338,30 @@ void CppPlugin::findUsages()
editor
->
findUsages
();
}
void
CppPlugin
::
quickFix
(
TextEditor
::
ITextEditable
*
editable
)
{
m_currentTextEditable
=
editable
;
quickFixNow
();
}
void
CppPlugin
::
quickFixNow
()
{
if
(
!
m_currentTextEditable
)
return
;
Core
::
EditorManager
*
em
=
Core
::
EditorManager
::
instance
();
CPPEditor
*
currentEditor
=
qobject_cast
<
CPPEditor
*>
(
em
->
currentEditor
()
->
widget
());
if
(
CPPEditor
*
editor
=
qobject_cast
<
CPPEditor
*>
(
m_currentTextEditable
->
widget
()))
{
if
(
currentEditor
==
editor
)
{
if
(
editor
->
isOutdated
())
m_quickFixTimer
->
start
(
QUICKFIX_INTERVAL
);
else
TextEditor
::
Internal
::
CompletionSupport
::
instance
()
->
quickFix
(
m_currentTextEditable
);
}
}
}
void
CppPlugin
::
onTaskStarted
(
const
QString
&
type
)
{
if
(
type
==
CppTools
::
Constants
::
TASK_INDEX
)
{
...
...
src/plugins/cppeditor/cppplugin.h
View file @
8fd0777a
...
...
@@ -39,6 +39,7 @@
namespace
TextEditor
{
class
TextEditorActionHandler
;
class
ITextEditable
;
}
// namespace TextEditor
namespace
CppEditor
{
...
...
@@ -78,6 +79,8 @@ private slots:
void
onTaskStarted
(
const
QString
&
type
);
void
onAllTasksFinished
(
const
QString
&
type
);
void
findUsages
();
void
quickFix
(
TextEditor
::
ITextEditable
*
editable
);
void
quickFixNow
();
private:
Core
::
IEditor
*
createEditor
(
QWidget
*
parent
);
...
...
@@ -91,6 +94,9 @@ private:
QAction
*
m_renameSymbolUnderCursorAction
;
QAction
*
m_findUsagesAction
;
QAction
*
m_updateCodeModelAction
;
QTimer
*
m_quickFixTimer
;
QPointer
<
TextEditor
::
ITextEditable
>
m_currentTextEditable
;
};
class
CppEditorFactory
:
public
Core
::
IEditorFactory
...
...
src/plugins/qmleditor/qmleditorplugin.cpp
View file @
8fd0777a
...
...
@@ -174,8 +174,8 @@ void QmlEditorPlugin::initializeEditor(QmlEditor::Internal::ScriptEditor *editor
TextEditor
::
TextEditorSettings
::
instance
()
->
initializeEditor
(
editor
);
// auto completion
connect
(
editor
,
SIGNAL
(
requestAutoCompletion
(
ITextEditable
*
,
bool
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
(),
SLOT
(
autoComplete
(
ITextEditable
*
,
bool
)));
connect
(
editor
,
SIGNAL
(
requestAutoCompletion
(
TextEditor
::
ITextEditable
*
,
bool
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
(),
SLOT
(
autoComplete
(
TextEditor
::
ITextEditable
*
,
bool
)));
}
Q_EXPORT_PLUGIN
(
QmlEditorPlugin
)
src/plugins/qtscripteditor/qtscripteditorplugin.cpp
View file @
8fd0777a
...
...
@@ -140,8 +140,8 @@ void QtScriptEditorPlugin::initializeEditor(QtScriptEditor::Internal::ScriptEdit
TextEditor
::
TextEditorSettings
::
instance
()
->
initializeEditor
(
editor
);
// auto completion
connect
(
editor
,
SIGNAL
(
requestAutoCompletion
(
ITextEditable
*
,
bool
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
(),
SLOT
(
autoComplete
(
ITextEditable
*
,
bool
)));
connect
(
editor
,
SIGNAL
(
requestAutoCompletion
(
TextEditor
::
ITextEditable
*
,
bool
)),
TextEditor
::
Internal
::
CompletionSupport
::
instance
(),
SLOT
(
autoComplete
(
TextEditor
::
ITextEditable
*
,
bool
)));
}
void
QtScriptEditorPlugin
::
registerActions
()
...
...
src/plugins/texteditor/basetexteditor.h
View file @
8fd0777a
...
...
@@ -573,8 +573,8 @@ protected slots:
signals:
void
requestFontSize
(
int
pointSize
);
void
requestBlockUpdate
(
const
QTextBlock
&
);
void
requestAutoCompletion
(
ITextEditable
*
editor
,
bool
forced
);
void
requestQuickFix
(
ITextEditable
*
editor
);
void
requestAutoCompletion
(
TextEditor
::
ITextEditable
*
editor
,
bool
forced
);
void
requestQuickFix
(
TextEditor
::
ITextEditable
*
editor
);
private:
void
indentOrUnindent
(
bool
doIndent
);
...
...
src/plugins/texteditor/completionsupport.h
View file @
8fd0777a
...
...
@@ -56,8 +56,8 @@ public:
static
CompletionSupport
*
instance
();
public
slots
:
void
autoComplete
(
ITextEditable
*
editor
,
bool
forced
);
void
quickFix
(
ITextEditable
*
editor
);
void
autoComplete
(
TextEditor
::
ITextEditable
*
editor
,
bool
forced
);
void
quickFix
(
TextEditor
::
ITextEditable
*
editor
);
private
slots
:
void
performCompletion
(
const
TextEditor
::
CompletionItem
&
item
);
...
...
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