Bug with the edited message fixed, some further work on message correction
This commit is contained in:
parent
0823b35148
commit
bf4a27f35d
6 changed files with 61 additions and 3 deletions
|
@ -224,8 +224,20 @@ std::set<Models::MessageFeed::MessageRoles> Models::MessageFeed::detectChanges(c
|
|||
|
||||
void Models::MessageFeed::removeMessage(const QString& id)
|
||||
{
|
||||
//todo;
|
||||
}
|
||||
|
||||
Shared::Message Models::MessageFeed::getMessage(const QString& id)
|
||||
{
|
||||
StorageById::iterator itr = indexById.find(id);
|
||||
if (itr == indexById.end()) {
|
||||
throw NotFound(id.toStdString(), rosterItem->getJid().toStdString(), rosterItem->getAccountName().toStdString());
|
||||
}
|
||||
|
||||
return **itr;
|
||||
}
|
||||
|
||||
|
||||
QVariant Models::MessageFeed::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
int i = index.row();
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <shared/message.h>
|
||||
#include <shared/icons.h>
|
||||
#include <shared/exception.h>
|
||||
|
||||
|
||||
namespace Models {
|
||||
|
@ -55,6 +56,7 @@ public:
|
|||
void addMessage(const Shared::Message& msg);
|
||||
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||
void removeMessage(const QString& id);
|
||||
Shared::Message getMessage(const QString& id);
|
||||
|
||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
@ -103,6 +105,21 @@ public:
|
|||
Error,
|
||||
Bulk
|
||||
};
|
||||
|
||||
class NotFound:
|
||||
public Utils::Exception
|
||||
{
|
||||
public:
|
||||
NotFound(const std::string& k, const std::string& j, const std::string& acc):Exception(), key(k), jid(j), account(acc){}
|
||||
|
||||
std::string getMessage() const {
|
||||
return "Message with id " + key + " wasn't found in messageFeed " + account + " of the chat with " + jid;
|
||||
}
|
||||
private:
|
||||
std::string key;
|
||||
std::string jid;
|
||||
std::string account;
|
||||
};
|
||||
|
||||
protected:
|
||||
bool sentByMe(const Shared::Message& msg) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue