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 "recipientseditor.h"
00025
00026 #include <klistview.h>
00027 #include <klistviewsearchline.h>
00028 #include <kabc/addressee.h>
00029
00030 #include <qwidget.h>
00031 #include <qdialog.h>
00032 #include <qtooltip.h>
00033
00034 class QComboBox;
00035
00036 namespace KABC {
00037 class DistributionList;
00038 class DistributionListManager;
00039 }
00040
00041 class RecipientItem
00042 {
00043 public:
00044 typedef QValueList<RecipientItem *> List;
00045
00046 RecipientItem();
00047
00048 void setDistributionList( KABC::DistributionList * );
00049 void setAddressee( const KABC::Addressee &, const QString &email );
00050
00051 void setRecipientType( const QString &type );
00052 QString recipientType() const;
00053
00054 QString recipient() const;
00055
00056 QPixmap icon() const;
00057 QString name() const;
00058 QString email() const;
00059
00060 QString key() const { return mKey; }
00061
00062 QString toolTip() const;
00063
00064 private:
00065 KABC::Addressee mAddressee;
00066 QString mEmail;
00067 KABC::DistributionList *mDistributionList;
00068 QString mType;
00069
00070 QPixmap mIcon;
00071
00072 QString mKey;
00073 };
00074
00075 class RecipientViewItem : public KListViewItem
00076 {
00077 public:
00078 RecipientViewItem( RecipientItem *, KListView * );
00079
00080 RecipientItem *recipientItem() const;
00081
00082 private:
00083 RecipientItem *mRecipientItem;
00084 };
00085
00086 class RecipientsListToolTip : public QToolTip
00087 {
00088 public:
00089 RecipientsListToolTip( QWidget *parent, KListView * );
00090
00091 protected:
00092 void maybeTip( const QPoint &pos );
00093
00094 private:
00095 KListView *mListView;
00096 };
00097
00098 class RecipientsCollection
00099 {
00100 public:
00101 RecipientsCollection();
00102 ~RecipientsCollection();
00103
00104 void setTitle( const QString & );
00105 QString title() const;
00106
00107 void addItem( RecipientItem * );
00108
00109 RecipientItem::List items() const;
00110
00111 bool hasEquivalentItem( RecipientItem * ) const;
00112
00113 void clear();
00114
00115 void deleteAll();
00116
00117 private:
00118 QString mTitle;
00119 RecipientItem::List mItems;
00120 QMap<QString, RecipientItem *> mKeyMap;
00121 };
00122
00123 class SearchLine : public KListViewSearchLine
00124 {
00125 Q_OBJECT
00126 public:
00127 SearchLine( QWidget *parent, KListView *listView );
00128
00129 signals:
00130 void downPressed();
00131
00132 protected:
00133 void keyPressEvent( QKeyEvent * );
00134 };
00135
00136 class RecipientsPicker : public QDialog
00137 {
00138 Q_OBJECT
00139 public:
00140 RecipientsPicker( QWidget *parent );
00141 ~RecipientsPicker();
00142
00143 void setRecipients( const Recipient::List & );
00144 void updateRecipient( const Recipient & );
00145
00146 void setDefaultType( Recipient::Type );
00147
00148 signals:
00149 void pickedRecipient( const Recipient & );
00150
00151 protected:
00152 void initCollections();
00153 void insertDistributionLists();
00154 void insertRecentAddresses();
00155 void insertCollection( RecipientsCollection *coll );
00156
00157 void keyPressEvent( QKeyEvent *ev );
00158
00159 void readConfig();
00160 void writeConfig();
00161
00162 void pick( Recipient::Type );
00163
00164 void setDefaultButton( QPushButton *button );
00165
00166 protected slots:
00167 void updateList();
00168 void slotToClicked();
00169 void slotCcClicked();
00170 void slotBccClicked();
00171 void slotPicked( QListViewItem * );
00172 void slotPicked();
00173 void setFocusList();
00174 void resetSearch();
00175
00176 private:
00177 QComboBox *mCollectionCombo;
00178 KListView *mRecipientList;
00179 KListViewSearchLine *mSearchLine;
00180
00181 QPushButton *mToButton;
00182 QPushButton *mCcButton;
00183 QPushButton *mBccButton;
00184
00185 QMap<int,RecipientsCollection *> mCollectionMap;
00186 RecipientsCollection *mAllRecipients;
00187 RecipientsCollection *mSelectedRecipients;
00188
00189 KABC::DistributionListManager *mDistributionListManager;
00190
00191 Recipient::Type mDefaultType;
00192 };
00193
00194 #endif
|