Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117755594
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
9 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/pim/lib/contactquery.cpp b/src/pim/lib/contactquery.cpp
index 87c8a726..1c0b69c8 100644
--- a/src/pim/lib/contactquery.cpp
+++ b/src/pim/lib/contactquery.cpp
@@ -1,199 +1,199 @@
/*
* This file is part of the KDE Baloo Project
* Copyright (C) 2013 Vishesh Handa <me@vhanda.in>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) version 3, or any
* later version accepted by the membership of KDE e.V. (or its
* successor approved by the membership of KDE e.V.), which shall
* act as a proxy defined in Section 6 of version 3 of the license.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "contactquery.h"
#include "resultiterator_p.h"
#include "xapian.h"
-#include <KDebug>
+#include <QDebug>
#include <QList>
#include <QDebug>
#include <QStandardPaths>
#include <QFile>
using namespace Baloo::PIM;
class ContactQuery::Private {
public:
QString name;
QString nick;
QString email;
QString uid;
QString any;
int limit;
MatchCriteria criteria;
};
ContactQuery::ContactQuery()
: Query()
, d(new Private)
{
d->criteria = StartsWithMatch;
}
ContactQuery::~ContactQuery()
{
delete d;
}
void ContactQuery::matchName(const QString& name)
{
d->name = name;
}
void ContactQuery::matchNickname(const QString& nick)
{
d->nick = nick;
}
void ContactQuery::matchEmail(const QString& email)
{
d->email = email;
}
void ContactQuery::matchUID(const QString& uid)
{
d->uid = uid;
}
void ContactQuery::match(const QString& str)
{
d->any = str;
}
int ContactQuery::limit() const
{
return d->limit;
}
void ContactQuery::setLimit(int limit)
{
d->limit = limit;
}
ContactQuery::MatchCriteria ContactQuery::matchCriteria() const
{
return d->criteria;
}
void ContactQuery::setMatchCriteria(ContactQuery::MatchCriteria m)
{
d->criteria = m;
}
ResultIterator ContactQuery::exec()
{
const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/baloo/contacts/";
Xapian::Database db;
try {
db = Xapian::Database(QFile::encodeName(dir).constData());
} catch (const Xapian::DatabaseError& e) {
- kWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
+ qWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
return ResultIterator();
}
QList<Xapian::Query> m_queries;
if (d->criteria == ExactMatch) {
if (!d->any.isEmpty()) {
const QByteArray ba = d->any.toUtf8();
m_queries << Xapian::Query(ba.constData());
}
if (!d->name.isEmpty()) {
const QByteArray ba = "NA" + d->name.toUtf8();
m_queries << Xapian::Query(ba.constData());
}
if (!d->nick.isEmpty()) {
const QByteArray ba = "NI" + d->nick.toUtf8();
m_queries << Xapian::Query(ba.constData());
}
if (!d->email.isEmpty()) {
const QByteArray ba = d->email.toUtf8();
m_queries << Xapian::Query(ba.constData());
}
if (!d->uid.isEmpty()) {
m_queries << Xapian::Query(d->uid.toStdString());
}
}
else if (d->criteria == StartsWithMatch) {
if (!d->any.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
const QByteArray ba = d->any.toUtf8();
m_queries << parser.parse_query(ba.constData(), Xapian::QueryParser::FLAG_PARTIAL);
}
if (!d->name.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
parser.add_prefix("", "NA");
const QByteArray ba = d->name.toUtf8();
m_queries << parser.parse_query(ba.constData(), Xapian::QueryParser::FLAG_PARTIAL);
}
if (!d->nick.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
parser.add_prefix("", "NI");
const QByteArray ba = d->nick.toUtf8();
m_queries << parser.parse_query(ba.constData(), Xapian::QueryParser::FLAG_PARTIAL);
}
// FIXME: Check for exact match?
if (!d->email.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
const QByteArray ba = d->email.toUtf8();
m_queries << parser.parse_query(ba.constData(), Xapian::QueryParser::FLAG_PARTIAL);
}
if (!d->uid.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
m_queries << parser.parse_query(d->uid.toStdString(), Xapian::QueryParser::FLAG_PARTIAL);
}
}
Xapian::Query query(Xapian::Query::OP_OR, m_queries.begin(), m_queries.end());
qDebug() << query.get_description().c_str();
Xapian::Enquire enquire(db);
enquire.set_query(query);
if (d->limit == 0)
d->limit = 10000;
Xapian::MSet matches = enquire.get_mset(0, d->limit);
ResultIterator iter;
iter.d->init(matches);
return iter;
}
diff --git a/src/pim/lib/notequery.cpp b/src/pim/lib/notequery.cpp
index 73d9808c..63d9a8fb 100644
--- a/src/pim/lib/notequery.cpp
+++ b/src/pim/lib/notequery.cpp
@@ -1,130 +1,128 @@
/*
* This file is part of the KDE Baloo Project
* Copyright (C) 2014 Laurent Montel <montel@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) version 3, or any
* later version accepted by the membership of KDE e.V. (or its
* successor approved by the membership of KDE e.V.), which shall
* act as a proxy defined in Section 6 of version 3 of the license.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "notequery.h"
#include "resultiterator_p.h"
#include "xapian.h"
#include <QList>
#include <QDebug>
#include <QStandardPaths>
#include <QFile>
+#include <QDebug>
-#include <KGlobal>
-#include <KStandardDirs>
-#include <KDebug>
using namespace Baloo::PIM;
class NoteQuery::Private {
public:
Private()
: limit(0)
{
}
QString title;
QString note;
int limit;
};
NoteQuery::NoteQuery()
: Query()
, d(new Private)
{
}
NoteQuery::~NoteQuery()
{
delete d;
}
void NoteQuery::matchTitle(const QString &title)
{
d->title = title;
}
void NoteQuery::matchNote(const QString ¬e)
{
d->note = note;
}
void NoteQuery::setLimit(int limit)
{
d->limit = limit;
}
int NoteQuery::limit() const
{
return d->limit;
}
ResultIterator NoteQuery::exec()
{
const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/baloo/notes/";
Xapian::Database db;
try {
db = Xapian::Database(QFile::encodeName(dir).constData());
} catch (const Xapian::DatabaseError& e) {
- kWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
+ qWarning() << "Failed to open Xapian database:" << QString::fromStdString(e.get_error_string());
return ResultIterator();
}
QList<Xapian::Query> m_queries;
if (!d->note.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
parser.add_prefix("", "BO");
const QByteArray baNote = d->note.toUtf8();
m_queries << parser.parse_query(baNote.constData(), Xapian::QueryParser::FLAG_PARTIAL);
}
if (!d->title.isEmpty()) {
Xapian::QueryParser parser;
parser.set_database(db);
parser.add_prefix("", "SU");
parser.set_default_op(Xapian::Query::OP_AND);
const QByteArray baTitle = d->title.toUtf8();
m_queries << parser.parse_query(baTitle.constData(), Xapian::QueryParser::FLAG_PARTIAL);
}
Xapian::Query query(Xapian::Query::OP_OR, m_queries.begin(), m_queries.end());
qDebug() << query.get_description().c_str();
Xapian::Enquire enquire(db);
enquire.set_query(query);
if (d->limit == 0)
d->limit = 10000;
Xapian::MSet matches = enquire.get_mset(0, d->limit);
ResultIterator iter;
iter.d->init(matches);
return iter;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Apr 4, 8:10 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823148
Default Alt Text
(9 KB)
Attached To
Mode
rKB baloo
Attached
Detach File
Event Timeline