~phablet-team/telephony-service/qml-start-chat

« back to all changes in this revision

Viewing changes to libtelephonyservice/chatentry.cpp

  • Committer: Tiago Salem Herrmann
  • Date: 2017-02-15 21:17:33 UTC
  • Revision ID: tiago.herrmann@canonical.com-20170215211733-1q5emjwrajx5byp1
Add ParticipantsModel

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
    return mAutoRequest;
266
266
}
267
267
 
 
268
QList<Participant*> ChatEntry::allParticipants() const
 
269
{
 
270
    return mParticipants;
 
271
}
 
272
 
268
273
bool ChatEntry::canUpdateConfiguration() const
269
274
{
270
275
    return mCanUpdateConfiguration;
575
580
 
576
581
    // FIXME: check how to handle multiple channels in a better way,
577
582
    // for now, use the info from the last available channel
578
 
    Q_FOREACH(Participant *participant, mParticipants) {
579
 
        participant->deleteLater();
580
 
    }
581
583
    clearParticipants();
582
584
 
583
585
    onGroupMembersChanged(channel->groupContacts(false),
669
671
void ChatEntry::clearParticipants()
670
672
{
671
673
    Q_FOREACH(Participant *participant, mParticipants) {
 
674
        Q_EMIT participantRemoved(participant);
672
675
        participant->deleteLater();
673
676
    }
674
677
    Q_FOREACH(Participant *participant, mLocalPendingParticipants) {
 
678
        Q_EMIT participantRemoved(participant);
675
679
        participant->deleteLater();
676
680
    }
677
681
    Q_FOREACH(Participant *participant, mRemotePendingParticipants) {
 
682
        Q_EMIT participantRemoved(participant);
678
683
        participant->deleteLater();
679
684
    }
680
685
    mParticipants.clear();
681
686
    mLocalPendingParticipants.clear();
682
687
    mRemotePendingParticipants.clear();
 
688
    mRolesMap.clear();
683
689
    mSelfContactRoles = 0;
684
690
}
685
691
 
689
695
    Q_FOREACH(Tp::ContactPtr contact, removed) {
690
696
        Q_FOREACH(Participant *participant, list) {
691
697
            if (account->compareIds(contact->id(), participant->identifier())) {
 
698
                Q_EMIT participantRemoved(participant);
692
699
                participant->deleteLater();
693
700
                list.removeOne(participant);
694
701
                break;
703
710
    // FIXME: check for duplicates?
704
711
    Q_FOREACH(Tp::ContactPtr contact, added) {
705
712
        uint handle = contact->handle().at(0);
706
 
        list << new Participant(contact->id(), mRolesMap[handle], handle, this);
 
713
        Participant* participant = new Participant(contact->id(), mRolesMap[handle], handle, this);
 
714
        Q_EMIT participantAdded(participant);
 
715
        list << participant;
707
716
    }
708
717
}
709
718
 
794
803
        rolesInterface->disconnect(this);
795
804
        rolesInterface = 0;
796
805
    }
 
806
    clearParticipants();
797
807
    Q_EMIT activeChanged();
798
808
    Q_EMIT groupFlagsChanged();
799
809
    Q_EMIT selfContactRolesChanged();