Skip to content
GitLab
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
44e2704b
Commit
44e2704b
authored
Oct 05, 2009
by
con
Browse files
Refactor search result window for use of many items and checked state.
parent
406d35ac
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/plugins/cpptools/cppfindreferences.cpp
View file @
44e2704b
...
...
@@ -493,7 +493,10 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
void
CppFindReferences
::
findAll
(
Symbol
*
symbol
)
{
_resultWindow
->
clearContents
();
Find
::
SearchResult
*
search
=
_resultWindow
->
startNewSearch
();
connect
(
search
,
SIGNAL
(
activated
(
Find
::
SearchResultItem
)),
this
,
SLOT
(
openEditor
(
Find
::
SearchResultItem
)));
_resultWindow
->
setShowReplaceUI
(
true
);
_resultWindow
->
popup
(
true
);
...
...
@@ -515,14 +518,11 @@ void CppFindReferences::findAll(Symbol *symbol)
void
CppFindReferences
::
displayResult
(
int
index
)
{
Core
::
Utils
::
FileSearchResult
result
=
m_watcher
.
future
().
resultAt
(
index
);
Find
::
ResultWindowItem
*
item
=
_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
if
(
item
)
connect
(
item
,
SIGNAL
(
activated
(
const
QString
&
,
int
,
int
)),
this
,
SLOT
(
openEditor
(
const
QString
&
,
int
,
int
)));
_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
}
void
CppFindReferences
::
searchFinished
()
...
...
@@ -530,8 +530,8 @@ void CppFindReferences::searchFinished()
emit
changed
();
}
void
CppFindReferences
::
openEditor
(
const
QString
&
fileName
,
int
line
,
int
column
)
void
CppFindReferences
::
openEditor
(
const
Find
::
SearchResultItem
&
item
)
{
TextEditor
::
BaseTextEditor
::
openEditorAt
(
fileName
,
line
,
column
);
TextEditor
::
BaseTextEditor
::
openEditorAt
(
item
.
fileName
,
item
.
lineNumber
,
item
.
searchTermStart
);
}
src/plugins/cpptools/cppfindreferences.h
View file @
44e2704b
...
...
@@ -39,6 +39,7 @@
namespace
Find
{
class
SearchResultWindow
;
struct
SearchResultItem
;
}
// end of namespace Find
namespace
CppTools
{
...
...
@@ -67,7 +68,7 @@ public:
private
Q_SLOTS
:
void
displayResult
(
int
);
void
searchFinished
();
void
openEditor
(
const
QString
&
,
int
,
int
);
void
openEditor
(
const
Find
::
SearchResultItem
&
item
);
private:
QPointer
<
CppModelManager
>
_modelManager
;
...
...
src/plugins/cpptools/cpptoolsplugin.cpp
View file @
44e2704b
...
...
@@ -86,7 +86,10 @@ FindClassDeclarations::FindClassDeclarations(CppModelManager *modelManager)
void
FindClassDeclarations
::
findAll
(
const
QString
&
text
,
QTextDocument
::
FindFlags
findFlags
)
{
_resultWindow
->
clearContents
();
Find
::
SearchResult
*
search
=
_resultWindow
->
startNewSearch
();
connect
(
search
,
SIGNAL
(
activated
(
Find
::
SearchResultItem
)),
this
,
SLOT
(
openEditor
(
Find
::
SearchResultItem
)));
_resultWindow
->
popup
(
true
);
Core
::
ProgressManager
*
progressManager
=
Core
::
ICore
::
instance
()
->
progressManager
();
...
...
@@ -107,14 +110,11 @@ void FindClassDeclarations::findAll(const QString &text, QTextDocument::FindFlag
void
FindClassDeclarations
::
displayResult
(
int
index
)
{
Core
::
Utils
::
FileSearchResult
result
=
m_watcher
.
future
().
resultAt
(
index
);
Find
::
ResultWindowItem
*
item
=
_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
if
(
item
)
connect
(
item
,
SIGNAL
(
activated
(
const
QString
&
,
int
,
int
)),
this
,
SLOT
(
openEditor
(
const
QString
&
,
int
,
int
)));
_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
}
void
FindClassDeclarations
::
searchFinished
()
...
...
@@ -122,9 +122,9 @@ void FindClassDeclarations::searchFinished()
emit
changed
();
}
void
FindClassDeclarations
::
openEditor
(
const
QString
&
fileName
,
int
line
,
int
column
)
void
FindClassDeclarations
::
openEditor
(
const
Find
::
SearchResultItem
&
item
)
{
TextEditor
::
BaseTextEditor
::
openEditorAt
(
fileName
,
line
,
column
);
TextEditor
::
BaseTextEditor
::
openEditorAt
(
item
.
fileName
,
item
.
lineNumber
,
item
.
searchTermStart
);
}
//////
...
...
@@ -139,7 +139,10 @@ FindFunctionCalls::FindFunctionCalls(CppModelManager *modelManager)
void
FindFunctionCalls
::
findAll
(
const
QString
&
text
,
QTextDocument
::
FindFlags
findFlags
)
{
_resultWindow
->
clearContents
();
Find
::
SearchResult
*
search
=
_resultWindow
->
startNewSearch
();
connect
(
search
,
SIGNAL
(
activated
(
Find
::
SearchResultItem
)),
this
,
SLOT
(
openEditor
(
Find
::
SearchResultItem
)));
_resultWindow
->
popup
(
true
);
Core
::
ProgressManager
*
progressManager
=
Core
::
ICore
::
instance
()
->
progressManager
();
...
...
@@ -160,14 +163,11 @@ void FindFunctionCalls::findAll(const QString &text, QTextDocument::FindFlags fi
void
FindFunctionCalls
::
displayResult
(
int
index
)
{
Core
::
Utils
::
FileSearchResult
result
=
m_watcher
.
future
().
resultAt
(
index
);
Find
::
ResultWindowItem
*
item
=
_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
if
(
item
)
connect
(
item
,
SIGNAL
(
activated
(
const
QString
&
,
int
,
int
)),
this
,
SLOT
(
openEditor
(
const
QString
&
,
int
,
int
)));
_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
}
void
FindFunctionCalls
::
searchFinished
()
...
...
@@ -175,9 +175,9 @@ void FindFunctionCalls::searchFinished()
emit
changed
();
}
void
FindFunctionCalls
::
openEditor
(
const
QString
&
fileName
,
int
line
,
int
column
)
void
FindFunctionCalls
::
openEditor
(
const
Find
::
SearchResultItem
&
item
)
{
TextEditor
::
BaseTextEditor
::
openEditorAt
(
fileName
,
line
,
column
);
TextEditor
::
BaseTextEditor
::
openEditorAt
(
item
.
fileName
,
item
.
lineNumber
,
item
.
searchTermStart
);
}
...
...
src/plugins/cpptools/cpptoolsplugin.h
View file @
44e2704b
...
...
@@ -53,6 +53,7 @@ class Snapshot;
namespace
Find
{
class
SearchResultWindow
;
struct
SearchResultItem
;
}
namespace
CppTools
{
...
...
@@ -79,7 +80,7 @@ public:
protected
Q_SLOTS
:
void
displayResult
(
int
);
void
searchFinished
();
void
openEditor
(
const
QString
&
,
int
,
int
);
void
openEditor
(
const
Find
::
SearchResultItem
&
item
);
private:
QPointer
<
CppModelManager
>
_modelManager
;
...
...
@@ -104,7 +105,7 @@ public:
protected
Q_SLOTS
:
void
displayResult
(
int
);
void
searchFinished
();
void
openEditor
(
const
QString
&
,
int
,
int
);
void
openEditor
(
const
Find
::
SearchResultItem
&
item
);
private:
QPointer
<
CppModelManager
>
_modelManager
;
...
...
src/plugins/find/searchresulttreeview.cpp
View file @
44e2704b
...
...
@@ -81,13 +81,10 @@ void SearchResultTreeView::emitJumpToSearchResult(const QModelIndex &index)
if
(
model
()
->
data
(
index
,
ItemDataRoles
::
TypeRole
).
toString
().
compare
(
"row"
)
!=
0
)
return
;
QString
fileName
=
model
()
->
data
(
index
,
ItemDataRoles
::
FileNameRole
).
toString
();
int
position
=
model
()
->
data
(
index
,
ItemDataRoles
::
ResultIndexRole
).
toInt
();
int
lineNumber
=
model
()
->
data
(
index
,
ItemDataRoles
::
ResultLineNumberRole
).
toInt
();
int
searchTermStart
=
model
()
->
data
(
index
,
ItemDataRoles
::
SearchTermStartRole
).
toInt
();
int
searchTermLength
=
model
()
->
data
(
index
,
ItemDataRoles
::
SearchTermLengthRole
).
toInt
();
int
checked
=
model
()
->
data
(
index
,
Qt
::
CheckStateRole
).
toBool
();
emit
jumpToSearchResult
(
position
,
fileName
,
lineNumber
,
searchTermStart
,
searchTermLength
);
emit
jumpToSearchResult
(
position
,
checked
);
}
void
SearchResultTreeView
::
keyPressEvent
(
QKeyEvent
*
e
)
...
...
src/plugins/find/searchresulttreeview.h
View file @
44e2704b
...
...
@@ -51,8 +51,7 @@ public:
SearchResultTreeModel
*
model
()
const
;
signals:
void
jumpToSearchResult
(
int
index
,
const
QString
&
fileName
,
int
lineNumber
,
int
searchTermStart
,
int
searchTermLength
);
void
jumpToSearchResult
(
int
index
,
bool
checked
);
public
slots
:
void
clear
();
...
...
src/plugins/find/searchresultwindow.cpp
View file @
44e2704b
...
...
@@ -29,8 +29,10 @@
#include
"searchresultwindow.h"
#include
"searchresulttreemodel.h"
#include
"searchresulttreeitems.h"
#include
<coreplugin/icore.h>
#include
<utils/qtcassert.h>
#include
<QtCore/QFile>
#include
<QtCore/QTextStream>
...
...
@@ -49,18 +51,9 @@ static const QString SETTINGSKEYSECTIONNAME("SearchResults");
static
const
QString
SETTINGSKEYEXPANDRESULTS
(
"ExpandResults"
);
void
ResultWindowItem
::
setData
(
const
QVariant
&
data
)
{
m_data
=
data
;
}
QVariant
ResultWindowItem
::
data
()
const
{
return
m_data
;
}
SearchResultWindow
::
SearchResultWindow
()
:
m_isShowingReplaceUI
(
false
)
:
m_currentSearch
(
0
),
m_isShowingReplaceUI
(
false
)
{
m_widget
=
new
QStackedWidget
;
m_widget
->
setWindowTitle
(
name
());
...
...
@@ -91,8 +84,8 @@ SearchResultWindow::SearchResultWindow()
m_replaceButton
->
setAutoRaise
(
true
);
m_replaceTextEdit
->
setTabOrder
(
m_replaceTextEdit
,
m_searchResultTreeView
);
connect
(
m_searchResultTreeView
,
SIGNAL
(
jumpToSearchResult
(
int
,
const
QString
&
,
int
,
int
,
int
)),
this
,
SLOT
(
handleJumpToSearchResult
(
int
,
const
QString
&
,
int
,
int
,
int
)));
connect
(
m_searchResultTreeView
,
SIGNAL
(
jumpToSearchResult
(
int
,
bool
)),
this
,
SLOT
(
handleJumpToSearchResult
(
int
,
bool
)));
connect
(
m_expandCollapseToolButton
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
handleExpandCollapseToolButton
(
bool
)));
connect
(
m_replaceButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
handleReplaceButton
()));
...
...
@@ -103,9 +96,10 @@ SearchResultWindow::SearchResultWindow()
SearchResultWindow
::~
SearchResultWindow
()
{
writeSettings
();
delete
m_currentSearch
;
m_currentSearch
=
0
;
delete
m_widget
;
m_widget
=
0
;
qDeleteAll
(
m_items
);
m_items
.
clear
();
}
...
...
@@ -115,7 +109,6 @@ void SearchResultWindow::setShowReplaceUI(bool show)
m_replaceLabel
->
setVisible
(
show
);
m_replaceTextEdit
->
setVisible
(
show
);
m_replaceButton
->
setVisible
(
show
);
// TODO m_searchResultTreeView->setShowCheckboxes(show);
m_isShowingReplaceUI
=
show
;
}
...
...
@@ -126,18 +119,27 @@ bool SearchResultWindow::isShowingReplaceUI() const
void
SearchResultWindow
::
handleReplaceButton
()
{
emit
replaceButtonClicked
(
m_replaceTextEdit
->
text
());
QTC_ASSERT
(
m_currentSearch
,
return
);
m_currentSearch
->
replaceButtonClicked
(
m_replaceTextEdit
->
text
(),
checkedItems
());
}
QList
<
Result
Window
Item
*
>
SearchResultWindow
::
sel
ec
t
edItems
()
const
QList
<
Search
ResultItem
>
SearchResultWindow
::
ch
ec
k
edItems
()
const
{
QList
<
ResultWindowItem
*>
items
;
// TODO
// foreach (ResultWindowItem *item, m_items) {
// if (item->isSelected)
// items << item;
// }
return
items
;
QList
<
SearchResultItem
>
result
;
SearchResultTreeModel
*
model
=
m_searchResultTreeView
->
model
();
const
int
fileCount
=
model
->
rowCount
(
QModelIndex
());
for
(
int
i
=
0
;
i
<
fileCount
;
++
i
)
{
QModelIndex
fileIndex
=
model
->
index
(
i
,
0
,
QModelIndex
());
SearchResultFile
*
fileItem
=
static_cast
<
SearchResultFile
*>
(
fileIndex
.
internalPointer
());
Q_ASSERT
(
fileItem
!=
0
);
for
(
int
rowIndex
=
0
;
rowIndex
<
fileItem
->
childrenCount
();
++
rowIndex
)
{
QModelIndex
textIndex
=
model
->
index
(
rowIndex
,
0
,
fileIndex
);
SearchResultTextRow
*
rowItem
=
static_cast
<
SearchResultTextRow
*>
(
textIndex
.
internalPointer
());
if
(
rowItem
->
checkState
())
result
<<
m_items
.
at
(
rowItem
->
index
());
}
}
return
result
;
}
void
SearchResultWindow
::
visibilityChanged
(
bool
/*visible*/
)
...
...
@@ -154,18 +156,27 @@ QList<QWidget*> SearchResultWindow::toolBarWidgets() const
return
QList
<
QWidget
*>
()
<<
m_expandCollapseToolButton
<<
m_replaceLabel
<<
m_replaceTextEdit
<<
m_replaceButton
;
}
SearchResult
*
SearchResultWindow
::
startNewSearch
(
SearchMode
searchOrSearchAndReplace
)
{
clearContents
();
setShowReplaceUI
(
searchOrSearchAndReplace
!=
SearchOnly
);
delete
m_currentSearch
;
m_currentSearch
=
new
SearchResult
;
return
m_currentSearch
;
}
void
SearchResultWindow
::
clearContents
()
{
setShowReplaceUI
(
false
);
m_widget
->
setCurrentWidget
(
m_searchResultTreeView
);
setReplaceUIEnabled
(
false
);
m_searchResultTreeView
->
clear
();
qDeleteAll
(
m_items
);
m_items
.
clear
();
m_widget
->
setCurrentWidget
(
m_searchResultTreeView
);
navigateStateChanged
();
}
void
SearchResultWindow
::
showNoMatchesFound
()
{
setReplaceUIEnabled
(
false
);
m_widget
->
setCurrentWidget
(
m_noMatchesFoundDisplay
);
}
...
...
@@ -176,7 +187,7 @@ bool SearchResultWindow::isEmpty() const
int
SearchResultWindow
::
numberOfResults
()
const
{
return
m_
searchResultTreeView
->
model
()
->
rowC
ount
();
return
m_
items
.
c
ount
();
}
bool
SearchResultWindow
::
hasFocus
()
...
...
@@ -210,30 +221,41 @@ void SearchResultWindow::setTextEditorFont(const QFont &font)
m_searchResultTreeView
->
setTextEditorFont
(
font
);
}
void
SearchResultWindow
::
handleJumpToSearchResult
(
int
index
,
const
QString
&
fileName
,
int
lineNumber
,
int
searchTermStart
,
int
searchTermLength
)
void
SearchResultWindow
::
handleJumpToSearchResult
(
int
index
,
bool
checked
)
{
Q_UNUSED
(
searchTermLength
)
ResultWindowItem
*
item
=
m_items
.
at
(
index
);
emit
item
->
activated
(
fileName
,
lineNumber
,
searchTermStart
);
QTC_ASSERT
(
m_currentSearch
,
return
);
m_currentSearch
->
activated
(
m_items
.
at
(
index
));
}
ResultWindowItem
*
SearchResultWindow
::
addResult
(
const
QString
&
fileName
,
int
lineNumber
,
const
QString
&
rowText
,
int
searchTermStart
,
int
searchTermLength
)
void
SearchResultWindow
::
addResult
(
const
QString
&
fileName
,
int
lineNumber
,
const
QString
&
rowText
,
int
searchTermStart
,
int
searchTermLength
,
const
QVariant
&
userData
)
{
//qDebug()<<"###"<<fileName;
m_widget
->
setCurrentWidget
(
m_searchResultTreeView
);
int
index
=
m_items
.
size
();
ResultWindowItem
*
item
=
new
ResultWindowItem
;
SearchResultItem
item
;
item
.
fileName
=
fileName
;
item
.
lineNumber
=
lineNumber
;
item
.
lineText
=
rowText
;
item
.
searchTermStart
=
searchTermStart
;
item
.
searchTermLength
=
searchTermLength
;
item
.
userData
=
userData
;
item
.
index
=
index
;
m_items
.
append
(
item
);
m_searchResultTreeView
->
appendResultLine
(
index
,
fileName
,
lineNumber
,
rowText
,
searchTermStart
,
searchTermLength
);
if
(
index
==
0
)
{
setReplaceUIEnabled
(
true
);
// We didn't have an item before, set the focus to the m_searchResultTreeView
setFocus
();
m_searchResultTreeView
->
selectionModel
()
->
select
(
m_searchResultTreeView
->
model
()
->
index
(
0
,
0
,
QModelIndex
()),
QItemSelectionModel
::
Select
);
emit
navigateStateChanged
();
}
return
item
;
}
void
SearchResultWindow
::
setReplaceUIEnabled
(
bool
enabled
)
{
m_replaceTextEdit
->
setEnabled
(
enabled
);
m_replaceButton
->
setEnabled
(
enabled
);
}
void
SearchResultWindow
::
handleExpandCollapseToolButton
(
bool
checked
)
...
...
@@ -272,17 +294,17 @@ int SearchResultWindow::priorityInStatusBar() const
bool
SearchResultWindow
::
canNext
()
{
return
m_
searchResultTreeView
->
model
()
->
rowC
ount
();
return
m_
items
.
c
ount
()
>
0
;
}
bool
SearchResultWindow
::
canPrevious
()
{
return
m_
searchResultTreeView
->
model
()
->
rowC
ount
();
return
m_
items
.
c
ount
()
>
0
;
}
void
SearchResultWindow
::
goToNext
()
{
if
(
!
m_
searchResultTreeView
->
model
()
->
rowC
ount
())
if
(
m_
items
.
c
ount
()
==
0
)
return
;
QModelIndex
idx
=
m_searchResultTreeView
->
model
()
->
next
(
m_searchResultTreeView
->
currentIndex
());
if
(
idx
.
isValid
())
{
...
...
src/plugins/find/searchresultwindow.h
View file @
44e2704b
...
...
@@ -47,19 +47,25 @@ namespace Find {
class
SearchResultWindow
;
class
FIND_EXPORT
ResultWindowItem
:
public
QObject
struct
FIND_EXPORT
SearchResultItem
{
Q_OBJECT
QString
fileName
;
int
lineNumber
;
QString
lineText
;
int
searchTermStart
;
int
searchTermLength
;
int
index
;
QVariant
userData
;
// whatever information we also need here
};
public:
void
setData
(
const
QVariant
&
data
);
Q
Variant
data
()
const
;
class
FIND_EXPORT
SearchResult
:
public
QObject
{
Q
_OBJECT
signals:
void
activated
(
const
QString
&
fileName
,
int
lineNumber
,
int
column
);
private:
QVariant
m_data
;
void
activated
(
const
Find
::
SearchResultItem
&
item
);
void
replaceButtonClicked
(
const
QString
&
replaceText
,
const
QList
<
Find
::
SearchResultItem
>
&
checkedItems
);
friend
class
SearchResultWindow
;
};
...
...
@@ -69,6 +75,11 @@ class FIND_EXPORT SearchResultWindow : public Core::IOutputPane
Q_OBJECT
public:
enum
SearchMode
{
SearchOnly
,
SearchAndReplace
};
SearchResultWindow
();
~
SearchResultWindow
();
...
...
@@ -90,30 +101,30 @@ public:
void
goToPrev
();
bool
canNavigate
();
void
setTextEditorFont
(
const
QFont
&
font
);
void
setShowReplaceUI
(
bool
show
);
bool
isShowingReplaceUI
()
const
;
QList
<
ResultWindowItem
*>
selectedItems
()
const
;
void
setTextEditorFont
(
const
QFont
&
font
);
signals:
void
replaceButtonClicked
(
const
QString
&
replaceText
);
// search result object only lives till next startnewsearch call
SearchResult
*
startNewSearch
(
SearchMode
searchOrSearchAndReplace
=
SearchOnly
);
public
slots
:
void
clearContents
();
void
showNoMatchesFound
();
ResultWindowItem
*
addResult
(
const
QString
&
fileName
,
int
lineNumber
,
const
QString
&
lineText
,
int
searchTermStart
,
int
searchTermLength
);
void
addResult
(
const
QString
&
fileName
,
int
lineNumber
,
const
QString
&
lineText
,
int
searchTermStart
,
int
searchTermLength
,
const
QVariant
&
userData
=
QVariant
()
);
private
slots
:
void
handleExpandCollapseToolButton
(
bool
checked
);
void
handleJumpToSearchResult
(
int
index
,
const
QString
&
fileName
,
int
lineNumber
,
int
searchTermStart
,
int
searchTermLength
);
void
handleJumpToSearchResult
(
int
index
,
bool
checked
);
void
handleReplaceButton
();
void
setReplaceUIEnabled
(
bool
enabled
);
private:
void
readSettings
();
void
writeSettings
();
QList
<
SearchResultItem
>
checkedItems
()
const
;
Internal
::
SearchResultTreeView
*
m_searchResultTreeView
;
QListWidget
*
m_noMatchesFoundDisplay
;
...
...
@@ -123,7 +134,8 @@ private:
QToolButton
*
m_replaceButton
;
static
const
bool
m_initiallyExpand
=
false
;
QStackedWidget
*
m_widget
;
QList
<
ResultWindowItem
*>
m_items
;
SearchResult
*
m_currentSearch
;
QList
<
SearchResultItem
>
m_items
;
bool
m_isShowingReplaceUI
;
};
...
...
src/plugins/texteditor/basefilefind.cpp
View file @
44e2704b
...
...
@@ -91,7 +91,8 @@ void BaseFileFind::findAll(const QString &txt, QTextDocument::FindFlags findFlag
if
(
m_filterCombo
)
updateComboEntries
(
m_filterCombo
,
false
);
m_watcher
.
setFuture
(
QFuture
<
FileSearchResult
>
());
m_resultWindow
->
clearContents
();
SearchResult
*
result
=
m_resultWindow
->
startNewSearch
();
connect
(
result
,
SIGNAL
(
activated
(
Find
::
SearchResultItem
)),
this
,
SLOT
(
openEditor
(
Find
::
SearchResultItem
)));
m_resultWindow
->
popup
(
true
);
if
(
m_useRegExp
)
m_watcher
.
setFuture
(
Core
::
Utils
::
findInFilesRegExp
(
txt
,
files
(),
findFlags
,
ITextEditor
::
openedTextEditorsContents
()));
...
...
@@ -109,14 +110,11 @@ void BaseFileFind::findAll(const QString &txt, QTextDocument::FindFlags findFlag
void
BaseFileFind
::
displayResult
(
int
index
)
{
Core
::
Utils
::
FileSearchResult
result
=
m_watcher
.
future
().
resultAt
(
index
);
ResultWindowItem
*
item
=
m_resultWindow
->
addResult
(
result
.
fileName
,
m_resultWindow
->
addResult
(
result
.
fileName
,
result
.
lineNumber
,
result
.
matchingLine
,
result
.
matchStart
,
result
.
matchLength
);
if
(
item
)
connect
(
item
,
SIGNAL
(
activated
(
const
QString
&
,
int
,
int
)),
this
,
SLOT
(
openEditor
(
const
QString
&
,
int
,
int
)));
if
(
m_resultLabel
)
m_resultLabel
->
setText
(
tr
(
"%1 found"
).
arg
(
m_resultWindow
->
numberOfResults
()));
}
...
...
@@ -236,7 +234,7 @@ void BaseFileFind::syncRegExpSetting(bool useRegExp)
m_useRegExp
=
useRegExp
;
}
void
BaseFileFind
::
openEditor
(
const
QString
&
fileName
,
int
line
,
int
column
)
void
BaseFileFind
::
openEditor
(
const
Find
::
SearchResultItem
&
item
)
{
TextEditor
::
BaseTextEditor
::
openEditorAt
(
fileName
,
line
,
column
);
TextEditor
::
BaseTextEditor
::
openEditorAt
(
item
.
fileName
,
item
.
lineNumber
,
item
.
searchTermStart
);
}
src/plugins/texteditor/basefilefind.h
View file @
44e2704b
...
...
@@ -49,6 +49,7 @@ QT_END_NAMESPACE
namespace
Find
{
class
SearchResultWindow
;
struct
SearchResultItem
;
}
namespace
TextEditor
{
...
...
@@ -76,7 +77,7 @@ protected:
private
slots
:
void
displayResult
(
int
index
);
void
searchFinished
();
void
openEditor
(
const
QString
&
fileName
,
int
line
,
int
column
);
void
openEditor
(
const
Find
::
SearchResultItem
&
item
);
void
syncRegExpSetting
(
bool
useRegExp
);
private:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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