36
36
txt += QString::fromLatin1( "<b>%1</b>" ).arg( i18n( "Distribution List %1", group.name() ) );
37
37
txt += QLatin1String( "<ul>" );
38
const int groupDataCount( group.dataCount() );
38
const uint groupDataCount( group.dataCount() );
39
39
for ( uint i = 0; i < groupDataCount; ++i ) {
40
40
txt += QLatin1String( "<li>" );
41
41
txt += group.data( i ).name() + QLatin1Char( ' ' );
42
42
txt += QLatin1String( "<em>" );
43
43
txt += group.data( i ).email();
44
txt += QLatin1String("</em></li>" );
44
txt += QLatin1String( "</em></li>" );
46
46
txt += QLatin1String( "</ul>" );
47
47
txt += QLatin1String( "</qt>" );
107
107
const Akonadi::Item item = index.data( ContactsTreeModel::ItemRole ).value<Akonadi::Item>();
108
108
if ( item.hasPayload<KABC::Addressee>() ) {
109
109
const KABC::Addressee contact = item.payload<KABC::Addressee>();
110
if ( contact.emails().count() == 1 )
110
if ( contact.emails().count() == 1 ) {
113
113
return contact.emails().count();
114
115
} else if ( item.hasPayload<KABC::ContactGroup>() ) {
115
116
const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
116
117
return group.dataCount();
122
123
int EmailAddressSelectionProxyModel::leafColumnCount( const QModelIndex &index ) const
124
125
const Akonadi::Item item = index.data( ContactsTreeModel::ItemRole ).value<Akonadi::Item>();
125
if ( item.hasPayload<KABC::Addressee>() )
127
else if ( item.hasPayload<KABC::ContactGroup>() )
126
if ( item.hasPayload<KABC::Addressee>() ) {
128
} else if ( item.hasPayload<KABC::ContactGroup>() ) {
133
135
QVariant EmailAddressSelectionProxyModel::leafData( const QModelIndex &index, int row, int, int role ) const
136
138
const Akonadi::Item item = index.data( ContactsTreeModel::ItemRole ).value<Akonadi::Item>();
137
139
if ( item.hasPayload<KABC::Addressee>() ) {
138
140
const KABC::Addressee contact = item.payload<KABC::Addressee>();
139
if ( row >= 0 && row < contact.emails().count() )
141
if ( row >= 0 && row < contact.emails().count() ) {
140
142
return contact.emails().at( row );
141
144
} else if ( item.hasPayload<KABC::ContactGroup>() ) {
142
145
const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
143
if ( row >= 0 && row < (int)group.dataCount() )
146
if ( row >= 0 && row < (int)group.dataCount() ) {
144
147
return i18nc( "Name and email address of a contact", "%1 <%2>",
145
148
group.data( row ).name(), group.data( row ).email() );
147
151
} else if ( role == NameRole ) {
148
152
const Akonadi::Item item = index.data( ContactsTreeModel::ItemRole ).value<Akonadi::Item>();
151
155
return contact.realName();
152
156
} else if ( item.hasPayload<KABC::ContactGroup>() ) {
153
157
const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
154
if ( row >= 0 && row < (int)group.dataCount() )
158
if ( row >= 0 && row < (int)group.dataCount() ) {
155
159
return group.data( row ).name();
157
162
} else if ( role == EmailAddressRole ) {
158
163
const Akonadi::Item item = index.data( ContactsTreeModel::ItemRole ).value<Akonadi::Item>();
159
164
if ( item.hasPayload<KABC::Addressee>() ) {
160
165
const KABC::Addressee contact = item.payload<KABC::Addressee>();
161
if ( row >= 0 && row < contact.emails().count() )
166
if ( row >= 0 && row < contact.emails().count() ) {
162
167
return contact.emails().at( row );
163
169
} else if ( item.hasPayload<KABC::ContactGroup>() ) {
164
170
const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
165
if ( row >= 0 && row < (int)group.dataCount() )
171
if ( row >= 0 && row < (int)group.dataCount() ) {
166
172
return group.data( row ).email();
168
175
} else if ( role == Qt::ToolTipRole ) {
169
176
const Akonadi::Item item = index.data( ContactsTreeModel::ItemRole ).value<Akonadi::Item>();
170
177
if ( item.hasPayload<KABC::Addressee>() ) {
171
178
const KABC::Addressee contact = item.payload<KABC::Addressee>();
172
if ( row >= 0 && row < contact.emails().count() )
179
if ( row >= 0 && row < contact.emails().count() ) {
173
180
return createToolTip( contact.realName(), contact.emails().at( row ) );
174
182
} else if ( item.hasPayload<KABC::ContactGroup>() ) {
175
183
const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
176
if ( row >= 0 && row < (int)group.dataCount() )
184
if ( row >= 0 && row < (int)group.dataCount() ) {
177
185
return createToolTip( group.data( row ).name(), group.data( row ).email() );
180
189
return index.data( role );