mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Optimization of Conference list loading.
This commit is contained in:
parent
8a1a3c4542
commit
ddc4143885
8 changed files with 51 additions and 12 deletions
|
|
@ -66,6 +66,11 @@ public:
|
|||
mList << item;
|
||||
endInsertRows();
|
||||
}
|
||||
virtual void add(QList<T> items){
|
||||
beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1);
|
||||
mList << items;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
virtual void prepend(T item){
|
||||
beginInsertRows(QModelIndex(), 0, 0);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ public:
|
|||
void add(QSharedPointer<T> item){
|
||||
ProxyAbstractListModel<QSharedPointer<QObject>>::add(item.template objectCast<QObject>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void add(QList<QSharedPointer<T>> items){
|
||||
beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1);
|
||||
for(auto i : items)
|
||||
mList << i.template objectCast<QObject>();
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void prepend(QSharedPointer<T> item){
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,25 +39,36 @@
|
|||
|
||||
ConferenceInfoListModel::ConferenceInfoListModel (QObject *parent) : ProxyListModel(parent) {
|
||||
auto conferenceInfos = CoreManager::getInstance()->getCore()->getConferenceInformationList();
|
||||
QList<QSharedPointer<ConferenceInfoModel> > 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<linphone::ConferenceInfo> & conferenceInfo, const bool& sendEvents){
|
||||
QSharedPointer<ConferenceInfoModel> ConferenceInfoListModel::build(const std::shared_ptr<linphone::ConferenceInfo> & conferenceInfo) const{
|
||||
auto me = CoreManager::getInstance()->getCore()->getDefaultAccount()->getParams()->getIdentityAddress();
|
||||
std::list<std::shared_ptr<linphone::Address>> participants = conferenceInfo->getParticipants();
|
||||
bool haveMe = conferenceInfo->getOrganizer()->weakEqual(me);
|
||||
if(!haveMe)
|
||||
haveMe = (std::find_if(participants.begin(), participants.end(), [me](const std::shared_ptr<linphone::Address>& 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<linphone::Address>& address){
|
||||
return me->weakEqual(address);
|
||||
}) != participants.end());
|
||||
if(haveMe)
|
||||
return ConferenceInfoModel::create( conferenceInfo );
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ConferenceInfoListModel::add(const std::shared_ptr<linphone::ConferenceInfo> & conferenceInfo, const bool& sendEvents){
|
||||
auto item = build(conferenceInfo);
|
||||
if( item)
|
||||
ProxyListModel::add(item);
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ConferenceInfoListModel::roleNames () const{
|
||||
|
|
|
|||
|
|
@ -30,13 +30,17 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
class ConferenceInfoModel;
|
||||
|
||||
class ConferenceInfoListModel : public ProxyListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConferenceInfoListModel (QObject *parent = Q_NULLPTR);
|
||||
QSharedPointer<ConferenceInfoModel> build(const std::shared_ptr<linphone::ConferenceInfo> & conferenceInfo) const;
|
||||
void add(const std::shared_ptr<linphone::ConferenceInfo> & conferenceInfo, const bool& sendEvents = true);
|
||||
|
||||
|
||||
QHash<int, QByteArray> roleNames () const override;
|
||||
virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue