muc participant avatars
This commit is contained in:
parent
efc90e18c3
commit
55703c2007
15 changed files with 506 additions and 221 deletions
|
@ -34,6 +34,15 @@ Models::Participant::Participant(const QMap<QString, QVariant>& data, Models::It
|
|||
if (itr != data.end()) {
|
||||
setRole(itr.value().toUInt());
|
||||
}
|
||||
|
||||
itr = data.find("avatarState");
|
||||
if (itr != data.end()) {
|
||||
setAvatarState(itr.value().toUInt());
|
||||
}
|
||||
itr = data.find("avatarPath");
|
||||
if (itr != data.end()) {
|
||||
setAvatarPath(itr.value().toString());
|
||||
}
|
||||
}
|
||||
|
||||
Models::Participant::~Participant()
|
||||
|
@ -42,7 +51,7 @@ Models::Participant::~Participant()
|
|||
|
||||
int Models::Participant::columnCount() const
|
||||
{
|
||||
return 6;
|
||||
return 8;
|
||||
}
|
||||
|
||||
QVariant Models::Participant::data(int column) const
|
||||
|
@ -52,6 +61,10 @@ QVariant Models::Participant::data(int column) const
|
|||
return static_cast<uint8_t>(affiliation);
|
||||
case 5:
|
||||
return static_cast<uint8_t>(role);
|
||||
case 6:
|
||||
return static_cast<quint8>(getAvatarState());
|
||||
case 7:
|
||||
return getAvatarPath();
|
||||
default:
|
||||
return AbstractParticipant::data(column);
|
||||
}
|
||||
|
@ -63,6 +76,10 @@ void Models::Participant::update(const QString& key, const QVariant& value)
|
|||
setAffiliation(value.toUInt());
|
||||
} else if (key == "role") {
|
||||
setRole(value.toUInt());
|
||||
} else if (key == "avatarState") {
|
||||
setAvatarState(value.toUInt());
|
||||
} else if (key == "avatarPath") {
|
||||
setAvatarPath(value.toString());
|
||||
} else {
|
||||
AbstractParticipant::update(key, value);
|
||||
}
|
||||
|
@ -113,3 +130,39 @@ void Models::Participant::setRole(unsigned int p_role)
|
|||
qDebug() << "An attempt to set wrong role" << p_role << "to the room participant" << name;
|
||||
}
|
||||
}
|
||||
|
||||
QString Models::Participant::getAvatarPath() const
|
||||
{
|
||||
return avatarPath;
|
||||
}
|
||||
|
||||
Shared::Avatar Models::Participant::getAvatarState() const
|
||||
{
|
||||
return avatarState;
|
||||
}
|
||||
|
||||
void Models::Participant::setAvatarPath(const QString& path)
|
||||
{
|
||||
if (avatarPath != path) {
|
||||
avatarPath = path;
|
||||
changed(7);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Participant::setAvatarState(Shared::Avatar p_state)
|
||||
{
|
||||
if (avatarState != p_state) {
|
||||
avatarState = p_state;
|
||||
changed(6);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Participant::setAvatarState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= static_cast<quint8>(Shared::Avatar::valid)) {
|
||||
Shared::Avatar state = static_cast<Shared::Avatar>(p_state);
|
||||
setAvatarState(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid avatar state" << p_state << "to the room participant" << name << ", skipping";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,20 @@ public:
|
|||
Shared::Role getRole() const;
|
||||
void setRole(Shared::Role p_role);
|
||||
void setRole(unsigned int role);
|
||||
|
||||
Shared::Avatar getAvatarState() const;
|
||||
QString getAvatarPath() const;
|
||||
|
||||
protected:
|
||||
void setAvatarState(Shared::Avatar p_state);
|
||||
void setAvatarState(unsigned int p_state);
|
||||
void setAvatarPath(const QString& path);
|
||||
|
||||
private:
|
||||
Shared::Affiliation affiliation;
|
||||
Shared::Role role;
|
||||
Shared::Avatar avatarState;
|
||||
QString avatarPath;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
case Qt::DisplayRole:
|
||||
{
|
||||
if (index.column() != 0) {
|
||||
result = "";
|
||||
break;
|
||||
}
|
||||
switch (item->type) {
|
||||
|
@ -139,11 +140,20 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
}
|
||||
break;
|
||||
case Item::participant: {
|
||||
quint8 col = index.column();
|
||||
Participant* p = static_cast<Participant*>(item);
|
||||
if (col == 0) {
|
||||
result = p->getStatusIcon(false);
|
||||
} else if (col == 1) {
|
||||
QString path = p->getAvatarPath();
|
||||
if (path.size() > 0) {
|
||||
result = QIcon(path);
|
||||
}
|
||||
}
|
||||
if (index.column() != 0) {
|
||||
break;
|
||||
}
|
||||
Participant* p = static_cast<Participant*>(item);
|
||||
result = p->getStatusIcon(false);
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -213,7 +213,6 @@ void Squawk::addContact(const QString& account, const QString& jid, const QStrin
|
|||
settings.beginGroup(account);
|
||||
if (settings.value("expanded", false).toBool()) {
|
||||
QModelIndex ind = rosterModel.getAccountIndex(account);
|
||||
qDebug() << "expanding account " << ind.data();
|
||||
m_ui->roster->expand(ind);
|
||||
}
|
||||
settings.endGroup();
|
||||
|
|
|
@ -23,7 +23,16 @@
|
|||
#include <QRegularExpression>
|
||||
#include "message.h"
|
||||
|
||||
const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])((?:https?|ftp)://\\S+)"); //finds all hypertext references which are not wrapped in a or img tags
|
||||
const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])("
|
||||
"(?:https?|ftp):\\/\\/"
|
||||
"\\w+"
|
||||
"(?:"
|
||||
"[\\w\\.\\/\\:\\;\\?\\&\\=\\@\\%\\#\\+]?"
|
||||
"(?:"
|
||||
"\\([\\w\\.\\/\\:\\;\\?\\&\\=\\@\\%\\#\\+]+\\)"
|
||||
")?"
|
||||
")*"
|
||||
")");
|
||||
const QRegularExpression imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
||||
|
||||
Message::Message(const Shared::Message& source, bool outgoing, const QString& p_sender, const QString& avatarPath, QWidget* parent):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue