started the work to get the list of participants in the room, license fix, little gui models refactor

This commit is contained in:
Blue 2019-09-01 22:46:12 +03:00
parent f5fa45d853
commit 70f9739cf5
25 changed files with 508 additions and 117 deletions

View File

@ -224,7 +224,6 @@ void Core::Account::onRosterItemChanged(const QString& bareJid)
QXmppRosterManager& rm = client.rosterManager();
QXmppRosterIq::Item re = rm.getRosterEntry(bareJid);
QStringList res = rm.getResources(bareJid);
Shared::SubscriptionState state = castSubscriptionState(re.subscriptionType());
contact->setGroups(re.groups());
@ -315,6 +314,11 @@ void Core::Account::handleNewConference(Core::Conference* contact)
QObject::connect(contact, SIGNAL(nickChanged(const QString&)), this, SLOT(onMucNickNameChanged(const QString&)));
QObject::connect(contact, SIGNAL(joinedChanged(bool)), this, SLOT(onMucJoinedChanged(bool)));
QObject::connect(contact, SIGNAL(autoJoinChanged(bool)), this, SLOT(onMucAutoJoinChanged(bool)));
QObject::connect(contact, SIGNAL(addParticipant(const QString&, const QMap<QString, QVariant>&)),
this, SLOT(onMucAddParticipant(const QString&, const QMap<QString, QVariant>&)));
QObject::connect(contact, SIGNAL(changeParticipant(const QString&, const QMap<QString, QVariant>&)),
this, SLOT(onMucChangeParticipant(const QString&, const QMap<QString, QVariant>&)));
QObject::connect(contact, SIGNAL(removeParticipant(const QString&)), this, SLOT(onMucRemoveParticipant(const QString&)));
}
@ -1058,3 +1062,21 @@ void Core::Account::setRoomJoined(const QString& jid, bool joined)
cItr->second->setJoined(joined);
}
void Core::Account::onMucAddParticipant(const QString& nickName, const QMap<QString, QVariant>& data)
{
Conference* room = static_cast<Conference*>(sender());
emit addRoomParticipant(room->jid, nickName, data);
}
void Core::Account::onMucChangeParticipant(const QString& nickName, const QMap<QString, QVariant>& data)
{
Conference* room = static_cast<Conference*>(sender());
emit changeRoomParticipant(room->jid, nickName, data);
}
void Core::Account::onMucRemoveParticipant(const QString& nickName)
{
Conference* room = static_cast<Conference*>(sender());
emit removeRoomParticipant(room->jid, nickName);
}

View File

@ -91,6 +91,9 @@ signals:
void message(const Shared::Message& data);
void responseArchive(const QString& jid, const std::list<Shared::Message>& list);
void error(const QString& text);
void addRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data);
void changeRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data);
void removeRoomParticipant(const QString& jid, const QString& nickName);
private:
QString name;
@ -136,6 +139,9 @@ private slots:
void onMucJoinedChanged(bool joined);
void onMucAutoJoinChanged(bool autoJoin);
void onMucNickNameChanged(const QString& nickName);
void onMucAddParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
void onMucChangeParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
void onMucRemoveParticipant(const QString& nickName);
void bookmarksReceived(const QXmppBookmarkSet& bookmarks);

View File

