File: gwcontactproperties.cpp

package info (click to toggle)
kopete 4%3A17.08.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 38,864 kB
  • sloc: cpp: 348,298; ansic: 13,983; xml: 1,775; lex: 1,735; python: 421; sh: 271; perl: 126; ruby: 28; makefile: 18
file content (134 lines) | stat: -rw-r--r-- 4,500 bytes parent folder | download | duplicates (2)
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
/*
    Kopete Groupwise Protocol
    gwcontactproperties.cpp - dialog showing a contact's server side properties

    Copyright (c) 2006,2007 Novell, Inc	 	 	 http://www.opensuse.org
    Copyright (c) 2004      SUSE Linux AG	 	 http://www.suse.com
    
    Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
 
    *************************************************************************
    *                                                                       *
    * This library 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 "gwcontactproperties.h"
#include <qclipboard.h>
#include <q3header.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qmap.h>
#include <QMenu>
#include <QHeaderView>
#include <QTreeWidget>

#include <kdebug.h>
#include <klocale.h>
#include <kopeteglobal.h>
#include <kopeteonlinestatus.h>
#include <kopetemetacontact.h>
#include <kopeteuiglobal.h>
#include <kaction.h>
#include <kstandardaction.h>

#include "gwcontact.h"
#include "gwprotocol.h"

GroupWiseContactProperties::GroupWiseContactProperties( GroupWiseContact * contact, QWidget *parent )
 : QObject(parent)
{
	init();
	// set up the contents of the props widget
	m_ui.userId->setText( contact->contactId() );
	m_ui.status->setText( contact->onlineStatus().description() );
	m_ui.displayName->setText( contact->metaContact()->displayName() );
	m_ui.firstName->setText( contact->property( Kopete::Global::Properties::self()->firstName() ).value().toString() );
	m_ui.lastName->setText( contact->property( Kopete::Global::Properties::self()->lastName() ).value().toString() );
	
	setupProperties( contact->serverProperties() );
	m_dialog->show();
}

GroupWiseContactProperties::GroupWiseContactProperties( GroupWise::ContactDetails cd, QWidget *parent )
 : QObject(parent)
{
	init();
	// set up the contents of the props widget
	m_ui.userId->setText( GroupWiseProtocol::protocol()->dnToDotted( cd.dn ) );
	m_ui.status->setText( GroupWiseProtocol::protocol()->gwStatusToKOS( cd.status ).description() );
	m_ui.displayName->setText( cd.fullName.isEmpty() ? ( cd.givenName + ' ' + cd.surname ) : cd.fullName );
	m_ui.firstName->setText( cd.givenName );
	m_ui.lastName->setText( cd.surname );

	setupProperties( cd.properties );

	m_dialog->show();
}

GroupWiseContactProperties::~GroupWiseContactProperties()
{
}

void GroupWiseContactProperties::init()
{
	m_dialog = new KDialog( qobject_cast<QWidget*>( parent() ));
	m_dialog->setCaption(i18n( "Contact Properties" ));
	m_dialog->setButtons(KDialog::Ok);
	m_dialog->setDefaultButton(KDialog::Ok);
	m_dialog->setModal(false);
	QWidget * wid = new QWidget( m_dialog );
	m_dialog->setMainWidget( wid );
	m_ui.setupUi( wid );
	m_copyAction = KStandardAction::copy( this, SLOT(copy()), 0 );
	m_ui.propsView->addAction( m_copyAction );
}

void GroupWiseContactProperties::setupProperties( QMap< QString, QVariant > serverProps )
{
	m_ui.propsView->header()->hide();
	QMapIterator< QString, QVariant > i( serverProps );
	while ( i.hasNext() )
	{
		i.next();
		QString key = i.key();
		kDebug() << " adding property: " << key << ", " << i.value();
		QString localised;
		if ( key == "telephoneNumber" )
			localised = i18n( "Telephone Number" );
		else if ( key == "OU" )
			localised = i18n( "Department" );
		else if ( key == "L" )
			localised = i18n( "Location" );
		else if ( key == "mailstop" )
			localised = i18n( "Mailstop" );
		else if ( key == "personalTitle" )
			localised = i18n( "Personal Title" );
		else if ( key == "title" )
			localised = i18n( "Title" );
		else if ( key == "Internet EMail Address" )
			localised = i18n( "Email Address" );
		else
			localised = key;

		QTreeWidgetItem * item = new QTreeWidgetItem( m_ui.propsView, 0 );
		item->setText( 0, localised );
		item->setText( 1, i.value().toString() );
	}
}

void GroupWiseContactProperties::copy()
{
	kDebug() ;
	QList<QTreeWidgetItem *> selection = m_ui.propsView->selectedItems();
	if ( !selection.isEmpty() )
	{
		QClipboard *cb = QApplication::clipboard();
		cb->setText( selection.first()->text( 1 ) );
	}
}
#include "gwcontactproperties.moc"