From 25b692597718ed04536d83480349da64b990b520 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 29 Dec 2016 16:51:39 +0100 Subject: [PATCH] fix(app): little fixes & coding style --- tests/src/components/chat/ChatProxyModel.hpp | 2 -- tests/src/components/contact/ContactModel.cpp | 2 +- tests/src/components/core/CoreManager.hpp | 1 - .../smart-search-bar/SmartSearchBarModel.cpp | 14 ++++++-------- tests/src/components/timeline/TimelineModel.cpp | 11 +++-------- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/tests/src/components/chat/ChatProxyModel.hpp b/tests/src/components/chat/ChatProxyModel.hpp index ddb559acc..bc780375c 100644 --- a/tests/src/components/chat/ChatProxyModel.hpp +++ b/tests/src/components/chat/ChatProxyModel.hpp @@ -45,9 +45,7 @@ public: public slots: void loadMoreEntries (); - void setEntryTypeFilter (ChatModel::EntryType type); - void removeEntry (int id); void removeAllEntries () { diff --git a/tests/src/components/contact/ContactModel.cpp b/tests/src/components/contact/ContactModel.cpp index 5e8641cee..51bae4779 100644 --- a/tests/src/components/contact/ContactModel.cpp +++ b/tests/src/components/contact/ContactModel.cpp @@ -17,7 +17,7 @@ ContactModel::ContactModel (shared_ptr linphone_friend) { ContactModel::ContactModel (VcardModel *vcard) { QQmlEngine *engine = App::getInstance()->getEngine(); if (engine->objectOwnership(vcard) == QQmlEngine::CppOwnership) - throw std::invalid_argument("A contact is already linked to this vcard."); + throw invalid_argument("A contact is already linked to this vcard."); m_linphone_friend = linphone::Friend::newFromVcard(vcard->m_vcard); m_vcard.reset(vcard); diff --git a/tests/src/components/core/CoreManager.hpp b/tests/src/components/core/CoreManager.hpp index 5739c9386..755acfde1 100644 --- a/tests/src/components/core/CoreManager.hpp +++ b/tests/src/components/core/CoreManager.hpp @@ -1,7 +1,6 @@ #ifndef CORE_MANAGER_H_ #define CORE_MANAGER_H_ -#include "../contact/VcardModel.hpp" #include "../contacts/ContactsListModel.hpp" #include "../sip-addresses/SipAddressesModel.hpp" diff --git a/tests/src/components/smart-search-bar/SmartSearchBarModel.cpp b/tests/src/components/smart-search-bar/SmartSearchBarModel.cpp index 365ecffac..a21b24bd0 100644 --- a/tests/src/components/smart-search-bar/SmartSearchBarModel.cpp +++ b/tests/src/components/smart-search-bar/SmartSearchBarModel.cpp @@ -35,18 +35,16 @@ void SmartSearchBarModel::setFilter (const QString &pattern) { // ----------------------------------------------------------------------------- bool SmartSearchBarModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { - const QModelIndex index = sourceModel()->index(source_row, 0, source_parent); - const QVariantMap map = index.data().toMap(); - - return computeStringWeight(map["sipAddress"].toString()) > 0; + const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); + return computeStringWeight(index.data().toMap()["sipAddress"].toString()) > 0; } bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { - const QVariantMap map_a = sourceModel()->data(left).toMap(); - const QVariantMap map_b = sourceModel()->data(right).toMap(); + const QVariantMap &map_a = sourceModel()->data(left).toMap(); + const QVariantMap &map_b = sourceModel()->data(right).toMap(); - const QString sip_address_a = map_a["sipAddress"].toString(); - const QString sip_address_b = map_b["sipAddress"].toString(); + const QString &sip_address_a = map_a["sipAddress"].toString(); + const QString &sip_address_b = map_b["sipAddress"].toString(); int weight_a = computeStringWeight(sip_address_a); int weight_b = computeStringWeight(sip_address_b); diff --git a/tests/src/components/timeline/TimelineModel.cpp b/tests/src/components/timeline/TimelineModel.cpp index 08592e5f6..572927c35 100644 --- a/tests/src/components/timeline/TimelineModel.cpp +++ b/tests/src/components/timeline/TimelineModel.cpp @@ -18,15 +18,10 @@ QHash TimelineModel::roleNames () const { // ----------------------------------------------------------------------------- bool TimelineModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { - const QModelIndex index = sourceModel()->index(source_row, 0, source_parent); - const QVariantMap map = index.data().toMap(); - - return map.contains("timestamp"); + const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); + return index.data().toMap().contains("timestamp"); } bool TimelineModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { - const QVariantMap sip_address_a = sourceModel()->data(left).toMap(); - const QVariantMap sip_address_b = sourceModel()->data(right).toMap(); - - return sip_address_a["timestamp"] > sip_address_b["timestamp"]; + return sourceModel()->data(left).toMap()["timestamp"] > sourceModel()->data(right).toMap()["timestamp"]; }