kmail

recipientspicker.h

00001 /*
00002     This file is part of KMail.
00003 
00004     Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 #ifndef RECIPIENTSPICKER_H
00022 #define RECIPIENTSPICKER_H
00023 
00024 #include <config.h> // for KDEPIM_NEW_DISTRLISTS
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 <qwidget.h>
00034 #include <qdialog.h>
00035 #include <qtooltip.h>
00036 
00037 class QComboBox;
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 QValueList<RecipientItem *> List;
00056 
00057 #ifdef KDEPIM_NEW_DISTRLISTS
00058     RecipientItem( KABC::AddressBook *ab );
00059     void setDistributionList( const KPIM::DistributionList& );
00060 #else
00061     RecipientItem();
00062     void setDistributionList( KABC::DistributionList * );
00063 #endif
00064     void setAddressee( const KABC::Addressee &, const QString &email );
00065 
00066     void setRecipientType( const QString &type );
00067     QString recipientType() const;
00068 
00069     QString recipient() const;
00070 
00071     QPixmap icon() const;
00072     QString name() const;
00073     QString email() const;
00074 
00075     QString key() const { return mKey; }
00076 
00077     QString toolTip() const;
00078 
00079   private:
00080     KABC::Addressee mAddressee;
00081     QString mEmail;
00082 #ifdef KDEPIM_NEW_DISTRLISTS
00083     KPIM::DistributionList mDistributionList;
00084     KABC::AddressBook *mAddressBook;
00085 #else
00086     KABC::DistributionList *mDistributionList;
00087 #endif
00088     QString mType;
00089 
00090     QPixmap mIcon;
00091 
00092     QString mKey;
00093 };
00094 
00095 class RecipientViewItem : public KListViewItem
00096 {
00097   public:
00098     RecipientViewItem( RecipientItem *, KListView * );
00099 
00100     RecipientItem *recipientItem() const;
00101 
00102   private:
00103     RecipientItem *mRecipientItem;
00104 };
00105 
00106 class RecipientsListToolTip : public QToolTip
00107 {
00108   public:
00109     RecipientsListToolTip( QWidget *parent, KListView * );
00110 
00111   protected:
00112     void maybeTip( const QPoint &pos );
00113 
00114   private:
00115     KListView *mListView;
00116 };
00117 
00118 class RecipientsCollection
00119 {
00120   public:
00121     RecipientsCollection();
00122     ~RecipientsCollection();
00123 
00124     void setTitle( const QString & );
00125     QString title() const;
00126 
00127     void addItem( RecipientItem * );
00128 
00129     RecipientItem::List items() const;
00130 
00131     bool hasEquivalentItem( RecipientItem * ) const;
00132 
00133     void clear();
00134 
00135     void deleteAll();
00136 
00137   private:
00138     QString mTitle;
00139     RecipientItem::List mItems;
00140     QMap<QString, RecipientItem *> mKeyMap;
00141 };
00142 
00143 class SearchLine : public KListViewSearchLine
00144 {
00145     Q_OBJECT
00146   public:
00147     SearchLine( QWidget *parent, KListView *listView );
00148 
00149   signals:
00150     void downPressed();
00151 
00152   protected:
00153     void keyPressEvent( QKeyEvent * );
00154 };
00155 
00156 using namespace KABC;
00157 
00158 class RecipientsPicker : public QDialog
00159 {
00160     Q_OBJECT
00161   public:
00162     RecipientsPicker( QWidget *parent );
00163     ~RecipientsPicker();
00164 
00165     void setRecipients( const Recipient::List & );
00166     void updateRecipient( const Recipient & );
00167 
00168     void setDefaultType( Recipient::Type );
00169 
00170   signals:
00171     void pickedRecipient( const Recipient & );
00172 
00173   protected:
00174     void initCollections();
00175     void insertDistributionLists();
00176     void insertRecentAddresses();
00177     void insertCollection( RecipientsCollection *coll );
00178 
00179     void keyPressEvent( QKeyEvent *ev );
00180 
00181     void readConfig();
00182     void writeConfig();
00183 
00184     void pick( Recipient::Type );
00185 
00186     void setDefaultButton( QPushButton *button );
00187 
00188   protected slots:
00189     void updateList();
00190     void slotToClicked();
00191     void slotCcClicked();
00192     void slotBccClicked();
00193     void slotPicked( QListViewItem * );
00194     void slotPicked();
00195     void setFocusList();
00196     void resetSearch();
00197     void insertAddressBook( AddressBook * );
00198     void slotSearchLDAP();
00199     void ldapSearchResult();
00200   private:
00201     KABC::StdAddressBook *mAddressBook;
00202 
00203     QComboBox *mCollectionCombo;
00204     KListView *mRecipientList;
00205     KListViewSearchLine *mSearchLine;
00206 
00207     QPushButton *mToButton;
00208     QPushButton *mCcButton;
00209     QPushButton *mBccButton;
00210 
00211     QPushButton *mSearchLDAPButton;
00212     KPIM::LDAPSearchDialog *mLdapSearchDialog;
00213 
00214     QMap<int,RecipientsCollection *> mCollectionMap;
00215     RecipientsCollection *mAllRecipients;
00216     RecipientsCollection *mSelectedRecipients;
00217 
00218 #ifndef KDEPIM_NEW_DISTRLISTS
00219     KABC::DistributionListManager *mDistributionListManager;
00220 #endif
00221 
00222     Recipient::Type mDefaultType;
00223 };
00224 
00225 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys