36 #include "identitylistview.h"
38 #include "identitydrag.h"
39 #include <libkpimidentities/identitymanager.h>
42 #include <tdelocale.h>
43 #include <kiconloader.h>
55 IdentityListViewItem::IdentityListViewItem( IdentityListView * parent,
const KPIM::Identity & ident )
56 : TDEListViewItem( parent ), mUOID( ident.uoid() ) {
60 IdentityListViewItem::IdentityListViewItem( IdentityListView * parent, TQListViewItem * after,
const KPIM::Identity & ident )
61 : TDEListViewItem( parent, after ), mUOID( ident.uoid() ) {
65 KPIM::Identity & IdentityListViewItem::identity()
const {
66 KPIM::IdentityManager * im = kmkernel->identityManager();
68 return im->modifyIdentityForUoid( uoid() );
71 void IdentityListViewItem::setIdentity(
const KPIM::Identity & ident ) {
76 void IdentityListViewItem::redisplay() {
80 void IdentityListViewItem::init(
const KPIM::Identity & ident ) {
81 if ( ident.isDefault() )
83 setText( 0, i18n(
"%1: identity name. Used in the config "
84 "dialog, section Identity, to indicate the "
85 "default identity",
"%1 (Default)")
86 .arg( ident.identityName() ) );
88 setText( 0, ident.identityName() );
89 setText( 1, ident.fullEmailAddr() );
98 IdentityListView::IdentityListView( TQWidget * parent,
const char * name )
99 : TDEListView( parent, name )
101 setFullWidth(
true );
102 setDragEnabled(
true );
103 setAcceptDrops(
true );
104 setDropVisualizer(
true );
105 addColumn( i18n(
"Identity Name") );
106 addColumn( i18n(
"Email Address") );
107 setRootIsDecorated(
false );
109 setItemsRenameable(
true );
111 setItemsMovable(
false );
112 setAllColumnsShowFocus(
true );
114 setSelectionModeExt( Single );
117 void IdentityListView::rename( TQListViewItem * i,
int col ) {
118 if ( col == 0 && isRenameable( col ) ) {
119 IdentityListViewItem * item =
dynamic_cast<IdentityListViewItem*
>( i );
121 KPIM::Identity & ident = item->identity();
122 if ( ident.isDefault() )
123 item->setText( 0, ident.identityName() );
126 TDEListView::rename( i, col );
129 bool IdentityListView::acceptDrag( TQDropEvent * e )
const {
131 return e->source() != viewport() && IdentityDrag::canDecode( e );
134 TQDragObject * IdentityListView::dragObject() {
135 IdentityListViewItem * item =
dynamic_cast<IdentityListViewItem*
>( currentItem() );
136 if ( !item )
return 0;
138 IdentityDrag * drag =
new IdentityDrag( item->identity(), viewport() );
139 drag->setPixmap( SmallIcon(
"identity") );
146 #include "identitylistview.moc"