diff --git a/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp b/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp index 92ccfa493..55e72b270 100644 --- a/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp +++ b/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp @@ -66,6 +66,11 @@ public: mList << item; endInsertRows(); } + virtual void add(QList items){ + beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1); + mList << items; + endInsertRows(); + } virtual void prepend(T item){ beginInsertRows(QModelIndex(), 0, 0); diff --git a/linphone-app/src/app/proxyModel/ProxyListModel.hpp b/linphone-app/src/app/proxyModel/ProxyListModel.hpp index fb4c83380..704daf38d 100644 --- a/linphone-app/src/app/proxyModel/ProxyListModel.hpp +++ b/linphone-app/src/app/proxyModel/ProxyListModel.hpp @@ -62,6 +62,14 @@ public: void add(QSharedPointer item){ ProxyAbstractListModel>::add(item.template objectCast()); } + + template + void add(QList> items){ + beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1); + for(auto i : items) + mList << i.template objectCast(); + endInsertRows(); + } template void prepend(QSharedPointer item){ diff --git a/linphone-app/src/app/proxyModel/SortFilterProxyModel.cpp b/linphone-app/src/app/proxyModel/SortFilterProxyModel.cpp index 782bcea9a..f60c5149f 100644 --- a/linphone-app/src/app/proxyModel/SortFilterProxyModel.cpp +++ b/linphone-app/src/app/proxyModel/SortFilterProxyModel.cpp @@ -39,6 +39,10 @@ QVariant SortFilterProxyModel::getAt(const int& atIndex) const { return sourceModel()->data(mapToSource(modelIndex), 0); } +void SortFilterProxyModel::setSortOrder(const Qt::SortOrder& order){ + sort(0, order); +} + void SortFilterProxyModel::setFilterType (int filterType) { if (getFilterType() != filterType) { mFilterType = filterType; diff --git a/linphone-app/src/app/proxyModel/SortFilterProxyModel.hpp b/linphone-app/src/app/proxyModel/SortFilterProxyModel.hpp index 700060ef1..518593faa 100644 --- a/linphone-app/src/app/proxyModel/SortFilterProxyModel.hpp +++ b/linphone-app/src/app/proxyModel/SortFilterProxyModel.hpp @@ -34,6 +34,7 @@ public: virtual int getCount() const; virtual int getFilterType () const; Q_INVOKABLE QVariant getAt(const int& index) const; + Q_INVOKABLE void setSortOrder(const Qt::SortOrder& order); virtual void setFilterType (int filterType); diff --git a/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.cpp b/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.cpp index 24d3ae01c..5e88f7075 100644 --- a/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.cpp +++ b/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.cpp @@ -39,25 +39,36 @@ ConferenceInfoListModel::ConferenceInfoListModel (QObject *parent) : ProxyListModel(parent) { auto conferenceInfos = CoreManager::getInstance()->getCore()->getConferenceInformationList(); + QList > items; for(auto conferenceInfo : conferenceInfos){ - add(conferenceInfo, false); + auto item = build(conferenceInfo); + if(item) + items << item; } + if(items.size() > 0) + ProxyListModel::add(items); } // ----------------------------------------------------------------------------- -void ConferenceInfoListModel::add(const std::shared_ptr & conferenceInfo, const bool& sendEvents){ +QSharedPointer ConferenceInfoListModel::build(const std::shared_ptr & conferenceInfo) const{ auto me = CoreManager::getInstance()->getCore()->getDefaultAccount()->getParams()->getIdentityAddress(); std::list> participants = conferenceInfo->getParticipants(); - bool haveMe = conferenceInfo->getOrganizer()->weakEqual(me); - if(!haveMe) - haveMe = (std::find_if(participants.begin(), participants.end(), [me](const std::shared_ptr& address){ - return me->weakEqual(address); - }) != participants.end()); - if(haveMe){ - auto conferenceInfoModel = ConferenceInfoModel::create( conferenceInfo ); - ProxyListModel::add(conferenceInfoModel); - } + bool haveMe = conferenceInfo->getOrganizer()->weakEqual(me); + if(!haveMe) + haveMe = (std::find_if(participants.begin(), participants.end(), [me](const std::shared_ptr& address){ + return me->weakEqual(address); + }) != participants.end()); + if(haveMe) + return ConferenceInfoModel::create( conferenceInfo ); + else + return nullptr; +} + +void ConferenceInfoListModel::add(const std::shared_ptr & conferenceInfo, const bool& sendEvents){ + auto item = build(conferenceInfo); + if( item) + ProxyListModel::add(item); } QHash ConferenceInfoListModel::roleNames () const{ diff --git a/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.hpp b/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.hpp index 3cf822144..f4918f218 100644 --- a/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.hpp +++ b/linphone-app/src/components/conferenceInfo/ConferenceInfoListModel.hpp @@ -30,13 +30,17 @@ // ============================================================================= +class ConferenceInfoModel; + class ConferenceInfoListModel : public ProxyListModel { Q_OBJECT public: ConferenceInfoListModel (QObject *parent = Q_NULLPTR); + QSharedPointer build(const std::shared_ptr & conferenceInfo) const; void add(const std::shared_ptr & conferenceInfo, const bool& sendEvents = true); + QHash roleNames () const override; virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/linphone-app/ui/modules/Common/View/ScrollableListView.qml b/linphone-app/ui/modules/Common/View/ScrollableListView.qml index 984f0ca0a..9e5b8d7bc 100644 --- a/linphone-app/ui/modules/Common/View/ScrollableListView.qml +++ b/linphone-app/ui/modules/Common/View/ScrollableListView.qml @@ -11,6 +11,8 @@ ListView { property alias verticalScrollPolicy : vScrollBar.policy property alias horizontalScrollPolicy : hScrollBar.policy + property bool fitCacheToContent: true + function getVisibleIndex(checkMax) { var center_x = view.x + view.width / 2 var index = -1 @@ -57,8 +59,10 @@ ListView { contentHeight: height - (hScrollBar.visible?hScrollBar.height:0) spacing: 0 synchronousDrag: true + onContentHeightChanged: { - cacheBuffer= (view.contentHeight > 0 ? view.contentHeight : 0) + if(fitCacheToContent) + cacheBuffer= (view.contentHeight > 0 ? view.contentHeight : 0) } cacheBuffer: height > 0 ? height : 0 // --------------------------------------------------------------------------- diff --git a/linphone-app/ui/views/App/Main/Conferences.qml b/linphone-app/ui/views/App/Main/Conferences.qml index 0eaf70a16..03e8f2198 100644 --- a/linphone-app/ui/views/App/Main/Conferences.qml +++ b/linphone-app/ui/views/App/Main/Conferences.qml @@ -90,6 +90,7 @@ Item{ spacing: 10 highlightFollowsCurrentItem: false + fitCacheToContent: false section { criteria: ViewSection.FullString @@ -100,6 +101,7 @@ Item{ model: ConferenceInfoProxyModel{ id: conferencesProxyModel filterType: mainItem.filterType + onFilterTypeChanged: setSortOrder(filterType == ConferenceInfoProxyModel.Ended ? Qt.AscendingOrder : Qt.DescendingOrder) } // -----------------------------------------------------------------------