mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-06 20:23:08 +00:00
feat(app): rename SmartSearchBarModel to SipAddressesProxyModel
This commit is contained in:
parent
c1275cab32
commit
6c25f7e655
9 changed files with 30 additions and 38 deletions
|
|
@ -119,8 +119,8 @@ set(SOURCES
|
|||
src/components/settings/AccountSettingsModel.cpp
|
||||
src/components/settings/SettingsModel.cpp
|
||||
src/components/sip-addresses/SipAddressesModel.cpp
|
||||
src/components/sip-addresses/SipAddressesProxyModel.cpp
|
||||
src/components/sip-addresses/SipAddressObserver.cpp
|
||||
src/components/smart-search-bar/SmartSearchBarModel.cpp
|
||||
src/components/sound-player/SoundPlayer.cpp
|
||||
src/components/timeline/TimelineModel.cpp
|
||||
src/externals/single-application/SingleApplication.cpp
|
||||
|
|
@ -161,8 +161,8 @@ set(HEADERS
|
|||
src/components/settings/AccountSettingsModel.hpp
|
||||
src/components/settings/SettingsModel.hpp
|
||||
src/components/sip-addresses/SipAddressesModel.hpp
|
||||
src/components/sip-addresses/SipAddressesProxyModel.hpp
|
||||
src/components/sip-addresses/SipAddressObserver.hpp
|
||||
src/components/smart-search-bar/SmartSearchBarModel.hpp
|
||||
src/components/sound-player/SoundPlayer.hpp
|
||||
src/components/timeline/TimelineModel.hpp
|
||||
src/externals/single-application/SingleApplication.hpp
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ void App::registerTypes () {
|
|||
registerType<ChatProxyModel>("ChatProxyModel");
|
||||
registerType<ConferenceHelperModel>("ConferenceHelperModel");
|
||||
registerType<ContactsListProxyModel>("ContactsListProxyModel");
|
||||
registerType<SmartSearchBarModel>("SmartSearchBarModel");
|
||||
registerType<SipAddressesProxyModel>("SipAddressesProxyModel");
|
||||
registerType<SoundPlayer>("SoundPlayer");
|
||||
|
||||
registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "core/CoreManager.hpp"
|
||||
#include "presence/OwnPresenceModel.hpp"
|
||||
#include "settings/AccountSettingsModel.hpp"
|
||||
#include "smart-search-bar/SmartSearchBarModel.hpp"
|
||||
#include "sip-addresses/SipAddressesProxyModel.hpp"
|
||||
#include "sound-player/SoundPlayer.hpp"
|
||||
#include "timeline/TimelineModel.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "../../Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "../smart-search-bar/SmartSearchBarModel.hpp"
|
||||
#include "../sip-addresses/SipAddressesProxyModel.hpp"
|
||||
|
||||
#include "ConferenceHelperModel.hpp"
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProx
|
|||
QObject::connect(calls, &CallsListModel::rowsAboutToBeRemoved, this, &ConferenceHelperModel::handleCallsAboutToBeRemoved);
|
||||
QObject::connect(calls, &CallsListModel::callRunning, this, &ConferenceHelperModel::handleCallRunning);
|
||||
|
||||
setSourceModel(new SmartSearchBarModel(this));
|
||||
setSourceModel(new SipAddressesProxyModel(this));
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ConferenceHelperModel::roleNames () const {
|
||||
|
|
@ -51,7 +51,7 @@ QHash<int, QByteArray> ConferenceHelperModel::roleNames () const {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
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 {
|
|||
// Grant access to `mLinphoneFriend`.
|
||||
friend class ContactsListModel;
|
||||
friend class ContactsListProxyModel;
|
||||
friend class SmartSearchBarModel;
|
||||
friend class SipAddressesProxyModel;
|
||||
|
||||
public:
|
||||
ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphoneFriend);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SmartSearchBarModel.cpp
|
||||
* SipAddressesProxyModel.cpp
|
||||
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "../core/CoreManager.hpp"
|
||||
|
||||
#include "SmartSearchBarModel.hpp"
|
||||
#include "SipAddressesProxyModel.hpp"
|
||||
|
||||
#define WEIGHT_POS_0 5
|
||||
#define WEIGHT_POS_1 4
|
||||
|
|
@ -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());
|
||||
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;
|
||||
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);
|
||||
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 &mapB = sourceModel()->data(right).toMap();
|
||||
|
||||
|
|
@ -100,7 +94,7 @@ bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &
|
|||
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));
|
||||
|
||||
const ContactModel *contact = entry.value("contact").value<ContactModel *>();
|
||||
|
|
@ -110,7 +104,7 @@ int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const {
|
|||
return weight;
|
||||
}
|
||||
|
||||
int SmartSearchBarModel::computeStringWeight (const QString &string) const {
|
||||
int SipAddressesProxyModel::computeStringWeight (const QString &string) const {
|
||||
int index = -1;
|
||||
int offset = -1;
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SmartSearchBarModel.hpp
|
||||
* SipAddressesProxyModel.hpp
|
||||
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
|
@ -20,21 +20,19 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#ifndef SMART_SEARCH_BAR_MODEL_H_
|
||||
#define SMART_SEARCH_BAR_MODEL_H_
|
||||
#ifndef SIP_ADDRESSES_PROXY_MODEL_H_
|
||||
#define SIP_ADDRESSES_PROXY_MODEL_H_
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class SmartSearchBarModel : public QSortFilterProxyModel {
|
||||
class SipAddressesProxyModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
SmartSearchBarModel (QObject *parent = Q_NULLPTR);
|
||||
~SmartSearchBarModel () = default;
|
||||
|
||||
QHash<int, QByteArray> roleNames () const override;
|
||||
SipAddressesProxyModel (QObject *parent = Q_NULLPTR);
|
||||
~SipAddressesProxyModel () = default;
|
||||
|
||||
Q_INVOKABLE void setFilter (const QString &pattern);
|
||||
|
||||
|
|
@ -51,4 +49,4 @@ private:
|
|||
static const QRegExp mSearchSeparators;
|
||||
};
|
||||
|
||||
#endif // SMART_SEARCH_BAR_MODEL_H_
|
||||
#endif // SIP_ADDRESSES_PROXY_MODEL_H_
|
||||
|
|
@ -207,7 +207,7 @@ SearchBox {
|
|||
Contact {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
entry: $entry
|
||||
entry: $sipAddress
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
|
@ -219,7 +219,7 @@ SearchBox {
|
|||
|
||||
onClicked: {
|
||||
searchBox.closeMenu()
|
||||
searchBox.entryClicked($entry)
|
||||
searchBox.entryClicked($sipAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ SearchBox {
|
|||
icon: 'video_call'
|
||||
onClicked: {
|
||||
searchBox.closeMenu()
|
||||
searchBox.launchVideoCall($entry.sipAddress)
|
||||
searchBox.launchVideoCall($sipAddress.sipAddress)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ SearchBox {
|
|||
icon: 'call'
|
||||
onClicked: {
|
||||
searchBox.closeMenu()
|
||||
searchBox.launchCall($entry.sipAddress)
|
||||
searchBox.launchCall($sipAddress.sipAddress)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ SearchBox {
|
|||
icon: 'chat'
|
||||
onClicked: {
|
||||
searchBox.closeMenu()
|
||||
searchBox.launchChat($entry.sipAddress)
|
||||
searchBox.launchChat($sipAddress.sipAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ ApplicationWindow {
|
|||
maxMenuHeight: MainWindowStyle.searchBox.maxHeight
|
||||
placeholderText: qsTr('mainSearchBarPlaceholder')
|
||||
|
||||
model: SmartSearchBarModel {}
|
||||
model: SipAddressesProxyModel {}
|
||||
|
||||
onAddContact: window.setView('ContactEdit', {
|
||||
sipAddress: sipAddress
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue