Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
Akonadi Search
Commits
df428756
Commit
df428756
authored
Jul 30, 2020
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up code
parent
bbed6bc6
Pipeline
#28838
passed with stage
in 21 minutes and 54 seconds
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
41 additions
and
57 deletions
+41
-57
agent/akonotesindexer.cpp
agent/akonotesindexer.cpp
+0
-3
agent/calendarindexer.cpp
agent/calendarindexer.cpp
+0
-1
agent/collectionindexer.cpp
agent/collectionindexer.cpp
+1
-2
agent/collectionindexingjob.cpp
agent/collectionindexingjob.cpp
+0
-3
agent/collectionindexingjob.h
agent/collectionindexingjob.h
+4
-4
agent/contactindexer.cpp
agent/contactindexer.cpp
+0
-1
agent/emailindexer.cpp
agent/emailindexer.cpp
+0
-3
agent/index.cpp
agent/index.cpp
+0
-1
agent/scheduler.cpp
agent/scheduler.cpp
+0
-1
lib/collectionquery.cpp
lib/collectionquery.cpp
+2
-2
lib/contactquery.cpp
lib/contactquery.cpp
+5
-5
lib/emailquery.cpp
lib/emailquery.cpp
+9
-11
lib/indexeditems.cpp
lib/indexeditems.cpp
+9
-9
lib/notequery.cpp
lib/notequery.cpp
+7
-7
lib/query.cpp
lib/query.cpp
+3
-2
runner/pimcontactsrunner.cpp
runner/pimcontactsrunner.cpp
+0
-1
runner/pimcontactsrunner.h
runner/pimcontactsrunner.h
+1
-1
No files found.
agent/akonotesindexer.cpp
View file @
df428756
...
...
@@ -12,9 +12,6 @@
AkonotesIndexer
::
AkonotesIndexer
(
const
QString
&
path
)
:
AbstractIndexer
()
,
m_db
(
nullptr
)
,
m_doc
(
nullptr
)
,
m_termGen
(
nullptr
)
{
try
{
m_db
=
new
Xapian
::
WritableDatabase
(
path
.
toUtf8
().
constData
(),
Xapian
::
DB_CREATE_OR_OPEN
);
...
...
agent/calendarindexer.cpp
View file @
df428756
...
...
@@ -15,7 +15,6 @@
CalendarIndexer
::
CalendarIndexer
(
const
QString
&
path
)
:
AbstractIndexer
()
,
m_db
(
nullptr
)
{
try
{
m_db
=
new
Akonadi
::
Search
::
XapianDatabase
(
path
,
true
);
...
...
agent/collectionindexer.cpp
View file @
df428756
...
...
@@ -41,8 +41,7 @@ CollectionIndexer::~CollectionIndexer()
static
QByteArray
getPath
(
const
Akonadi
::
Collection
&
collection
)
{
QStringList
pathParts
;
pathParts
<<
collection
.
displayName
();
QStringList
pathParts
=
{
collection
.
displayName
()};
Akonadi
::
Collection
col
=
collection
;
while
(
col
.
parentCollection
().
isValid
()
&&
(
col
.
parentCollection
()
!=
Akonadi
::
Collection
::
root
()))
{
col
=
col
.
parentCollection
();
...
...
agent/collectionindexingjob.cpp
View file @
df428756
...
...
@@ -22,9 +22,6 @@ CollectionIndexingJob::CollectionIndexingJob(Index &index, const Akonadi::Collec
,
m_collection
(
col
)
,
m_pending
(
pending
)
,
m_index
(
index
)
,
m_reindexingLock
(
false
)
,
m_fullSync
(
true
)
,
m_progressTotal
(
0
)
{
}
...
...
agent/collectionindexingjob.h
View file @
df428756
...
...
@@ -49,10 +49,10 @@ private:
QList
<
Akonadi
::
Item
::
Id
>
m_needsIndexing
;
Index
&
m_index
;
QElapsedTimer
m_time
;
bool
m_reindexingLock
;
bool
m_fullSync
;
int
m_progressCounter
;
int
m_progressTotal
;
bool
m_reindexingLock
=
false
;
bool
m_fullSync
=
true
;
int
m_progressCounter
=
0
;
int
m_progressTotal
=
0
;
};
#endif
agent/contactindexer.cpp
View file @
df428756
...
...
@@ -16,7 +16,6 @@
ContactIndexer
::
ContactIndexer
(
const
QString
&
path
)
:
AbstractIndexer
()
,
m_db
(
nullptr
)
{
try
{
m_db
=
new
Akonadi
::
Search
::
XapianDatabase
(
path
,
true
);
...
...
agent/emailindexer.cpp
View file @
df428756
...
...
@@ -16,9 +16,6 @@
EmailIndexer
::
EmailIndexer
(
const
QString
&
path
,
const
QString
&
contactDbPath
)
:
AbstractIndexer
()
,
m_doc
(
nullptr
)
,
m_termGen
(
nullptr
)
,
m_contactDb
(
nullptr
)
{
try
{
m_db
=
new
Xapian
::
WritableDatabase
(
path
.
toUtf8
().
constData
(),
Xapian
::
DB_CREATE_OR_OPEN
);
...
...
agent/index.cpp
View file @
df428756
...
...
@@ -22,7 +22,6 @@
using
namespace
Akonadi
::
Search
::
PIM
;
Index
::
Index
(
QObject
*
parent
)
:
QObject
(
parent
)
,
m_collectionIndexer
(
nullptr
)
{
m_indexedItems
=
new
IndexedItems
(
this
);
m_commitTimer
.
setInterval
(
1000
);
...
...
agent/scheduler.cpp
View file @
df428756
...
...
@@ -33,7 +33,6 @@ Scheduler::Scheduler(Index &index, const KSharedConfigPtr &config, const QShared
:
QObject
(
parent
)
,
m_config
(
config
)
,
m_index
(
index
)
,
m_currentJob
(
nullptr
)
,
m_jobFactory
(
jobFactory
)
,
m_busyTimeout
(
5000
)
{
...
...
lib/collectionquery.cpp
View file @
df428756
...
...
@@ -10,7 +10,7 @@
#include "collectionquery.h"
#include "resultiterator_p.h"
#include "akonadi_search_pim_debug.h"
#include <QList>
#include <QFile>
...
...
@@ -82,7 +82,7 @@ ResultIterator CollectionQuery::exec()
try
{
db
=
Xapian
::
Database
(
QFile
::
encodeName
(
d
->
databaseDir
).
constData
());
}
catch
(
const
Xapian
::
DatabaseError
&
e
)
{
qWarning
()
<<
"Failed to open Xapian database:"
<<
d
->
databaseDir
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Failed to open Xapian database:"
<<
d
->
databaseDir
<<
"; error:"
<<
QString
::
fromStdString
(
e
.
get_error_string
());
return
ResultIterator
();
}
...
...
lib/contactquery.cpp
View file @
df428756
...
...
@@ -97,16 +97,16 @@ ResultIterator ContactQuery::exec()
try
{
db
=
Xapian
::
Database
(
QFile
::
encodeName
(
dir
).
constData
());
}
catch
(
const
Xapian
::
DatabaseOpeningError
&
)
{
qWarning
()
<<
"Xapian Database does not exist at "
<<
dir
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Xapian Database does not exist at "
<<
dir
;
return
ResultIterator
();
}
catch
(
const
Xapian
::
DatabaseCorruptError
&
)
{
qWarning
()
<<
"Xapian Database corrupted"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Xapian Database corrupted"
;
return
ResultIterator
();
}
catch
(
const
Xapian
::
DatabaseError
&
e
)
{
qWarning
()
<<
"Failed to open Xapian database:"
<<
QString
::
fromStdString
(
e
.
get_error_string
());
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Failed to open Xapian database:"
<<
QString
::
fromStdString
(
e
.
get_error_string
());
return
ResultIterator
();
}
catch
(...)
{
qWarning
()
<<
"Random exception, but we do not want to crash"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Random exception, but we do not want to crash"
;
return
ResultIterator
();
}
...
...
@@ -194,7 +194,7 @@ ResultIterator ContactQuery::exec()
iter
.
d
->
init
(
matches
);
return
iter
;
}
catch
(
const
Xapian
::
Error
&
e
)
{
qWarning
()
<<
QString
::
fromStdString
(
e
.
get_type
())
<<
QString
::
fromStdString
(
e
.
get_description
());
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
QString
::
fromStdString
(
e
.
get_type
())
<<
QString
::
fromStdString
(
e
.
get_description
());
return
ResultIterator
();
}
}
lib/emailquery.cpp
View file @
df428756
...
...
@@ -11,6 +11,7 @@
#include "emailquery.h"
#include "resultiterator_p.h"
#include "../search/email/agepostingsource.h"
#include "akonadi_search_pim_debug.h"
#include <QStandardPaths>
#include <QRegularExpression>
...
...
@@ -39,18 +40,15 @@ public:
QString
subjectMatchString
;
QString
bodyMatchString
;
EmailQuery
::
OpType
opType
;
int
limit
;
bool
splitSearchMatchString
;
EmailQuery
::
OpType
opType
=
EmailQuery
::
OpAnd
;
int
limit
=
0
;
bool
splitSearchMatchString
=
true
;
};
EmailQuery
::
Private
::
Private
()
:
important
(
'0'
)
,
read
(
'0'
)
,
attachment
(
'0'
)
,
opType
(
OpAnd
)
,
limit
(
0
)
,
splitSearchMatchString
(
true
)
{
}
...
...
@@ -182,16 +180,16 @@ ResultIterator EmailQuery::exec()
try
{
db
=
Xapian
::
Database
(
QFile
::
encodeName
(
dir
).
constData
());
}
catch
(
const
Xapian
::
DatabaseOpeningError
&
)
{
qWarning
()
<<
"Xapian Database does not exist at "
<<
dir
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Xapian Database does not exist at "
<<
dir
;
return
ResultIterator
();
}
catch
(
const
Xapian
::
DatabaseCorruptError
&
)
{
qWarning
()
<<
"Xapian Database corrupted"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Xapian Database corrupted"
;
return
ResultIterator
();
}
catch
(
const
Xapian
::
DatabaseError
&
e
)
{
qWarning
()
<<
"Failed to open Xapian database:"
<<
QString
::
fromStdString
(
e
.
get_description
());
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Failed to open Xapian database:"
<<
QString
::
fromStdString
(
e
.
get_description
());
return
ResultIterator
();
}
catch
(...)
{
qWarning
()
<<
"Random exception, but we do not want to crash"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Random exception, but we do not want to crash"
;
return
ResultIterator
();
}
...
...
@@ -350,7 +348,7 @@ ResultIterator EmailQuery::exec()
iter
.
d
->
init
(
mset
);
return
iter
;
}
catch
(
const
Xapian
::
Error
&
e
)
{
qWarning
()
<<
QString
::
fromStdString
(
e
.
get_type
())
<<
QString
::
fromStdString
(
e
.
get_description
());
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
QString
::
fromStdString
(
e
.
get_type
())
<<
QString
::
fromStdString
(
e
.
get_description
());
return
ResultIterator
();
}
}
lib/indexeditems.cpp
View file @
df428756
...
...
@@ -25,18 +25,18 @@ public:
{
}
QString
dbPath
(
const
QString
&
dbName
)
const
;
QString
emailIndexingPath
()
const
;
QString
collectionIndexingPath
()
const
;
QString
calendarIndexingPath
()
const
;
QString
akonotesIndexingPath
()
const
;
QString
emailContactsIndexingPath
()
const
;
QString
contactIndexingPath
()
const
;
Q_REQUIRED_RESULT
QString
dbPath
(
const
QString
&
dbName
)
const
;
Q_REQUIRED_RESULT
QString
emailIndexingPath
()
const
;
Q_REQUIRED_RESULT
QString
collectionIndexingPath
()
const
;
Q_REQUIRED_RESULT
QString
calendarIndexingPath
()
const
;
Q_REQUIRED_RESULT
QString
akonotesIndexingPath
()
const
;
Q_REQUIRED_RESULT
QString
emailContactsIndexingPath
()
const
;
Q_REQUIRED_RESULT
QString
contactIndexingPath
()
const
;
mutable
QHash
<
QString
,
QString
>
m_cachePath
;
QString
m_overridePrefixPath
;
qlonglong
indexedItems
(
const
qlonglong
id
);
qlonglong
indexedItemsInDatabase
(
const
std
::
string
&
term
,
const
QString
&
dbPath
)
const
;
Q_REQUIRED_RESULT
qlonglong
indexedItems
(
const
qlonglong
id
);
Q_REQUIRED_RESULT
qlonglong
indexedItemsInDatabase
(
const
std
::
string
&
term
,
const
QString
&
dbPath
)
const
;
void
findIndexedInDatabase
(
QSet
<
Akonadi
::
Item
::
Id
>
&
indexed
,
Akonadi
::
Collection
::
Id
collectionId
,
const
QString
&
dbPath
);
void
findIndexed
(
QSet
<
Akonadi
::
Item
::
Id
>
&
indexed
,
Akonadi
::
Collection
::
Id
collectionId
);
};
...
...
lib/notequery.cpp
View file @
df428756
...
...
@@ -10,6 +10,7 @@
#include "notequery.h"
#include "resultiterator_p.h"
#include "akonadi_search_pim_debug.h"
#include <QList>
#include <QStandardPaths>
...
...
@@ -22,13 +23,12 @@ class Q_DECL_HIDDEN NoteQuery::Private
{
public:
Private
()
:
limit
(
0
)
{
}
QString
title
;
QString
note
;
int
limit
;
int
limit
=
0
;
};
NoteQuery
::
NoteQuery
()
...
...
@@ -70,16 +70,16 @@ ResultIterator NoteQuery::exec()
try
{
db
=
Xapian
::
Database
(
QFile
::
encodeName
(
dir
).
constData
());
}
catch
(
const
Xapian
::
DatabaseOpeningError
&
)
{
qWarning
()
<<
"Xapian Database does not exist at "
<<
dir
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Xapian Database does not exist at "
<<
dir
;
return
ResultIterator
();
}
catch
(
const
Xapian
::
DatabaseCorruptError
&
)
{
qWarning
()
<<
"Xapian Database corrupted"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Xapian Database corrupted"
;
return
ResultIterator
();
}
catch
(
const
Xapian
::
DatabaseError
&
e
)
{
qWarning
()
<<
"Failed to open Xapian database:"
<<
QString
::
fromStdString
(
e
.
get_error_string
());
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Failed to open Xapian database:"
<<
QString
::
fromStdString
(
e
.
get_error_string
());
return
ResultIterator
();
}
catch
(...)
{
qWarning
()
<<
"Random exception, but we do not want to crash"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Random exception, but we do not want to crash"
;
return
ResultIterator
();
}
...
...
@@ -120,7 +120,7 @@ ResultIterator NoteQuery::exec()
iter
.
d
->
init
(
matches
);
return
iter
;
}
catch
(
const
Xapian
::
Error
&
e
)
{
qWarning
()
<<
QString
::
fromStdString
(
e
.
get_type
())
<<
QString
::
fromStdString
(
e
.
get_description
());
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
QString
::
fromStdString
(
e
.
get_type
())
<<
QString
::
fromStdString
(
e
.
get_description
());
return
ResultIterator
();
}
}
lib/query.cpp
View file @
df428756
...
...
@@ -8,6 +8,7 @@
#include "query.h"
#include "contactquery.h"
#include "akonadi_search_pim_debug.h"
#include <QVariant>
#include <QDebug>
...
...
@@ -32,14 +33,14 @@ Query *Query::fromJSON(const QByteArray &json)
QJsonParseError
error
;
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
json
,
&
error
);
if
(
doc
.
isNull
())
{
qWarning
()
<<
"Could not parse json query"
<<
error
.
errorString
();
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Could not parse json query"
<<
error
.
errorString
();
return
nullptr
;
}
QVariantMap
result
=
doc
.
toVariant
().
toMap
();
const
QString
type
=
result
[
QStringLiteral
(
"type"
)].
toString
().
toLower
();
if
(
type
!=
QLatin1String
(
"contact"
))
{
qWarning
()
<<
"Can only handle contact queries"
;
q
C
Warning
(
AKONADI_SEARCH_PIM_LOG
)
<<
"Can only handle contact queries"
;
return
nullptr
;
}
...
...
runner/pimcontactsrunner.cpp
View file @
df428756
...
...
@@ -35,7 +35,6 @@ Q_DECLARE_METATYPE(KContacts::Addressee *)
PIMContactsRunner
::
PIMContactsRunner
(
QObject
*
parent
,
const
QVariantList
&
args
)
:
Plasma
::
AbstractRunner
(
parent
,
args
)
,
mQueryAutocompleter
(
true
)
{
setObjectName
(
QStringLiteral
(
"PIMContactsRunner"
));
setSpeed
(
Plasma
::
AbstractRunner
::
SlowSpeed
);
...
...
runner/pimcontactsrunner.h
View file @
df428756
...
...
@@ -30,7 +30,7 @@ private:
void
queryAutocompleter
(
Plasma
::
RunnerContext
&
context
,
const
QString
&
queryString
);
private:
bool
mQueryAutocompleter
;
bool
mQueryAutocompleter
=
true
;
};
#endif // PIMCONTACTSRUNNER_H
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