2
Kopete Groupwise Protocol
3
gwcontactproperties.cpp - dialog showing a contact's server side properties
5
Copyright (c) 2006,2007 Novell, Inc http://www.opensuse.org
6
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
8
Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
10
*************************************************************************
12
* This library is free software; you can redistribute it and/or *
13
* modify it under the terms of the GNU General Public *
14
* License as published by the Free Software Foundation; either *
15
* version 2 of the License, or (at your option) any later version. *
17
*************************************************************************
20
#include "gwcontactproperties.h"
21
#include <qclipboard.h>
24
#include <qlineedit.h>
25
#include <k3listview.h>
28
#include <QHeaderView>
29
#include <QTreeWidget>
33
#include <kopeteglobal.h>
34
#include <kopeteonlinestatus.h>
35
#include <kopetemetacontact.h>
36
#include <kopeteuiglobal.h>
38
#include <kstandardaction.h>
40
#include "gwcontact.h"
41
#include "gwprotocol.h"
43
GroupWiseContactProperties::GroupWiseContactProperties( GroupWiseContact * contact, QWidget *parent )
47
// set up the contents of the props widget
48
m_ui.userId->setText( contact->contactId() );
49
m_ui.status->setText( contact->onlineStatus().description() );
50
m_ui.displayName->setText( contact->metaContact()->displayName() );
51
m_ui.firstName->setText( contact->property( Kopete::Global::Properties::self()->firstName() ).value().toString() );
52
m_ui.lastName->setText( contact->property( Kopete::Global::Properties::self()->lastName() ).value().toString() );
54
setupProperties( contact->serverProperties() );
58
GroupWiseContactProperties::GroupWiseContactProperties( GroupWise::ContactDetails cd, QWidget *parent )
62
// set up the contents of the props widget
63
m_ui.userId->setText( GroupWiseProtocol::protocol()->dnToDotted( cd.dn ) );
64
m_ui.status->setText( GroupWiseProtocol::protocol()->gwStatusToKOS( cd.status ).description() );
65
m_ui.displayName->setText( cd.fullName.isEmpty() ? ( cd.givenName + ' ' + cd.surname ) : cd.fullName );
66
m_ui.firstName->setText( cd.givenName );
67
m_ui.lastName->setText( cd.surname );
69
setupProperties( cd.properties );
74
GroupWiseContactProperties::~GroupWiseContactProperties()
78
void GroupWiseContactProperties::init()
80
m_dialog = new KDialog( qobject_cast<QWidget*>( parent() ));
81
m_dialog->setCaption(i18n( "Contact Properties" ));
82
m_dialog->setButtons(KDialog::Ok);
83
m_dialog->setDefaultButton(KDialog::Ok);
84
m_dialog->setModal(false);
85
QWidget * wid = new QWidget( m_dialog );
86
m_dialog->setMainWidget( wid );
88
m_copyAction = KStandardAction::copy( this, SLOT(copy()), 0 );
89
m_ui.propsView->addAction( m_copyAction );
92
void GroupWiseContactProperties::setupProperties( QMap< QString, QVariant > serverProps )
94
m_ui.propsView->header()->hide();
95
QMapIterator< QString, QVariant > i( serverProps );
99
QString key = i.key();
100
kDebug() << " adding property: " << key << ", " << i.value();
102
if ( key == "telephoneNumber" )
103
localised = i18n( "Telephone Number" );
104
else if ( key == "OU" )
105
localised = i18n( "Department" );
106
else if ( key == "L" )
107
localised = i18n( "Location" );
108
else if ( key == "mailstop" )
109
localised = i18n( "Mailstop" );
110
else if ( key == "personalTitle" )
111
localised = i18n( "Personal Title" );
112
else if ( key == "title" )
113
localised = i18n( "Title" );
114
else if ( key == "Internet EMail Address" )
115
localised = i18n( "Email Address" );
119
QTreeWidgetItem * item = new QTreeWidgetItem( m_ui.propsView, 0 );
120
item->setText( 0, localised );
121
item->setText( 1, i.value().toString() );
125
void GroupWiseContactProperties::copy()
128
QList<QTreeWidgetItem *> selection = m_ui.propsView->selectedItems();
129
if ( !selection.isEmpty() )
131
QClipboard *cb = QApplication::clipboard();
132
cb->setText( selection.first()->text( 1 ) );
135
#include "gwcontactproperties.moc"