From e69d7fcdf35ab6a926b4b86aa217d8b83e93805d Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 20 Dec 2016 09:39:17 +0100 Subject: [PATCH] feat(app): add `sip-addresses`/* components --- tests/CMakeLists.txt | 4 ++ .../sip-addresses/SipAddressModel.cpp | 3 ++ .../sip-addresses/SipAddressModel.hpp | 14 ++++++ .../sip-addresses/SipAddressesModel.cpp | 3 ++ .../sip-addresses/SipAddressesModel.hpp | 14 ++++++ .../src/components/timeline/TimelineModel.cpp | 50 +++++++++---------- .../src/components/timeline/TimelineModel.hpp | 4 +- 7 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 tests/src/components/sip-addresses/SipAddressModel.cpp create mode 100644 tests/src/components/sip-addresses/SipAddressModel.hpp create mode 100644 tests/src/components/sip-addresses/SipAddressesModel.cpp create mode 100644 tests/src/components/sip-addresses/SipAddressesModel.hpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 82e42802d..bc151ce7e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -66,6 +66,8 @@ set(SOURCES src/components/notifier/Notifier.cpp src/components/settings/AccountSettingsModel.cpp src/components/settings/SettingsModel.cpp + src/components/sip-addresses/SipAddressesModel.cpp + src/components/sip-addresses/SipAddressModel.cpp src/components/smart-search-bar/SmartSearchBarModel.cpp src/components/smart-search-bar/SmartSearchBarProxyModel.cpp src/components/timeline/TimelineModel.cpp @@ -90,6 +92,8 @@ set(HEADERS src/components/presence/Presence.hpp src/components/settings/AccountSettingsModel.hpp src/components/settings/SettingsModel.hpp + src/components/sip-addresses/SipAddressesModel.hpp + src/components/sip-addresses/SipAddressModel.hpp src/components/smart-search-bar/SmartSearchBarModel.hpp src/components/smart-search-bar/SmartSearchBarProxyModel.hpp src/components/timeline/TimelineModel.hpp diff --git a/tests/src/components/sip-addresses/SipAddressModel.cpp b/tests/src/components/sip-addresses/SipAddressModel.cpp new file mode 100644 index 000000000..b267f0ce3 --- /dev/null +++ b/tests/src/components/sip-addresses/SipAddressModel.cpp @@ -0,0 +1,3 @@ +#include "SipAddressModel.hpp" + +// ============================================================================= diff --git a/tests/src/components/sip-addresses/SipAddressModel.hpp b/tests/src/components/sip-addresses/SipAddressModel.hpp new file mode 100644 index 000000000..67270fbd2 --- /dev/null +++ b/tests/src/components/sip-addresses/SipAddressModel.hpp @@ -0,0 +1,14 @@ +#ifndef SIP_ADDRESS_MODEL_H_ +#define SIP_ADDRESS_MODEL_H_ + +#include + +// ============================================================================= + +class SipAddressModel : public QObject { + Q_OBJECT; + +public: +}; + +#endif // SIP_ADDRESS_H_ diff --git a/tests/src/components/sip-addresses/SipAddressesModel.cpp b/tests/src/components/sip-addresses/SipAddressesModel.cpp new file mode 100644 index 000000000..528aabc05 --- /dev/null +++ b/tests/src/components/sip-addresses/SipAddressesModel.cpp @@ -0,0 +1,3 @@ +#include "SipAddressesModel.hpp" + +// ============================================================================= diff --git a/tests/src/components/sip-addresses/SipAddressesModel.hpp b/tests/src/components/sip-addresses/SipAddressesModel.hpp new file mode 100644 index 000000000..3c12c7f7d --- /dev/null +++ b/tests/src/components/sip-addresses/SipAddressesModel.hpp @@ -0,0 +1,14 @@ +#ifndef SIP_ADDRESSES_MODEL_H_ +#define SIP_ADDRESSES_MODEL_H_ + +#include + +// ============================================================================= + +class SipAddresses : public QAbstractListModel { + Q_OBJECT; + +public: +}; + +#endif // SIP_ADDRESSES_MODEL_H_ diff --git a/tests/src/components/timeline/TimelineModel.cpp b/tests/src/components/timeline/TimelineModel.cpp index c30eb43fa..5a34f3c09 100644 --- a/tests/src/components/timeline/TimelineModel.cpp +++ b/tests/src/components/timeline/TimelineModel.cpp @@ -1,8 +1,8 @@ #include +#include #include #include -#include #include "../../utils.hpp" #include "../contacts/ContactsListModel.hpp" @@ -56,16 +56,16 @@ QVariant TimelineModel::data (const QModelIndex &index, int role) const { void TimelineModel::init_entries () { // Returns an iterator entry position to insert a new entry. auto search_entry = [this]( - const QVariantMap &map, - const QList >::iterator *start = NULL - ) { - return lower_bound( - start ? *start : m_entries.begin(), m_entries.end(), map, - [](const QVariantMap &a, const QVariantMap &b) { - return a["timestamp"] > b["timestamp"]; - } - ); - }; + const QVariantMap &map, + const QList >::iterator *start = NULL + ) { + return lower_bound( + start ? *start : m_entries.begin(), m_entries.end(), map, + [](const QVariantMap &a, const QVariantMap &b) { + return a["timestamp"] > b["timestamp"]; + } + ); + }; shared_ptr core(CoreManager::getInstance()->getCore()); @@ -82,11 +82,11 @@ void TimelineModel::init_entries () { // Insert event message in timeline entries. QVariantMap map; map["timestamp"] = QDateTime::fromMSecsSinceEpoch( - static_cast(message->getTime()) * 1000 - ); - map["sipAddresses"] = Utils::linphoneStringToQString( - chat_room->getPeerAddress()->asString() - ); + static_cast(message->getTime()) * 1000 + ); + map["sipAddresses"] = ::Utils::linphoneStringToQString( + chat_room->getPeerAddress()->asString() + ); m_entries.insert(search_entry(map), map); } @@ -95,9 +95,9 @@ void TimelineModel::init_entries () { QSet address_done; for (const auto &call_log : core->getCallLogs()) { // Get a sip uri to check. - QString address = Utils::linphoneStringToQString( - call_log->getRemoteAddress()->asString() - ); + QString address = ::Utils::linphoneStringToQString( + call_log->getRemoteAddress()->asString() + ); if (address_done.contains(address)) continue; // Already used. @@ -107,16 +107,16 @@ void TimelineModel::init_entries () { // Make a new map. QVariantMap map; map["timestamp"] = QDateTime::fromMSecsSinceEpoch( - static_cast(call_log->getStartDate() + call_log->getDuration()) * 1000 - ); + static_cast(call_log->getStartDate() + call_log->getDuration()) * 1000 + ); map["sipAddresses"] = address; // Search existing entry. auto it = find_if( - m_entries.begin(), m_entries.end(), [&address](const QVariantMap &map) { - return address == map["sipAddresses"].toString(); - } - ); + m_entries.begin(), m_entries.end(), [&address](const QVariantMap &map) { + return address == map["sipAddresses"].toString(); + } + ); // Is it a new entry? if (it == m_entries.cend()) diff --git a/tests/src/components/timeline/TimelineModel.hpp b/tests/src/components/timeline/TimelineModel.hpp index 30bb1eb83..96193ec34 100644 --- a/tests/src/components/timeline/TimelineModel.hpp +++ b/tests/src/components/timeline/TimelineModel.hpp @@ -5,7 +5,7 @@ class ContactsListModel; -// =================================================================== +// ============================================================================= class TimelineModel : public QAbstractListModel { Q_OBJECT; @@ -23,7 +23,7 @@ private: // A timeline enty is a object that contains: // - A QDateTime `timestamp`. // - A `sipAddresses` value, if it exists only one address, it's - // a string, otherwise it's a string array. + // a string, otherwise it's a string array. QList m_entries; };