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
Marco Bubke
flatpak-qt-creator
Commits
c49412ac
Commit
c49412ac
authored
May 29, 2009
by
con
Browse files
Prepare for being able to add find flags that are not in QTextDocument
parent
592b0d7c
Changes
16
Hide whitespace changes
Inline
Side-by-side
src/plugins/bineditor/bineditorplugin.cpp
View file @
c49412ac
...
...
@@ -69,51 +69,51 @@ public:
QString
completedFindString
()
const
{
return
QString
();
}
int
find
(
const
QByteArray
&
pattern
,
int
pos
,
QTextDocumen
t
::
FindFlags
findFlags
)
{
int
find
(
const
QByteArray
&
pattern
,
int
pos
,
Find
::
IFindSuppor
t
::
FindFlags
findFlags
)
{
if
(
pattern
.
isEmpty
())
{
m_editor
->
setCursorPosition
(
pos
);
return
pos
;
}
int
found
=
m_editor
->
find
(
pattern
,
pos
,
findFlags
);
int
found
=
m_editor
->
find
(
pattern
,
pos
,
Find
::
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
if
(
found
<
0
)
found
=
m_editor
->
find
(
pattern
,
(
findFlags
&
QTextDocumen
t
::
FindBackward
)
?
m_editor
->
data
().
size
()
-
1
:
0
,
findFlags
);
(
findFlags
&
Find
::
IFindSuppor
t
::
FindBackward
)
?
m_editor
->
data
().
size
()
-
1
:
0
,
Find
::
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
return
found
;
}
bool
findIncremental
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
{
bool
findIncremental
(
const
QString
&
txt
,
Find
::
IFindSuppor
t
::
FindFlags
findFlags
)
{
QByteArray
pattern
=
txt
.
toLatin1
();
if
(
m_incrementalStartPos
<
0
)
m_incrementalStartPos
=
m_editor
->
selectionStart
();
int
pos
=
m_incrementalStartPos
;
findFlags
&=
~
QTextDocumen
t
::
FindBackward
;
findFlags
&=
~
Find
::
IFindSuppor
t
::
FindBackward
;
int
found
=
find
(
pattern
,
pos
,
findFlags
);
if
(
found
>=
0
)
m_editor
->
highlightSearchResults
(
pattern
,
findFlags
);
m_editor
->
highlightSearchResults
(
pattern
,
Find
::
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
else
m_editor
->
highlightSearchResults
(
QByteArray
(),
0
);
return
found
>=
0
;
}
bool
findStep
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
{
bool
findStep
(
const
QString
&
txt
,
Find
::
IFindSuppor
t
::
FindFlags
findFlags
)
{
QByteArray
pattern
=
txt
.
toLatin1
();
bool
wasReset
=
(
m_incrementalStartPos
<
0
);
int
pos
=
m_editor
->
cursorPosition
();
if
(
findFlags
&
QTextDocumen
t
::
FindBackward
)
if
(
findFlags
&
Find
::
IFindSuppor
t
::
FindBackward
)
pos
=
m_editor
->
selectionStart
()
-
1
;
int
found
=
find
(
pattern
,
pos
,
findFlags
);
if
(
found
)
m_incrementalStartPos
=
found
;
if
(
wasReset
&&
found
>=
0
)
m_editor
->
highlightSearchResults
(
pattern
,
findFlags
);
m_editor
->
highlightSearchResults
(
pattern
,
Find
::
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
return
found
>=
0
;
}
bool
replaceStep
(
const
QString
&
,
const
QString
&
,
QTextDocumen
t
::
FindFlags
)
{
return
false
;}
Find
::
IFindSuppor
t
::
FindFlags
)
{
return
false
;}
int
replaceAll
(
const
QString
&
,
const
QString
&
,
QTextDocumen
t
::
FindFlags
)
{
return
0
;
}
Find
::
IFindSuppor
t
::
FindFlags
)
{
return
0
;
}
private:
BinEditor
*
m_editor
;
...
...
src/plugins/find/basetextfind.cpp
View file @
c49412ac
...
...
@@ -119,13 +119,13 @@ QString BaseTextFind::completedFindString() const
return
cursor
.
selectedText
();
}
bool
BaseTextFind
::
findIncremental
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
bool
BaseTextFind
::
findIncremental
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTextCursor
cursor
=
textCursor
();
if
(
m_incrementalStartPos
<
0
)
m_incrementalStartPos
=
cursor
.
selectionStart
();
cursor
.
setPosition
(
m_incrementalStartPos
);
findFlags
&=
~
QTextDocumen
t
::
FindBackward
;
findFlags
&=
~
IFindSuppor
t
::
FindBackward
;
bool
found
=
find
(
txt
,
findFlags
,
cursor
);
if
(
found
)
emit
highlightAll
(
txt
,
findFlags
);
...
...
@@ -134,7 +134,7 @@ bool BaseTextFind::findIncremental(const QString &txt, QTextDocument::FindFlags
return
found
;
}
bool
BaseTextFind
::
findStep
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
bool
BaseTextFind
::
findStep
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
)
{
bool
found
=
find
(
txt
,
findFlags
,
textCursor
());
if
(
found
)
...
...
@@ -143,21 +143,21 @@ bool BaseTextFind::findStep(const QString &txt, QTextDocument::FindFlags findFla
}
bool
BaseTextFind
::
replaceStep
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
)
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTextCursor
cursor
=
textCursor
();
if
(
cursor
.
selectedText
().
compare
(
before
,
((
findFlags
&
QTextDocumen
t
::
FindCaseSensitively
)
!=
0
)
?
Qt
::
CaseSensitive
:
Qt
::
CaseInsensitive
)
==
0
)
{
((
findFlags
&
IFindSuppor
t
::
FindCaseSensitively
)
!=
0
)
?
Qt
::
CaseSensitive
:
Qt
::
CaseInsensitive
)
==
0
)
{
int
start
=
cursor
.
selectionStart
();
cursor
.
insertText
(
after
);
if
((
findFlags
&
QTextDocumen
t
::
FindBackward
)
!=
0
)
if
((
findFlags
&
IFindSuppor
t
::
FindBackward
)
!=
0
)
cursor
.
setPosition
(
start
);
}
return
find
(
before
,
findFlags
,
cursor
);
}
int
BaseTextFind
::
replaceAll
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
)
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTextCursor
editCursor
=
textCursor
();
if
(
!
m_findScope
.
isNull
())
...
...
@@ -167,27 +167,27 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
editCursor
.
beginEditBlock
();
int
count
=
0
;
QTextCursor
found
;
found
=
document
()
->
find
(
before
,
editCursor
,
findFlags
);
found
=
document
()
->
find
(
before
,
editCursor
,
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
while
(
!
found
.
isNull
()
&&
inScope
(
found
.
selectionStart
(),
found
.
selectionEnd
()))
{
++
count
;
editCursor
.
setPosition
(
found
.
selectionStart
());
editCursor
.
setPosition
(
found
.
selectionEnd
(),
QTextCursor
::
KeepAnchor
);
editCursor
.
insertText
(
after
);
found
=
document
()
->
find
(
before
,
editCursor
,
findFlags
);
found
=
document
()
->
find
(
before
,
editCursor
,
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
}
editCursor
.
endEditBlock
();
return
count
;
}
bool
BaseTextFind
::
find
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
,
IFindSuppor
t
::
FindFlags
findFlags
,
QTextCursor
start
)
{
if
(
txt
.
isEmpty
())
{
setTextCursor
(
start
);
return
true
;
}
QTextCursor
found
=
document
()
->
find
(
txt
,
start
,
findFlags
);
QTextCursor
found
=
document
()
->
find
(
txt
,
start
,
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
if
(
!
m_findScope
.
isNull
())
{
...
...
@@ -197,7 +197,7 @@ bool BaseTextFind::find(const QString &txt,
start
.
setPosition
(
m_findScope
.
selectionStart
());
else
start
.
setPosition
(
m_findScope
.
selectionEnd
());
found
=
document
()
->
find
(
txt
,
start
,
findFlags
);
found
=
document
()
->
find
(
txt
,
start
,
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
if
(
found
.
isNull
()
||
!
inScope
(
found
.
selectionStart
(),
found
.
selectionEnd
()))
return
false
;
}
...
...
@@ -209,7 +209,7 @@ bool BaseTextFind::find(const QString &txt,
start
.
movePosition
(
QTextCursor
::
Start
);
else
start
.
movePosition
(
QTextCursor
::
End
);
found
=
document
()
->
find
(
txt
,
start
,
findFlags
);
found
=
document
()
->
find
(
txt
,
start
,
IFindSupport
::
textDocumentFlagsForFindFlags
(
findFlags
)
)
;
if
(
found
.
isNull
())
{
return
false
;
}
...
...
src/plugins/find/basetextfind.h
View file @
c49412ac
...
...
@@ -52,23 +52,23 @@ public:
QString
currentFindString
()
const
;
QString
completedFindString
()
const
;
bool
findIncremental
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
);
bool
findStep
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
);
bool
findIncremental
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
);
bool
findStep
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
);
bool
replaceStep
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
);
IFindSuppor
t
::
FindFlags
findFlags
);
int
replaceAll
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
);
IFindSuppor
t
::
FindFlags
findFlags
);
void
defineFindScope
();
void
clearFindScope
();
signals:
void
highlightAll
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
);
void
highlightAll
(
const
QString
&
txt
,
Find
::
IFindSuppor
t
::
FindFlags
findFlags
);
void
findScopeChanged
(
const
QTextCursor
&
);
private:
bool
find
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
,
IFindSuppor
t
::
FindFlags
findFlags
,
QTextCursor
start
);
QTextCursor
textCursor
()
const
;
...
...
src/plugins/find/currentdocumentfind.cpp
View file @
c49412ac
...
...
@@ -89,33 +89,33 @@ QString CurrentDocumentFind::completedFindString() const
return
m_currentFind
->
completedFindString
();
}
void
CurrentDocumentFind
::
highlightAll
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
void
CurrentDocumentFind
::
highlightAll
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTC_ASSERT
(
m_currentFind
,
return
);
m_currentFind
->
highlightAll
(
txt
,
findFlags
);
}
bool
CurrentDocumentFind
::
findIncremental
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
bool
CurrentDocumentFind
::
findIncremental
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTC_ASSERT
(
m_currentFind
,
return
false
);
return
m_currentFind
->
findIncremental
(
txt
,
findFlags
);
}
bool
CurrentDocumentFind
::
findStep
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
bool
CurrentDocumentFind
::
findStep
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTC_ASSERT
(
m_currentFind
,
return
false
);
return
m_currentFind
->
findStep
(
txt
,
findFlags
);
}
bool
CurrentDocumentFind
::
replaceStep
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
)
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTC_ASSERT
(
m_currentFind
,
return
false
);
return
m_currentFind
->
replaceStep
(
before
,
after
,
findFlags
);
}
int
CurrentDocumentFind
::
replaceAll
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
)
IFindSuppor
t
::
FindFlags
findFlags
)
{
QTC_ASSERT
(
m_currentFind
,
return
0
);
return
m_currentFind
->
replaceAll
(
before
,
after
,
findFlags
);
...
...
src/plugins/find/currentdocumentfind.h
View file @
c49412ac
...
...
@@ -30,7 +30,7 @@
#ifndef CURRENTDOCUMENTFIND_H
#define CURRENTDOCUMENTFIND_H
#include "ifind
filter
.h"
#include "ifind
support
.h"
#include <QtCore/QPointer>
#include <QtGui/QWidget>
...
...
@@ -52,13 +52,13 @@ public:
QString
completedFindString
()
const
;
bool
isEnabled
()
const
;
void
highlightAll
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
);
bool
findIncremental
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
);
bool
findStep
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
);
void
highlightAll
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
);
bool
findIncremental
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
);
bool
findStep
(
const
QString
&
txt
,
IFindSuppor
t
::
FindFlags
findFlags
);
bool
replaceStep
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
);
IFindSuppor
t
::
FindFlags
findFlags
);
int
replaceAll
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocumen
t
::
FindFlags
findFlags
);
IFindSuppor
t
::
FindFlags
findFlags
);
void
defineFindScope
();
void
clearFindScope
();
...
...
src/plugins/find/findplugin.cpp
View file @
c49412ac
...
...
@@ -248,6 +248,7 @@ void FindPlugin::writeSettings()
settings
->
setValue
(
"FindStrings"
,
m_findCompletions
);
settings
->
setValue
(
"ReplaceStrings"
,
m_replaceCompletions
);
settings
->
endGroup
();
m_findToolBar
->
writeSettings
();
m_findDialog
->
writeSettings
();
}
...
...
@@ -265,6 +266,7 @@ void FindPlugin::readSettings()
m_findCompletionModel
->
setStringList
(
m_findCompletions
);
m_replaceCompletionModel
->
setStringList
(
m_replaceCompletions
);
settings
->
endGroup
();
m_findToolBar
->
readSettings
();
m_findDialog
->
readSettings
();
emit
findFlagsChanged
();
// would have been done in the setXXX methods above
}
...
...
src/plugins/find/findplugin.h
View file @
c49412ac
...
...
@@ -30,7 +30,6 @@
#ifndef FINDPLUGIN_H
#define FINDPLUGIN_H
#include "ui_findwidget.h"
#include "ifindfilter.h"
#include "findtoolbar.h"
...
...
src/plugins/find/findtoolbar.cpp
View file @
c49412ac
...
...
@@ -202,7 +202,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_caseSensitiveAction
->
setChecked
(
false
);
cmd
=
am
->
registerAction
(
m_caseSensitiveAction
,
Constants
::
CASE_SENSITIVE
,
globalcontext
);
mfind
->
addAction
(
cmd
,
Constants
::
G_FIND_FLAGS
);
connect
(
m_caseSensitiveAction
,
SIGNAL
(
triggered
(
bool
)),
m_plugin
,
SLOT
(
setCaseSensitive
(
bool
)));
connect
(
m_caseSensitiveAction
,
SIGNAL
(
triggered
(
bool
)),
this
,
SLOT
(
setCaseSensitive
(
bool
)));
lineEditMenu
->
addAction
(
m_caseSensitiveAction
);
m_wholeWordAction
=
new
QAction
(
tr
(
"Whole Words Only"
),
this
);
...
...
@@ -211,13 +211,12 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_wholeWordAction
->
setChecked
(
false
);
cmd
=
am
->
registerAction
(
m_wholeWordAction
,
Constants
::
WHOLE_WORDS
,
globalcontext
);
mfind
->
addAction
(
cmd
,
Constants
::
G_FIND_FLAGS
);
connect
(
m_wholeWordAction
,
SIGNAL
(
triggered
(
bool
)),
m_plugin
,
SLOT
(
setWholeWord
(
bool
)));
connect
(
m_wholeWordAction
,
SIGNAL
(
triggered
(
bool
)),
this
,
SLOT
(
setWholeWord
(
bool
)));
lineEditMenu
->
addAction
(
m_wholeWordAction
);
connect
(
m_currentDocumentFind
,
SIGNAL
(
changed
()),
this
,
SLOT
(
updateActions
()));
updateActions
();
updateIcons
();
connect
(
m_plugin
,
SIGNAL
(
findFlagsChanged
()),
this
,
SLOT
(
findFlagsChanged
()));
}
FindToolBar
::~
FindToolBar
()
...
...
@@ -314,13 +313,13 @@ void FindToolBar::invokeClearResults()
void
FindToolBar
::
invokeFindNext
()
{
m_plugin
->
set
Backward
(
false
);
setFindFlag
(
IFindSupport
::
Find
Backward
,
false
);
invokeFindStep
();
}
void
FindToolBar
::
invokeFindPrevious
()
{
m_plugin
->
set
Backward
(
true
);
setFindFlag
(
IFindSupport
::
Find
Backward
,
true
);
invokeFindStep
();
}
...
...
@@ -350,7 +349,7 @@ void FindToolBar::invokeFindStep()
{
if
(
m_currentDocumentFind
->
isEnabled
())
{
m_plugin
->
updateFindCompletion
(
getFindText
());
m_currentDocumentFind
->
findStep
(
getFindText
(),
m_
plugin
->
findFlags
()
);
m_currentDocumentFind
->
findStep
(
getFindText
(),
m_findFlags
);
}
}
...
...
@@ -358,7 +357,7 @@ void FindToolBar::invokeFindIncremental()
{
if
(
m_currentDocumentFind
->
isEnabled
())
{
QString
text
=
getFindText
();
m_currentDocumentFind
->
findIncremental
(
text
,
m_
plugin
->
findFlags
()
);
m_currentDocumentFind
->
findIncremental
(
text
,
m_findFlags
);
if
(
text
.
isEmpty
())
m_currentDocumentFind
->
clearResults
();
}
...
...
@@ -366,13 +365,13 @@ void FindToolBar::invokeFindIncremental()
void
FindToolBar
::
invokeReplaceNext
()
{
m_plugin
->
set
Backward
(
false
);
setFindFlag
(
IFindSupport
::
Find
Backward
,
false
);
invokeReplaceStep
();
}
void
FindToolBar
::
invokeReplacePrevious
()
{
m_plugin
->
set
Backward
(
true
);
setFindFlag
(
IFindSupport
::
Find
Backward
,
true
);
invokeReplaceStep
();
}
...
...
@@ -381,7 +380,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_
plugin
->
findFlags
()
);
m_currentDocumentFind
->
replaceStep
(
getFindText
(),
getReplaceText
(),
m_findFlags
);
}
}
...
...
@@ -390,7 +389,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_
plugin
->
findFlags
()
);
m_currentDocumentFind
->
replaceAll
(
getFindText
(),
getReplaceText
(),
m_findFlags
);
}
}
...
...
@@ -427,8 +426,8 @@ void FindToolBar::findFlagsChanged()
void
FindToolBar
::
updateIcons
()
{
bool
casesensitive
=
m_
plugin
->
findFlags
()
&
QTextDocument
::
FindCaseSensitively
;
bool
wholewords
=
m_
plugin
->
findFlags
()
&
QTextDocument
::
FindWholeWords
;
bool
casesensitive
=
m_findFlags
&
QTextDocument
::
FindCaseSensitively
;
bool
wholewords
=
m_findFlags
&
QTextDocument
::
FindWholeWords
;
if
(
casesensitive
&&
wholewords
)
{
QPixmap
image
=
QPixmap
(
":/find/images/wordandcase.png"
);
...
...
@@ -446,8 +445,8 @@ void FindToolBar::updateIcons()
void
FindToolBar
::
updateFlagMenus
()
{
bool
wholeOnly
=
((
m_
plugin
->
findFlags
()
&
QTextDocument
::
FindWholeWords
));
bool
sensitive
=
((
m_
plugin
->
findFlags
()
&
QTextDocument
::
FindCaseSensitively
));
bool
wholeOnly
=
((
m_findFlags
&
QTextDocument
::
FindWholeWords
));
bool
sensitive
=
((
m_findFlags
&
QTextDocument
::
FindCaseSensitively
));
if
(
m_wholeWordAction
->
isChecked
()
!=
wholeOnly
)
m_wholeWordAction
->
setChecked
(
wholeOnly
);
if
(
m_caseSensitiveAction
->
isChecked
()
!=
sensitive
)
...
...
@@ -482,7 +481,7 @@ void FindToolBar::openFind()
if
(
!
text
.
isEmpty
())
setFindText
(
text
);
m_currentDocumentFind
->
defineFindScope
();
m_currentDocumentFind
->
highlightAll
(
getFindText
(),
m_
plugin
->
findFlags
()
);
m_currentDocumentFind
->
highlightAll
(
getFindText
(),
m_findFlags
);
selectFindText
();
}
...
...
@@ -498,3 +497,61 @@ bool FindToolBar::focusNextPrevChild(bool next)
return
QToolBar
::
focusNextPrevChild
(
next
);
return
true
;
}
void
FindToolBar
::
writeSettings
()
{
QSettings
*
settings
=
Core
::
ICore
::
instance
()
->
settings
();
settings
->
beginGroup
(
"Find"
);
settings
->
beginGroup
(
"FindToolBar"
);
settings
->
setValue
(
"Backward"
,
QVariant
((
m_findFlags
&
IFindSupport
::
FindBackward
)
!=
0
));
settings
->
setValue
(
"CaseSensitively"
,
QVariant
((
m_findFlags
&
IFindSupport
::
FindCaseSensitively
)
!=
0
));
settings
->
setValue
(
"WholeWords"
,
QVariant
((
m_findFlags
&
IFindSupport
::
FindWholeWords
)
!=
0
));
settings
->
endGroup
();
settings
->
endGroup
();
}
void
FindToolBar
::
readSettings
()
{
QSettings
*
settings
=
Core
::
ICore
::
instance
()
->
settings
();
settings
->
beginGroup
(
"Find"
);
settings
->
beginGroup
(
"FindToolBar"
);
IFindSupport
::
FindFlags
flags
;
if
(
settings
->
value
(
"Backward"
,
false
).
toBool
())
flags
|=
IFindSupport
::
FindBackward
;
if
(
settings
->
value
(
"CaseSensitively"
,
false
).
toBool
())
flags
|=
IFindSupport
::
FindCaseSensitively
;
if
(
settings
->
value
(
"WholeWords"
,
false
).
toBool
())
flags
|=
IFindSupport
::
FindWholeWords
;
settings
->
endGroup
();
settings
->
endGroup
();
m_findFlags
=
flags
;
findFlagsChanged
();
}
void
FindToolBar
::
setFindFlag
(
IFindSupport
::
FindFlag
flag
,
bool
enabled
)
{
bool
hasFlag
=
hasFindFlag
(
flag
);
if
((
hasFlag
&&
enabled
)
||
(
!
hasFlag
&&
!
enabled
))
return
;
if
(
enabled
)
m_findFlags
|=
flag
;
else
m_findFlags
&=
~
flag
;
if
(
flag
!=
IFindSupport
::
FindBackward
)
findFlagsChanged
();
}
bool
FindToolBar
::
hasFindFlag
(
IFindSupport
::
FindFlag
flag
)
{
return
m_findFlags
&
flag
;
}
void
FindToolBar
::
setCaseSensitive
(
bool
sensitive
)
{
setFindFlag
(
IFindSupport
::
FindCaseSensitively
,
sensitive
);
}
void
FindToolBar
::
setWholeWord
(
bool
wholeOnly
)
{
setFindFlag
(
IFindSupport
::
FindWholeWords
,
wholeOnly
);
}
src/plugins/find/findtoolbar.h
View file @
c49412ac
...
...
@@ -52,7 +52,8 @@ public:
FindToolBar
(
FindPlugin
*
plugin
,
CurrentDocumentFind
*
currentDocumentFind
);
~
FindToolBar
();
void
invokeClearResults
();
void
readSettings
();
void
writeSettings
();
private
slots
:
void
invokeFindNext
();
...
...
@@ -75,11 +76,17 @@ private slots:
void
updateActions
();
void
findFlagsChanged
();
void
setCaseSensitive
(
bool
sensitive
);
void
setWholeWord
(
bool
wholeOnly
);
protected:
bool
focusNextPrevChild
(
bool
next
);
private:
void
invokeClearResults
();
bool
setFocusToCurrentFindSupport
();
void
setFindFlag
(
IFindSupport
::
FindFlag
flag
,
bool
enabled
);
bool
hasFindFlag
(
IFindSupport
::
FindFlag
flag
);
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
void
setFindText
(
const
QString
&
text
);
...
...
@@ -104,6 +111,7 @@ private:
QAction
*
m_caseSensitiveAction
;
QAction
*
m_wholeWordAction
;
QWidget
*
m_widget
;
IFindSupport
::
FindFlags
m_findFlags
;
};
}
// namespace Internal
...
...
src/plugins/find/ifindfilter.h
View file @
c49412ac
...
...
@@ -30,11 +30,13 @@
#ifndef IFINDFILTER_H
#define IFINDFILTER_H
#include "ifindsupport.h"
#include "find_global.h"
#include <QtCore/QSettings>
#include <QtGui/QIcon>
#include <QtGui/QKeySequence>
#include <QtGui/QWidget>
#include <QtGui/QTextDocument>
namespace
Find
{
...
...
src/plugins/find/ifindsupport.h
View file @
c49412ac
...
...
@@ -31,7 +31,8 @@
#define IFINDSUPPORT_H
#include "find_global.h"
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtGui/QTextDocument>
namespace
Find
{
...
...
@@ -41,6 +42,12 @@ class FIND_EXPORT IFindSupport : public QObject
Q_OBJECT
public:
enum
FindFlag
{
FindBackward
=
0x01
,
FindCaseSensitively
=
0x02
,
FindWholeWords
=
0x04
,
};
Q_DECLARE_FLAGS
(
FindFlags
,
FindFlag
);
IFindSupport
()
:
QObject
(
0
)
{}
virtual
~
IFindSupport
()
{}
...
...
@@ -51,24 +58,37 @@ public:
virtual
QString
currentFindString
()
const
=
0
;
virtual
QString
completedFindString
()
const
=
0
;
virtual
void
highlightAll
(
const
QString
&
txt
,
QTextDocument
::
FindFlags
findFlags
);
virtual
bool
findIncremental
(
const
QString
&
txt
,
QTextDocument
::
FindFlags
findFlags
)
=
0
;
virtual
bool
findStep
(
const
QString
&
txt
,
QTextDocument
::
FindFlags
findFlags
)
=
0
;
virtual
void
highlightAll
(
const
QString
&
txt
,
FindFlags
findFlags
);
virtual
bool
findIncremental
(
const
QString
&
txt
,
FindFlags
findFlags
)
=
0
;
virtual
bool
findStep
(
const
QString
&
txt
,
FindFlags
findFlags
)
=
0
;
virtual
bool
replaceStep
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocument
::
FindFlags
findFlags
)
=
0
;
FindFlags
findFlags
)
=
0
;
virtual
int
replaceAll
(
const
QString
&
before
,
const
QString
&
after
,
QTextDocument
::
FindFlags
findFlags
)
=
0
;
FindFlags
findFlags
)
=
0
;
virtual
void
defineFindScope
(){}
virtual
void
clearFindScope
(){}
static
QTextDocument
::
FindFlags
textDocumentFlagsForFindFlags
(
IFindSupport
::
FindFlags
flags
)
{
QTextDocument
::
FindFlags
textDocFlags
;
if
(
flags
&
IFindSupport
::
FindBackward
)
textDocFlags
|=
QTextDocument
::
FindBackward
;
if
(
flags
&
IFindSupport
::
FindCaseSensitively
)
textDocFlags
|=
QTextDocument
::
FindCaseSensitively
;
if
(
flags
&
IFindSupport
::
FindWholeWords
)
textDocFlags
|=
QTextDocument
::
FindWholeWords
;
return
textDocFlags
;
}
signals:
void
changed
();
};
inline
void
IFindSupport
::
highlightAll
(
const
QString
&
,
QTextDocument
::
FindFlags
)
{}
inline
void
IFindSupport
::
highlightAll
(
const
QString
&
,
FindFlags
)
{}
}
// namespace Find
Q_DECLARE_OPERATORS_FOR_FLAGS
(
Find
::
IFindSupport
::
FindFlags
)
#endif // IFINDSUPPORT_H
src/plugins/help/helpfindsupport.cpp
View file @
c49412ac
...
...
@@ -66,17 +66,17 @@ QString HelpFindSupport::completedFindString() const
return
QString
();
}
bool
HelpFindSupport
::
findIncremental
(
const
QString
&
txt
,
QTextDocumen
t
::
FindFlags
findFlags
)
bool
HelpFindSupport
::
findIncremental
(
const
QString
&
txt
,
Find
::
IFindSuppor
t
::
FindFlags
findFlags
)