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
e38cec51
Commit
e38cec51
authored
Jul 13, 2009
by
con
Browse files
Find implementations now tell what find flags are actually supported.
parent
7c6a9b6d
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/plugins/bineditor/bineditorplugin.cpp
View file @
e38cec51
...
...
@@ -63,6 +63,11 @@ public:
~
BinEditorFind
()
{}
bool
supportsReplace
()
const
{
return
false
;
}
IFindSupport
::
FindFlags
supportedFindFlags
()
const
{
return
IFindSupport
::
FindBackward
|
IFindSupport
::
FindCaseSensitively
;
}
void
resetIncrementalSearch
()
{
m_incrementalStartPos
=
-
1
;
}
void
clearResults
()
{
m_editor
->
highlightSearchResults
(
QByteArray
());
}
QString
currentFindString
()
const
{
return
QString
();
}
...
...
src/plugins/find/basetextfind.cpp
View file @
e38cec51
...
...
@@ -75,6 +75,12 @@ bool BaseTextFind::supportsReplace() const
return
!
isReadOnly
();
}
IFindSupport
::
FindFlags
BaseTextFind
::
supportedFindFlags
()
const
{
return
IFindSupport
::
FindBackward
|
IFindSupport
::
FindCaseSensitively
|
IFindSupport
::
FindRegularExpression
|
IFindSupport
::
FindWholeWords
;
}
void
BaseTextFind
::
resetIncrementalSearch
()
{
m_incrementalStartPos
=
-
1
;
...
...
src/plugins/find/basetextfind.h
View file @
e38cec51
...
...
@@ -47,6 +47,7 @@ public:
BaseTextFind
(
QTextEdit
*
editor
);
bool
supportsReplace
()
const
;
IFindSupport
::
FindFlags
supportedFindFlags
()
const
;
void
resetIncrementalSearch
();
void
clearResults
();
QString
currentFindString
()
const
;
...
...
src/plugins/find/currentdocumentfind.cpp
View file @
e38cec51
...
...
@@ -77,6 +77,12 @@ bool CurrentDocumentFind::supportsReplace() const
return
m_currentFind
->
supportsReplace
();
}
IFindSupport
::
FindFlags
CurrentDocumentFind
::
supportedFindFlags
()
const
{
QTC_ASSERT
(
m_currentFind
,
return
0
);
return
m_currentFind
->
supportedFindFlags
();
}
QString
CurrentDocumentFind
::
currentFindString
()
const
{
QTC_ASSERT
(
m_currentFind
,
return
QString
());
...
...
src/plugins/find/currentdocumentfind.h
View file @
e38cec51
...
...
@@ -48,6 +48,7 @@ public:
void
resetIncrementalSearch
();
void
clearResults
();
bool
supportsReplace
()
const
;
IFindSupport
::
FindFlags
supportedFindFlags
()
const
;
QString
currentFindString
()
const
;
QString
completedFindString
()
const
;
...
...
src/plugins/find/findtoolbar.cpp
View file @
e38cec51
...
...
@@ -228,7 +228,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
connect
(
m_currentDocumentFind
,
SIGNAL
(
changed
()),
this
,
SLOT
(
updateActions
()));
updateActions
();
updateIcons
();
}
FindToolBar
::~
FindToolBar
()
...
...
@@ -300,6 +299,8 @@ void FindToolBar::updateActions()
m_ui
.
replaceLabel
->
setEnabled
(
replaceEnabled
);
if
(
!
replaceEnabled
&&
enabled
&&
replaceFocus
)
m_ui
.
findEdit
->
setFocus
();
updateIcons
();
updateFlagMenus
();
}
void
FindToolBar
::
invokeFindEnter
()
...
...
@@ -365,7 +366,7 @@ void FindToolBar::invokeFindStep()
{
if
(
m_currentDocumentFind
->
isEnabled
())
{
m_plugin
->
updateFindCompletion
(
getFindText
());
m_currentDocumentFind
->
findStep
(
getFindText
(),
m_f
indFlags
);
m_currentDocumentFind
->
findStep
(
getFindText
(),
effectiveF
indFlags
()
);
}
}
...
...
@@ -373,7 +374,7 @@ void FindToolBar::invokeFindIncremental()
{
if
(
m_currentDocumentFind
->
isEnabled
())
{
QString
text
=
getFindText
();
m_currentDocumentFind
->
findIncremental
(
text
,
m_f
indFlags
);
m_currentDocumentFind
->
findIncremental
(
text
,
effectiveF
indFlags
()
);
if
(
text
.
isEmpty
())
m_currentDocumentFind
->
clearResults
();
}
...
...
@@ -396,7 +397,7 @@ void FindToolBar::invokeReplaceStep()
if
(
m_currentDocumentFind
->
isEnabled
()
&&
m_currentDocumentFind
->
supportsReplace
())
{
m_plugin
->
updateFindCompletion
(
getFindText
());
m_plugin
->
updateReplaceCompletion
(
getReplaceText
());
m_currentDocumentFind
->
replaceStep
(
getFindText
(),
getReplaceText
(),
m_f
indFlags
);
m_currentDocumentFind
->
replaceStep
(
getFindText
(),
getReplaceText
(),
effectiveF
indFlags
()
);
}
}
...
...
@@ -405,7 +406,7 @@ void FindToolBar::invokeReplaceAll()
m_plugin
->
updateFindCompletion
(
getFindText
());
m_plugin
->
updateReplaceCompletion
(
getReplaceText
());
if
(
m_currentDocumentFind
->
isEnabled
()
&&
m_currentDocumentFind
->
supportsReplace
())
{
m_currentDocumentFind
->
replaceAll
(
getFindText
(),
getReplaceText
(),
m_f
indFlags
);
m_currentDocumentFind
->
replaceAll
(
getFindText
(),
getReplaceText
(),
effectiveF
indFlags
()
);
}
}
...
...
@@ -442,9 +443,10 @@ void FindToolBar::findFlagsChanged()
void
FindToolBar
::
updateIcons
()
{
bool
casesensitive
=
m_findFlags
&
IFindSupport
::
FindCaseSensitively
;
bool
wholewords
=
m_findFlags
&
IFindSupport
::
FindWholeWords
;
bool
regexp
=
m_findFlags
&
IFindSupport
::
FindRegularExpression
;
IFindSupport
::
FindFlags
effectiveFlags
=
effectiveFindFlags
();
bool
casesensitive
=
effectiveFlags
&
IFindSupport
::
FindCaseSensitively
;
bool
wholewords
=
effectiveFlags
&
IFindSupport
::
FindWholeWords
;
bool
regexp
=
effectiveFlags
&
IFindSupport
::
FindRegularExpression
;
QPixmap
pixmap
(
17
,
17
);
QPainter
painter
(
&
pixmap
);
painter
.
eraseRect
(
0
,
0
,
17
,
17
);
...
...
@@ -468,6 +470,16 @@ void FindToolBar::updateIcons()
m_ui
.
findEdit
->
setPixmap
(
pixmap
);
}
IFindSupport
::
FindFlags
FindToolBar
::
effectiveFindFlags
()
{
IFindSupport
::
FindFlags
supportedFlags
;
if
(
m_currentDocumentFind
->
isEnabled
())
supportedFlags
=
m_currentDocumentFind
->
supportedFindFlags
();
else
supportedFlags
=
(
IFindSupport
::
FindFlags
)
0xFFFFFF
;
return
supportedFlags
&
m_findFlags
;
}
void
FindToolBar
::
updateFlagMenus
()
{
bool
wholeOnly
=
((
m_findFlags
&
IFindSupport
::
FindWholeWords
));
...
...
@@ -479,6 +491,12 @@ void FindToolBar::updateFlagMenus()
m_caseSensitiveAction
->
setChecked
(
sensitive
);
if
(
m_regularExpressionAction
->
isChecked
()
!=
regexp
)
m_regularExpressionAction
->
setChecked
(
regexp
);
IFindSupport
::
FindFlags
supportedFlags
;
if
(
m_currentDocumentFind
->
isEnabled
())
supportedFlags
=
m_currentDocumentFind
->
supportedFindFlags
();
m_wholeWordAction
->
setEnabled
(
supportedFlags
&
IFindSupport
::
FindWholeWords
);
m_caseSensitiveAction
->
setEnabled
(
supportedFlags
&
IFindSupport
::
FindCaseSensitively
);
m_regularExpressionAction
->
setEnabled
(
supportedFlags
&
IFindSupport
::
FindRegularExpression
);
}
bool
FindToolBar
::
setFocusToCurrentFindSupport
()
...
...
@@ -509,7 +527,7 @@ void FindToolBar::openFind()
if
(
!
text
.
isEmpty
())
setFindText
(
text
);
m_currentDocumentFind
->
defineFindScope
();
m_currentDocumentFind
->
highlightAll
(
getFindText
(),
m_f
indFlags
);
m_currentDocumentFind
->
highlightAll
(
getFindText
(),
effectiveF
indFlags
()
);
selectFindText
();
}
...
...
src/plugins/find/findtoolbar.h
View file @
e38cec51
...
...
@@ -88,6 +88,7 @@ private:
bool
setFocusToCurrentFindSupport
();
void
setFindFlag
(
IFindSupport
::
FindFlag
flag
,
bool
enabled
);
bool
hasFindFlag
(
IFindSupport
::
FindFlag
flag
);
IFindSupport
::
FindFlags
effectiveFindFlags
();
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
void
setFindText
(
const
QString
&
text
);
...
...
src/plugins/find/ifindsupport.h
View file @
e38cec51
...
...
@@ -54,6 +54,7 @@ public:
virtual
~
IFindSupport
()
{}
virtual
bool
supportsReplace
()
const
=
0
;
virtual
FindFlags
supportedFindFlags
()
const
=
0
;
virtual
void
resetIncrementalSearch
()
=
0
;
virtual
void
clearResults
()
=
0
;
virtual
QString
currentFindString
()
const
=
0
;
...
...
src/plugins/help/helpfindsupport.cpp
View file @
e38cec51
...
...
@@ -48,6 +48,12 @@ bool HelpFindSupport::isEnabled() const
return
true
;
}
Find
::
IFindSupport
::
FindFlags
HelpFindSupport
::
supportedFindFlags
()
const
{
return
Find
::
IFindSupport
::
FindBackward
|
Find
::
IFindSupport
::
FindCaseSensitively
|
Find
::
IFindSupport
::
FindWholeWords
;
}
QString
HelpFindSupport
::
currentFindString
()
const
{
QTC_ASSERT
(
m_centralWidget
,
return
QString
());
...
...
@@ -84,6 +90,12 @@ HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
{
}
Find
::
IFindSupport
::
FindFlags
HelpViewerFindSupport
::
supportedFindFlags
()
const
{
return
Find
::
IFindSupport
::
FindBackward
|
Find
::
IFindSupport
::
FindCaseSensitively
|
Find
::
IFindSupport
::
FindWholeWords
;
}
QString
HelpViewerFindSupport
::
currentFindString
()
const
{
QTC_ASSERT
(
m_viewer
,
return
QString
());
...
...
src/plugins/help/helpfindsupport.h
View file @
e38cec51
...
...
@@ -50,6 +50,8 @@ public:
bool
isEnabled
()
const
;
bool
supportsReplace
()
const
{
return
false
;
}
IFindSupport
::
FindFlags
supportedFindFlags
()
const
;
void
resetIncrementalSearch
()
{}
void
clearResults
()
{}
QString
currentFindString
()
const
;
...
...
@@ -76,6 +78,7 @@ public:
bool
isEnabled
()
const
{
return
true
;
}
bool
supportsReplace
()
const
{
return
false
;
}
IFindSupport
::
FindFlags
supportedFindFlags
()
const
;
void
resetIncrementalSearch
()
{}
void
clearResults
()
{}
QString
currentFindString
()
const
;
...
...
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