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
|
/*
oscarvisibilitydialog.cpp - Visibility Dialog
Copyright (c) 2005 by Roman Jarosz <[email protected]>
Kopete (c) 2005 by the Kopete developers <[email protected]>
*************************************************************************
* *
* 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 "oscarvisibilitydialog.h"
#include <tqstringlist.h>
#include <tqpushbutton.h>
#include <tdelocale.h>
#include "oscarvisibilitybase.h"
#include "client.h"
OscarVisibilityDialog::OscarVisibilityDialog( Client* client, TQWidget* parent )
: KDialogBase( parent, 0, false, i18n( "Add Contacts to Visible or Invisible List" ),
Ok | Cancel ), m_client( client )
{
m_visibilityUI = new OscarVisibilityBase( this );
setMainWidget( m_visibilityUI );
TQObject::connect(m_visibilityUI->visibleAdd, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotAddToVisible()));
TQObject::connect(m_visibilityUI->visibleRemove, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotRemoveFromVisible()));
TQObject::connect(m_visibilityUI->invisibleAdd, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotAddToInvisible()));
TQObject::connect(m_visibilityUI->invisibleRemove, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotRemoveFromInvisible()));
}
void OscarVisibilityDialog::addContacts( const ContactMap& contacts )
{
m_contactMap = contacts;
ContactMap::Iterator it, cEnd = m_contactMap.end();
for ( it = m_contactMap.begin(); it != cEnd; ++it )
m_visibilityUI->contacts->insertItem( it.key() );
}
void OscarVisibilityDialog::addVisibleContacts( const TQStringList& contactList )
{
m_visibilityUI->visibleContacts->insertStringList( contactList );
}
void OscarVisibilityDialog::addInvisibleContacts( const TQStringList& contactList )
{
m_visibilityUI->invisibleContacts->insertStringList( contactList );
}
void OscarVisibilityDialog::slotAddToVisible()
{
TQListBoxItem *itm = m_visibilityUI->contacts->selectedItem();
if ( !itm ) return;
TQString contactId = m_contactMap[itm->text()];
m_visibleListChangesMap[contactId] = Add;
if ( !m_visibilityUI->visibleContacts->findItem( itm->text(), TQt::CaseSensitive | TQt::ExactMatch ) )
m_visibilityUI->visibleContacts->insertItem( itm->text() );
}
void OscarVisibilityDialog::slotRemoveFromVisible()
{
TQListBoxItem *itm = m_visibilityUI->visibleContacts->selectedItem();
if ( !itm ) return;
TQString contactId = m_contactMap[itm->text()];
m_visibleListChangesMap[contactId] = Remove;
int visIdx = m_visibilityUI->visibleContacts->index( itm );
m_visibilityUI->visibleContacts->removeItem( visIdx );
}
void OscarVisibilityDialog::slotAddToInvisible()
{
TQListBoxItem *itm = m_visibilityUI->contacts->selectedItem();
if ( !itm ) return;
TQString contactId = m_contactMap[itm->text()];
m_invisibleListChangesMap[contactId] = Add;
if ( !m_visibilityUI->invisibleContacts->findItem( itm->text(), TQt::CaseSensitive | TQt::ExactMatch ) )
m_visibilityUI->invisibleContacts->insertItem( itm->text() );
}
void OscarVisibilityDialog::slotRemoveFromInvisible()
{
TQListBoxItem *itm = m_visibilityUI->invisibleContacts->selectedItem();
if ( !itm ) return;
TQString contactId = m_contactMap[itm->text()];
m_invisibleListChangesMap[contactId] = Remove;
int visIdx = m_visibilityUI->invisibleContacts->index( itm );
m_visibilityUI->invisibleContacts->removeItem( visIdx );
}
void OscarVisibilityDialog::slotOk()
{
ChangeMap::Iterator it, cEnd = m_visibleListChangesMap.end();
for ( it = m_visibleListChangesMap.begin(); it != cEnd; ++it ) {
m_client->setVisibleTo( it.key(), it.data() );
}
cEnd = m_invisibleListChangesMap.end();
for ( it = m_invisibleListChangesMap.begin(); it != cEnd; ++it ) {
m_client->setInvisibleTo( it.key(), it.data() );
}
KDialogBase::slotOk();
emit closing();
}
void OscarVisibilityDialog::slotCancel()
{
KDialogBase::slotCancel();
emit closing();
}
#include "oscarvisibilitydialog.moc"
|