forked from blue/squawk
muc joining leaving debug, notification debug, delayed delivery wannabe detection
This commit is contained in:
parent
a51907b810
commit
f5fa45d853
8 changed files with 87 additions and 22 deletions
|
@ -219,11 +219,11 @@ void Models::Contact::setState(Shared::SubscriptionState p_state)
|
|||
QIcon Models::Contact::getStatusIcon(bool big) const
|
||||
{
|
||||
if (getMessagesCount() > 0) {
|
||||
return Shared::icon("mail-message");
|
||||
return Shared::icon("mail-message", big);
|
||||
} else if (state == Shared::both) {
|
||||
return Shared::availabilityIcon(availability, big);;
|
||||
} else {
|
||||
return Shared::subscriptionStateIcon(state);
|
||||
return Shared::subscriptionStateIcon(state, big);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ unsigned int Models::Room::getUnreadMessagesCount() const
|
|||
|
||||
int Models::Room::columnCount() const
|
||||
{
|
||||
return 5;
|
||||
return 6;
|
||||
}
|
||||
|
||||
QString Models::Room::getJid() const
|
||||
|
@ -99,6 +99,8 @@ QVariant Models::Room::data(int column) const
|
|||
return getAutoJoin();
|
||||
case 4:
|
||||
return getNick();
|
||||
case 5:
|
||||
return getMessagesCount();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -153,17 +155,21 @@ void Models::Room::update(const QString& field, const QVariant& value)
|
|||
|
||||
QIcon Models::Room::getStatusIcon(bool big) const
|
||||
{
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connected, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::disconnected, big);
|
||||
}
|
||||
if (messages.size() > 0) {
|
||||
return Shared::icon("mail-message", big);
|
||||
} else {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connecting, big);
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connected, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::disconnected, big);
|
||||
}
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::error, big);
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connecting, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::error, big);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,3 +190,30 @@ QString Models::Room::getStatusText() const
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Models::Room::getMessagesCount() const
|
||||
{
|
||||
return messages.size();
|
||||
}
|
||||
|
||||
void Models::Room::addMessage(const Shared::Message& data)
|
||||
{
|
||||
messages.emplace_back(data);
|
||||
changed(5);
|
||||
}
|
||||
|
||||
void Models::Room::dropMessages()
|
||||
{
|
||||
if (messages.size() > 0) {
|
||||
messages.clear();
|
||||
changed(5);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Room::getMessages(Models::Room::Messages& container) const
|
||||
{
|
||||
for (Messages::const_iterator itr = messages.begin(), end = messages.end(); itr != end; ++itr) {
|
||||
const Shared::Message& msg = *itr;
|
||||
container.push_back(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class Room : public Models::Item
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef std::deque<Shared::Message> Messages;
|
||||
Room(const QString& p_jid, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
~Room();
|
||||
|
||||
|
@ -53,6 +54,11 @@ public:
|
|||
void setNick(const QString& p_nick);
|
||||
|
||||
void update(const QString& field, const QVariant& value);
|
||||
|
||||
void addMessage(const Shared::Message& data);
|
||||
unsigned int getMessagesCount() const;
|
||||
void dropMessages();
|
||||
void getMessages(Messages& container) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -61,7 +67,7 @@ private:
|
|||
bool joined;
|
||||
QString jid;
|
||||
QString nick;
|
||||
std::deque<Shared::Message> messages;
|
||||
Messages messages;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -615,6 +615,11 @@ void Models::Roster::addMessage(const QString& account, const Shared::Message& d
|
|||
for (;cBeg != cEnd; ++cBeg) {
|
||||
cBeg->second->addMessage(data);
|
||||
}
|
||||
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr != rooms.end()) {
|
||||
rItr->second->addMessage(data);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Roster::dropMessages(const QString& account, const QString& jid)
|
||||
|
@ -623,6 +628,11 @@ void Models::Roster::dropMessages(const QString& account, const QString& jid)
|
|||
for (std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(id), cEnd = contacts.upper_bound(id) ;cBeg != cEnd; ++cBeg) {
|
||||
cBeg->second->dropMessages();
|
||||
}
|
||||
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr != rooms.end()) {
|
||||
rItr->second->dropMessages();
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Roster::removeAccount(const QString& account)
|
||||
|
@ -677,12 +687,20 @@ void Models::Roster::removeAccount(const QString& account)
|
|||
|
||||
QString Models::Roster::getContactName(const QString& account, const QString& jid)
|
||||
{
|
||||
std::multimap<ElId, Contact*>::const_iterator cItr = contacts.find({account, jid});
|
||||
ElId id(account, jid);
|
||||
std::multimap<ElId, Contact*>::const_iterator cItr = contacts.find(id);
|
||||
QString name = "";
|
||||
if (cItr == contacts.end()) {
|
||||
qDebug() << "An attempt to get a name of non existing contact " << account << ":" << jid << ", skipping";
|
||||
return "";
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr == rooms.end()) {
|
||||
qDebug() << "An attempt to get a name of non existing contact/room " << account << ":" << jid << ", skipping";
|
||||
} else {
|
||||
name = rItr->second->getName();
|
||||
}
|
||||
} else {
|
||||
name = cItr->second->getContactName();
|
||||
}
|
||||
return cItr->second->getContactName();
|
||||
return name;
|
||||
}
|
||||
|
||||
void Models::Roster::addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue