Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
magicseteditor
Commits
974d7bd5
Commit
974d7bd5
authored
Jan 08, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#58: Add operators to quick search.
Added quotes and - operator, which are the most important ones
parent
9c19f338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
12 deletions
+36
-12
src/data/card.cpp
src/data/card.cpp
+36
-12
No files found.
src/data/card.cpp
View file @
974d7bd5
...
...
@@ -55,6 +55,41 @@ String Card::identification() const {
}
}
/// Does the given object match the quick search query?
template
<
typename
T
>
bool
match_quicksearch_query
(
String
const
&
query
,
T
const
&
object
)
{
bool
need_match
=
true
;
// iterate over the components of the query
for
(
size_t
i
=
0
;
i
<
query
.
size
()
;
)
{
if
(
query
.
GetChar
(
i
)
==
_
(
' '
))
{
// skip spaces
i
++
;
}
else
if
(
query
.
GetChar
(
i
)
==
_
(
'-'
))
{
// negate the next query, i.e. match only if it is not on the card
need_match
=
!
need_match
;
i
++
;
}
else
{
size_t
end
,
next
;
if
(
query
.
GetChar
(
i
)
==
_
(
'"'
))
{
// quoted string, match exactly
i
++
;
end
=
query
.
find_first_of
(
_
(
'"'
),
i
);
next
=
min
(
end
,
query
.
size
())
+
1
;
}
else
{
// single word
next
=
end
=
query
.
find_first_of
(
_
(
' '
),
i
);
}
bool
match
=
object
.
contains
(
query
.
substr
(
i
,
end
-
i
));
if
(
match
!=
need_match
)
{
return
false
;
}
need_match
=
true
;
// next word is no longer negated
i
=
next
;
}
}
return
true
;
}
bool
Card
::
contains
(
String
const
&
query
)
const
{
FOR_EACH_CONST
(
v
,
data
)
{
if
(
find_i
(
v
->
toString
(),
query
)
!=
String
::
npos
)
return
true
;
...
...
@@ -63,18 +98,7 @@ bool Card::contains(String const& query) const {
return
false
;
}
bool
Card
::
contains_words
(
String
const
&
query
)
const
{
// iterate over the words
for
(
size_t
i
=
0
;
i
<
query
.
size
()
;
)
{
size_t
end
=
query
.
find_first_of
(
_
(
" "
),
i
);
if
(
end
==
i
)
{
i
++
;
}
else
{
end
=
min
(
end
,
query
.
size
());
if
(
!
contains
(
query
.
substr
(
i
,
end
-
i
)))
return
false
;
i
=
end
;
}
}
return
true
;
return
match_quicksearch_query
(
query
,
*
this
);
}
IndexMap
<
FieldP
,
ValueP
>&
Card
::
extraDataFor
(
const
StyleSheet
&
stylesheet
)
{
...
...
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