Commit 63174734 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(components/contacts/ContactsListModel): `mapSipAddressToContact` working

parent e6c45503
linphone @ 797eea2a
Subproject commit 8544d5033e56d755c4acedc402983d1c89d8e53f
Subproject commit 797eea2a56bc4bfaa0df76884b7f4e5228e80de8
......@@ -18,33 +18,39 @@
// ===================================================================
void qmlLogger (QtMsgType type, const QMessageLogContext &context, const QString &msg) {
void logger (QtMsgType type, const QMessageLogContext &context, const QString &msg) {
QByteArray local_msg = msg.toLocal8Bit();
QByteArray date_time = QDateTime::currentDateTime()
.toString("HH:mm:ss").toLocal8Bit();
const char *context_file = context.file ?: "cpp";
const char *context_file = "cpp";
int context_line = 0;
if (context.file && !context.function) {
context_file = context.file;
context_line = context.line;
}
switch (type) {
case QtDebugMsg:
fprintf(stderr, GREEN "[%s][Debug]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context.line, local_msg.constData());
date_time.constData(), context_file, context_line, local_msg.constData());
break;
case QtInfoMsg:
fprintf(stderr, BLUE "[%s][Info]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context.line, local_msg.constData());
date_time.constData(), context_file, context_line, local_msg.constData());
break;
case QtWarningMsg:
fprintf(stderr, RED "[%s][Warning]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context.line, local_msg.constData());
date_time.constData(), context_file, context_line, local_msg.constData());
break;
case QtCriticalMsg:
fprintf(stderr, RED "[%s][Critical]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context.line, local_msg.constData());
date_time.constData(), context_file, context_line, local_msg.constData());
break;
case QtFatalMsg:
fprintf(stderr, RED "[%s][Fatal]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context.line, local_msg.constData());
date_time.constData(), context_file, context_line, local_msg.constData());
abort();
}
}
......@@ -3,6 +3,6 @@
#include <QtGlobal>
void qmlLogger (QtMsgType type, const QMessageLogContext &context, const QString &msg);
void logger (QtMsgType type, const QMessageLogContext &context, const QString &msg);
#endif // LOGGER_H_
#include <QtDebug>
#include "../core/CoreManager.hpp"
#include "ContactsListProxyModel.hpp"
......@@ -38,10 +40,14 @@ QVariant ContactsListModel::data (const QModelIndex &index, int role) const {
// -------------------------------------------------------------------
ContactModel *ContactsListModel::mapSipAddressToContact (const QString &sipAddress) {
return m_friend_to_contact[
ContactModel *ContactsListModel::mapSipAddressToContact (const QString &sipAddress) const {
ContactModel *contact = m_friend_to_contact[
CoreManager::getInstance()->getCore()->getFriendsLists().front()->findFriendByUri(
sipAddress.toStdString()
).get()
];
qInfo() << "Map sip address to contact:" << sipAddress << "->" << contact;
return contact;
}
......@@ -23,11 +23,11 @@ public:
QVariant data (const QModelIndex &index, int role) const;
public slots:
ContactModel *mapSipAddressToContact (const QString &sipAddress);
ContactModel *mapSipAddressToContact (const QString &sipAddress) const;
private:
QList<ContactModel *> m_list;
QHash<linphone::Friend *, ContactModel* > m_friend_to_contact;
QHash<const linphone::Friend *, ContactModel* > m_friend_to_contact;
};
#endif // CONTACTS_LIST_MODEL_H
......@@ -4,7 +4,7 @@
// ===================================================================
int main (int argc, char *argv[]) {
qInstallMessageHandler(qmlLogger);
qInstallMessageHandler(logger);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
App::init(argc, argv);
......
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