Better wording
[kdepim.git] / libkdepim / addresseelineedit.h
bloba195d855704d78bbd4cfdb20807802c49655846c
1 /*
2 This file is part of libkdepim.
4 Copyright (c) 2002 Helge Deller <deller@gmx.de>
5 Copyright (c) 2002 Lubos Lunak <llunak@suse.cz>
6 Copyright (c) 2001,2003 Carsten Pfeiffer <pfeiffer@kde.org>
7 Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
8 Copyright (c) 2004 Daniel Molkentin <danimo@klaralvdalens-datakonsult.se>
9 Copyright (c) 2004 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se>
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
21 You should have received a copy of the GNU Library General Public License
22 along with this library; see the file COPYING.LIB. If not, write to
23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA.
27 #ifndef KDEPIM_ADDRESSEELINEEDIT_H
28 #define KDEPIM_ADDRESSEELINEEDIT_H
30 #include "kmailcompletion.h"
31 #include "kdepim_export.h"
33 #include "ldap/ldapclient.h"
35 #include <KLineEdit>
37 class QDropEvent;
38 class QEvent;
39 class QKeyEvent;
40 class QMenu;
41 class QMouseEvent;
42 class QObject;
44 namespace Akonadi {
45 class Item;
48 namespace KABC {
49 class Addressee;
50 class ContactGroup;
53 namespace KPIM {
54 typedef QMap< QString, QPair<int,int> > CompletionItemsMap;
57 namespace Nepomuk2 {
58 namespace Query {
59 class Result;
63 namespace KPIM {
66 class KDEPIM_EXPORT AddresseeLineEdit : public KLineEdit
68 Q_OBJECT
70 public:
71 /**
72 * Creates a new addressee line edit.
74 * @param parent The parent object.
75 * @param enableCompletion Whether autocompletion shall be enabled.
77 explicit AddresseeLineEdit( QWidget *parent, bool enableCompletion = true );
79 /**
80 * Destroys the addressee line edit.
82 virtual ~AddresseeLineEdit();
84 /**
85 * Sets whether semicolons are allowed as separators.
87 void allowSemicolonAsSeparator( bool allow );
89 /**
90 * Reimplemented for setting the @p font for line edit and completion box.
92 void setFont( const QFont &font );
93 Q_SIGNALS:
94 void textCompleted();
96 public Q_SLOTS:
97 /**
98 * Moves the cursor at the end of the line edit.
100 void cursorAtEnd();
103 * Sets whether autocompletion shall be enabled.
105 void enableCompletion( bool enable );
108 * Reimplemented for stripping whitespace after completion
109 * Danger: This is _not_ virtual in the base class!
111 virtual void setText( const QString &text );
113 protected:
115 * Adds a new @p contact to the completion with a given @p weight and @p source index.
117 void addContact( const KABC::Addressee &contact, int weight, int source = -1 );
120 * Same as the above, but this time with contact groups.
122 void addContactGroup( const KABC::ContactGroup &group, int weight, int source = -1 );
124 void addItem( const Akonadi::Item &item, int weight, int source = -1 );
127 * Adds the @p name of a completion source and its @p weight
128 * to the internal list of completion sources and returns its index,
129 * which can be used for insertion of items associated with that source.
131 * If the source already exists, the weight will be updated.
133 int addCompletionSource( const QString &name, int weight );
136 * Reimplemented for smart insertion of email addresses.
137 * Features:
138 * - Automatically adds ',' if necessary to separate email addresses
139 * - Correctly decodes mailto URLs
140 * - Recognizes email addresses which are protected against address
141 * harvesters, i.e. "name at kde dot org" and "name(at)kde.org"
143 virtual void insert( const QString & );
146 * Reimplemented for smart insertion of pasted email addresses.
148 virtual void paste();
151 * Reimplemented for smart insertion with middle mouse button.
153 virtual void mouseReleaseEvent( QMouseEvent * );
155 #ifndef QT_NO_DRAGANDDROP
157 * Reimplemented for smart insertion of dragged email addresses.
159 virtual void dropEvent( QDropEvent * );
160 #endif
163 * Reimplemented for internal reasons.
165 virtual void keyPressEvent( QKeyEvent * );
167 #ifndef QT_NO_CONTEXTMENU
169 * Reimplemented for subclass access to menu
171 virtual QMenu *createStandardContextMenu();
174 * Reimplemented for internal reasons. API not affected.
176 * See QLineEdit::contextMenuEvent().
178 virtual void contextMenuEvent( QContextMenuEvent * );
179 #endif
181 private:
182 virtual bool eventFilter( QObject *, QEvent * );
183 void emitTextCompleted();
185 //@cond PRIVATE
186 class Private;
187 Private *const d;
189 Q_PRIVATE_SLOT( d, void slotCompletion() )
190 Q_PRIVATE_SLOT( d, void slotPopupCompletion( const QString & ) )
191 Q_PRIVATE_SLOT( d, void slotReturnPressed( const QString & ) )
192 Q_PRIVATE_SLOT( d, void slotStartLDAPLookup() )
193 Q_PRIVATE_SLOT( d, void slotLDAPSearchData( const KLDAP::LdapResult::List & ) )
194 Q_PRIVATE_SLOT( d, void slotEditCompletionOrder() )
195 Q_PRIVATE_SLOT( d, void slotUserCancelled( const QString & ) )
196 Q_PRIVATE_SLOT( d, void slotAkonadiSearchResult( KJob * ) )
197 Q_PRIVATE_SLOT( d, void slotAkonadiSearchDbResult( KJob * ) )
198 Q_PRIVATE_SLOT( d, void slotAkonadiCollectionsReceived( const Akonadi::Collection::List & ) )
199 Q_PRIVATE_SLOT( d, void slotNepomukHits( const QList<Nepomuk2::Query::Result>& ) )
200 Q_PRIVATE_SLOT( d, void slotNepomukSearchFinished() )
201 //@endcond
206 #endif