fix errors found while translating
[kdepim.git] / kmail / recipientspicker.h
blob877ec4e09943781daa3c55d62f5c659f60274ab3
1 /*
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>
28 #include <KDialog>
29 #include <KTreeWidgetSearchLine>
31 #include <QPixmap>
32 #include <QTreeWidgetItem>
34 class KComboBox;
36 class QKeyEvent;
37 class QTreeWidget;
38 class QWidget;
40 namespace KABC {
41 class DistributionList;
44 namespace KPIM {
45 class LdapSearchDialog;
48 class RecipientItem
50 public:
51 typedef QList<RecipientItem *> List;
53 RecipientItem();
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;
64 QPixmap icon() const;
65 QString name() const;
66 QString email() const;
68 QString key() const { return mKey; }
70 QString tooltip() const;
72 private:
73 QString createTooltip( KABC::DistributionList * ) const;
75 KABC::Addressee mAddressee;
76 QString mName;
77 QString mEmail;
78 QString mRecipient;
79 KABC::DistributionList *mDistributionList;
80 QString mType;
81 QString mTooltip;
83 QPixmap mIcon;
85 QString mKey;
88 class RecipientViewItem : public QTreeWidgetItem
90 public:
91 RecipientViewItem( RecipientItem *, QTreeWidget * );
93 RecipientItem *recipientItem() const;
95 private:
96 RecipientItem *mRecipientItem;
99 class RecipientsCollection
101 public:
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;
118 void clear();
120 void deleteAll();
122 QString id() const;
124 private:
125 // flag to indicate if this collection contains just references
126 // or should manage memory (de)allocation as well.
127 bool mIsReferenceContainer;
128 QString mId;
129 QString mTitle;
130 QMap<QString, RecipientItem *> mKeyMap;
133 class SearchLine : public KTreeWidgetSearchLine
135 Q_OBJECT
136 public:
137 SearchLine( QWidget *parent, QTreeWidget *listView );
139 signals:
140 void downPressed();
142 protected:
143 void keyPressEvent( QKeyEvent * );
146 //This is a TreeWidget which has an additional signal, returnPressed().
147 class RecipientsTreeWidget : public QTreeWidget
149 Q_OBJECT
150 public:
151 RecipientsTreeWidget( QWidget *parent );
153 signals:
155 //This signal is emitted whenever the user presses the return key and this
156 //widget has focus.
157 void returnPressed();
159 protected:
161 //This function is reimplemented so that the returnPressed() signal can
162 //be emitted.
163 virtual void keyPressEvent ( QKeyEvent *event );
166 using namespace KABC;
168 class RecipientsPicker : public KDialog
170 Q_OBJECT
171 public:
172 RecipientsPicker( QWidget *parent );
173 ~RecipientsPicker();
175 void setRecipients( const Recipient::List & );
176 void updateRecipient( const Recipient & );
178 void setDefaultType( Recipient::Type );
180 signals:
181 void pickedRecipient( const Recipient & );
183 protected:
184 void initCollections();
185 void insertDistributionLists();
186 void insertRecentAddresses();
187 void insertCollection( RecipientsCollection *coll );
189 void keyPressEvent( QKeyEvent *ev );
191 void readConfig();
192 void writeConfig();
194 void pick( Recipient::Type );
196 void setDefaultButton( QPushButton *button );
198 void rebuildAllRecipientsList();
200 protected slots:
201 void updateList();
202 void slotToClicked();
203 void slotCcClicked();
204 void slotBccClicked();
205 void slotPicked( QTreeWidgetItem * );
206 void slotPicked();
207 void setFocusList();
208 void insertAddressBook( AddressBook * );
209 void slotSearchLDAP();
210 void ldapSearchResult();
211 private:
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;
233 #endif