summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/ui/yahooinvitelistimpl.cpp
blob: 594e7a01868b47c81c3c04b5a2bdd6564df94bde (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
    YahooInviteListImpl - conference invitation dialog
    
    Copyright (c) 2004 by Duncan Mac-Vicar P.    <duncan@kde.org>
    
    Kopete    (c) 2002-2004 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "yahooinvitelistimpl.h"

#include <kdebug.h>

#include <tqlistbox.h>
#include <tqlineedit.h>

YahooInviteListImpl::YahooInviteListImpl(TQWidget *parent, const char *name) : YahooInviteListBase(parent,name)
{
	listFriends->setSelectionMode( TQListBox::Extended );
	listInvited->setSelectionMode( TQListBox::Extended );
}

YahooInviteListImpl::~YahooInviteListImpl()
{
}

void YahooInviteListImpl::setRoom( const TQString &room )
{
	kdDebug(14180) << k_funcinfo << "Setting roomname to: " << room << endl;

	m_room = room;
}

void YahooInviteListImpl::fillFriendList( const TQStringList &buddies )
{	
	kdDebug(14180) << k_funcinfo << "Adding friends: " << buddies << endl;

	m_buddyList = buddies;
	updateListBoxes();
}

void YahooInviteListImpl::updateListBoxes()
{
	kdDebug(14180) << k_funcinfo << endl;

	listFriends->clear();
	listInvited->clear();
	listFriends->insertStringList( m_buddyList );
	listFriends->sort();
	listInvited->insertStringList( m_inviteeList );
	listInvited->sort();
}

void YahooInviteListImpl::addInvitees( const TQStringList &invitees )
{
	kdDebug(14180) << k_funcinfo << "Adding invitees: " << invitees << endl;

	for( TQStringList::const_iterator it = invitees.begin(); it != invitees.end(); it++ )
	{
		if( m_inviteeList.find( *it ) == m_inviteeList.end() )
			m_inviteeList.push_back( *it );
		if( m_buddyList.find( *it ) != m_buddyList.end() )
			m_buddyList.remove( *it );
	}

	updateListBoxes();
}

void YahooInviteListImpl::removeInvitees( const TQStringList &invitees )
{
	kdDebug(14180) << k_funcinfo << "Removing invitees: " << invitees << endl;

	for( TQStringList::const_iterator it = invitees.begin(); it != invitees.end(); it++ )
	{
		if( m_buddyList.find( *it ) == m_buddyList.end() )
			m_buddyList.push_back( *it );
		if( m_inviteeList.find( *it ) != m_inviteeList.end() )
			m_inviteeList.remove( *it );
	}

	updateListBoxes();
}

void YahooInviteListImpl::addParticipant( const TQString &p )
{
	m_participants.push_back( p );
}

void YahooInviteListImpl::btnInvite_clicked()
{
	kdDebug(14180) << k_funcinfo << endl;

	if( m_inviteeList.count() )
		emit readyToInvite( m_room, m_inviteeList,m_participants, editMessage->text() );
	TQDialog::accept();
}


void YahooInviteListImpl::btnCancel_clicked()
{
	kdDebug(14180) << k_funcinfo << endl;

	TQDialog::reject();
}


void YahooInviteListImpl::btnAddCustom_clicked()
{
	kdDebug(14180) << k_funcinfo << endl;

	TQString userId;
	userId = editBuddyAdd->text();
	if( userId.isEmpty() )
		return;
	
	addInvitees( TQStringList(userId) );
	editBuddyAdd->clear();
}


void YahooInviteListImpl::btnRemove_clicked()
{
	kdDebug(14180) << k_funcinfo << endl;

	TQStringList buddies;
	for( uint i=0; i<listInvited->count(); i++ )
	{
		if (listInvited->isSelected(i))
		{
			buddies.push_back( listInvited->text(i) );
		}
	}
	removeInvitees( buddies );
}


void YahooInviteListImpl::btnAdd_clicked()
{
	kdDebug(14180) << k_funcinfo << endl;

	TQStringList buddies;
	for( uint i=0; i<listFriends->count(); i++ )
	{
		if (listFriends->isSelected(i))
		{
			buddies.push_back( listFriends->text(i) );
		}
	}
	addInvitees( buddies );
}


#include "yahooinvitelistimpl.moc"