Fix participant Device

This commit is contained in:
Julien Wadel 2021-08-25 18:07:20 +02:00
parent d444375ea4
commit de5322327e
5 changed files with 27 additions and 4 deletions

View file

@ -42,6 +42,23 @@ int ParticipantDeviceListModel::rowCount (const QModelIndex &index) const{
return mList.count();
}
int ParticipantDeviceListModel::count(){
return mList.count();
}
void ParticipantDeviceListModel::updateDevices(std::shared_ptr<linphone::Participant> participant){
std::list<std::shared_ptr<linphone::ParticipantDevice>> devices = participant->getDevices() ;
beginResetModel();
mList.clear();
for(auto device : devices){
auto deviceModel = std::make_shared<ParticipantDeviceModel>(device);
connect(this, &ParticipantDeviceListModel::securityLevelChanged, deviceModel.get(), &ParticipantDeviceModel::onSecurityLevelChanged);
mList << deviceModel;
}
endResetModel();
emit layoutChanged();
}
QHash<int, QByteArray> ParticipantDeviceListModel::roleNames () const {
QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$participantDevice";

View file

@ -38,6 +38,9 @@ public:
ParticipantDeviceListModel (std::shared_ptr<linphone::Participant> participant, QObject *parent = nullptr);
int rowCount (const QModelIndex &index = QModelIndex()) const override;
int count();
void updateDevices(std::shared_ptr<linphone::Participant> participant);
virtual QHash<int, QByteArray> roleNames () const override;
virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;

View file

@ -170,7 +170,6 @@ bool ParticipantListModel::removeRows (int row, int count, const QModelIndex &pa
void ParticipantListModel::updateParticipants () {
if( mChatRoomModel) {
bool changed = false;
CoreManager *coreManager = CoreManager::getInstance();
auto dbParticipants = mChatRoomModel->getChatRoom()->getParticipants();
auto me = mChatRoomModel->getChatRoom()->getMe();
dbParticipants.push_front(me);

View file

@ -52,8 +52,12 @@ int ParticipantModel::getSecurityLevel() const{
return (mParticipant ? (int)mParticipant->getSecurityLevel() : 0);
}
int ParticipantModel::getDeviceCount() const{
return (mParticipant ? mParticipant->getDevices().size() : 0);
int ParticipantModel::getDeviceCount(){
int count = (mParticipant ? mParticipant->getDevices().size() : 0);
if(mParticipant && count != mParticipantDevices->count()){
mParticipantDevices->updateDevices(mParticipant);
}
return count;
}
bool ParticipantModel::getInviting() const{

View file

@ -55,7 +55,7 @@ public:
bool getAdminStatus() const;
bool isFocus() const;
int getSecurityLevel() const;
int getDeviceCount() const;
int getDeviceCount();
bool getInviting() const;
void setSipAddress(const QString& address);