kmail
recipientspicker.h00001
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 QToolTip
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 public:
00167 SearchLine( TQWidget *parent, KListView *listView );
00168
00169 signals:
00170 void downPressed();
00171
00172 protected:
00173 void keyPressEvent( TQKeyEvent * );
00174 };
00175
00176 using namespace KABC;
00177
00178 class RecipientsPicker : public QDialog
00179 {
00180 Q_OBJECT
00181 public:
00182 RecipientsPicker( TQWidget *parent );
00183 ~RecipientsPicker();
00184
00185 void setRecipients( const Recipient::List & );
00186 void updateRecipient( const Recipient & );
00187
00188 void setDefaultType( Recipient::Type );
00189
00190 signals:
00191 void pickedRecipient( const Recipient & );
00192
00193 protected:
00194 void initCollections();
00195 void insertDistributionLists();
00196 void insertRecentAddresses();
00197 void insertCollection( RecipientsCollection *coll );
00198
00199 void keyPressEvent( TQKeyEvent *ev );
00200
00201 void readConfig();
00202 void writeConfig();
00203
00204 void pick( Recipient::Type );
00205
00206 void setDefaultButton( TQPushButton *button );
00207
00208 void rebuildAllRecipientsList();
00209
00210 protected slots:
00211 void updateList();
00212 void slotToClicked();
00213 void slotCcClicked();
00214 void slotBccClicked();
00215 void slotPicked( TQListViewItem * );
00216 void slotPicked();
00217 void setFocusList();
00218 void resetSearch();
00219 void insertAddressBook( AddressBook * );
00220 void slotSearchLDAP();
00221 void ldapSearchResult();
00222 private:
00223 KABC::StdAddressBook *mAddressBook;
00224
00225 TQComboBox *mCollectionCombo;
00226 KListView *mRecipientList;
00227 KListViewSearchLine *mSearchLine;
00228
00229 TQPushButton *mToButton;
00230 TQPushButton *mCcButton;
00231 TQPushButton *mBccButton;
00232
00233 TQPushButton *mSearchLDAPButton;
00234 KPIM::LDAPSearchDialog *mLdapSearchDialog;
00235
00236 TQMap<int,RecipientsCollection *> mCollectionMap;
00237 RecipientsCollection *mAllRecipients;
00238 RecipientsCollection *mDistributionLists;
00239 RecipientsCollection *mSelectedRecipients;
00240
00241 #ifndef KDEPIM_NEW_DISTRLISTS
00242 KABC::DistributionListManager *mDistributionListManager;
00243 #endif
00244
00245 Recipient::Type mDefaultType;
00246 };
00247
00248 #endif
|