From 4bcfad32968f6a9e762faa3716c2b00255510f3b Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Mon, 15 Dec 2025 14:41:10 +0100 Subject: [PATCH] hide current call in transfer call list #LINQT-2256 --- Linphone/core/App.cpp | 5 +++ Linphone/core/App.hpp | 3 ++ Linphone/core/call/CallProxy.cpp | 34 +++++++++++++------ Linphone/core/call/CallProxy.hpp | 15 +++++--- .../core/participant/ParticipantProxy.cpp | 5 +++ Linphone/core/proxy/LimitProxy.cpp | 19 ++++++++++- Linphone/core/proxy/SortFilterProxy.cpp | 10 +++++- Linphone/core/proxy/SortFilterProxy.hpp | 1 + Linphone/data/languages/de.ts | 8 ++--- Linphone/data/languages/en.ts | 8 ++--- Linphone/data/languages/fr_FR.ts | 8 ++--- .../Control/Display/Call/CallListView.qml | 16 +++++---- .../Display/Contact/ContactListItem.qml | 8 ++--- 13 files changed, 100 insertions(+), 40 deletions(-) diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 1a1ae7783..d00839ba3 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -1293,12 +1293,17 @@ void App::setSysTrayIcon() { void App::setLocale(QString configLocale) { if (!configLocale.isEmpty()) mLocale = QLocale(configLocale); else mLocale = QLocale(QLocale::system().name()); + emit localeChanged(); } QLocale App::getLocale() { return mLocale; } +QString App::getLocaleAsString() { + return mLocale.name(); +} + //----------------------------------------------------------- // Version infos. //----------------------------------------------------------- diff --git a/Linphone/core/App.hpp b/Linphone/core/App.hpp index 128d935dd..b7a9c0e96 100644 --- a/Linphone/core/App.hpp +++ b/Linphone/core/App.hpp @@ -45,6 +45,7 @@ class App : public SingleApplication, public AbstractObject { Q_PROPERTY(QString shortApplicationVersion READ getShortApplicationVersion CONSTANT) Q_PROPERTY(QString gitBranchName READ getGitBranchName CONSTANT) Q_PROPERTY(QString sdkVersion READ getSdkVersion CONSTANT) + Q_PROPERTY(QString localeAsString READ getLocaleAsString CONSTANT) public: App(int &argc, char *argv[]); @@ -127,6 +128,7 @@ public: } void updateSysTrayCount(int n); QLocale getLocale(); + QString getLocaleAsString(); void onLoggerInitialized(); void sendCommand(); @@ -181,6 +183,7 @@ signals: void accountsChanged(); void callsChanged(); void currentDateChanged(); + void localeChanged(); // void executeCommand(QString command); private: diff --git a/Linphone/core/call/CallProxy.cpp b/Linphone/core/call/CallProxy.cpp index c52bae809..743944e77 100644 --- a/Linphone/core/call/CallProxy.cpp +++ b/Linphone/core/call/CallProxy.cpp @@ -25,20 +25,32 @@ DEFINE_ABSTRACT_OBJECT(CallProxy) -CallProxy::CallProxy(QObject *parent) : LimitProxy(parent) { +CallProxy::CallProxy() : SortFilterProxy() { + mShowCurrentCall = true; } CallProxy::~CallProxy() { } CallGui *CallProxy::getCurrentCall() { - auto model = getListModel(); + auto model = qobject_cast(sourceModel()); if (!mCurrentCall && model) mCurrentCall = model->getCurrentCall(); return mCurrentCall; } +void CallProxy::setShowCurrentCall(bool show) { + if (mShowCurrentCall != show) { + mShowCurrentCall = show; + emit showCurrentCallChanged(); + } +} + +bool CallProxy::showCurrentCall() const { + return mShowCurrentCall; +} + void CallProxy::setCurrentCall(CallGui *call) { - getListModel()->setCurrentCall(call); + qobject_cast(sourceModel())->setCurrentCall(call); } // Reset the default account to let UI build its new object if needed. @@ -48,12 +60,12 @@ void CallProxy::resetCurrentCall() { } bool CallProxy::getHaveCall() const { - auto model = getListModel(); + auto model = qobject_cast(sourceModel()); return model ? model->getHaveCall() : false; } void CallProxy::setSourceModel(QAbstractItemModel *model) { - auto oldCallList = getListModel(); + auto oldCallList = qobject_cast(sourceModel()); if (oldCallList) { disconnect(oldCallList); } @@ -63,24 +75,24 @@ void CallProxy::setSourceModel(QAbstractItemModel *model) { connect(newCallList, &CallList::haveCallChanged, this, &CallProxy::haveCallChanged, Qt::QueuedConnection); connect(this, &CallProxy::lMergeAll, newCallList, &CallList::lMergeAll); } - setSourceModels(new SortFilterList(model, Qt::AscendingOrder)); + QSortFilterProxyModel::setSourceModel(model); } -bool CallProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { +bool CallProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { bool show = (mFilterText.isEmpty() || mFilterText == "*"); + auto callList = qobject_cast(sourceModel()); + auto call = callList->getAt(sourceRow); + if (!mShowCurrentCall && call == callList->getCurrentCallCore()) return false; if (!show) { QRegularExpression search(QRegularExpression::escape(mFilterText), QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); - auto call = qobject_cast(sourceModel())->getAt(sourceRow); - show = call->getRemoteAddress().contains(search); } - return show; } -bool CallProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { +bool CallProxy::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { auto l = getItemAtSource(sourceLeft.row()); auto r = getItemAtSource(sourceRight.row()); diff --git a/Linphone/core/call/CallProxy.hpp b/Linphone/core/call/CallProxy.hpp index 591d0a06f..86ba42870 100644 --- a/Linphone/core/call/CallProxy.hpp +++ b/Linphone/core/call/CallProxy.hpp @@ -28,15 +28,14 @@ // ============================================================================= -class CallProxy : public LimitProxy, public AbstractObject { +class CallProxy : public SortFilterProxy, public AbstractObject { Q_OBJECT Q_PROPERTY(CallGui *currentCall READ getCurrentCall WRITE setCurrentCall NOTIFY currentCallChanged) Q_PROPERTY(bool haveCall READ getHaveCall NOTIFY haveCallChanged) + Q_PROPERTY(bool showCurrentCall READ showCurrentCall WRITE setShowCurrentCall NOTIFY showCurrentCallChanged) public: - DECLARE_SORTFILTER_CLASS() - - CallProxy(QObject *parent = Q_NULLPTR); + CallProxy(); ~CallProxy(); // Get a new object from List or give the stored one. @@ -48,15 +47,23 @@ public: bool getHaveCall() const; + void setShowCurrentCall(bool show); + bool showCurrentCall() const; + void setSourceModel(QAbstractItemModel *sourceModel) override; + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + virtual bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override; + signals: void lMergeAll(); void currentCallChanged(); void haveCallChanged(); + void showCurrentCallChanged(); protected: CallGui *mCurrentCall = nullptr; // When null, a new UI object is build from List + bool mShowCurrentCall = false; DECLARE_ABSTRACT_OBJECT }; diff --git a/Linphone/core/participant/ParticipantProxy.cpp b/Linphone/core/participant/ParticipantProxy.cpp index 6c53404f6..81b815697 100644 --- a/Linphone/core/participant/ParticipantProxy.cpp +++ b/Linphone/core/participant/ParticipantProxy.cpp @@ -110,7 +110,12 @@ void ParticipantProxy::setShowMe(const bool &show) { if (list->mShowMe != show) { list->mShowMe = show; emit showMeChanged(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) + QSortFilterProxyModel::beginFilterChange(); + QSortFilterProxyModel::endFilterChange(); +#else invalidateFilter(); +#endif } } diff --git a/Linphone/core/proxy/LimitProxy.cpp b/Linphone/core/proxy/LimitProxy.cpp index 7a3c61547..95eb51d72 100644 --- a/Linphone/core/proxy/LimitProxy.cpp +++ b/Linphone/core/proxy/LimitProxy.cpp @@ -43,7 +43,14 @@ void LimitProxy::setSourceModels(SortFilterProxy *firstList) { if (secondList) { connect(secondList, &QAbstractItemModel::rowsInserted, this, &LimitProxy::onAdded); connect(secondList, &QAbstractItemModel::rowsRemoved, this, &LimitProxy::onRemoved); - connect(secondList, &QAbstractItemModel::modelReset, this, &LimitProxy::invalidateRowsFilter); + connect(secondList, &QAbstractItemModel::modelReset, this, [this] { +#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) + QSortFilterProxyModel::beginFilterChange(); + QSortFilterProxyModel::endFilterChange(); +#else + invalidateRowsFilter(); +#endif + }); } connect(firstList, &SortFilterProxy::filterTextChanged, this, &LimitProxy::filterTextChanged); connect(firstList, &SortFilterProxy::filterTypeChanged, this, &LimitProxy::filterTypeChanged); @@ -110,7 +117,12 @@ void LimitProxy::setMaxDisplayItems(int maxItems) { emit maxDisplayItemsChanged(); if (model && getDisplayCount(modelCount) != oldCount) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) + QSortFilterProxyModel::beginFilterChange(); + QSortFilterProxyModel::endFilterChange(); +#else invalidateFilter(); +#endif } } } @@ -169,6 +181,11 @@ void LimitProxy::onAdded() { void LimitProxy::onRemoved() { int count = sourceModel()->rowCount(); if (mMaxDisplayItems > 0 && mMaxDisplayItems <= count) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) + QSortFilterProxyModel::beginFilterChange(); + QSortFilterProxyModel::endFilterChange(); +#else invalidateFilter(); +#endif } } diff --git a/Linphone/core/proxy/SortFilterProxy.cpp b/Linphone/core/proxy/SortFilterProxy.cpp index cfeff8291..74b0dc885 100644 --- a/Linphone/core/proxy/SortFilterProxy.cpp +++ b/Linphone/core/proxy/SortFilterProxy.cpp @@ -20,6 +20,9 @@ #include "SortFilterProxy.hpp" +SortFilterProxy::SortFilterProxy() : QSortFilterProxyModel() { +} + SortFilterProxy::SortFilterProxy(QAbstractItemModel *list) : QSortFilterProxyModel(list) { connect(this, &SortFilterProxy::rowsInserted, this, &SortFilterProxy::countChanged); connect(this, &SortFilterProxy::rowsRemoved, this, &SortFilterProxy::countChanged); @@ -90,5 +93,10 @@ void SortFilterProxy::remove(int index, int count) { } void SortFilterProxy::invalidateFilter() { - QSortFilterProxyModel::invalidateFilter(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) + QSortFilterProxyModel::beginFilterChange(); + QSortFilterProxyModel::endFilterChange(); +#else + invalidateFilter(); +#endif } diff --git a/Linphone/core/proxy/SortFilterProxy.hpp b/Linphone/core/proxy/SortFilterProxy.hpp index f604de42f..57a623d91 100644 --- a/Linphone/core/proxy/SortFilterProxy.hpp +++ b/Linphone/core/proxy/SortFilterProxy.hpp @@ -41,6 +41,7 @@ public: Q_PROPERTY(int filterType READ getFilterType WRITE setFilterType NOTIFY filterTypeChanged) Q_PROPERTY(QString filterText READ getFilterText WRITE setFilterText NOTIFY filterTextChanged) + SortFilterProxy(); SortFilterProxy(QAbstractItemModel *parent); SortFilterProxy(QAbstractItemModel *parent, Qt::SortOrder order); virtual ~SortFilterProxy(); diff --git a/Linphone/data/languages/de.ts b/Linphone/data/languages/de.ts index 0431731ac..5ac2c8eee 100644 --- a/Linphone/data/languages/de.ts +++ b/Linphone/data/languages/de.ts @@ -820,25 +820,25 @@ CallListView - + meeting "Réunion Besprechung - + call "Appel" Anruf - + paused_call_or_meeting "%1 en pause" %1 pausiert - + ongoing_call_or_meeting "%1 en cours" %1 laufend diff --git a/Linphone/data/languages/en.ts b/Linphone/data/languages/en.ts index 4d7fab56c..6b12731c4 100644 --- a/Linphone/data/languages/en.ts +++ b/Linphone/data/languages/en.ts @@ -820,25 +820,25 @@ CallListView - + meeting "Réunion Meeting - + call "Appel" Call - + paused_call_or_meeting "%1 en pause" %1 paused - + ongoing_call_or_meeting "%1 en cours" Ongoing %1 diff --git a/Linphone/data/languages/fr_FR.ts b/Linphone/data/languages/fr_FR.ts index 1a1c60115..a6c017f7f 100644 --- a/Linphone/data/languages/fr_FR.ts +++ b/Linphone/data/languages/fr_FR.ts @@ -820,25 +820,25 @@ CallListView - + meeting "Réunion Réunion - + call "Appel" Appel - + paused_call_or_meeting "%1 en pause" %1 en pause - + ongoing_call_or_meeting "%1 en cours" %1 en cours diff --git a/Linphone/view/Control/Display/Call/CallListView.qml b/Linphone/view/Control/Display/Call/CallListView.qml index 73bb0a2b4..f83534753 100644 --- a/Linphone/view/Control/Display/Call/CallListView.qml +++ b/Linphone/view/Control/Display/Call/CallListView.qml @@ -9,19 +9,21 @@ import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle ListView { id: mainItem - model: CallProxy { - id: callProxy - sourceModel: AppCpp.calls - } implicitHeight: contentHeight spacing: Math.round(15 * DefaultStyle.dp) clip: true - onCountChanged: forceLayout() - - signal transferCallToAnotherRequested(CallGui dest) property bool isTransferList: false property string currentRemoteAddress: AppCpp.calls.currentCall ? AppCpp.calls.currentCall.core.remoteAddress : "" + signal transferCallToAnotherRequested(CallGui dest) + + onCountChanged: forceLayout() + + model: CallProxy { + id: callProxy + sourceModel: AppCpp.calls + showCurrentCall: !mainItem.isTransferList + } delegate: RowLayout { spacing: Math.round(8 * DefaultStyle.dp) diff --git a/Linphone/view/Control/Display/Contact/ContactListItem.qml b/Linphone/view/Control/Display/Contact/ContactListItem.qml index 49d5e5dfd..10b20e976 100644 --- a/Linphone/view/Control/Display/Contact/ContactListItem.qml +++ b/Linphone/view/Control/Display/Contact/ContactListItem.qml @@ -3,8 +3,8 @@ import QtQuick.Layouts import QtQuick.Controls.Basic as Control import Linphone -import UtilsCpp 1.0 -import ConstantsCpp 1.0 +import UtilsCpp +import ConstantsCpp import SettingsCpp import "qrc:/qt/qml/Linphone/view/Style/buttonStyle.js" as ButtonStyle @@ -34,8 +34,8 @@ FocusScope { // Use directly previous initial property real itemsRightMargin: Math.round(39 * DefaultStyle.dp) - property var displayName: searchResultItem.core.fullName - property var initial: displayName ? displayName[0].toLocaleLowerCase(ConstantsCpp.DefaultLocale) : '' + property string displayName: searchResultItem?.core.fullName || "" + property string initial: displayName.length > 0 ? displayName[0].toLocaleLowerCase(AppCpp.localeAsString) : '' signal clicked(var mouse) signal contactDeletionRequested(FriendGui contact)