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
64710c2b
Commit
64710c2b
authored
Oct 05, 2009
by
Roberto Raggi
Browse files
Perform renaming.
parent
1ba39198
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/cpptools/cppfindreferences.cpp
View file @
64710c2b
...
...
@@ -534,17 +534,24 @@ static void find_helper(QFutureInterface<Utils::FileSearchResult> &future,
void
CppFindReferences
::
findUsages
(
Symbol
*
symbol
)
{
_resultWindow
->
clearContents
();
Find
::
SearchResult
*
search
=
_resultWindow
->
startNewSearch
(
Find
::
SearchResultWindow
::
SearchOnly
);
connect
(
search
,
SIGNAL
(
activated
(
Find
::
SearchResultItem
)),
this
,
SLOT
(
openEditor
(
Find
::
SearchResultItem
)));
findAll_helper
(
symbol
);
}
void
CppFindReferences
::
renameUsages
(
Symbol
*
symbol
)
{
Find
::
SearchResult
*
search
=
_resultWindow
->
startNewSearch
();
Find
::
SearchResult
*
search
=
_resultWindow
->
startNewSearch
(
Find
::
SearchResultWindow
::
SearchAndReplace
);
connect
(
search
,
SIGNAL
(
activated
(
Find
::
SearchResultItem
)),
this
,
SLOT
(
openEditor
(
Find
::
SearchResultItem
)));
_resultWindow
->
setShowReplaceUI
(
true
);
connect
(
search
,
SIGNAL
(
replaceButtonClicked
(
QString
,
QList
<
Find
::
SearchResultItem
>
)),
SLOT
(
onReplaceButtonClicked
(
QString
,
QList
<
Find
::
SearchResultItem
>
)));
findAll_helper
(
symbol
);
}
...
...
@@ -567,6 +574,60 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
connect
(
progress
,
SIGNAL
(
clicked
()),
_resultWindow
,
SLOT
(
popup
()));
}
void
CppFindReferences
::
onReplaceButtonClicked
(
const
QString
&
text
,
const
QList
<
Find
::
SearchResultItem
>
&
items
)
{
if
(
text
.
isEmpty
())
return
;
QHash
<
QString
,
QList
<
Find
::
SearchResultItem
>
>
changes
;
foreach
(
const
Find
::
SearchResultItem
&
item
,
items
)
changes
[
item
.
fileName
].
append
(
item
);
QHashIterator
<
QString
,
QList
<
Find
::
SearchResultItem
>
>
it
(
changes
);
while
(
it
.
hasNext
())
{
it
.
next
();
const
QString
fileName
=
it
.
key
();
QFile
file
(
fileName
);
if
(
file
.
open
(
QFile
::
ReadOnly
))
{
QTextStream
stream
(
&
file
);
// ### set the encoding
const
QString
plainText
=
stream
.
readAll
();
file
.
close
();
QTextDocument
doc
;
doc
.
setPlainText
(
plainText
);
QList
<
QTextCursor
>
cursors
;
const
QList
<
Find
::
SearchResultItem
>
items
=
it
.
value
();
foreach
(
const
Find
::
SearchResultItem
&
item
,
items
)
{
const
int
blockNumber
=
item
.
lineNumber
-
1
;
QTextCursor
tc
(
doc
.
findBlockByNumber
(
blockNumber
));
tc
.
setPosition
(
tc
.
position
()
+
item
.
searchTermStart
);
tc
.
setPosition
(
tc
.
position
()
+
item
.
searchTermLength
,
QTextCursor
::
KeepAnchor
);
cursors
.
append
(
tc
);
}
foreach
(
QTextCursor
tc
,
cursors
)
tc
.
insertText
(
text
);
QFile
newFile
(
fileName
);
if
(
newFile
.
open
(
QFile
::
WriteOnly
))
{
QTextStream
stream
(
&
newFile
);
// ### set the encoding
stream
<<
doc
.
toPlainText
();
}
}
}
const
QStringList
fileNames
=
changes
.
keys
();
_modelManager
->
updateSourceFiles
(
fileNames
);
}
void
CppFindReferences
::
displayResult
(
int
index
)
{
Utils
::
FileSearchResult
result
=
m_watcher
.
future
().
resultAt
(
index
);
...
...
src/plugins/cpptools/cppfindreferences.h
View file @
64710c2b
...
...
@@ -70,6 +70,7 @@ private Q_SLOTS:
void
displayResult
(
int
);
void
searchFinished
();
void
openEditor
(
const
Find
::
SearchResultItem
&
item
);
void
onReplaceButtonClicked
(
const
QString
&
text
,
const
QList
<
Find
::
SearchResultItem
>
&
items
);
private:
void
findAll_helper
(
CPlusPlus
::
Symbol
*
symbol
);
...
...
src/plugins/find/searchresultwindow.cpp
View file @
64710c2b
...
...
@@ -87,6 +87,7 @@ SearchResultWindow::SearchResultWindow()
connect
(
m_searchResultTreeView
,
SIGNAL
(
jumpToSearchResult
(
int
,
bool
)),
this
,
SLOT
(
handleJumpToSearchResult
(
int
,
bool
)));
connect
(
m_expandCollapseToolButton
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
handleExpandCollapseToolButton
(
bool
)));
connect
(
m_replaceTextEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
handleReplaceButton
()));
connect
(
m_replaceButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
handleReplaceButton
()));
readSettings
();
...
...
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