Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Hunger
qt-creator
Commits
64710c2b
Commit
64710c2b
authored
Oct 05, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perform renaming.
parent
1ba39198
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
3 deletions
+66
-3
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/cppfindreferences.cpp
+64
-3
src/plugins/cpptools/cppfindreferences.h
src/plugins/cpptools/cppfindreferences.h
+1
-0
src/plugins/find/searchresultwindow.cpp
src/plugins/find/searchresultwindow.cpp
+1
-0
No files found.
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
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