83
83
Kopete::StatusMessage statusMessage;
84
84
KToggleAction* toggleAlwaysVisibleAction;
86
Kopete::Contact::NameType preferredNameType;
91
Kopete::Contact::NameType Kopete::Contact::nameTypeFromString(const QString &nameType)
93
if (nameType == "nickName")
94
return Kopete::Contact::NickName;
95
else if (nameType == "customName")
96
return Kopete::Contact::CustomName;
97
else if (nameType == "formattedName")
98
return Kopete::Contact::FormattedName;
99
else if (nameType == "contactId")
100
return Kopete::Contact::ContactId;
101
else // fallback to custom name
102
return Kopete::Contact::CustomName;
106
const QString Kopete::Contact::nameTypeToString(Kopete::Contact::NameType nameType)
110
case Kopete::Contact::NickName:
111
return QString("nickName");
112
case Kopete::Contact::FormattedName:
113
return QString("formattedName");
114
case Kopete::Contact::ContactId:
115
return QString("contactId");
116
case Kopete::Contact::CustomName:
117
default: // fallback to custom name
118
return QString("customName");
87
122
Contact::Contact( Account *account, const QString &contactId,
88
123
MetaContact *parent, const QString &icon )
89
124
: ContactListElement( parent ), d(new Private())
98
133
d->account = account;
136
d->preferredNameType = Kopete::Contact::CustomName;
137
d->oldName = displayName();
139
connect( this, SIGNAL(propertyChanged(Kopete::PropertyContainer*,QString,QVariant,QVariant)),
140
this, SLOT(slotPropertyChanged(Kopete::PropertyContainer*,QString,QVariant,QVariant)) );
102
142
bool duplicate = false;
103
143
// If can happend that a MetaContact may be used without a account
243
283
KMenu *menu = new KMenu();
245
285
QString titleText;
246
const QString nick = nickName();
286
const QString nick = displayName();
247
287
if( nick == contactId() )
248
288
titleText = QString::fromLatin1( "%1 (%2)" ).arg( contactId(), onlineStatus().description() );
600
640
QString(QUrl::toPercentEncoding( contactId() )) );
603
// TODO: the nickname should be a configurable properties, like others. -Olivier
604
QString nick = nickName();
643
QString nick = displayName();
605
644
if ( nick == contactId() )
607
646
tip = i18nc( "@label:textbox %3 is contact-display-name, %1 is its status",
816
855
return contactId();
858
void Kopete::Contact::setCustomName( const QString &name )
860
setProperty( Kopete::Global::Properties::self()->customName(), name );
863
QString Kopete::Contact::customName() const
865
const QString name = property( Kopete::Global::Properties::self()->customName() ).value().toString();
819
871
void Kopete::Contact::setPhoto(const QString &photoPath)
821
873
setProperty( Kopete::Global::Properties::self()->photo(), photoPath );
876
void Kopete::Contact::slotPropertyChanged(Kopete::PropertyContainer *, const QString &key,
877
const QVariant &, const QVariant &)
879
if (key != Kopete::Global::Properties::self()->customName().key()
880
&& key != Kopete::Global::Properties::self()->fullName().key()
881
&& key != Kopete::Global::Properties::self()->firstName().key()
882
&& key != Kopete::Global::Properties::self()->lastName().key()
883
&& key != Kopete::Global::Properties::self()->nickName().key())
886
const QString oldName = d->oldName;
887
const QString newName = displayName();
888
if (oldName != newName) {
889
d->oldName = newName;
890
emit displayNameChanged(oldName, newName);
894
void Kopete::Contact::setPreferredNameType(Kopete::Contact::NameType preferredNameType)
896
if (d->preferredNameType != preferredNameType)
898
const QString oldName = displayName();
899
d->preferredNameType = preferredNameType;
900
const QString newName = displayName();
901
if (oldName != newName) {
902
d->oldName = newName;
903
emit displayNameChanged(oldName, newName);
908
Kopete::Contact::NameType Kopete::Contact::preferredNameType() const
910
return d->preferredNameType;
913
QString Kopete::Contact::displayName() const
916
switch (d->preferredNameType)
922
name = formattedName();
928
default: // fallback to custom name
825
939
} //END namespace Kopete