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