libkdepim
addresseeselector.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KPIM_ADDRESSEESELECTOR_H
00023 #define KPIM_ADDRESSEESELECTOR_H
00024
00025 #include <kabc/addressee.h>
00026 #include <kabc/distributionlist.h>
00027 #include <kabc/resource.h>
00028 #include <kdialogbase.h>
00029 #include <kdepimmacros.h>
00030
00031 #include <qbitarray.h>
00032 #include <qpixmap.h>
00033 #include <qwidget.h>
00034
00035 class KComboBox;
00036 class KLineEdit;
00037 class KListView;
00038 class QSignalMapper;
00039
00040 namespace KPIM {
00041
00042 class AddresseeSelector;
00043
00044 class KDE_EXPORT Selection
00045 {
00046 friend class AddresseeSelector;
00047
00048 public:
00049 virtual ~Selection() {}
00050
00054 virtual uint fieldCount() const = 0;
00055
00059 virtual QString fieldTitle( uint index ) const = 0;
00060
00064 virtual uint itemCount( const KABC::Addressee &addresse ) const = 0;
00065
00069 virtual QString itemText( const KABC::Addressee &addresse, uint index ) const = 0;
00070
00074 virtual QPixmap itemIcon( const KABC::Addressee &addresse, uint index ) const = 0;
00075
00079 virtual bool itemEnabled( const KABC::Addressee &addresse, uint index ) const = 0;
00080
00084 virtual bool itemMatches( const KABC::Addressee &addresse, uint index, const QString &pattern ) const = 0;
00085
00089 virtual bool itemEquals( const KABC::Addressee &addresse, uint index, const QString &pattern ) const = 0;
00090
00094 virtual QString distributionListText( const KABC::DistributionList *distributionList ) const = 0;
00095
00099 virtual QPixmap distributionListIcon( const KABC::DistributionList *distributionList ) const = 0;
00100
00104 virtual bool distributionListEnabled( const KABC::DistributionList *distributionList ) const = 0;
00105
00109 virtual bool distributionListMatches( const KABC::DistributionList *distributionList,
00110 const QString &pattern ) const = 0;
00111
00115 virtual uint addressBookCount() const = 0;
00116
00120 virtual QString addressBookTitle( uint index ) const = 0;
00121
00125 virtual KABC::Addressee::List addressBookContent( uint index ) const = 0;
00126
00127 protected:
00128 AddresseeSelector* selector() { return mSelector; }
00129
00130 private:
00131 virtual void addSelectedAddressees( uint fieldIndex, const KABC::Addressee&, uint itemIndex ) = 0;
00132 virtual void addSelectedDistributionList( uint fieldIndex, const KABC::DistributionList* ) = 0;
00133
00134 void setSelector( AddresseeSelector *selector ) { mSelector = selector; }
00135
00136 AddresseeSelector *mSelector;
00137 };
00138
00142 class SelectionItem
00143 {
00144 public:
00145 typedef QValueList<SelectionItem> List;
00146
00147 SelectionItem( const KABC::Addressee &addressee, uint index );
00148 SelectionItem( KABC::DistributionList *list, uint index );
00149 SelectionItem();
00150
00151 void addToField( int index );
00152 void removeFromField( int index );
00153 bool isInField( int index );
00154
00155 KABC::Addressee addressee() const;
00156 KABC::DistributionList* distributionList() const;
00157 uint index() const;
00158
00159 private:
00160 KABC::Addressee mAddressee;
00161 KABC::DistributionList *mDistributionList;
00162 uint mIndex;
00163 QBitArray mField;
00164 };
00165
00166 class KDE_EXPORT AddresseeSelector : public QWidget
00167 {
00168 Q_OBJECT
00169
00170 public:
00171 AddresseeSelector( Selection *selection,
00172 QWidget *parent, const char *name = 0 );
00173 ~AddresseeSelector();
00174
00178 void finish();
00179
00180 void setItemSelected( uint fieldIndex, const KABC::Addressee&, uint itemIndex );
00181 void setItemSelected( uint fieldIndex, const KABC::Addressee&,
00182 uint itemIndex, const QString& );
00183
00184 private slots:
00185 void move( int index );
00186 void remove( int index );
00187
00188 void updateAddresseeView();
00189 void reloadAddressBook();
00190
00191 private:
00192 void init();
00193 void initGUI();
00194
00195 void updateSelectionView( int index );
00196 void updateSelectionViews();
00197
00198 Selection *mSelection;
00199
00200 KComboBox *mAddressBookCombo;
00201 KLineEdit *mAddresseeFilter;
00202 KListView *mAddresseeView;
00203 SelectionItem::List mSelectionItems;
00204
00205 QValueList<KListView*> mSelectionViews;
00206 QSignalMapper *mMoveMapper;
00207 QSignalMapper *mRemoveMapper;
00208
00209 KABC::DistributionListManager *mManager;
00210
00211 class AddressBookManager;
00212 AddressBookManager *mAddressBookManager;
00213 };
00214
00215 class KDE_EXPORT AddresseeSelectorDialog : public KDialogBase
00216 {
00217 Q_OBJECT
00218
00219 public:
00220 AddresseeSelectorDialog( Selection *selection,
00221 QWidget *parent = 0, const char *name = 0 );
00222
00223 protected slots:
00224 void accept();
00225
00226 private:
00227 AddresseeSelector *mSelector;
00228 };
00229
00230 }
00231
00232 #endif
|