Refactoring, new messages thread beggining

This commit is contained in:
Blue 2019-04-11 17:58:59 +03:00
parent 5575cff1f5
commit e48444636a
25 changed files with 610 additions and 163 deletions

View file

@ -182,7 +182,7 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
conv->setAttribute(Qt::WA_DeleteOnClose);
connect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
connect(conv, SIGNAL(sendMessage(const QString&)), this, SLOT(onConversationMessage(const QString&)));
connect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&)));
conversations.insert(std::make_pair(id, conv));
rosterModel.dropMessages(account, jid);
@ -204,9 +204,9 @@ void Squawk::onConversationClosed(QObject* parent)
conversations.erase(itr);
}
void Squawk::accountMessage(const QString& account, const QMap<QString, QString>& data)
void Squawk::accountMessage(const QString& account, const Shared::Message& data)
{
const QString& from = data.value("from");
const QString& from = data.getPenPalJid();
Conversations::iterator itr = conversations.find({account, from});
if (itr != conversations.end()) {
qDebug() << "adding message";
@ -217,11 +217,9 @@ void Squawk::accountMessage(const QString& account, const QMap<QString, QString>
}
}
void Squawk::onConversationMessage(const QString& item)
void Squawk::onConversationMessage(const Shared::Message& msg)
{
Conversation* conv = static_cast<Conversation*>(sender());
emit sendMessage(conv->getAccount(), {
{"to", conv->getJid()},
{"body", item}
});
emit sendMessage(conv->getAccount(), msg);
}