libtdepim

addresseelineedit.h
1/*
2 This file is part of libtdepim.
3 Copyright (c) 2002 Helge Deller <deller@gmx.de>
4 2002 Lubos Lunak <llunak@suse.cz>
5 2001,2003 Carsten Pfeiffer <pfeiffer@kde.org>
6 2001 Waldo Bastian <bastian@kde.org>
7 2004 Daniel Molkentin <danimo@klaralvdalens-datakonsult.se>
8 2004 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se>
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
24*/
25
26#ifndef ADDRESSEELINEEDIT_H
27#define ADDRESSEELINEEDIT_H
28
29#include <tqobject.h>
30#include <tqptrlist.h>
31#include <tqtimer.h>
32#include <tqpair.h>
33#include <tqvaluelist.h>
34
35#include <tdeabc/addressee.h>
36
37#include "clicklineedit.h"
38#include "kmailcompletion.h"
39#include <dcopobject.h>
40#include <tdemacros.h>
41
42class TDEConfig;
43
44namespace KPIM {
45class LdapSearch;
46class LdapResult;
47typedef TQValueList<LdapResult> LdapResultList;
48typedef TQMap< TQString, TQPair<int,int> > CompletionItemsMap;
49}
50
51namespace KPIM {
52
53class TDE_EXPORT AddresseeLineEdit : public ClickLineEdit, public DCOPObject
54{
55 K_DCOP
56 TQ_OBJECT
57
58
59 public:
60 AddresseeLineEdit( TQWidget* parent, bool useCompletion = true,
61 const char *name = 0L);
62 virtual ~AddresseeLineEdit();
63
64 virtual void setFont( const TQFont& );
65 void allowSemiColonAsSeparator( bool );
66
71 void allowDistributionLists( bool allowDistLists );
72
73 public slots:
74 void cursorAtEnd();
75 void enableCompletion( bool enable );
77 virtual void setText( const TQString& txt );
78
79 protected slots:
80 virtual void loadContacts();
81 protected:
82 void addContact( const TDEABC::Addressee&, int weight, int source = -1 );
83 virtual void keyPressEvent( TQKeyEvent* );
92 virtual void insert( const TQString &text );
94 virtual void paste();
96 virtual void mouseReleaseEvent( TQMouseEvent *e );
98 virtual void dropEvent( TQDropEvent *e );
99 void doCompletion( bool ctrlT );
100 virtual TQPopupMenu *createPopupMenu();
101
109 int addCompletionSource( const TQString&, int weight );
110
112 static TDECompletion::CompOrder completionOrder();
113
114 k_dcop:
115 // Connected to the DCOP signal
116 void slotIMAPCompletionOrderChanged();
117
118 private slots:
119 void slotCompletion();
120 void slotPopupCompletion( const TQString& );
121 void slotReturnPressed( const TQString& );
122 void slotStartLDAPLookup();
123 void slotLDAPSearchData( const KPIM::LdapResultList& );
124 void slotEditCompletionOrder();
125 void slotUserCancelled( const TQString& );
126
127 private:
128 virtual bool eventFilter(TQObject *o, TQEvent *e);
129 void init();
130 void startLoadingLDAPEntries();
131 void stopLDAPLookup();
132 void updateLDAPWeights();
133
134 void setCompletedItems( const TQStringList& items, bool autoSuggest );
135 void addCompletionItem( const TQString& string, int weight, int source, const TQStringList * keyWords=0 );
136 TQString completionSearchText( TQString& );
137 const TQStringList getAdjustedCompletionItems( bool fullSearch );
138 void updateSearchString();
139
140 TQString m_previousAddresses;
141 TQString m_searchString;
142 bool m_useCompletion;
143 bool m_completionInitialized;
144 bool m_smartPaste;
145 bool m_addressBookConnected;
146 bool m_lastSearchMode;
147 bool m_searchExtended; //has \" been added?
148 bool m_useSemiColonAsSeparator;
149 bool m_allowDistLists;
150
151 //TQMap<TQString, TDEABC::Addressee> m_contactMap;
152
153 static bool s_addressesDirty;
154 static KMailCompletion *s_completion;
155 static CompletionItemsMap* s_completionItemMap;
156 static TQTimer *s_LDAPTimer;
157 static KPIM::LdapSearch *s_LDAPSearch;
158 static TQString *s_LDAPText;
159 static AddresseeLineEdit *s_LDAPLineEdit;
160 static TQStringList *s_completionSources;
161 static TQMap<int,int> *s_ldapClientToCompletionSourceMap;
162
163 class AddresseeLineEditPrivate;
164 AddresseeLineEditPrivate *d;
165
166 //until MenuID moves into protected in KLineEdit, we keep a copy here
167 //Constants that represent the ID's of the popup menu.
168 enum MenuID
169 {
170 Default = 42,
171 NoCompletion,
172 AutoCompletion,
173 ShellCompletion,
174 PopupCompletion,
175 ShortAutoCompletion,
176 PopupAutoCompletion
177 };
178
179};
180
181}
182
183#endif
This class is internal.
Definition: ldapclient.h:247
TDEPIM classes for drag and drop of mails.