00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef RECIPIENTSPICKER_H
00022 #define RECIPIENTSPICKER_H
00023
00024 #include <config.h>
00025
00026 #include "recipientseditor.h"
00027
00028 #include <klistview.h>
00029 #include <klistviewsearchline.h>
00030 #include <kabc/addressee.h>
00031 #include <kabc/stdaddressbook.h>
00032
00033 #include <tqwidget.h>
00034 #include <tqdialog.h>
00035 #include <tqtooltip.h>
00036
00037 class TQComboBox;
00038
00039 #ifdef KDEPIM_NEW_DISTRLISTS
00040 #include <libkdepim/distributionlist.h>
00041 #else
00042 namespace KABC {
00043 class DistributionList;
00044 class DistributionListManager;
00045 }
00046 #endif
00047
00048 namespace KPIM {
00049 class LDAPSearchDialog;
00050 }
00051
00052 class RecipientItem
00053 {
00054 public:
00055 typedef TQValueList<RecipientItem *> List;
00056
00057 #ifdef KDEPIM_NEW_DISTRLISTS
00058 RecipientItem( KABC::AddressBook *ab );
00059 void setDistributionList( KPIM::DistributionList& );
00060 KPIM::DistributionList& distributionList();
00061 #else
00062 RecipientItem();
00063 void setDistributionList( KABC::DistributionList * );
00064 KABC::DistributionList * distributionList();
00065 #endif
00066 void setAddressee( const KABC::Addressee &, const TQString &email );
00067
00068 void setRecipientType( const TQString &type );
00069 TQString recipientType() const;
00070
00071 TQString recipient() const;
00072
00073 TQPixmap icon() const;
00074 TQString name() const;
00075 TQString email() const;
00076
00077 TQString key() const { return mKey; }
00078
00079 TQString tooltip() const;
00080
00081 private:
00082 #ifdef KDEPIM_NEW_DISTRLISTS
00083 TQString createTooltip( KPIM::DistributionList & ) const;
00084 #else
00085 TQString createTooltip( KABC::DistributionList * ) const;
00086 #endif
00087
00088 KABC::Addressee mAddressee;
00089 TQString mName;
00090 TQString mEmail;
00091 TQString mRecipient;
00092 #ifdef KDEPIM_NEW_DISTRLISTS
00093 KPIM::DistributionList mDistributionList;
00094 KABC::AddressBook *mAddressBook;
00095 #else
00096 KABC::DistributionList *mDistributionList;
00097 #endif
00098 TQString mType;
00099 TQString mTooltip;
00100
00101 TQPixmap mIcon;
00102
00103 TQString mKey;
00104 };
00105
00106 class RecipientViewItem : public KListViewItem
00107 {
00108 public:
00109 RecipientViewItem( RecipientItem *, KListView * );
00110
00111 RecipientItem *recipientItem() const;
00112
00113 private:
00114 RecipientItem *mRecipientItem;
00115 };
00116
00117 class RecipientsListToolTip : public TQToolTip
00118 {
00119 public:
00120 RecipientsListToolTip( TQWidget *parent, KListView * );
00121
00122 protected:
00123 void maybeTip( const TQPoint &pos );
00124
00125 private:
00126 KListView *mListView;
00127 };
00128
00129 class RecipientsCollection
00130 {
00131 public:
00132 RecipientsCollection( const TQString & );
00133 ~RecipientsCollection();
00134
00135 void setReferenceContainer( bool );
00136 bool isReferenceContainer() const;
00137
00138 void setTitle( const TQString & );
00139 TQString title() const;
00140
00141 void addItem( RecipientItem * );
00142
00143 RecipientItem::List items() const;
00144
00145 bool hasEquivalentItem( RecipientItem * ) const;
00146 RecipientItem * getEquivalentItem( RecipientItem *) const;
00147
00148 void clear();
00149
00150 void deleteAll();
00151
00152 TQString id() const;
00153
00154 private:
00155
00156
00157 bool mIsReferenceContainer;
00158 TQString mId;
00159 TQString mTitle;
00160 TQMap<TQString, RecipientItem *> mKeyMap;
00161 };
00162
00163 class SearchLine : public KListViewSearchLine
00164 {
00165 Q_OBJECT
00166 TQ_OBJECT
00167 public:
00168 SearchLine( TQWidget *parent, KListView *listView );
00169
00170 signals:
00171 void downPressed();
00172
00173 protected:
00174 void keyPressEvent( TQKeyEvent * );
00175 };
00176
00177 using namespace KABC;
00178
00179 class RecipientsPicker : public TQDialog
00180 {
00181 Q_OBJECT
00182 TQ_OBJECT
00183 public:
00184 RecipientsPicker( TQWidget *parent );
00185 ~RecipientsPicker();
00186
00187 void setRecipients( const Recipient::List & );
00188 void updateRecipient( const Recipient & );
00189
00190 void setDefaultType( Recipient::Type );
00191
00192 signals:
00193 void pickedRecipient( const Recipient & );
00194
00195 protected:
00196 void initCollections();
00197 void insertDistributionLists();
00198 void insertRecentAddresses();
00199 void insertCollection( RecipientsCollection *coll );
00200
00201 void keyPressEvent( TQKeyEvent *ev );
00202
00203 void readConfig();
00204 void writeConfig();
00205
00206 void pick( Recipient::Type );
00207
00208 void setDefaultButton( TQPushButton *button );
00209
00210 void rebuildAllRecipientsList();
00211
00212 protected slots:
00213 void updateList();
00214 void slotToClicked();
00215 void slotCcClicked();
00216 void slotBccClicked();
00217 void slotPicked( TQListViewItem * );
00218 void slotPicked();
00219 void setFocusList();
00220 void resetSearch();
00221 void insertAddressBook( AddressBook * );
00222 void slotSearchLDAP();
00223 void ldapSearchResult();
00224 private:
00225 KABC::StdAddressBook *mAddressBook;
00226
00227 TQComboBox *mCollectionCombo;
00228 KListView *mRecipientList;
00229 KListViewSearchLine *mSearchLine;
00230
00231 TQPushButton *mToButton;
00232 TQPushButton *mCcButton;
00233 TQPushButton *mBccButton;
00234
00235 TQPushButton *mSearchLDAPButton;
00236 KPIM::LDAPSearchDialog *mLdapSearchDialog;
00237
00238 TQMap<int,RecipientsCollection *> mCollectionMap;
00239 RecipientsCollection *mAllRecipients;
00240 RecipientsCollection *mDistributionLists;
00241 RecipientsCollection *mSelectedRecipients;
00242
00243 #ifndef KDEPIM_NEW_DISTRLISTS
00244 KABC::DistributionListManager *mDistributionListManager;
00245 #endif
00246
00247 Recipient::Type mDefaultType;
00248 };
00249
00250 #endif