From e3c11fd05496bb2953e4dfe031afb1c180604d30 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 27 Aug 2023 22:54:06 +0200 Subject: jiddb: Remove 'get' from public functions --- jiddb.cpp | 20 ++++++++++---------- jiddb.h | 4 ++-- xxcc.cpp | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/jiddb.cpp b/jiddb.cpp index 7d0d6da..b555f87 100644 --- a/jiddb.cpp +++ b/jiddb.cpp @@ -84,7 +84,7 @@ int JidDb::ensureContactDb(const QString &jid) const return 0; } -QList JidDb::getMessages(const QString &jid, +QList JidDb::messages(const QString &jid, const int tail) const { QSqlQuery q(db); @@ -95,14 +95,14 @@ QList JidDb::getMessages(const QString &jid, { if (!q.exec("select * from '" + jid + "' order by time;")) { - std::cerr << "JidDb::getMessages: query exec failed"; + std::cerr << "JidDb::messages: query exec failed"; return QList(); } } else if (!q.exec("select * from '" + jid + "' order by time desc limit " + QString::number(tail) + ";")) { - std::cerr << "JidDb::getMessages: query exec failed" << std::endl; + std::cerr << "JidDb::messages: query exec failed" << std::endl; return QList(); } @@ -116,7 +116,7 @@ QList JidDb::getMessages(const QString &jid, if (!ok) { - std::cerr << "JidDb::getMessages: invalid time" << std::endl; + std::cerr << "JidDb::messages: invalid time" << std::endl; // Attempt to read other messages. continue; } @@ -132,7 +132,7 @@ QList JidDb::getMessages(const QString &jid, m.direction = Direction::Out; else { - std::cerr << "JidDb::getMessages: invalid direction" << std::endl; + std::cerr << "JidDb::messages: invalid direction" << std::endl; // Attempt to read other messages. continue; } @@ -181,7 +181,7 @@ QStringList JidDb::tables() const if (!q.exec("select name from sqlite_schema where " "type = 'table' and name not like 'sqlite_%'")) { - std::cerr << "JidDb::getConversations: query failed" << std::endl; + std::cerr << "JidDb::conversations: query failed" << std::endl; return QStringList(); } @@ -193,7 +193,7 @@ QStringList JidDb::tables() const return ret; } -QList JidDb::getConversations() const +QList JidDb::conversations() const { const auto conversations = tables(); QList ret; @@ -201,11 +201,11 @@ QList JidDb::getConversations() const for (const auto &jid : conversations) if (jid.contains('@')) { - const auto messages = getMessages(jid, 1); + const auto msgs = messages(jid, 1); - if (!messages.isEmpty()) + if (!msgs.isEmpty()) { - const auto &m = messages.first(); + const auto &m = msgs.first(); ret << Conversation(jid, m.body, m.dt); } diff --git a/jiddb.h b/jiddb.h index 86e0028..6d6860a 100644 --- a/jiddb.h +++ b/jiddb.h @@ -35,8 +35,8 @@ public: const QString jid; public Q_SLOTS: - QList getConversations() const; - QList getMessages(const QString &jid, + QList conversations() const; + QList messages(const QString &jid, int tail = -1) const; int storeMessage(const Message &msg) const; int addToRoster(const QString &jid); diff --git a/xxcc.cpp b/xxcc.cpp index ebe8cbb..b55d58a 100644 --- a/xxcc.cpp +++ b/xxcc.cpp @@ -81,7 +81,7 @@ xxcc::xxcc(QWidget *const parent) : { const auto &db = selected->database(); static const auto n_messages = 20; - const auto messages = db.getMessages(conv->to, n_messages); + const auto messages = db.messages(conv->to, n_messages); for (auto it = messages.rbegin(); it != messages.rend(); it++) new Message(it->body, it->dt, it->direction, ui.messages); @@ -250,7 +250,7 @@ void xxcc::retrieveConversations() { const auto &db = c->database(); - for (const auto &conv : db.getConversations()) + for (const auto &conv : db.conversations()) new Conversation(db.jid, conv.to, ui.conversations_list, conv.last_msg, conv.dt); } -- cgit v1.2.3