2020-08-11 22:49:51 +00:00
|
|
|
/*
|
|
|
|
* Squawk messenger.
|
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ELEMENT_H
|
|
|
|
#define ELEMENT_H
|
|
|
|
|
|
|
|
#include "item.h"
|
|
|
|
#include "messagefeed.h"
|
|
|
|
|
|
|
|
namespace Models {
|
|
|
|
|
|
|
|
class Element : public Item
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
|
|
Element(Type p_type, const Account* acc, const QString& p_jid, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
|
|
|
~Element();
|
|
|
|
|
|
|
|
public:
|
|
|
|
QString getJid() const;
|
|
|
|
Shared::Avatar getAvatarState() const;
|
|
|
|
QString getAvatarPath() const;
|
|
|
|
|
|
|
|
virtual void update(const QString& field, const QVariant& value);
|
|
|
|
|
|
|
|
void addMessage(const Shared::Message& data);
|
|
|
|
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
|
|
|
unsigned int getMessagesCount() const;
|
2020-08-21 20:57:48 +00:00
|
|
|
void responseArchive(const std::list<Shared::Message> list, bool last);
|
2020-08-20 21:32:30 +00:00
|
|
|
bool isRoom() const;
|
2021-04-18 12:49:20 +00:00
|
|
|
void fileProgress(const QString& messageId, qreal value, bool up);
|
|
|
|
void fileError(const QString& messageId, const QString& error, bool up);
|
|
|
|
void fileComplete(const QString& messageId, bool up);
|
2020-08-11 22:49:51 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void requestArchive(const QString& before);
|
2021-04-18 12:49:20 +00:00
|
|
|
void fileDownloadRequest(const QString& url);
|
2021-04-27 19:29:15 +00:00
|
|
|
void unnoticedMessage(const QString& account, const Shared::Message& msg);
|
2020-08-11 22:49:51 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void setJid(const QString& p_jid);
|
|
|
|
void setAvatarState(Shared::Avatar p_state);
|
|
|
|
void setAvatarState(unsigned int p_state);
|
|
|
|
void setAvatarPath(const QString& path);
|
|
|
|
bool columnInvolvedInDisplay(int col) override;
|
|
|
|
const Account* getParentAccount() const override;
|
|
|
|
|
2021-04-27 19:29:15 +00:00
|
|
|
protected slots:
|
|
|
|
void onFeedUnreadMessagesCountChanged();
|
|
|
|
void onFeedUnnoticedMessage(const Shared::Message& msg);
|
|
|
|
|
2020-08-11 22:49:51 +00:00
|
|
|
protected:
|
|
|
|
QString jid;
|
|
|
|
QString avatarPath;
|
|
|
|
Shared::Avatar avatarState;
|
|
|
|
|
|
|
|
const Account* account;
|
|
|
|
|
|
|
|
public:
|
|
|
|
MessageFeed* feed;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // ELEMENT_H
|