forked from blue/squawk
icon and tooltip information in participants, saving bookmarks, subscription and unsubscription, deletion of MUCs
This commit is contained in:
parent
5547d78608
commit
5f8d38bd9a
19 changed files with 216 additions and 9 deletions
|
@ -26,6 +26,7 @@ Models::Room::Room(const QString& p_jid, const QMap<QString, QVariant>& data, Mo
|
|||
joined(false),
|
||||
jid(p_jid),
|
||||
nick(""),
|
||||
subject(""),
|
||||
messages(),
|
||||
participants()
|
||||
{
|
||||
|
@ -43,6 +44,11 @@ Models::Room::Room(const QString& p_jid, const QMap<QString, QVariant>& data, Mo
|
|||
if (itr != data.end()) {
|
||||
setNick(itr.value().toString());
|
||||
}
|
||||
|
||||
itr = data.find("subject");
|
||||
if (itr != data.end()) {
|
||||
setSubject(itr.value().toString());
|
||||
}
|
||||
}
|
||||
|
||||
Models::Room::~Room()
|
||||
|
@ -56,7 +62,7 @@ unsigned int Models::Room::getUnreadMessagesCount() const
|
|||
|
||||
int Models::Room::columnCount() const
|
||||
{
|
||||
return 6;
|
||||
return 7;
|
||||
}
|
||||
|
||||
QString Models::Room::getJid() const
|
||||
|
@ -103,6 +109,8 @@ QVariant Models::Room::data(int column) const
|
|||
return getNick();
|
||||
case 5:
|
||||
return getMessagesCount();
|
||||
case 6:
|
||||
return getSubject();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -155,6 +163,8 @@ void Models::Room::update(const QString& field, const QVariant& value)
|
|||
setAutoJoin(value.toBool());
|
||||
} else if (field == "nick") {
|
||||
setNick(value.toString());
|
||||
} else if (field == "subject") {
|
||||
setSubject(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,3 +296,16 @@ void Models::Room::handleParticipantUpdate(std::map<QString, Participant*>::cons
|
|||
participants.insert(std::make_pair(part->getName(), part));
|
||||
}
|
||||
}
|
||||
|
||||
QString Models::Room::getSubject() const
|
||||
{
|
||||
return subject;
|
||||
}
|
||||
|
||||
void Models::Room::setSubject(const QString& sub)
|
||||
{
|
||||
if (sub != subject) {
|
||||
subject = sub;
|
||||
changed(6);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
QString getJid() const;
|
||||
QString getNick() const;
|
||||
QString getRoomName() const;
|
||||
QString getSubject() const;
|
||||
|
||||
QIcon getStatusIcon(bool big = false) const;
|
||||
QString getStatusText() const;
|
||||
|
@ -53,6 +54,7 @@ public:
|
|||
void setAutoJoin(bool p_autoJoin);
|
||||
void setJid(const QString& p_jid);
|
||||
void setNick(const QString& p_nick);
|
||||
void setSubject(const QString& sub);
|
||||
|
||||
void update(const QString& field, const QVariant& value);
|
||||
|
||||
|
@ -75,6 +77,7 @@ private:
|
|||
bool joined;
|
||||
QString jid;
|
||||
QString nick;
|
||||
QString subject;
|
||||
Messages messages;
|
||||
std::map<QString, Participant*> participants;
|
||||
|
||||
|
|
|
@ -112,6 +112,11 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
result = room->getStatusIcon(false);
|
||||
}
|
||||
break;
|
||||
case Item::participant: {
|
||||
Participant* p = static_cast<Participant*>(item);
|
||||
result = p->getStatusIcon(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -148,6 +153,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
if (mc > 0) {
|
||||
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
|
||||
}
|
||||
str += "Jabber ID: " + contact->getJid();
|
||||
Shared::SubscriptionState ss = contact->getState();
|
||||
if (ss == Shared::both) {
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
|
@ -180,6 +186,22 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
str += "\nStatus: " + s;
|
||||
}
|
||||
|
||||
result = str;
|
||||
}
|
||||
break;
|
||||
case Item::participant: {
|
||||
Participant* p = static_cast<Participant*>(item);
|
||||
QString str("");
|
||||
Shared::Availability av = p->getAvailability();
|
||||
str += "Availability: " + Shared::availabilityNames[av] + "\n";
|
||||
QString s = p->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += "Status: " + s + "\n";
|
||||
}
|
||||
|
||||
str += "Affiliation: " + Shared::affiliationNames[static_cast<unsigned int>(p->getAffiliation())] + "\n";
|
||||
str += "Role: " + Shared::roleNames[static_cast<unsigned int>(p->getRole())];
|
||||
|
||||
result = str;
|
||||
}
|
||||
break;
|
||||
|
@ -203,6 +225,9 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
str += QString("New messages: ") + std::to_string(count).c_str() + "\n";
|
||||
}
|
||||
str += QString("Subscription: ") + rm->getStatusText();
|
||||
if (rm->getJoined()) {
|
||||
str += QString("\nMembers: ") + std::to_string(rm->childCount()).c_str();
|
||||
}
|
||||
result = str;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -455,6 +455,41 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
emit removeContactRequest(cnt->getAccountName(), cnt->getJid());
|
||||
});
|
||||
|
||||
}
|
||||
break;
|
||||
case Models::Item::room: {
|
||||
Models::Room* room = static_cast<Models::Room*>(item);
|
||||
hasMenu = true;
|
||||
|
||||
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), "Open conversation");
|
||||
connect(dialog, &QAction::triggered, [this, index]() {
|
||||
onRosterItemDoubleClicked(index);
|
||||
});
|
||||
|
||||
|
||||
Models::Roster::ElId id(room->getAccountName(), room->getJid());
|
||||
if (room->getAutoJoin()) {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), "Unsubscribe");
|
||||
connect(unsub, &QAction::triggered, [this, id]() {
|
||||
emit setRoomAutoJoin(id.account, id.name, false);
|
||||
if (conversations.find(id) == conversations.end()) { //to leave the room if it's not opened in a conversation window
|
||||
emit setRoomJoined(id.account, id.name, false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-subscribe"), "Subscribe");
|
||||
connect(unsub, &QAction::triggered, [this, id]() {
|
||||
emit setRoomAutoJoin(id.account, id.name, true);
|
||||
if (conversations.find(id) == conversations.end()) { //to join the room if it's not already joined
|
||||
emit setRoomJoined(id.account, id.name, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), "Remove");
|
||||
connect(remove, &QAction::triggered, [this, id]() {
|
||||
emit removeRoomRequest(id.account, id.name);
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -62,6 +62,7 @@ signals:
|
|||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||
void removeRoomRequest(const QString& account, const QString& jid);
|
||||
|
||||
public slots:
|
||||
void newAccount(const QMap<QString, QVariant>& account);
|
||||
|
|
|
@ -66,11 +66,6 @@ void Chat::updateState()
|
|||
statusIcon->setToolTip(Shared::availabilityNames[av]);
|
||||
}
|
||||
|
||||
void Chat::setStatus(const QString& status)
|
||||
{
|
||||
statusLabel->setText(status);
|
||||
}
|
||||
|
||||
void Chat::handleSendMessage(const QString& text)
|
||||
{
|
||||
Shared::Message msg(Shared::Message::chat);
|
||||
|
|
|
@ -37,14 +37,13 @@ public:
|
|||
|
||||
protected slots:
|
||||
void onContactChanged(Models::Item* item, int row, int col);
|
||||
void handleSendMessage(const QString & text) override;
|
||||
|
||||
protected:
|
||||
void setName(const QString & name) override;
|
||||
void handleSendMessage(const QString & text) override;
|
||||
|
||||
private:
|
||||
void updateState();
|
||||
void setStatus(const QString& status);
|
||||
|
||||
private:
|
||||
Models::Contact* contact;
|
||||
|
|
|
@ -254,3 +254,8 @@ void Conversation::onFileSelected()
|
|||
|
||||
d->deleteLater();
|
||||
}
|
||||
|
||||
void Conversation::setStatus(const QString& status)
|
||||
{
|
||||
statusLabel->setText(status);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
|||
virtual void setName(const QString& name);
|
||||
void applyVisualEffects();
|
||||
virtual void handleSendMessage(const QString& text) = 0;
|
||||
void setStatus(const QString& status);
|
||||
|
||||
protected slots:
|
||||
void onEnterPressed();
|
||||
|
|
|
@ -24,6 +24,9 @@ Room::Room(Models::Room* p_room, QWidget* parent):
|
|||
{
|
||||
setName(p_room->getName());
|
||||
line->setMyName(room->getNick());
|
||||
setStatus(room->getSubject());
|
||||
|
||||
connect(room, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onRoomChanged(Models::Item*, int, int)));
|
||||
}
|
||||
|
||||
Room::~Room()
|
||||
|
@ -48,3 +51,17 @@ bool Room::autoJoined() const
|
|||
{
|
||||
return room->getAutoJoin();
|
||||
}
|
||||
|
||||
void Room::onRoomChanged(Models::Item* item, int row, int col)
|
||||
{
|
||||
if (item == room) {
|
||||
switch (col) {
|
||||
case 0:
|
||||
setName(room->getRoomName());
|
||||
break;
|
||||
case 6:
|
||||
setStatus(room->getSubject());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ public:
|
|||
|
||||
bool autoJoined() const;
|
||||
|
||||
protected slots:
|
||||
void onRoomChanged(Models::Item* item, int row, int col);
|
||||
|
||||
protected:
|
||||
void handleSendMessage(const QString & text) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue