libkdepim
addresseelineedit.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ADDRESSEELINEEDIT_H
00027 #define ADDRESSEELINEEDIT_H
00028
00029 #include <tqobject.h>
00030 #include <tqptrlist.h>
00031 #include <tqtimer.h>
00032 #include <tqpair.h>
00033 #include <tqvaluelist.h>
00034
00035 #include <kabc/addressee.h>
00036
00037 #include "clicklineedit.h"
00038 #include "kmailcompletion.h"
00039 #include <dcopobject.h>
00040 #include <kdepimmacros.h>
00041
00042 class KConfig;
00043
00044 namespace KPIM {
00045 class LdapSearch;
00046 class LdapResult;
00047 typedef TQValueList<LdapResult> LdapResultList;
00048 typedef TQMap< TQString, QPair<int,int> > CompletionItemsMap;
00049 }
00050
00051 namespace KPIM {
00052
00053 class KDE_EXPORT AddresseeLineEdit : public ClickLineEdit, public DCOPObject
00054 {
00055 K_DCOP
00056 Q_OBJECT
00057
00058 public:
00059 AddresseeLineEdit( TQWidget* parent, bool useCompletion = true,
00060 const char *name = 0L);
00061 virtual ~AddresseeLineEdit();
00062
00063 virtual void setFont( const TQFont& );
00064 void allowSemiColonAsSeparator( bool );
00065
00070 void allowDistributionLists( bool allowDistLists );
00071
00072 public slots:
00073 void cursorAtEnd();
00074 void enableCompletion( bool enable );
00076 virtual void setText( const TQString& txt );
00077
00078 protected slots:
00079 virtual void loadContacts();
00080 protected:
00081 void addContact( const KABC::Addressee&, int weight, int source = -1 );
00082 virtual void keyPressEvent( TQKeyEvent* );
00091 virtual void insert( const TQString &text );
00093 virtual void paste();
00095 virtual void mouseReleaseEvent( TQMouseEvent *e );
00097 virtual void dropEvent( TQDropEvent *e );
00098 void doCompletion( bool ctrlT );
00099 virtual TQPopupMenu *createPopupMenu();
00100
00108 int addCompletionSource( const TQString&, int weight );
00109
00111 static KCompletion::CompOrder completionOrder();
00112
00113 k_dcop:
00114
00115 void slotIMAPCompletionOrderChanged();
00116
00117 private slots:
00118 void slotCompletion();
00119 void slotPopupCompletion( const TQString& );
00120 void slotReturnPressed( const TQString& );
00121 void slotStartLDAPLookup();
00122 void slotLDAPSearchData( const KPIM::LdapResultList& );
00123 void slotEditCompletionOrder();
00124 void slotUserCancelled( const TQString& );
00125
00126 private:
00127 virtual bool eventFilter(TQObject *o, TQEvent *e);
00128 void init();
00129 void startLoadingLDAPEntries();
00130 void stopLDAPLookup();
00131 void updateLDAPWeights();
00132
00133 void setCompletedItems( const TQStringList& items, bool autoSuggest );
00134 void addCompletionItem( const TQString& string, int weight, int source, const TQStringList * keyWords=0 );
00135 TQString completionSearchText( TQString& );
00136 const TQStringList getAdjustedCompletionItems( bool fullSearch );
00137 void updateSearchString();
00138
00139 TQString m_previousAddresses;
00140 TQString m_searchString;
00141 bool m_useCompletion;
00142 bool m_completionInitialized;
00143 bool m_smartPaste;
00144 bool m_addressBookConnected;
00145 bool m_lastSearchMode;
00146 bool m_searchExtended;
00147 bool m_useSemiColonAsSeparator;
00148 bool m_allowDistLists;
00149
00150
00151
00152 static bool s_addressesDirty;
00153 static KMailCompletion *s_completion;
00154 static CompletionItemsMap* s_completionItemMap;
00155 static TQTimer *s_LDAPTimer;
00156 static KPIM::LdapSearch *s_LDAPSearch;
00157 static TQString *s_LDAPText;
00158 static AddresseeLineEdit *s_LDAPLineEdit;
00159 static TQStringList *s_completionSources;
00160 static TQMap<int,int> *s_ldapClientToCompletionSourceMap;
00161
00162 class AddresseeLineEditPrivate;
00163 AddresseeLineEditPrivate *d;
00164
00165
00166
00167 enum MenuID
00168 {
00169 Default = 42,
00170 NoCompletion,
00171 AutoCompletion,
00172 ShellCompletion,
00173 PopupCompletion,
00174 ShortAutoCompletion,
00175 PopupAutoCompletion
00176 };
00177
00178 };
00179
00180 }
00181
00182 #endif
|