[kopete-devel] "patch"-proposal for kopetechatsession.cpp: chat-members-list-sorting by weight & nickName

View: New views
1 Messages — Rating Filter:   Alert me  

[kopete-devel] "patch"-proposal for kopetechatsession.cpp: chat-members-list-sorting by weight & nickName

by Bugzilla from folkyvolk@gmx.de :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am writing a new IRC Plugin for Kopete. Until now, the chat-members list is
not sorted. That is no fun for group chats.

I propose the following (tested by me) solution for kopetechatsession.cpp:

Add a new method to the private class KMMPrivate, which inserts contacts at
the right position (feel free to optimize this):

        void addContact(Kopete::Contact *contact)
        {
                QMutableListIterator<Kopete::Contact *> it(mContactList);
                Kopete::Contact *c;
                bool inserted = false;
                while (it.hasNext())
                {
                        c = it.next();
                        //order by weight and then lexically
                        if ((contact->onlineStatus().weight()>c->onlineStatus().weight())
                                || (contact->onlineStatus().weight()==c->onlineStatus().weight()
                                && contact->nickName().compare(c->nickName(),Qt::CaseInsensitive)<=0))
                        {
                                it.previous();
                                it.insert(contact);
                                inserted = true;
                                break;
                        }
                }
                if (!inserted)
                        mContactList.append(contact);
        }

and replace the 2 occurences of d->mContactList.append(...) in
Chatsession-Class by using this method.

I know that this is not the most efficient method for inserting, but in the
other case I would have to use a better Collection-Structure like QMap for
the members. Also no headers have to be modified.


Another problem: the "myself" contact is always on top in a chatsession-view.
I don't like that behaviour. In an 2-person chat, it does not matter, but is
there a reason why put it on top in a group chat? I added "myself" to the
membersList in the Chatsession-Constructor (by using my new method), and
modified the ChatMembersListModel-Implementation, so that it does no
workaround anymore, that also beautifies it's code.


And a third problem: adding contacts to a chatsession with displayed view and
many people is VERY slow, I think because of the "reset()"-Call in the
ChatMembersListModel Implementation on every "addmember"-call.

I am not subscribed to this mailing list, but I really like to hear, if
someone would care to submit my proposed changes. I already have an svn
account. If I should submit by myself, please tell me, but I currently
compile against 4.3.1.

best regards,
Volker
_______________________________________________
kopete-devel mailing list
kopete-devel@...
https://mail.kde.org/mailman/listinfo/kopete-devel