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
PIM
Akonadi Search
Commits
109dfe13
Commit
109dfe13
authored
Sep 30, 2020
by
Laurent Montel
😁
Browse files
Use .toStdString() + const'ify variables
parent
7c317f3e
Pipeline
#36007
passed with stage
in 20 minutes and 37 seconds
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
agent/akonotesindexer.cpp
View file @
109dfe13
...
...
@@ -54,8 +54,8 @@ void AkonotesIndexer::index(const Akonadi::Item &item)
process
(
msg
);
Akonadi
::
Collection
::
Id
colId
=
item
.
parentCollection
().
id
();
QByteArray
term
=
'C'
+
QByteArray
::
number
(
colId
);
const
Akonadi
::
Collection
::
Id
colId
=
item
.
parentCollection
().
id
();
const
QByteArray
term
=
'C'
+
QByteArray
::
number
(
colId
);
m_doc
->
add_boolean_term
(
term
.
data
());
m_db
->
replace_document
(
item
.
id
(),
*
m_doc
);
...
...
@@ -74,7 +74,7 @@ void AkonotesIndexer::process(const KMime::Message::Ptr &msg)
// (Give the subject a higher priority)
KMime
::
Headers
::
Subject
*
subject
=
msg
->
subject
(
false
);
if
(
subject
)
{
std
::
string
str
(
subject
->
asUnicodeString
().
to
Utf8
().
constData
());
const
std
::
string
str
(
subject
->
asUnicodeString
().
to
StdString
());
qCDebug
(
AKONADI_INDEXER_AGENT_LOG
)
<<
"Indexing"
<<
str
.
c_str
();
m_termGen
->
index_text_without_positions
(
str
,
1
,
"SU"
);
m_termGen
->
index_text_without_positions
(
str
,
100
);
...
...
@@ -83,7 +83,7 @@ void AkonotesIndexer::process(const KMime::Message::Ptr &msg)
KMime
::
Content
*
mainBody
=
msg
->
mainBodyPart
(
"text/plain"
);
if
(
mainBody
)
{
const
std
::
string
text
(
mainBody
->
decodedText
().
to
Utf8
().
constData
());
const
std
::
string
text
(
mainBody
->
decodedText
().
to
StdString
());
m_termGen
->
index_text_without_positions
(
text
);
m_termGen
->
index_text_without_positions
(
text
,
1
,
"BO"
);
}
else
{
...
...
@@ -115,7 +115,7 @@ void AkonotesIndexer::processPart(KMime::Content *content, KMime::Content *mainC
QTextDocument
doc
;
doc
.
setHtml
(
content
->
decodedText
());
const
std
::
string
text
(
doc
.
toPlainText
().
to
Utf8
().
constData
());
const
std
::
string
text
(
doc
.
toPlainText
().
to
StdString
());
m_termGen
->
index_text_without_positions
(
text
);
}
}
...
...
@@ -153,7 +153,7 @@ void AkonotesIndexer::remove(const Akonadi::Collection &collection)
return
;
}
try
{
Xapian
::
Query
query
(
'C'
+
QString
::
number
(
collection
.
id
()).
toStdString
());
const
Xapian
::
Query
query
(
'C'
+
QString
::
number
(
collection
.
id
()).
toStdString
());
Xapian
::
Enquire
enquire
(
*
m_db
);
enquire
.
set_query
(
query
);
...
...
agent/calendarindexer.cpp
View file @
109dfe13
...
...
@@ -87,7 +87,7 @@ void CalendarIndexer::remove(const Akonadi::Collection &collection)
return
;
}
try
{
Xapian
::
Query
query
(
'C'
+
QString
::
number
(
collection
.
id
()).
toStdString
());
const
Xapian
::
Query
query
(
'C'
+
QString
::
number
(
collection
.
id
()).
toStdString
());
Xapian
::
Enquire
enquire
(
*
(
m_db
->
db
()));
enquire
.
set_query
(
query
);
...
...
@@ -129,7 +129,7 @@ void CalendarIndexer::indexEventItem(const Akonadi::Item &item, const KCalendarC
doc
.
indexText
(
event
->
organizer
().
email
(),
QStringLiteral
(
"O"
));
doc
.
indexText
(
event
->
summary
(),
QStringLiteral
(
"S"
));
doc
.
indexText
(
event
->
location
(),
QStringLiteral
(
"L"
));
KCalendarCore
::
Attendee
::
List
attendees
=
event
->
attendees
();
const
KCalendarCore
::
Attendee
::
List
attendees
=
event
->
attendees
();
KCalendarCore
::
Attendee
::
List
::
ConstIterator
it
;
KCalendarCore
::
Attendee
::
List
::
ConstIterator
end
(
attendees
.
constEnd
());
for
(
it
=
attendees
.
constBegin
();
it
!=
end
;
++
it
)
{
...
...
agent/collectionindexer.cpp
View file @
109dfe13
...
...
@@ -63,8 +63,8 @@ void CollectionIndexer::index(const Akonadi::Collection &collection)
gen
.
set_document
(
doc
);
gen
.
set_database
(
*
m_db
);
gen
.
index_text_without_positions
(
collection
.
displayName
().
to
Utf8
().
constData
());
gen
.
index_text_without_positions
(
collection
.
displayName
().
to
Utf8
().
constData
(),
1
,
"N"
);
gen
.
index_text_without_positions
(
collection
.
displayName
().
to
StdString
());
gen
.
index_text_without_positions
(
collection
.
displayName
().
to
StdString
(),
1
,
"N"
);
//We index with positions so we can do phrase searches (required for exact matches)
{
...
...
@@ -74,7 +74,7 @@ void CollectionIndexer::index(const Akonadi::Collection &collection)
doc
.
add_term
(
term
.
constData
());
}
Akonadi
::
Collection
::
Id
colId
=
collection
.
parentCollection
().
id
();
const
Akonadi
::
Collection
::
Id
colId
=
collection
.
parentCollection
().
id
();
const
QByteArray
term
=
'C'
+
QByteArray
::
number
(
colId
);
doc
.
add_boolean_term
(
term
.
constData
());
...
...
agent/collectionupdatejob.h
View file @
109dfe13
...
...
@@ -30,7 +30,7 @@ private Q_SLOTS:
private:
bool
shouldIndex
(
const
Akonadi
::
Collection
&
col
)
const
;
Akonadi
::
Collection
mCol
;
const
Akonadi
::
Collection
mCol
;
Index
&
mIndex
;
};
...
...
agent/emailindexer.cpp
View file @
109dfe13
...
...
@@ -103,7 +103,7 @@ void EmailIndexer::index(const Akonadi::Item &item)
void
EmailIndexer
::
insert
(
const
QByteArray
&
key
,
KMime
::
Headers
::
Base
*
unstructured
)
{
if
(
unstructured
)
{
m_termGen
->
index_text_without_positions
(
unstructured
->
asUnicodeString
().
to
Utf8
().
constData
(),
1
,
key
.
data
());
m_termGen
->
index_text_without_positions
(
unstructured
->
asUnicodeString
().
to
StdString
(),
1
,
key
.
data
());
}
}
...
...
@@ -141,7 +141,7 @@ void EmailIndexer::insert(const QByteArray &key, const KMime::Types::Mailbox::Li
return
;
}
for
(
const
KMime
::
Types
::
Mailbox
&
mbox
:
list
)
{
std
::
string
name
(
mbox
.
name
().
to
Utf8
().
constData
());
std
::
string
name
(
mbox
.
name
().
to
StdString
());
m_termGen
->
index_text_without_positions
(
name
,
1
,
key
.
data
());
m_termGen
->
index_text_without_positions
(
name
,
1
);
m_termGen
->
index_text_without_positions
(
mbox
.
address
().
data
(),
1
,
key
.
data
());
...
...
@@ -160,7 +160,7 @@ void EmailIndexer::insert(const QByteArray &key, const KMime::Types::Mailbox::Li
continue
;
}
catch
(
const
Xapian
::
DocNotFoundError
&
)
{
Xapian
::
Document
doc
;
std
::
string
pretty
(
pa
.
to
Utf8
().
constData
());
std
::
string
pretty
(
pa
.
to
StdString
());
doc
.
set_data
(
pretty
);
Xapian
::
TermGenerator
termGen
;
...
...
@@ -181,7 +181,7 @@ void EmailIndexer::process(const KMime::Message::Ptr &msg)
// (Give the subject a higher priority)
KMime
::
Headers
::
Subject
*
subject
=
msg
->
subject
(
false
);
if
(
subject
)
{
std
::
string
str
(
subject
->
asUnicodeString
().
to
Utf8
().
constData
());
std
::
string
str
(
subject
->
asUnicodeString
().
to
StdString
());
qCDebug
(
AKONADI_INDEXER_AGENT_LOG
)
<<
"Indexing"
<<
str
.
c_str
();
m_termGen
->
index_text_without_positions
(
str
,
1
,
"SU"
);
m_termGen
->
index_text_without_positions
(
str
,
100
);
...
...
@@ -217,7 +217,7 @@ void EmailIndexer::process(const KMime::Message::Ptr &msg)
KMime
::
Content
*
mainBody
=
msg
->
mainBodyPart
(
"text/plain"
);
if
(
mainBody
)
{
const
std
::
string
text
(
mainBody
->
decodedText
().
to
Utf8
().
constData
());
const
std
::
string
text
(
mainBody
->
decodedText
().
to
StdString
());
m_termGen
->
index_text_without_positions
(
text
);
m_termGen
->
index_text_without_positions
(
text
,
1
,
"BO"
);
}
else
{
...
...
@@ -248,7 +248,7 @@ void EmailIndexer::processPart(KMime::Content *content, KMime::Content *mainCont
QTextDocument
doc
;
doc
.
setHtml
(
content
->
decodedText
());
const
std
::
string
text
(
doc
.
toPlainText
().
to
Utf8
().
constData
());
const
std
::
string
text
(
doc
.
toPlainText
().
to
StdString
());
m_termGen
->
index_text_without_positions
(
text
);
}
}
...
...
lib/collectionquery.cpp
View file @
109dfe13
...
...
@@ -95,7 +95,7 @@ ResultIterator CollectionQuery::exec()
parser
.
set_database
(
db
);
parser
.
add_prefix
(
""
,
"N"
);
parser
.
set_default_op
(
Xapian
::
Query
::
OP_AND
);
queries
<<
parser
.
parse_query
(
d
->
nameString
.
to
Utf8
().
constData
(),
queries
<<
parser
.
parse_query
(
d
->
nameString
.
to
StdString
(),
Xapian
::
QueryParser
::
FLAG_PARTIAL
);
}
...
...
@@ -104,7 +104,7 @@ ResultIterator CollectionQuery::exec()
parser
.
set_database
(
db
);
parser
.
add_prefix
(
""
,
"I"
);
parser
.
set_default_op
(
Xapian
::
Query
::
OP_AND
);
queries
<<
parser
.
parse_query
(
d
->
identifierString
.
to
Utf8
().
constData
(),
queries
<<
parser
.
parse_query
(
d
->
identifierString
.
to
StdString
(),
Xapian
::
QueryParser
::
FLAG_PARTIAL
);
}
...
...
@@ -113,7 +113,7 @@ ResultIterator CollectionQuery::exec()
parser
.
set_database
(
db
);
parser
.
add_prefix
(
""
,
"P"
);
parser
.
set_default_op
(
Xapian
::
Query
::
OP_AND
);
queries
<<
parser
.
parse_query
(
d
->
pathString
.
to
Utf8
().
constData
(),
queries
<<
parser
.
parse_query
(
d
->
pathString
.
to
StdString
(),
Xapian
::
QueryParser
::
FLAG_PARTIAL
|
Xapian
::
QueryParser
::
FLAG_PHRASE
);
}
...
...
lib/contactcompleter.h
View file @
109dfe13
...
...
@@ -22,11 +22,11 @@ class AKONADI_SEARCH_PIM_EXPORT ContactCompleter
public:
explicit
ContactCompleter
(
const
QString
&
prefix
,
int
limit
=
10
);
QStringList
complete
();
Q_REQUIRED_RESULT
QStringList
complete
();
private:
QString
m_prefix
;
int
m_limit
;
const
QString
m_prefix
;
const
int
m_limit
;
};
}
}
...
...
runner/pimcontactsrunnerconfig.cpp
View file @
109dfe13
...
...
@@ -22,7 +22,7 @@ PIMContactsRunnerConfig::PIMContactsRunnerConfig(QWidget *parent, const QVariant
{
QVBoxLayout
*
vbox
=
new
QVBoxLayout
(
this
);
mQueryCompletionCheckBox
=
new
QCheckBox
(
i18n
(
"Search in contacts indexed from sent and received emails too"
));
mQueryCompletionCheckBox
=
new
QCheckBox
(
i18n
(
"Search in contacts indexed from sent and received emails too"
)
,
this
);
connect
(
mQueryCompletionCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
PIMContactsRunnerConfig
::
configChanged
);
...
...
search/email/agepostingsource.cpp
View file @
109dfe13
...
...
@@ -17,27 +17,27 @@ using namespace Akonadi::Search;
AgePostingSource
::
AgePostingSource
(
Xapian
::
valueno
slot_
)
:
Xapian
::
ValuePostingSource
(
slot_
)
,
m_currentTime_t
(
QDateTime
::
currentDateTimeUtc
().
toSecsSinceEpoch
())
{
m_currentTime_t
=
QDateTime
::
currentDateTimeUtc
().
toSecsSinceEpoch
();
}
Xapian
::
weight
AgePostingSource
::
get_weight
()
const
{
std
::
string
s
=
*
value_it
;
QString
str
=
QString
::
fromUtf8
(
s
.
c_str
(),
s
.
length
());
const
std
::
string
s
=
*
value_it
;
const
QString
str
=
QString
::
fromUtf8
(
s
.
c_str
(),
s
.
length
());
bool
ok
=
false
;
uint
time
=
str
.
toUInt
(
&
ok
);
const
uint
time
=
str
.
toUInt
(
&
ok
);
if
(
!
ok
)
{
return
0.0
;
}
uint
diff
=
m_currentTime_t
-
time
;
const
uint
diff
=
m_currentTime_t
-
time
;
// Each day is given a penalty of penalty of 1.0
double
penalty
=
1.0
/
(
24
*
60
*
60
);
double
result
=
1000.0
-
(
diff
*
penalty
);
const
double
penalty
=
1.0
/
(
24
*
60
*
60
);
const
double
result
=
1000.0
-
(
diff
*
penalty
);
if
(
result
<
0.0
)
{
return
0.0
;
...
...
search/email/agepostingsource.h
View file @
109dfe13
...
...
@@ -29,7 +29,7 @@ public:
void
init
(
const
Xapian
::
Database
&
db_
)
override
;
private:
unsigned
int
m_currentTime_t
;
const
unsigned
int
m_currentTime_t
;
};
}
}
...
...
search/email/emailsearchstore.cpp
View file @
109dfe13
...
...
@@ -92,7 +92,7 @@ QString EmailSearchStore::text(int queryId)
// Nothing to do, move along
}
QString
subject
=
QString
::
fromUtf8
(
data
.
c_str
(),
data
.
length
());
const
QString
subject
=
QString
::
fromUtf8
(
data
.
c_str
(),
data
.
length
());
if
(
subject
.
isEmpty
())
{
return
QStringLiteral
(
"No Subject"
);
}
...
...
search/pimsearchstore.cpp
View file @
109dfe13
...
...
@@ -90,7 +90,7 @@ Xapian::Query PIMSearchStore::constructQuery(const QString &property, const QVar
if
(
m_boolWithValue
.
contains
(
prop
))
{
std
::
string
term
(
m_prefix
.
value
(
prop
).
toStdString
());
std
::
string
val
(
value
.
toString
().
to
Utf8
().
constData
());
std
::
string
val
(
value
.
toString
().
to
StdString
());
return
Xapian
::
Query
(
term
+
val
);
}
...
...
@@ -117,7 +117,7 @@ Xapian::Query PIMSearchStore::constructQuery(const QString &property, const QVar
parser
.
set_database
(
*
xapianDb
());
std
::
string
p
=
m_prefix
.
value
(
prop
).
toStdString
();
std
::
string
str
(
value
.
toString
().
to
Utf8
().
constData
());
std
::
string
str
(
value
.
toString
().
to
StdString
());
int
flags
=
Xapian
::
QueryParser
::
FLAG_DEFAULT
;
if
(
com
==
Term
::
Contains
)
{
flags
|=
Xapian
::
QueryParser
::
FLAG_PARTIAL
;
...
...
xapian/xapiandocument.cpp
View file @
109dfe13
...
...
@@ -56,7 +56,7 @@ Xapian::Document XapianDocument::doc() const
void
XapianDocument
::
addValue
(
int
pos
,
const
QString
&
value
)
{
m_doc
.
add_value
(
pos
,
value
.
to
Utf8
().
constData
());
m_doc
.
add_value
(
pos
,
value
.
to
StdString
());
}
QString
XapianDocument
::
fetchTermStartsWith
(
const
QByteArray
&
term
)
...
...
xapian/xapianqueryparser.cpp
View file @
109dfe13
...
...
@@ -37,8 +37,8 @@ struct Term {
Xapian
::
Query
makeQuery
(
const
QString
&
string
,
int
position
,
Xapian
::
Database
*
db
)
{
if
(
!
db
)
{
QByteArray
arr
=
string
.
toUtf8
();
std
::
string
stdString
(
arr
.
constData
(),
arr
.
size
());
const
QByteArray
arr
=
string
.
toUtf8
();
const
std
::
string
stdString
(
arr
.
constData
(),
arr
.
size
());
return
Xapian
::
Query
(
stdString
,
1
,
position
);
}
...
...
@@ -47,7 +47,7 @@ Xapian::Query makeQuery(const QString &string, int position, Xapian::Database *d
QList
<
Term
>
topTerms
;
topTerms
.
reserve
(
MaxTerms
+
1
);
const
std
::
string
stdString
(
string
.
to
Utf8
().
constData
());
const
std
::
string
stdString
(
string
.
to
StdString
());
Xapian
::
TermIterator
it
=
db
->
allterms_begin
(
stdString
);
Xapian
::
TermIterator
end
=
db
->
allterms_end
(
stdString
);
for
(;
it
!=
end
;
++
it
)
{
...
...
@@ -76,7 +76,7 @@ Xapian::Query makeQuery(const QString &string, int position, Xapian::Database *d
}
if
(
queries
.
isEmpty
())
{
return
Xapian
::
Query
(
string
.
to
Utf8
().
constData
(),
1
,
position
);
return
Xapian
::
Query
(
string
.
to
StdString
(),
1
,
position
);
}
Xapian
::
Query
finalQ
(
Xapian
::
Query
::
OP_SYNONYM
,
queries
.
begin
(),
queries
.
end
());
return
finalQ
;
...
...
@@ -105,7 +105,7 @@ Xapian::Query XapianQueryParser::parseQuery(const QString &text, const QString &
int flags = Xapian::QueryParser::FLAG_PHRASE | Xapian::QueryParser::FLAG_PARTIAL;
std::string stdString(text.to
Utf8().constData
());
std::string stdString(text.to
StdString
());
return parser.parse_query(stdString, flags);
*/
...
...
@@ -198,7 +198,7 @@ Xapian::Query XapianQueryParser::parseQuery(const QString &text, const QString &
if
(
m_autoExpand
)
{
queries
<<
makeQuery
(
term
,
position
,
m_db
);
}
else
{
queries
<<
Xapian
::
Query
(
term
.
to
Utf8
().
constData
(),
1
,
position
);
queries
<<
Xapian
::
Query
(
term
.
to
StdString
(),
1
,
position
);
}
}
}
...
...
xapian/xapiantermgenerator.cpp
View file @
109dfe13
...
...
@@ -81,10 +81,10 @@ void XapianTermGenerator::indexText(const QString &text, const QString &prefix,
const
QStringList
terms
=
termList
(
text
);
for
(
const
QString
&
term
:
terms
)
{
QByteArray
arr
=
term
.
toUtf8
();
const
QByteArray
arr
=
term
.
toUtf8
();
QByteArray
finalArr
=
par
+
arr
;
std
::
string
stdString
(
finalArr
.
constData
(),
finalArr
.
size
());
const
QByteArray
finalArr
=
par
+
arr
;
const
std
::
string
stdString
(
finalArr
.
constData
(),
finalArr
.
size
());
m_doc
->
add_posting
(
stdString
,
m_position
,
wdfInc
);
m_position
++
;
...
...
Write
Preview
Supports
Markdown
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