summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircchannellist.cpp
blob: 4e13deea577b072e0a641f7cf080e6e99514267f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <qpe/resource.h>
#include "ircchannellist.h"

IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) {
    m_channel = channel;
}

void IRCChannelList::update() {
    QPixmap op = Resource::loadPixmap("opieirc/op");
    QPixmap hop = Resource::loadPixmap("opieirc/hop");
    QPixmap voice = Resource::loadPixmap("opieirc/voice");
    QListIterator<IRCChannelPerson> it = m_channel->people();
    clear();
    for (; it.current(); ++it) {
        IRCChannelPerson *person = it.current();
        if (person->flags & PERSON_FLAG_OP) {
            insertItem(op, person->person->nick());
        } else if (person->flags & PERSON_FLAG_HALFOP) {
            insertItem(op, person->person->nick());
        } else if (person->flags & PERSON_FLAG_VOICE) {
            insertItem(voice, person->person->nick());
        } else {
            insertItem(person->person->nick());
        }
    }
    sort();
}


bool IRCChannelList::hasPerson(QString nick) {
    for (unsigned int i=0; i<count(); i++) {
        if (text(i) == nick)
            return TRUE;
    }
    return FALSE;
}

bool IRCChannelList::removePerson(QString nick) {
    for (unsigned int i=0; i<count(); i++) {
        if (text(i) == nick){
            removeItem(i);
            return TRUE;
            }
    }
    return FALSE;
}