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
90e7bac4
Commit
90e7bac4
authored
Aug 04, 2009
by
Roberto Raggi
Browse files
Made `Rename Symbol under Cursor' a command/action.
parent
2356bdc7
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
90e7bac4
...
...
@@ -543,9 +543,6 @@ CPPEditor::CPPEditor(QWidget *parent)
setCodeFoldingVisible
(
true
);
baseTextDocument
()
->
setSyntaxHighlighter
(
new
CppHighlighter
);
new
QShortcut
(
QKeySequence
(
tr
(
"CTRL+SHIFT+r"
)),
this
,
SLOT
(
renameInPlace
()),
/*ambiguousMember=*/
0
,
Qt
::
WidgetShortcut
);
#ifdef WITH_TOKEN_MOVE_POSITION
new
QShortcut
(
QKeySequence
::
MoveToPreviousWord
,
this
,
SLOT
(
moveToPreviousToken
()),
/*ambiguousMember=*/
0
,
Qt
::
WidgetShortcut
);
...
...
@@ -829,7 +826,7 @@ void CPPEditor::reformatDocument()
c
.
insertText
(
QString
::
fromUtf8
(
str
.
c_str
(),
str
.
length
()));
}
void
CPPEditor
::
rename
InPlace
()
void
CPPEditor
::
rename
SymbolUnderCursor
()
{
updateSemanticInfo
(
m_semanticHighlighter
->
semanticInfo
(
currentSource
()));
...
...
@@ -1331,8 +1328,8 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
if
(
lastAction
->
menu
()
&&
QLatin1String
(
lastAction
->
menu
()
->
metaObject
()
->
className
())
==
QLatin1String
(
"QUnicodeControlCharacterMenu"
))
menu
->
removeAction
(
lastAction
);
Core
::
Action
Container
*
mcontext
=
Core
::
ICore
::
instance
()
->
actionManager
()
->
actionContainer
(
CppEditor
::
Constants
::
M_CONTEXT
);
Core
::
Action
Manager
*
am
=
Core
::
ICore
::
instance
()
->
actionManager
();
Core
::
ActionContainer
*
mcontext
=
am
->
actionContainer
(
CppEditor
::
Constants
::
M_CONTEXT
);
QMenu
*
contextMenu
=
mcontext
->
menu
();
foreach
(
QAction
*
action
,
contextMenu
->
actions
())
...
...
@@ -1341,13 +1338,6 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
const
QList
<
QTextEdit
::
ExtraSelection
>
selections
=
extraSelections
(
BaseTextEditor
::
CodeSemanticsSelection
);
if
(
!
selections
.
isEmpty
())
{
const
QString
name
=
selections
.
first
().
cursor
.
selectedText
();
QAction
*
renameAction
=
new
QAction
(
tr
(
"Rename '%1'"
).
arg
(
name
),
menu
);
connect
(
renameAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
renameInPlace
()));
menu
->
addAction
(
renameAction
);
}
menu
->
exec
(
e
->
globalPos
());
delete
menu
;
}
...
...
src/plugins/cppeditor/cppeditor.h
View file @
90e7bac4
...
...
@@ -197,6 +197,7 @@ public Q_SLOTS:
void
setSortedMethodOverview
(
bool
sort
);
void
switchDeclarationDefinition
();
void
jumpToDefinition
();
void
renameSymbolUnderCursor
();
void
moveToPreviousToken
();
void
moveToNextToken
();
...
...
@@ -228,7 +229,6 @@ private Q_SLOTS:
void
updateUsesNow
();
void
onDocumentUpdated
(
CPlusPlus
::
Document
::
Ptr
doc
);
void
reformatDocument
();
void
renameInPlace
();
void
onContentsChanged
(
int
position
,
int
charsRemoved
,
int
charsAdded
);
void
semanticRehighlight
();
...
...
src/plugins/cppeditor/cppeditorconstants.h
View file @
90e7bac4
...
...
@@ -38,6 +38,7 @@ const char * const M_CONTEXT = "CppEditor.ContextMenu";
const
char
*
const
C_CPPEDITOR
=
"C++ Editor"
;
const
char
*
const
CPPEDITOR_KIND
=
QT_TRANSLATE_NOOP
(
"OpenWith::Editors"
,
"C++ Editor"
);
const
char
*
const
SWITCH_DECLARATION_DEFINITION
=
"CppEditor.SwitchDeclarationDefinition"
;
const
char
*
const
RENAME_SYMBOL_UNDER_CURSOR
=
"CppEditor.RenameSymbolUnderCursor"
;
const
char
*
const
JUMP_TO_DEFINITION
=
"CppEditor.JumpToDefinition"
;
const
char
*
const
HEADER_FILE_TYPE
=
"CppHeaderFiles"
;
...
...
src/plugins/cppeditor/cppplugin.cpp
View file @
90e7bac4
...
...
@@ -212,6 +212,14 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
am
->
actionContainer
(
CppEditor
::
Constants
::
M_CONTEXT
)
->
addAction
(
cmd
);
am
->
actionContainer
(
CppTools
::
Constants
::
M_TOOLS_CPP
)
->
addAction
(
cmd
);
QAction
*
renameSymbolUnderCursorAction
=
new
QAction
(
tr
(
"Rename Symbol under Cursor"
),
this
);
cmd
=
am
->
registerAction
(
renameSymbolUnderCursorAction
,
Constants
::
RENAME_SYMBOL_UNDER_CURSOR
,
context
);
cmd
->
setDefaultKeySequence
(
QKeySequence
(
"CTRL+SHIFT+R"
));
connect
(
renameSymbolUnderCursorAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
renameSymbolUnderCursor
()));
am
->
actionContainer
(
CppEditor
::
Constants
::
M_CONTEXT
)
->
addAction
(
cmd
);
am
->
actionContainer
(
CppTools
::
Constants
::
M_TOOLS_CPP
)
->
addAction
(
cmd
);
m_actionHandler
=
new
TextEditor
::
TextEditorActionHandler
(
CppEditor
::
Constants
::
C_CPPEDITOR
,
TextEditor
::
TextEditorActionHandler
::
Format
|
TextEditor
::
TextEditorActionHandler
::
UnCommentSelection
...
...
@@ -265,4 +273,12 @@ void CppPlugin::jumpToDefinition()
editor
->
jumpToDefinition
();
}
void
CppPlugin
::
renameSymbolUnderCursor
()
{
Core
::
EditorManager
*
em
=
Core
::
EditorManager
::
instance
();
CPPEditor
*
editor
=
qobject_cast
<
CPPEditor
*>
(
em
->
currentEditor
()
->
widget
());
if
(
editor
)
editor
->
renameSymbolUnderCursor
();
}
Q_EXPORT_PLUGIN
(
CppPlugin
)
src/plugins/cppeditor/cppplugin.h
View file @
90e7bac4
...
...
@@ -73,6 +73,7 @@ public slots:
private
slots
:
void
switchDeclarationDefinition
();
void
jumpToDefinition
();
void
renameSymbolUnderCursor
();
private:
Core
::
IEditor
*
createEditor
(
QWidget
*
parent
);
...
...
Write
Preview
Supports
Markdown
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