Commit 9cb733a2 authored by Ronan Abhamon's avatar Ronan Abhamon

unstable

parent 558a55de
......@@ -58,6 +58,7 @@ set(HEADERS
src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp
src/components/timeline/TimelineModel.hpp
src/utils.hpp
)
set(QRC_RESOURCES
......@@ -136,5 +137,7 @@ qt5_add_resources(RESOURCES ${QRC_RESOURCES})
add_executable(${LINPHONE_EXEC} ${SOURCES} ${HEADERS} ${RESOURCES})
add_dependencies(${LINPHONE_EXEC} update_translations)
add_dependencies(update_translations check_qml)
target_include_directories(${LINPHONE_EXEC} PRIVATE "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/include/")
target_link_libraries(${LINPHONE_EXEC} ${LIBS})
......@@ -3,6 +3,8 @@
#include <string>
// ===================================================================
namespace Database {
// Returns the databases paths.
// If files cannot be created or are unavailable, a empty string is returned.
......
......@@ -25,11 +25,3 @@ Presence::PresenceStatus ContactModel::getPresenceStatus () const {
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;
}
......@@ -2,9 +2,9 @@
#define CONTACT_MODEL_H
#include <QObject>
#include <linphone++/linphone.hh>
#include "../../utils.hpp"
#include "../presence/Presence.hpp"
// ===================================================================
......@@ -41,16 +41,14 @@ class ContactModel : public QObject {
);
Q_PROPERTY(
QStringList sipAddresses
READ getSipAddresses
WRITE setSipAddresses
QString sipAddress
READ getSipAddress
NOTIFY contactUpdated
);
public:
ContactModel (std::shared_ptr<linphone::Friend> linphone_friend) {
m_linphone_friend = linphone_friend;
m_sip_addresses << "jiiji";
}
signals:
......@@ -66,13 +64,18 @@ private:
Presence::PresenceStatus getPresenceStatus () const;
Presence::PresenceLevel getPresenceLevel () const;
QStringList getSipAddresses () const;
void setSipAddresses (const QStringList &sip_addresses);
QString getSipAddress () const {
// FIXME.
return "toto@linphone.org";
return Utils::linphoneStringToQString(
m_linphone_friend->getAddress()->asString()
);
}
QString m_username;
QString m_avatar;
Presence::PresenceStatus m_presence_status = Presence::Offline;
QStringList m_sip_addresses;
std::shared_ptr<linphone::Friend> m_linphone_friend;
};
......
......@@ -8,6 +8,7 @@
ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(parent) {
std::shared_ptr<linphone::Core> core(CoreManager::getInstance()->getCore());
// Init contacts with linphone friends list.
for (auto friend_ : core->getFriendsLists().front()->getFriends()) {
m_list << new ContactModel(friend_);
}
......
......@@ -51,9 +51,7 @@ bool ContactsListProxyModel::filterAcceptsRow (int source_row, const QModelIndex
index.data()
);
int weight = m_weights[contact] = static_cast<int>(
computeContactWeight(*contact)
);
int weight = m_weights[contact] = computeContactWeight(*contact);
return weight > 0 && (
!m_use_connected_filter ||
......@@ -117,14 +115,23 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact)
float weight = computeStringWeight(contact.m_username, USERNAME_WEIGHT);
// It exists at least one sip address.
const QStringList &addresses = contact.m_sip_addresses;
weight += computeStringWeight(addresses[0], MAIN_SIP_ADDRESS_WEIGHT);
const std::list<std::shared_ptr<linphone::Address> > addresses =
contact.m_linphone_friend->getAddresses();
// FIXME.
return 0;
weight += computeStringWeight(contact.getSipAddress(), MAIN_SIP_ADDRESS_WEIGHT);
// Compute for other addresses.
int size = addresses.size();
return 0;
if (size > 1)
for (auto it = ++addresses.constBegin(); it != addresses.constEnd(); ++it)
weight += computeStringWeight(*it, OTHER_SIP_ADDRESSES_WEIGHT / size);
for (auto it = ++addresses.cbegin(); it != addresses.cend(); ++it)
weight += computeStringWeight(
Utils::linphoneStringToQString((*it)->asString()),
OTHER_SIP_ADDRESSES_WEIGHT / size
);
return weight;
}
......
......@@ -40,7 +40,7 @@ Rectangle {
Layout.fillHeight: true
Layout.fillWidth: true
sipAddress: contact.sipAddresses[0]
sipAddress: contact.sipAddress
username: avatar.username
}
......
......@@ -40,7 +40,7 @@ ColumnLayout {
ContactDescription {
Layout.fillHeight: true
Layout.fillWidth: true
sipAddress: contact.sipAddresses[0]
sipAddress: contact.sipAddress
sipAddressColor: ConversationStyle.bar.description.sipAddressColor
username: contact.username
usernameColor: ConversationStyle.bar.description.usernameColor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment