forked from blue/squawk
beautifull messageList, messages now being sent to full jid
This commit is contained in:
parent
e48444636a
commit
6e9e100188
12 changed files with 160 additions and 28 deletions
|
@ -6,6 +6,7 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
|
|||
login(data.value("login").toString()),
|
||||
password(data.value("password").toString()),
|
||||
server(data.value("server").toString()),
|
||||
resource(data.value("resource").toString()),
|
||||
state(Shared::disconnected),
|
||||
availability(Shared::offline)
|
||||
{
|
||||
|
@ -135,6 +136,8 @@ QVariant Models::Account::data(int column) const
|
|||
return password;
|
||||
case 5:
|
||||
return Shared::availabilityNames[availability];
|
||||
case 6:
|
||||
return resource;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -142,7 +145,7 @@ QVariant Models::Account::data(int column) const
|
|||
|
||||
int Models::Account::columnCount() const
|
||||
{
|
||||
return 6;
|
||||
return 7;
|
||||
}
|
||||
|
||||
void Models::Account::update(const QString& field, const QVariant& value)
|
||||
|
@ -159,5 +162,21 @@ void Models::Account::update(const QString& field, const QVariant& value)
|
|||
setState(value.toUInt());
|
||||
} else if (field == "availability") {
|
||||
setAvailability(value.toUInt());
|
||||
} else if (field == "resource") {
|
||||
setResource(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
QString Models::Account::getResource() const
|
||||
{
|
||||
return resource;
|
||||
}
|
||||
|
||||
void Models::Account::setResource(const QString& p_resource)
|
||||
{
|
||||
if (resource != p_resource) {
|
||||
resource = p_resource;
|
||||
changed(6);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace Models {
|
|||
void setPassword(const QString& p_password);
|
||||
QString getPassword() const;
|
||||
|
||||
void setResource(const QString& p_resource);
|
||||
QString getResource() const;
|
||||
|
||||
void setAvailability(Shared::Availability p_avail);
|
||||
void setAvailability(unsigned int p_avail);
|
||||
Shared::Availability getAvailability() const;
|
||||
|
@ -40,6 +43,7 @@ namespace Models {
|
|||
QString login;
|
||||
QString password;
|
||||
QString server;
|
||||
QString resource;
|
||||
Shared::ConnectionState state;
|
||||
Shared::Availability availability;
|
||||
};
|
||||
|
|
|
@ -206,16 +206,12 @@ QIcon Models::Contact::getStatusIcon() const
|
|||
|
||||
QString Models::Contact::getAccountName() const
|
||||
{
|
||||
const Item* p = this;
|
||||
do {
|
||||
p = p->parentItemConst();
|
||||
} while (p != 0 && p->type != Item::account);
|
||||
|
||||
if (p == 0) {
|
||||
const Account* acc = getParentAccount();
|
||||
if (acc == 0) {
|
||||
qDebug() << "An attempt to request account name of the contact " << jid << " but the parent account wasn't found, returning empty string";
|
||||
return "";
|
||||
}
|
||||
return p->getName();
|
||||
return acc->getName();
|
||||
}
|
||||
|
||||
void Models::Contact::addMessage(const Shared::Message& data)
|
||||
|
@ -264,16 +260,31 @@ void Models::Contact::getMessages(Models::Contact::Messages& container) const
|
|||
}
|
||||
|
||||
QString Models::Contact::getAccountJid() const
|
||||
{
|
||||
const Account* acc = getParentAccount();
|
||||
if (acc == 0) {
|
||||
qDebug() << "An attempt to request account jid of the contact " << jid << " but the parent account wasn't found, returning empty string";
|
||||
return "";
|
||||
}
|
||||
return acc->getLogin() + "@" + acc->getServer();
|
||||
}
|
||||
|
||||
QString Models::Contact::getAccountResource() const
|
||||
{
|
||||
const Account* acc = getParentAccount();
|
||||
if (acc == 0) {
|
||||
qDebug() << "An attempt to request account resource of the contact " << jid << " but the parent account wasn't found, returning empty string";
|
||||
return "";
|
||||
}
|
||||
return acc->getResource();
|
||||
}
|
||||
|
||||
const Models::Account * Models::Contact::getParentAccount() const
|
||||
{
|
||||
const Item* p = this;
|
||||
do {
|
||||
p = p->parentItemConst();
|
||||
} while (p != 0 && p->type != Item::account);
|
||||
|
||||
if (p == 0) {
|
||||
qDebug() << "An attempt to request account jid of the contact " << jid << " but the parent account wasn't found, returning empty string";
|
||||
return "";
|
||||
}
|
||||
const Account* acc = static_cast<const Account*>(p);
|
||||
return acc->getLogin() + "@" + acc->getServer();
|
||||
return static_cast<const Account*>(p);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
#include <deque>
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
||||
class Account;
|
||||
class Contact : public Item
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -34,6 +35,7 @@ public:
|
|||
void appendChild(Models::Item * child) override;
|
||||
QString getAccountName() const;
|
||||
QString getAccountJid() const;
|
||||
QString getAccountResource() const;
|
||||
|
||||
void addMessage(const Shared::Message& data);
|
||||
unsigned int getMessagesCount() const;
|
||||
|
@ -42,6 +44,7 @@ public:
|
|||
|
||||
protected:
|
||||
void _removeChild(int index) override;
|
||||
const Account* getParentAccount() const;
|
||||
|
||||
protected slots:
|
||||
void refresh();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue