hide current call in transfer call list #LINQT-2256

This commit is contained in:
Gaelle Braud 2025-12-15 14:41:10 +01:00
parent 62bab0f091
commit 4bcfad3296
13 changed files with 100 additions and 40 deletions

View file

@ -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.
//-----------------------------------------------------------

View file

@ -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:

View file

@ -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<CallList>();
auto model = qobject_cast<CallList *>(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<CallList>()->setCurrentCall(call);
qobject_cast<CallList *>(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<CallList>();
auto model = qobject_cast<CallList *>(sourceModel());
return model ? model->getHaveCall() : false;
}
void CallProxy::setSourceModel(QAbstractItemModel *model) {
auto oldCallList = getListModel<CallList>();
auto oldCallList = qobject_cast<CallList *>(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<CallList *>(sourceModel());
auto call = callList->getAt<CallCore>(sourceRow);
if (!mShowCurrentCall && call == callList->getCurrentCallCore()) return false;
if (!show) {
QRegularExpression search(QRegularExpression::escape(mFilterText),
QRegularExpression::CaseInsensitiveOption |
QRegularExpression::UseUnicodePropertiesOption);
auto call = qobject_cast<CallList *>(sourceModel())->getAt<CallCore>(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<CallList, CallCore>(sourceLeft.row());
auto r = getItemAtSource<CallList, CallCore>(sourceRight.row());

View file

@ -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
};

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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
}

View file

@ -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();

View file

@ -820,25 +820,25 @@
<context>
<name>CallListView</name>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="54"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="56"/>
<source>meeting</source>
<extracomment>&quot;Réunion</extracomment>
<translation>Besprechung</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="56"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="58"/>
<source>call</source>
<extracomment>&quot;Appel&quot;</extracomment>
<translation>Anruf</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="61"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="63"/>
<source>paused_call_or_meeting</source>
<extracomment>&quot;%1 en pause&quot;</extracomment>
<translation>%1 pausiert</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="63"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="65"/>
<source>ongoing_call_or_meeting</source>
<extracomment>&quot;%1 en cours&quot;</extracomment>
<translation>%1 laufend</translation>

View file

@ -820,25 +820,25 @@
<context>
<name>CallListView</name>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="54"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="56"/>
<source>meeting</source>
<extracomment>&quot;Réunion</extracomment>
<translation>Meeting</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="56"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="58"/>
<source>call</source>
<extracomment>&quot;Appel&quot;</extracomment>
<translation>Call</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="61"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="63"/>
<source>paused_call_or_meeting</source>
<extracomment>&quot;%1 en pause&quot;</extracomment>
<translation>%1 paused</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="63"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="65"/>
<source>ongoing_call_or_meeting</source>
<extracomment>&quot;%1 en cours&quot;</extracomment>
<translation>Ongoing %1</translation>

View file

@ -820,25 +820,25 @@
<context>
<name>CallListView</name>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="54"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="56"/>
<source>meeting</source>
<extracomment>&quot;Réunion</extracomment>
<translation>Réunion</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="56"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="58"/>
<source>call</source>
<extracomment>&quot;Appel&quot;</extracomment>
<translation>Appel</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="61"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="63"/>
<source>paused_call_or_meeting</source>
<extracomment>&quot;%1 en pause&quot;</extracomment>
<translation>%1 en pause</translation>
</message>
<message>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="63"/>
<location filename="../../view/Control/Display/Call/CallListView.qml" line="65"/>
<source>ongoing_call_or_meeting</source>
<extracomment>&quot;%1 en cours&quot;</extracomment>
<translation>%1 en cours</translation>

View file

@ -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)

View file

@ -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)