2 This file is part of KMail.
4 Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 #ifndef RECIPIENTSPICKER_H
22 #define RECIPIENTSPICKER_H
24 #include "recipientseditor.h"
26 #include <kabc/addressee.h>
27 #include <kabc/stdaddressbook.h>
29 #include <KTreeWidgetSearchLine>
32 #include <QTreeWidgetItem>
41 class DistributionList
;
45 class LdapSearchDialog
;
51 typedef QList
<RecipientItem
*> List
;
54 void setDistributionList( KABC::DistributionList
* );
55 KABC::DistributionList
* distributionList() const;
57 void setAddressee( const KABC::Addressee
&, const QString
&email
);
59 void setRecipientType( const QString
&type
);
60 QString
recipientType() const;
62 QString
recipient() const;
66 QString
email() const;
68 QString
key() const { return mKey
; }
70 QString
tooltip() const;
73 QString
createTooltip( KABC::DistributionList
* ) const;
75 KABC::Addressee mAddressee
;
79 KABC::DistributionList
*mDistributionList
;
88 class RecipientViewItem
: public QTreeWidgetItem
91 RecipientViewItem( RecipientItem
*, QTreeWidget
* );
93 RecipientItem
*recipientItem() const;
96 RecipientItem
*mRecipientItem
;
99 class RecipientsCollection
102 RecipientsCollection( const QString
& );
103 ~RecipientsCollection();
105 void setReferenceContainer( bool );
106 bool isReferenceContainer() const;
108 void setTitle( const QString
& );
109 QString
title() const;
111 void addItem( RecipientItem
* );
113 RecipientItem::List
items() const;
115 bool hasEquivalentItem( RecipientItem
* ) const;
116 RecipientItem
* getEquivalentItem( RecipientItem
*) const;
125 // flag to indicate if this collection contains just references
126 // or should manage memory (de)allocation as well.
127 bool mIsReferenceContainer
;
130 QMap
<QString
, RecipientItem
*> mKeyMap
;
133 class SearchLine
: public KTreeWidgetSearchLine
137 SearchLine( QWidget
*parent
, QTreeWidget
*listView
);
143 void keyPressEvent( QKeyEvent
* );
146 //This is a TreeWidget which has an additional signal, returnPressed().
147 class RecipientsTreeWidget
: public QTreeWidget
151 RecipientsTreeWidget( QWidget
*parent
);
155 //This signal is emitted whenever the user presses the return key and this
157 void returnPressed();
161 //This function is reimplemented so that the returnPressed() signal can
163 virtual void keyPressEvent ( QKeyEvent
*event
);
166 using namespace KABC
;
168 class RecipientsPicker
: public KDialog
172 RecipientsPicker( QWidget
*parent
);
175 void setRecipients( const Recipient::List
& );
176 void updateRecipient( const Recipient
& );
178 void setDefaultType( Recipient::Type
);
181 void pickedRecipient( const Recipient
& );
184 void initCollections();
185 void insertDistributionLists();
186 void insertRecentAddresses();
187 void insertCollection( RecipientsCollection
*coll
);
189 void keyPressEvent( QKeyEvent
*ev
);
194 void pick( Recipient::Type
);
196 void setDefaultButton( QPushButton
*button
);
198 void rebuildAllRecipientsList();
202 void slotToClicked();
203 void slotCcClicked();
204 void slotBccClicked();
205 void slotPicked( QTreeWidgetItem
* );
208 void insertAddressBook( AddressBook
* );
209 void slotSearchLDAP();
210 void ldapSearchResult();
212 KABC::StdAddressBook
*mAddressBook
;
214 KComboBox
*mCollectionCombo
;
215 RecipientsTreeWidget
*mRecipientList
;
216 KTreeWidgetSearchLine
*mSearchLine
;
218 QPushButton
*mToButton
;
219 QPushButton
*mCcButton
;
220 QPushButton
*mBccButton
;
222 QPushButton
*mSearchLDAPButton
;
223 KPIM::LdapSearchDialog
*mLdapSearchDialog
;
225 QMap
<int,RecipientsCollection
*> mCollectionMap
;
226 RecipientsCollection
*mAllRecipients
;
227 RecipientsCollection
*mDistributionLists
;
228 RecipientsCollection
*mSelectedRecipients
;
230 Recipient::Type mDefaultType
;