Commit 6c25f7e6 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): rename `SmartSearchBarModel` to `SipAddressesProxyModel`

parent c1275cab
...@@ -119,8 +119,8 @@ set(SOURCES ...@@ -119,8 +119,8 @@ set(SOURCES
src/components/settings/AccountSettingsModel.cpp src/components/settings/AccountSettingsModel.cpp
src/components/settings/SettingsModel.cpp src/components/settings/SettingsModel.cpp
src/components/sip-addresses/SipAddressesModel.cpp src/components/sip-addresses/SipAddressesModel.cpp
src/components/sip-addresses/SipAddressesProxyModel.cpp
src/components/sip-addresses/SipAddressObserver.cpp src/components/sip-addresses/SipAddressObserver.cpp
src/components/smart-search-bar/SmartSearchBarModel.cpp
src/components/sound-player/SoundPlayer.cpp src/components/sound-player/SoundPlayer.cpp
src/components/timeline/TimelineModel.cpp src/components/timeline/TimelineModel.cpp
src/externals/single-application/SingleApplication.cpp src/externals/single-application/SingleApplication.cpp
...@@ -161,8 +161,8 @@ set(HEADERS ...@@ -161,8 +161,8 @@ set(HEADERS
src/components/settings/AccountSettingsModel.hpp src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp src/components/settings/SettingsModel.hpp
src/components/sip-addresses/SipAddressesModel.hpp src/components/sip-addresses/SipAddressesModel.hpp
src/components/sip-addresses/SipAddressesProxyModel.hpp
src/components/sip-addresses/SipAddressObserver.hpp src/components/sip-addresses/SipAddressObserver.hpp
src/components/smart-search-bar/SmartSearchBarModel.hpp
src/components/sound-player/SoundPlayer.hpp src/components/sound-player/SoundPlayer.hpp
src/components/timeline/TimelineModel.hpp src/components/timeline/TimelineModel.hpp
src/externals/single-application/SingleApplication.hpp src/externals/single-application/SingleApplication.hpp
......
...@@ -347,7 +347,7 @@ void App::registerTypes () { ...@@ -347,7 +347,7 @@ void App::registerTypes () {
registerType<ChatProxyModel>("ChatProxyModel"); registerType<ChatProxyModel>("ChatProxyModel");
registerType<ConferenceHelperModel>("ConferenceHelperModel"); registerType<ConferenceHelperModel>("ConferenceHelperModel");
registerType<ContactsListProxyModel>("ContactsListProxyModel"); registerType<ContactsListProxyModel>("ContactsListProxyModel");
registerType<SmartSearchBarModel>("SmartSearchBarModel"); registerType<SipAddressesProxyModel>("SipAddressesProxyModel");
registerType<SoundPlayer>("SoundPlayer"); registerType<SoundPlayer>("SoundPlayer");
registerSingletonType<AudioCodecsModel>("AudioCodecsModel"); registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "core/CoreManager.hpp" #include "core/CoreManager.hpp"
#include "presence/OwnPresenceModel.hpp" #include "presence/OwnPresenceModel.hpp"
#include "settings/AccountSettingsModel.hpp" #include "settings/AccountSettingsModel.hpp"
#include "smart-search-bar/SmartSearchBarModel.hpp" #include "sip-addresses/SipAddressesProxyModel.hpp"
#include "sound-player/SoundPlayer.hpp" #include "sound-player/SoundPlayer.hpp"
#include "timeline/TimelineModel.hpp" #include "timeline/TimelineModel.hpp"
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "../../Utils.hpp" #include "../../Utils.hpp"
#include "../core/CoreManager.hpp" #include "../core/CoreManager.hpp"
#include "../smart-search-bar/SmartSearchBarModel.hpp" #include "../sip-addresses/SipAddressesProxyModel.hpp"
#include "ConferenceHelperModel.hpp" #include "ConferenceHelperModel.hpp"
...@@ -39,7 +39,7 @@ ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProx ...@@ -39,7 +39,7 @@ ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProx
QObject::connect(calls, &CallsListModel::rowsAboutToBeRemoved, this, &ConferenceHelperModel::handleCallsAboutToBeRemoved); QObject::connect(calls, &CallsListModel::rowsAboutToBeRemoved, this, &ConferenceHelperModel::handleCallsAboutToBeRemoved);
QObject::connect(calls, &CallsListModel::callRunning, this, &ConferenceHelperModel::handleCallRunning); QObject::connect(calls, &CallsListModel::callRunning, this, &ConferenceHelperModel::handleCallRunning);
setSourceModel(new SmartSearchBarModel(this)); setSourceModel(new SipAddressesProxyModel(this));
} }
QHash<int, QByteArray> ConferenceHelperModel::roleNames () const { QHash<int, QByteArray> ConferenceHelperModel::roleNames () const {
...@@ -51,7 +51,7 @@ QHash<int, QByteArray> ConferenceHelperModel::roleNames () const { ...@@ -51,7 +51,7 @@ QHash<int, QByteArray> ConferenceHelperModel::roleNames () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ConferenceHelperModel::setFilter (const QString &pattern) { void ConferenceHelperModel::setFilter (const QString &pattern) {
static_cast<SmartSearchBarModel *>(sourceModel())->setFilter(pattern); static_cast<SipAddressesProxyModel *>(sourceModel())->setFilter(pattern);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -38,7 +38,7 @@ class ContactModel : public QObject { ...@@ -38,7 +38,7 @@ class ContactModel : public QObject {
// Grant access to `mLinphoneFriend`. // Grant access to `mLinphoneFriend`.
friend class ContactsListModel; friend class ContactsListModel;
friend class ContactsListProxyModel; friend class ContactsListProxyModel;
friend class SmartSearchBarModel; friend class SipAddressesProxyModel;
public: public:
ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphoneFriend); ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphoneFriend);
......
/* /*
* SmartSearchBarModel.cpp * SipAddressesProxyModel.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France * Copyright (C) 2017 Belledonne Communications, Grenoble, France
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "../core/CoreManager.hpp" #include "../core/CoreManager.hpp"
#include "SmartSearchBarModel.hpp" #include "SipAddressesProxyModel.hpp"
#define WEIGHT_POS_0 5 #define WEIGHT_POS_0 5
#define WEIGHT_POS_1 4 #define WEIGHT_POS_1 4
...@@ -32,36 +32,30 @@ ...@@ -32,36 +32,30 @@
// ============================================================================= // =============================================================================
const QRegExp SmartSearchBarModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]"); const QRegExp SipAddressesProxyModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
SmartSearchBarModel::SmartSearchBarModel (QObject *parent) : QSortFilterProxyModel(parent) { SipAddressesProxyModel::SipAddressesProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(CoreManager::getInstance()->getSipAddressesModel()); setSourceModel(CoreManager::getInstance()->getSipAddressesModel());
sort(0); sort(0);
} }
QHash<int, QByteArray> SmartSearchBarModel::roleNames () const {
QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$entry";
return roles;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SmartSearchBarModel::setFilter (const QString &pattern) { void SipAddressesProxyModel::setFilter (const QString &pattern) {
mFilter = pattern; mFilter = pattern;
invalidate(); invalidate();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool SmartSearchBarModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const { bool SipAddressesProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
return computeEntryWeight(index.data().toMap()) > 0; return computeEntryWeight(index.data().toMap()) > 0;
} }
bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { bool SipAddressesProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
const QVariantMap &mapA = sourceModel()->data(left).toMap(); const QVariantMap &mapA = sourceModel()->data(left).toMap();
const QVariantMap &mapB = sourceModel()->data(right).toMap(); const QVariantMap &mapB = sourceModel()->data(right).toMap();
...@@ -100,7 +94,7 @@ bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex & ...@@ -100,7 +94,7 @@ bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &
return sipAddressA <= sipAddressB; return sipAddressA <= sipAddressB;
} }
int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const { int SipAddressesProxyModel::computeEntryWeight (const QVariantMap &entry) const {
int weight = computeStringWeight(entry["sipAddress"].toString().mid(4)); int weight = computeStringWeight(entry["sipAddress"].toString().mid(4));
const ContactModel *contact = entry.value("contact").value<ContactModel *>(); const ContactModel *contact = entry.value("contact").value<ContactModel *>();
...@@ -110,7 +104,7 @@ int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const { ...@@ -110,7 +104,7 @@ int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const {
return weight; return weight;
} }
int SmartSearchBarModel::computeStringWeight (const QString &string) const { int SipAddressesProxyModel::computeStringWeight (const QString &string) const {
int index = -1; int index = -1;
int offset = -1; int offset = -1;
......
/* /*
* SmartSearchBarModel.hpp * SipAddressesProxyModel.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France * Copyright (C) 2017 Belledonne Communications, Grenoble, France
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -20,21 +20,19 @@ ...@@ -20,21 +20,19 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#ifndef SMART_SEARCH_BAR_MODEL_H_ #ifndef SIP_ADDRESSES_PROXY_MODEL_H_
#define SMART_SEARCH_BAR_MODEL_H_ #define SIP_ADDRESSES_PROXY_MODEL_H_
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
// ============================================================================= // =============================================================================
class SmartSearchBarModel : public QSortFilterProxyModel { class SipAddressesProxyModel : public QSortFilterProxyModel {
Q_OBJECT; Q_OBJECT;
public: public:
SmartSearchBarModel (QObject *parent = Q_NULLPTR); SipAddressesProxyModel (QObject *parent = Q_NULLPTR);
~SmartSearchBarModel () = default; ~SipAddressesProxyModel () = default;
QHash<int, QByteArray> roleNames () const override;
Q_INVOKABLE void setFilter (const QString &pattern); Q_INVOKABLE void setFilter (const QString &pattern);
...@@ -51,4 +49,4 @@ private: ...@@ -51,4 +49,4 @@ private:
static const QRegExp mSearchSeparators; static const QRegExp mSearchSeparators;
}; };
#endif // SMART_SEARCH_BAR_MODEL_H_ #endif // SIP_ADDRESSES_PROXY_MODEL_H_
...@@ -207,7 +207,7 @@ SearchBox { ...@@ -207,7 +207,7 @@ SearchBox {
Contact { Contact {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
entry: $entry entry: $sipAddress
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
...@@ -219,7 +219,7 @@ SearchBox { ...@@ -219,7 +219,7 @@ SearchBox {
onClicked: { onClicked: {
searchBox.closeMenu() searchBox.closeMenu()
searchBox.entryClicked($entry) searchBox.entryClicked($sipAddress)
} }
} }
} }
...@@ -235,7 +235,7 @@ SearchBox { ...@@ -235,7 +235,7 @@ SearchBox {
icon: 'video_call' icon: 'video_call'
onClicked: { onClicked: {
searchBox.closeMenu() searchBox.closeMenu()
searchBox.launchVideoCall($entry.sipAddress) searchBox.launchVideoCall($sipAddress.sipAddress)
} }
} }
...@@ -243,7 +243,7 @@ SearchBox { ...@@ -243,7 +243,7 @@ SearchBox {
icon: 'call' icon: 'call'
onClicked: { onClicked: {
searchBox.closeMenu() searchBox.closeMenu()
searchBox.launchCall($entry.sipAddress) searchBox.launchCall($sipAddress.sipAddress)
} }
} }
...@@ -251,7 +251,7 @@ SearchBox { ...@@ -251,7 +251,7 @@ SearchBox {
icon: 'chat' icon: 'chat'
onClicked: { onClicked: {
searchBox.closeMenu() searchBox.closeMenu()
searchBox.launchChat($entry.sipAddress) searchBox.launchChat($sipAddress.sipAddress)
} }
} }
} }
......
...@@ -154,7 +154,7 @@ ApplicationWindow { ...@@ -154,7 +154,7 @@ ApplicationWindow {
maxMenuHeight: MainWindowStyle.searchBox.maxHeight maxMenuHeight: MainWindowStyle.searchBox.maxHeight
placeholderText: qsTr('mainSearchBarPlaceholder') placeholderText: qsTr('mainSearchBarPlaceholder')
model: SmartSearchBarModel {} model: SipAddressesProxyModel {}
onAddContact: window.setView('ContactEdit', { onAddContact: window.setView('ContactEdit', {
sipAddress: sipAddress sipAddress: sipAddress
......
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