mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 22:58:15 +00:00
fix(presence): refactoring
This commit is contained in:
parent
877da996a1
commit
06ecb0b218
6 changed files with 73 additions and 65 deletions
|
|
@ -23,7 +23,7 @@ HEADERS = \
|
|||
src/components/contacts/ContactsListModel.hpp \
|
||||
src/components/contacts/ContactsListProxyModel.hpp \
|
||||
src/components/notification/Notification.hpp \
|
||||
src/components/presence/PresenceModel.hpp \
|
||||
src/components/presence/Presence.hpp \
|
||||
src/components/settings/AccountSettingsListModel.hpp \
|
||||
src/components/settings/AccountSettingsModel.hpp \
|
||||
src/components/settings/SettingsModel.hpp \
|
||||
|
|
|
|||
|
|
@ -1,3 +1,35 @@
|
|||
#include "ContactModel.hpp"
|
||||
|
||||
// ===================================================================
|
||||
|
||||
QString ContactModel::getUsername () const {
|
||||
return m_username;
|
||||
}
|
||||
|
||||
void ContactModel::setUsername (const QString &username) {
|
||||
m_username = username;
|
||||
}
|
||||
|
||||
QString ContactModel::getAvatar () const {
|
||||
return m_avatar;
|
||||
}
|
||||
|
||||
void ContactModel::setAvatar (const QString &avatar) {
|
||||
m_avatar = avatar;
|
||||
}
|
||||
|
||||
Presence::PresenceStatus ContactModel::getPresenceStatus () const {
|
||||
return m_presence_status;
|
||||
}
|
||||
|
||||
Presence::PresenceLevel ContactModel::getPresenceLevel () const {
|
||||
return Presence::getPresenceLevel(m_presence_status);
|
||||
}
|
||||
|
||||
QStringList ContactModel::getSipAddresses () const {
|
||||
return m_sip_addresses;
|
||||
}
|
||||
|
||||
void ContactModel::setSipAddresses (const QStringList &sip_addresses) {
|
||||
m_sip_addresses = sip_addresses;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "../presence/PresenceModel.hpp"
|
||||
#include "../presence/Presence.hpp"
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
|
@ -27,13 +27,13 @@ class ContactModel : public QObject {
|
|||
);
|
||||
|
||||
Q_PROPERTY(
|
||||
PresenceModel::Presence presence
|
||||
READ getPresence
|
||||
Presence::PresenceStatus presenceStatus
|
||||
READ getPresenceStatus
|
||||
CONSTANT
|
||||
);
|
||||
|
||||
Q_PROPERTY(
|
||||
PresenceModel::PresenceLevel presenceLevel
|
||||
Presence::PresenceLevel presenceLevel
|
||||
READ getPresenceLevel
|
||||
CONSTANT
|
||||
);
|
||||
|
|
@ -50,12 +50,12 @@ public:
|
|||
ContactModel (
|
||||
const QString &username,
|
||||
const QString &avatar,
|
||||
const PresenceModel::Presence &presence,
|
||||
const Presence::PresenceStatus &presence_status,
|
||||
const QStringList &sip_addresses
|
||||
): ContactModel() {
|
||||
): ContactModel () {
|
||||
m_username = username;
|
||||
m_avatar = avatar;
|
||||
m_presence = presence;
|
||||
m_presence_status = presence_status;
|
||||
m_sip_addresses = sip_addresses;
|
||||
}
|
||||
|
||||
|
|
@ -63,41 +63,21 @@ signals:
|
|||
void contactUpdated ();
|
||||
|
||||
private:
|
||||
QString getUsername () const {
|
||||
return m_username;
|
||||
}
|
||||
QString getUsername () const;
|
||||
void setUsername (const QString &username);
|
||||
|
||||
void setUsername (const QString &username) {
|
||||
m_username = username;
|
||||
}
|
||||
QString getAvatar () const;
|
||||
void setAvatar (const QString &avatar);
|
||||
|
||||
QString getAvatar () const {
|
||||
return m_avatar;
|
||||
}
|
||||
Presence::PresenceStatus getPresenceStatus () const;
|
||||
Presence::PresenceLevel getPresenceLevel () const;
|
||||
|
||||
void setAvatar (const QString &avatar) {
|
||||
m_avatar = avatar;
|
||||
}
|
||||
|
||||
PresenceModel::Presence getPresence () const {
|
||||
return m_presence;
|
||||
}
|
||||
|
||||
PresenceModel::PresenceLevel getPresenceLevel () const {
|
||||
return PresenceModel::getPresenceLevel(m_presence);
|
||||
}
|
||||
|
||||
QStringList getSipAddresses () const {
|
||||
return m_sip_addresses;
|
||||
}
|
||||
|
||||
void setSipAddresses (const QStringList &sip_addresses) {
|
||||
m_sip_addresses = sip_addresses;
|
||||
}
|
||||
QStringList getSipAddresses () const;
|
||||
void setSipAddresses (const QStringList &sip_addresses);
|
||||
|
||||
QString m_username;
|
||||
QString m_avatar;
|
||||
PresenceModel::Presence m_presence = PresenceModel::Online;
|
||||
Presence::PresenceStatus m_presence_status = Presence::Offline;
|
||||
QStringList m_sip_addresses;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(parent) {
|
||||
// TMP.
|
||||
m_list << new ContactModel("Toto Roi", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Mary Boreno", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Cecelia Cyler", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Daniel Elliott", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Effie Forton", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Agnes Hurner", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Luke Lemin", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Claire Manning", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Isabella Ahornton", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Mary Boreno", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Aman Than", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel(" abdoul", "", PresenceModel::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Toto Roi", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Mary Boreno", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Cecelia Cyler", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Daniel Elliott", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Effie Forton", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Agnes Hurner", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Luke Lemin", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Claire Manning", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Isabella Ahornton", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Mary Boreno", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel("Aman Than", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
m_list << new ContactModel(" abdoul", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#ifndef PRESENCE_MODEL_H_
|
||||
#define PRESENCE_MODEL_H_
|
||||
#ifndef PRESENCE_H_
|
||||
#define PRESENCE_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class PresenceModel : public QObject {
|
||||
class Presence : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
enum Presence {
|
||||
enum PresenceStatus {
|
||||
Online,
|
||||
BeRightBack,
|
||||
Away,
|
||||
|
|
@ -20,7 +20,7 @@ public:
|
|||
UsingAnotherMessagingService,
|
||||
Offline
|
||||
};
|
||||
Q_ENUM(Presence);
|
||||
Q_ENUM(PresenceStatus);
|
||||
|
||||
enum PresenceLevel {
|
||||
Green,
|
||||
|
|
@ -30,18 +30,18 @@ public:
|
|||
};
|
||||
Q_ENUM(PresenceLevel);
|
||||
|
||||
PresenceModel (QObject *parent = Q_NULLPTR) { }
|
||||
Presence (QObject *parent = Q_NULLPTR): QObject(parent) { }
|
||||
|
||||
static PresenceLevel getPresenceLevel (const Presence &presence) {
|
||||
if (presence == Online)
|
||||
static PresenceLevel getPresenceLevel (const PresenceStatus &presenceStatus) {
|
||||
if (presenceStatus == Online)
|
||||
return Green;
|
||||
if (presence == DoNotDisturb)
|
||||
if (presenceStatus == DoNotDisturb)
|
||||
return Red;
|
||||
if (presence == Offline)
|
||||
if (presenceStatus == Offline)
|
||||
return White;
|
||||
|
||||
return Orange;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // PRESENCE_MODEL_H_
|
||||
#endif // PRESENCE_H_
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
#include <cstdlib>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
|
@ -10,8 +9,6 @@
|
|||
|
||||
#include "app.hpp"
|
||||
#include "components/contacts/ContactsListProxyModel.hpp"
|
||||
|
||||
#include "components/contacts/ContactsListModel.hpp"
|
||||
#include "components/notification/Notification.hpp"
|
||||
|
||||
// ===================================================================
|
||||
|
|
@ -50,7 +47,7 @@ void setTrayIcon (QQmlApplicationEngine &engine) {
|
|||
}
|
||||
|
||||
void registerTypes () {
|
||||
qmlRegisterUncreatableType<PresenceModel>(
|
||||
qmlRegisterUncreatableType<Presence>(
|
||||
"Linphone", 1, 0, "Presence", "Presence is uncreatable"
|
||||
);
|
||||
|
||||
|
|
@ -62,7 +59,6 @@ void addContextProperties (QQmlApplicationEngine &engine) {
|
|||
QQmlContext *context = engine.rootContext();
|
||||
|
||||
context->setContextProperty("Notification", new Notification());
|
||||
context->setContextProperty("ContactsListModel", new ContactsListProxyModel());
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue