2019-07-11 08:51:52 +00:00
|
|
|
/*
|
2019-09-01 19:46:12 +00:00
|
|
|
* Squawk messenger.
|
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
2019-07-11 08:51:52 +00:00
|
|
|
*
|
|
|
|
* 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 MODELS_ROOM_H
|
|
|
|
#define MODELS_ROOM_H
|
|
|
|
|
2020-08-11 22:49:51 +00:00
|
|
|
#include "element.h"
|
2019-09-02 11:17:28 +00:00
|
|
|
#include "participant.h"
|
2020-04-03 22:28:15 +00:00
|
|
|
#include "shared/enums.h"
|
|
|
|
#include "shared/message.h"
|
2019-07-11 08:51:52 +00:00
|
|
|
|
|
|
|
namespace Models {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo write docs
|
|
|
|
*/
|
2020-08-11 22:49:51 +00:00
|
|
|
class Room : public Element
|
2019-07-11 08:51:52 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-08-11 22:49:51 +00:00
|
|
|
Room(const Account* acc, const QString& p_jid, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
2019-07-11 08:51:52 +00:00
|
|
|
~Room();
|
|
|
|
|
|
|
|
int columnCount() const override;
|
|
|
|
QVariant data(int column) const override;
|
|
|
|
|
|
|
|
bool getJoined() const;
|
|
|
|
bool getAutoJoin() const;
|
|
|
|
QString getNick() const;
|
|
|
|
QString getRoomName() const;
|
2019-09-03 20:28:58 +00:00
|
|
|
QString getSubject() const;
|
2019-07-11 08:51:52 +00:00
|
|
|
|
|
|
|
QIcon getStatusIcon(bool big = false) const;
|
|
|
|
QString getStatusText() const;
|
|
|
|
|
|
|
|
void setJoined(bool p_joined);
|
|
|
|
void setAutoJoin(bool p_autoJoin);
|
|
|
|
void setNick(const QString& p_nick);
|
2019-09-03 20:28:58 +00:00
|
|
|
void setSubject(const QString& sub);
|
2019-07-11 08:51:52 +00:00
|
|
|
|
2020-08-11 22:49:51 +00:00
|
|
|
void update(const QString& field, const QVariant& value) override;
|
2019-09-02 11:17:28 +00:00
|
|
|
|
|
|
|
void addParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void changeParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void removeParticipant(const QString& name);
|
2022-04-24 15:52:29 +00:00
|
|
|
Participant* getParticipant(const QString& name);
|
2019-09-02 11:17:28 +00:00
|
|
|
|
|
|
|
void toOfflineState() override;
|
2019-09-24 09:21:29 +00:00
|
|
|
QString getDisplayedName() const override;
|
2019-12-31 18:14:12 +00:00
|
|
|
std::map<QString, const Participant&> getParticipants() const;
|
|
|
|
QString getParticipantIconPath(const QString& name) const;
|
2020-04-13 19:57:23 +00:00
|
|
|
std::map<QString, QString> getExParticipantAvatars() const;
|
2019-12-31 18:14:12 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void participantJoined(const Participant& participant);
|
|
|
|
void participantLeft(const QString& name);
|
2019-09-02 11:17:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void handleParticipantUpdate(std::map<QString, Participant*>::const_iterator itr, const QMap<QString, QVariant>& data);
|
2019-07-11 08:51:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool autoJoin;
|
|
|
|
bool joined;
|
|
|
|
QString nick;
|
2019-09-03 20:28:58 +00:00
|
|
|
QString subject;
|
2019-09-02 11:17:28 +00:00
|
|
|
std::map<QString, Participant*> participants;
|
2020-04-13 19:57:23 +00:00
|
|
|
std::map<QString, QString> exParticipantAvatars;
|
2019-07-11 08:51:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MODELS_ROOM_H
|