~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/groupwise/ui/gwcontactproperties.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Kopete Groupwise Protocol
 
3
    gwcontactproperties.cpp - dialog showing a contact's server side properties
 
4
 
 
5
    Copyright (c) 2006,2007 Novell, Inc                  http://www.opensuse.org
 
6
    Copyright (c) 2004      SUSE Linux AG                http://www.suse.com
 
7
    
 
8
    Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
 
9
 
 
10
    *************************************************************************
 
11
    *                                                                       *
 
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.      *
 
16
    *                                                                       *
 
17
    *************************************************************************
 
18
*/
 
19
 
 
20
#include "gwcontactproperties.h"
 
21
#include <qclipboard.h>
 
22
#include <q3header.h>
 
23
#include <qlabel.h>
 
24
#include <qlineedit.h>
 
25
#include <k3listview.h>
 
26
#include <qmap.h>
 
27
#include <QMenu>
 
28
#include <QHeaderView>
 
29
#include <QTreeWidget>
 
30
 
 
31
#include <kdebug.h>
 
32
#include <klocale.h>
 
33
#include <kopeteglobal.h>
 
34
#include <kopeteonlinestatus.h>
 
35
#include <kopetemetacontact.h>
 
36
#include <kopeteuiglobal.h>
 
37
#include <kaction.h>
 
38
#include <kstandardaction.h>
 
39
 
 
40
#include "gwcontact.h"
 
41
#include "gwprotocol.h"
 
42
 
 
43
GroupWiseContactProperties::GroupWiseContactProperties( GroupWiseContact * contact, QWidget *parent )
 
44
 : QObject(parent)
 
45
{
 
46
        init();
 
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() );
 
53
        
 
54
        setupProperties( contact->serverProperties() );
 
55
        m_dialog->show();
 
56
}
 
57
 
 
58
GroupWiseContactProperties::GroupWiseContactProperties( GroupWise::ContactDetails cd, QWidget *parent )
 
59
 : QObject(parent)
 
60
{
 
61
        init();
 
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 );
 
68
 
 
69
        setupProperties( cd.properties );
 
70
 
 
71
        m_dialog->show();
 
72
}
 
73
 
 
74
GroupWiseContactProperties::~GroupWiseContactProperties()
 
75
{
 
76
}
 
77
 
 
78
void GroupWiseContactProperties::init()
 
79
{
 
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 );
 
87
        m_ui.setupUi( wid );
 
88
        m_copyAction = KStandardAction::copy( this, SLOT(copy()), 0 );
 
89
        m_ui.propsView->addAction( m_copyAction );
 
90
}
 
91
 
 
92
void GroupWiseContactProperties::setupProperties( QMap< QString, QVariant > serverProps )
 
93
{
 
94
        m_ui.propsView->header()->hide();
 
95
        QMapIterator< QString, QVariant > i( serverProps );
 
96
        while ( i.hasNext() )
 
97
        {
 
98
                i.next();
 
99
                QString key = i.key();
 
100
                kDebug() << " adding property: " << key << ", " << i.value();
 
101
                QString localised;
 
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" );
 
116
                else
 
117
                        localised = key;
 
118
 
 
119
                QTreeWidgetItem * item = new QTreeWidgetItem( m_ui.propsView, 0 );
 
120
                item->setText( 0, localised );
 
121
                item->setText( 1, i.value().toString() );
 
122
        }
 
123
}
 
124
 
 
125
void GroupWiseContactProperties::copy()
 
126
{
 
127
        kDebug() ;
 
128
        QList<QTreeWidgetItem *> selection = m_ui.propsView->selectedItems();
 
129
        if ( !selection.isEmpty() )
 
130
        {
 
131
                QClipboard *cb = QApplication::clipboard();
 
132
                cb->setText( selection.first()->text( 1 ) );
 
133
        }
 
134
}
 
135
#include "gwcontactproperties.moc"