2019-04-05 15:12:59 +00:00
|
|
|
#ifndef MODELS_CONTACT_H
|
|
|
|
#define MODELS_CONTACT_H
|
|
|
|
|
|
|
|
#include "item.h"
|
2019-04-07 14:02:41 +00:00
|
|
|
#include "presence.h"
|
|
|
|
#include "../../global.h"
|
|
|
|
#include <QMap>
|
2019-04-07 20:14:15 +00:00
|
|
|
#include <QIcon>
|
2019-04-09 22:01:25 +00:00
|
|
|
#include <deque>
|
2019-04-05 15:12:59 +00:00
|
|
|
|
|
|
|
namespace Models {
|
2019-04-12 05:51:36 +00:00
|
|
|
|
|
|
|
class Account;
|
2019-04-05 15:12:59 +00:00
|
|
|
class Contact : public Item
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-11 14:58:59 +00:00
|
|
|
typedef std::deque<Shared::Message> Messages;
|
2019-04-07 20:14:15 +00:00
|
|
|
Contact(const QString& p_jid ,const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
2019-04-05 15:12:59 +00:00
|
|
|
~Contact();
|
|
|
|
|
|
|
|
QString getJid() const;
|
2019-04-07 20:14:15 +00:00
|
|
|
Shared::Availability getAvailability() const;
|
|
|
|
Shared::SubscriptionState getState() const;
|
|
|
|
QIcon getStatusIcon() const;
|
2019-04-05 15:12:59 +00:00
|
|
|
|
|
|
|
int columnCount() const override;
|
|
|
|
QVariant data(int column) const override;
|
|
|
|
|
|
|
|
void update(const QString& field, const QVariant& value);
|
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
void addPresence(const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void removePresence(const QString& name);
|
|
|
|
|
|
|
|
void appendChild(Models::Item * child) override;
|
2019-04-09 15:04:08 +00:00
|
|
|
QString getAccountName() const;
|
2019-04-10 20:53:42 +00:00
|
|
|
QString getAccountJid() const;
|
2019-04-12 05:51:36 +00:00
|
|
|
QString getAccountResource() const;
|
2019-06-18 15:08:03 +00:00
|
|
|
QString getContactName() const;
|
2019-04-07 14:02:41 +00:00
|
|
|
|
2019-04-11 14:58:59 +00:00
|
|
|
void addMessage(const Shared::Message& data);
|
2019-04-09 22:01:25 +00:00
|
|
|
unsigned int getMessagesCount() const;
|
|
|
|
void dropMessages();
|
2019-04-10 20:53:42 +00:00
|
|
|
void getMessages(Messages& container) const;
|
2019-04-09 22:01:25 +00:00
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
protected:
|
|
|
|
void _removeChild(int index) override;
|
2019-04-12 05:51:36 +00:00
|
|
|
const Account* getParentAccount() const;
|
2019-04-07 14:02:41 +00:00
|
|
|
|
2019-04-09 15:04:08 +00:00
|
|
|
protected slots:
|
|
|
|
void refresh();
|
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
protected:
|
2019-04-07 20:14:15 +00:00
|
|
|
void setAvailability(Shared::Availability p_state);
|
|
|
|
void setAvailability(unsigned int p_state);
|
|
|
|
void setState(Shared::SubscriptionState p_state);
|
|
|
|
void setState(unsigned int p_state);
|
2019-04-07 14:02:41 +00:00
|
|
|
void setJid(const QString p_jid);
|
|
|
|
|
2019-04-05 15:12:59 +00:00
|
|
|
private:
|
|
|
|
QString jid;
|
2019-04-07 20:14:15 +00:00
|
|
|
Shared::Availability availability;
|
|
|
|
Shared::SubscriptionState state;
|
2019-04-07 14:02:41 +00:00
|
|
|
QMap<QString, Presence*> presences;
|
2019-04-09 22:01:25 +00:00
|
|
|
Messages messages;
|
|
|
|
unsigned int childMessages;
|
2019-04-05 15:12:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MODELS_CONTACT_H
|