@ -33,6 +33,9 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo
connect(room, SIGNAL(joined()), this, SLOT(onRoomJoined()));
connect(room, SIGNAL(left()), this, SLOT(onRoomLeft()));
connect(room, SIGNAL(nameChanged(const QString&)), this, SLOT(onRoomNameChanged(const QString&)));
connect(room, SIGNAL(participantAdded(const QString&)), this, SLOT(onRoomParticipantAdded(const QString&)));
connect(room, SIGNAL(participantChanged(const QString&)), this, SLOT(onRoomParticipantChanged(const QString&)));
connect(room, SIGNAL(participantRemoved(const QString&)), this, SLOT(onRoomParticipantRemoved(const QString&)));
connect(room, SIGNAL(nickNameChanged(const QString&)), this, SLOT(onRoomNickNameChanged(const QString&)));
connect(room, SIGNAL(error(const QXmppStanza::Error&)), this, SLOT(onRoomError(const QXmppStanza::Error&)));
@ -119,5 +122,65 @@ void Core::Conference::onRoomNickNameChanged(const QString& p_nick)
void Core::Conference::onRoomError(const QXmppStanza::Error& err)
{
qDebug() << "MUC error";
qDebug() << "MUC" << jid << "error:" << err.text();
}
void Core::Conference::onRoomParticipantAdded(const QString& p_name)
{
QStringList comps = p_name.split("/");
QString resource = comps.back();
if (resource == jid) {
qDebug() << "Room" << jid << "is reporting of adding itself to the list participants. Not sure what to do with that yet, skipping";
} else {
qDebug() << "Participant" << resource << "had entered room" << jid;
QXmppPresence pres = room->participantPresence(jid);
QDateTime lastInteraction = pres.lastUserInteraction();
if (!lastInteraction.isValid()) {
lastInteraction = QDateTime::currentDateTime();
}
QXmppMucItem mi = pres.mucItem();
emit addParticipant(resource, {
{"lastActivity", lastInteraction},
{"availability", pres.availableStatusType()},
{"status", pres.statusText()},
{"affiliation", mi.affiliation()},
{"role", mi.role()}
});
}
}
void Core::Conference::onRoomParticipantChanged(const QString& p_name)
{
QStringList comps = p_name.split("/");
QString resource = comps.back();
if (resource == jid) {
qDebug() << "Room" << jid << "is reporting of changing his own presence. Not sure what to do with that yet, skipping";
} else {
QXmppPresence pres = room->participantPresence(jid);
QDateTime lastInteraction = pres.lastUserInteraction();
if (!lastInteraction.isValid()) {
lastInteraction = QDateTime::currentDateTime();
}
QXmppMucItem mi = pres.mucItem();
emit changeParticipant(resource, {
{"lastActivity", lastInteraction},
{"availability", pres.availableStatusType()},
{"status", pres.statusText()},
{"affiliation", mi.affiliation()},
{"role", mi.role()}
});
}
}
void Core::Conference::onRoomParticipantRemoved(const QString& p_name)
{
QStringList comps = p_name.split("/");
QString resource = comps.back();
if (resource == jid) {
qDebug() << "Room" << jid << "is reporting of removing his own presence from the list of participants. Not sure what to do with that yet, skipping";
} else {
emit removeParticipant(resource);
}
}

View File

@ -48,6 +48,9 @@ signals:
void nickChanged(const QString& nick);
void joinedChanged(bool joined);
void autoJoinChanged(bool autoJoin);
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);
private:
QString nick;
@ -61,6 +64,9 @@ private slots:
void onRoomNameChanged(const QString& p_name);
void onRoomNickNameChanged(const QString& p_nick);
void onRoomError(const QXmppStanza::Error& err);
void onRoomParticipantAdded(const QString& p_name);
void onRoomParticipantChanged(const QString& p_name);
void onRoomParticipantRemoved(const QString& p_name);
};

View File

@ -440,3 +440,20 @@ void Core::Squawk::setRoomAutoJoin(const QString& account, const QString& jid, b
itr->second->setRoomAutoJoin(jid, joined);
}
void Core::Squawk::onAccountAddRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data)
{
Account* acc = static_cast<Account*>(sender());
emit addRoomParticipant(acc->getName(), jid, nick, data);
}
void Core::Squawk::onAccountChangeRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data)
{
Account* acc = static_cast<Account*>(sender());
emit changeRoomParticipant(acc->getName(), jid, nick, data);
}
void Core::Squawk::onAccountRemoveRoomPresence(const QString& jid, const QString& nick)
{
Account* acc = static_cast<Account*>(sender());
emit removeRoomParticipant(acc->getName(), jid, nick);
}

View File

@ -58,6 +58,9 @@ signals:
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
void changeRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
void removeRoom(const QString& account, const QString jid);
void addRoomParticipant(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
void changeRoomParticipant(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
void removeRoomParticipant(const QString& account, const QString& jid, const QString& name);
public slots:
void start();
@ -105,6 +108,9 @@ private slots:
void onAccountAddRoom(const QString jid, const QMap<QString, QVariant>& data);
void onAccountChangeRoom(const QString jid, const QMap<QString, QVariant>& data);
void onAccountRemoveRoom(const QString jid);
void onAccountAddRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data);
void onAccountChangeRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data);
void onAccountRemoveRoomPresence(const QString& jid, const QString& nick);
};
}

View File

@ -22,6 +22,7 @@ set(squawkUI_SRC
models/presence.cpp
models/group.cpp
models/room.cpp
models/abstractparticipant.cpp
widgets/conversation.cpp
widgets/chat.cpp
widgets/room.cpp

View File

@ -0,0 +1,126 @@
/*
* 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/>.
*/
#include "abstractparticipant.h"
using namespace Models;
Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem):
Item(p_type, data, parentItem),
availability(Shared::offline),
lastActivity(data.value("lastActivity").toDateTime()),
status(data.value("status").toString())
{
QMap<QString, QVariant>::const_iterator itr = data.find("availability");
if (itr != data.end()) {
setAvailability(itr.value().toUInt());
}
}
Models::AbstractParticipant::~AbstractParticipant()
{
}
int Models::AbstractParticipant::columnCount() const
{
return 5;
}
QVariant Models::AbstractParticipant::data(int column) const
{
switch (column) {
case 0:
return Item::data(column);
case 1:
return lastActivity;
case 2:
return availability;
case 3:
return status;
default:
return QVariant();
}
}
Shared::Availability Models::AbstractParticipant::getAvailability() const
{
return availability;
}
QDateTime Models::AbstractParticipant::getLastActivity() const
{
return lastActivity;
}
QString Models::AbstractParticipant::getStatus() const
{
return status;
}
void Models::AbstractParticipant::setAvailability(Shared::Availability p_avail)
{
if (availability != p_avail) {
availability = p_avail;
changed(2);
}
}
void Models::AbstractParticipant::setAvailability(unsigned int avail)
{
if (avail <= Shared::availabilityHighest) {
Shared::Availability state = static_cast<Shared::Availability>(avail);
setAvailability(state);
} else {
qDebug("An attempt to set wrong state to the contact");
}
}
void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time)
{
if (lastActivity != p_time) {
lastActivity = p_time;
changed(1);
}
}
void Models::AbstractParticipant::setStatus(const QString& p_state)
{
if (status != p_state) {
status = p_state;
changed(3);
}
}
QIcon Models::AbstractParticipant::getStatusIcon(bool big) const
{
return Shared::availabilityIcon(availability, big);
}
void Models::AbstractParticipant::update(const QString& key, const QVariant& value)
{
if (key == "name") {
setName(value.toString());
} else if (key == "status") {
setStatus(value.toString());
} else if (key == "availability") {
setAvailability(value.toUInt());
} else if (key == "lastActivity") {
setLastActivity(value.toDateTime());
}
}

View File

@ -0,0 +1,60 @@
/*
* 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 MODELS_ABSTRACTPARTICIPANT_H
#define MODELS_ABSTRACTPARTICIPANT_H
#include "item.h"
#include "../../global.h"
#include <QIcon>
namespace Models {
class AbstractParticipant : public Models::Item
{
Q_OBJECT
public:
explicit AbstractParticipant(Type p_type, const QMap<QString, QVariant> &data, Item *parentItem = 0);
~AbstractParticipant();
virtual int columnCount() const override;
virtual QVariant data(int column) const override;
Shared::Availability getAvailability() const;
void setAvailability(Shared::Availability p_avail);
void setAvailability(unsigned int avail);
QDateTime getLastActivity() const;
void setLastActivity(const QDateTime& p_time);
QString getStatus() const;
void setStatus(const QString& p_state);
virtual QIcon getStatusIcon(bool big = false) const;
virtual void update(const QString& key, const QVariant& value);
protected:
Shared::Availability availability;
QDateTime lastActivity;
QString status;
};
}
#endif // MODELS_ABSTRACTPARTICIPANT_H

View File

@ -1,3 +1,21 @@
/*
* 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/>.
*/
#include "account.h"
#include <QDebug>

View File

@ -1,3 +1,21 @@
/*
* 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 MODELS_ACCOUNT_H
#define MODELS_ACCOUNT_H

View File

@ -1,3 +1,21 @@
/*
* 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/>.
*/
#include "accounts.h"
#include "../../global.h"

View File

@ -1,3 +1,21 @@
/*
* 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 MODELS_ACCOUNTS_H
#define MODELS_ACCOUNTS_H

View File

@ -1,3 +1,21 @@
/*
* 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/>.
*/
#include "contact.h"
#include <QDebug>

View File

@ -1,3 +1,21 @@
/*
* 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 MODELS_CONTACT_H
#define MODELS_CONTACT_H

View File

@ -1,6 +1,6 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2019 Юрий Губич <y.gubich@initi.ru>
* 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

View File

@ -1,6 +1,6 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2019 Юрий Губич <y.gubich@initi.ru>
* 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

View File

@ -1,3 +1,21 @@
/*
* 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/>.
*/
#include "item.h"
#include "account.h"

View File

@ -1,3 +1,21 @@
/*
* 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 MODELS_ITEM_H
#define MODELS_ITEM_H
@ -18,6 +36,7 @@ class Item : public QObject{
contact,
room,
presence,
participant,
root
};

View File

@ -1,5 +1,5 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
@ -19,105 +19,22 @@
#include "presence.h"
Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem):
Item(Item::presence, data, parentItem),
availability(Shared::offline),
lastActivity(data.value("lastActivity").toDateTime()),
status(data.value("status").toString()),
AbstractParticipant(Item::presence, data, parentItem),
messages()
{
QMap<QString, QVariant>::const_iterator itr = data.find("availability");
if (itr != data.end()) {
setAvailability(itr.value().toUInt());
}
}
Models::Presence::~Presence()
{
}
int Models::Presence::columnCount() const
{
return 5;
}
QVariant Models::Presence::data(int column) const
{
switch (column) {
case 0:
return Item::data(column);
case 1:
return lastActivity;
case 2:
return availability;
case 3:
return status;
case 4:
return getMessagesCount();
default:
return QVariant();
}
}
Shared::Availability Models::Presence::getAvailability() const
{
return availability;
}
QDateTime Models::Presence::getLastActivity() const
{
return lastActivity;
}
QString Models::Presence::getStatus() const
{
return status;
}
void Models::Presence::setAvailability(Shared::Availability p_avail)
{
if (availability != p_avail) {
availability = p_avail;
changed(2);
}
}
void Models::Presence::setAvailability(unsigned int avail)
{
if (avail <= Shared::availabilityHighest) {
Shared::Availability state = static_cast<Shared::Availability>(avail);
setAvailability(state);
} else {
qDebug("An attempt to set wrong state to the contact");
}
}
void Models::Presence::setLastActivity(const QDateTime& p_time)
{
if (lastActivity != p_time) {
lastActivity = p_time;
changed(1);
}
}
void Models::Presence::setStatus(const QString& p_state)
{
if (status != p_state) {
status = p_state;
changed(3);
}
}
void Models::Presence::update(const QString& key, const QVariant& value)
{
if (key == "name") {
setName(value.toString());
} else if (key == "status") {
setStatus(value.toString());
} else if (key == "availability") {
setAvailability(value.toUInt());
} else if (key == "lastActivity") {
setLastActivity(value.toDateTime());
return AbstractParticipant::data(column);
}
}
@ -143,9 +60,9 @@ void Models::Presence::dropMessages()
QIcon Models::Presence::getStatusIcon(bool big) const
{
if (getMessagesCount() > 0) {
return Shared::icon("mail-message");
return Shared::icon("mail-message", big);
} else {
return Shared::availabilityIcon(availability, big);
return AbstractParticipant::getStatusIcon();
}
}

View File

@ -1,5 +1,5 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
@ -19,14 +19,14 @@
#ifndef MODELS_PRESENCE_H
#define MODELS_PRESENCE_H
#include "item.h"
#include "abstractparticipant.h"
#include "../../global.h"
#include <QDateTime>
#include <QIcon>
namespace Models {
class Presence : public Models::Item
class Presence : public Models::AbstractParticipant
{
Q_OBJECT
public:
@ -34,21 +34,10 @@ public:
explicit Presence(const QMap<QString, QVariant> &data, Item *parentItem = 0);
~Presence();
virtual int columnCount() const override;
virtual QVariant data(int column) const override;
QVariant data(int column) const override;
Shared::Availability getAvailability() const;
void setAvailability(Shared::Availability p_avail);
void setAvailability(unsigned int avail);
QIcon getStatusIcon(bool big = false) const override;
QDateTime getLastActivity() const;
void setLastActivity(const QDateTime& p_time);
QString getStatus() const;
void setStatus(const QString& p_state);
QIcon getStatusIcon(bool big = false) const;
void update(const QString& key, const QVariant& value);
unsigned int getMessagesCount() const;
void dropMessages();
void addMessage(const Shared::Message& data);
@ -56,9 +45,6 @@ public:
void getMessages(Messages& container) const;
private:
Shared::Availability availability;
QDateTime lastActivity;
QString status;
Messages messages;
};

View File

@ -1,6 +1,6 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2019 Юрий Губич <y.gubich@initi.ru>
* 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

View File

@ -1,6 +1,6 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2019 Юрий Губич <y.gubich@initi.ru>
* 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

View File

@ -1,3 +1,21 @@
/*
* 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/>.
*/
#include "roster.h"
#include <QDebug>
#include <QIcon>

View File

@ -1,3 +1,21 @@
/*
* 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 MODELS_ROSTER_H
#define MODELS_ROSTER_H