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

unstable

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