summaryrefslogtreecommitdiffstats
path: root/pica-client/history.cpp
diff options
context:
space:
mode:
authorAnton <anton@picapica>2019-04-27 20:59:48 +0400
committerAnton <anton@picapica>2019-04-27 20:59:48 +0400
commit850b332e7e591064bd8b3245554a05752240408e (patch)
treebb40b9caaa6f7a168896e9c34b88c59031399a1e /pica-client/history.cpp
parent194a8e3dede66de73323d539e9fdd4136ac111ed (diff)
downloadpica-pica-850b332e7e591064bd8b3245554a05752240408e.tar.gz
pica-pica-850b332e7e591064bd8b3245554a05752240408e.zip
pica-client: search in message history
Diffstat (limited to 'pica-client/history.cpp')
-rw-r--r--pica-client/history.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/pica-client/history.cpp b/pica-client/history.cpp
index 3d4e127..bef61b1 100644
--- a/pica-client/history.cpp
+++ b/pica-client/history.cpp
@@ -83,6 +83,41 @@ void History::SetDelivered(QByteArray peer_id)
lasterr = query.lastError();
}
+QList<History::HistoryRecord> History::GetMessages(QByteArray peer_id, QString keyword)
+{
+ QList<HistoryRecord> L;
+ HistoryRecord r;
+ QSqlQuery query;
+
+ query.setForwardOnly(true);
+ query.prepare("select contact_id, is_me, is_delivered, timestamp, message from history \
+ where contact_id=:peer_id and account_id=:me and message like :keyword order by id"
+ );
+
+ query.bindValue(":peer_id", peer_id);
+ query.bindValue(":me", me_);
+ query.bindValue(":keyword", QString("%%1%").arg(keyword));
+ query.exec();
+
+ lasterr = query.lastError();
+
+ if (lasterr.isValid())
+ return L;
+
+ while(query.next())
+ {
+ r.peer_id = query.value(0).toByteArray();
+ r.is_me = query.value(1).toBool();
+ r.is_delivered = query.value(2).toBool();
+ r.timestamp = query.value(3).toUInt();
+ r.message = query.value(4).toString();
+
+ L << r;
+ }
+
+ return L;
+}
+
QList<History::HistoryRecord> History::GetMessages(QByteArray peer_id, quint32 start_timestamp, quint32 end_timestamp)
{
QList<HistoryRecord> L;